Refactor audio and video decoder status into common file.
Completes a long standing refactor that rileya@ initiated in days of yore
before we had DecoderStream. Will make it easier to add a new entry for
PLATFORM_FAILURE in a followup CL.
Should be no functional changes, though it does include a fix to the
pepper video decoder shim which was silenting converting the int type
of VideoDecoder::Status to a int32_t which was expected to be PP_xxx
type value. This change sends PP_OK (== 0) where previously it was
sending VideoDecoder::kAborted (== 1).
BUG=595076
TEST=none
Review URL: https://codereview.chromium.org/1834303005
Cr-Commit-Position: refs/heads/master@{#384020}
diff --git a/chromecast/media/cma/decoder/cast_audio_decoder_linux.cc b/chromecast/media/cma/decoder/cast_audio_decoder_linux.cc
index d0b8bc4..316363c 100644
--- a/chromecast/media/cma/decoder/cast_audio_decoder_linux.cc
+++ b/chromecast/media/cma/decoder/cast_audio_decoder_linux.cc
@@ -184,13 +184,13 @@
void OnDecodeStatus(base::TimeDelta buffer_timestamp,
const DecodeCallback& decode_callback,
- ::media::AudioDecoder::Status status) {
+ ::media::DecodeStatus status) {
Status result_status = kDecodeOk;
scoped_refptr<media::DecoderBufferBase> decoded;
- if (status == ::media::AudioDecoder::kOk && !decoded_chunks_.empty()) {
+ if (status == ::media::DecodeStatus::OK && !decoded_chunks_.empty()) {
decoded = ConvertDecoded();
} else {
- if (status != ::media::AudioDecoder::kOk)
+ if (status != ::media::DecodeStatus::OK)
result_status = kDecodeError;
decoded = new media::DecoderBufferAdapter(config_.id,
new ::media::DecoderBuffer(0));
diff --git a/content/common/gpu/media/video_encode_accelerator_unittest.cc b/content/common/gpu/media/video_encode_accelerator_unittest.cc
index b108ceb..09f1c63 100644
--- a/content/common/gpu/media/video_encode_accelerator_unittest.cc
+++ b/content/common/gpu/media/video_encode_accelerator_unittest.cc
@@ -629,8 +629,8 @@
private:
void InitializeCB(bool success);
- void DecodeDone(media::VideoDecoder::Status status);
- void FlushDone(media::VideoDecoder::Status status);
+ void DecodeDone(media::DecodeStatus status);
+ void FlushDone(media::DecodeStatus status);
void VerifyOutputFrame(const scoped_refptr<media::VideoFrame>& output_frame);
void Decode();
@@ -712,9 +712,8 @@
original_frames_.push(frame);
}
-void VideoFrameQualityValidator::DecodeDone(
- media::VideoDecoder::Status status) {
- if (status == media::VideoDecoder::kOk) {
+void VideoFrameQualityValidator::DecodeDone(media::DecodeStatus status) {
+ if (status == media::DecodeStatus::OK) {
decoder_state_ = INITIALIZED;
Decode();
} else {
@@ -724,7 +723,7 @@
}
}
-void VideoFrameQualityValidator::FlushDone(media::VideoDecoder::Status status) {
+void VideoFrameQualityValidator::FlushDone(media::DecodeStatus status) {
flush_complete_cb_.Run();
}
diff --git a/content/renderer/pepper/video_decoder_shim.cc b/content/renderer/pepper/video_decoder_shim.cc
index 92ffcdb..c8e68ab 100644
--- a/content/renderer/pepper/video_decoder_shim.cc
+++ b/content/renderer/pepper/video_decoder_shim.cc
@@ -650,7 +650,7 @@
private:
void OnInitDone(bool success);
void DoDecode();
- void OnDecodeComplete(media::VideoDecoder::Status status);
+ void OnDecodeComplete(media::DecodeStatus status);
void OnOutputComplete(const scoped_refptr<media::VideoFrame>& frame);
void OnResetComplete();
@@ -732,8 +732,8 @@
const PendingDecode& decode = pending_decodes_.front();
scoped_ptr<PendingFrame> pending_frame(new PendingFrame(decode.decode_id));
main_task_runner_->PostTask(
- FROM_HERE, base::Bind(&VideoDecoderShim::OnDecodeComplete, shim_,
- media::VideoDecoder::kAborted, decode.decode_id));
+ FROM_HERE, base::Bind(&VideoDecoderShim::OnDecodeComplete, shim_, PP_OK,
+ decode.decode_id));
pending_decodes_.pop();
}
// Don't need to call Reset() if the |decoder_| hasn't been initialized.
@@ -781,23 +781,19 @@
}
void VideoDecoderShim::DecoderImpl::OnDecodeComplete(
- media::VideoDecoder::Status status) {
+ media::DecodeStatus status) {
DCHECK(awaiting_decoder_);
awaiting_decoder_ = false;
int32_t result;
switch (status) {
- case media::VideoDecoder::kOk:
- case media::VideoDecoder::kAborted:
+ case media::DecodeStatus::OK:
+ case media::DecodeStatus::ABORTED:
result = PP_OK;
break;
- case media::VideoDecoder::kDecodeError:
+ case media::DecodeStatus::DECODE_ERROR:
result = PP_ERROR_RESOURCE_FAILED;
break;
- default:
- NOTREACHED();
- result = PP_ERROR_FAILED;
- break;
}
main_task_runner_->PostTask(
diff --git a/media/base/BUILD.gn b/media/base/BUILD.gn
index c0f1787..6ed3bfa 100644
--- a/media/base/BUILD.gn
+++ b/media/base/BUILD.gn
@@ -94,6 +94,8 @@
"data_buffer.h",
"data_source.cc",
"data_source.h",
+ "decode_status.cc",
+ "decode_status.h",
"decoder_buffer.cc",
"decoder_buffer.h",
"decoder_buffer_queue.cc",
diff --git a/media/base/audio_decoder.h b/media/base/audio_decoder.h
index 5c6efd6c..a68c824 100644
--- a/media/base/audio_decoder.h
+++ b/media/base/audio_decoder.h
@@ -12,6 +12,7 @@
#include "base/memory/ref_counted.h"
#include "media/base/audio_decoder_config.h"
#include "media/base/channel_layout.h"
+#include "media/base/decode_status.h"
#include "media/base/decoder_buffer.h"
#include "media/base/media_export.h"
#include "media/base/pipeline_status.h"
@@ -24,15 +25,6 @@
class MEDIA_EXPORT AudioDecoder {
public:
- // Status codes for decode operations.
- // TODO(rileya): Now that both AudioDecoder and VideoDecoder Status enums
- // match, break them into a decoder_status.h.
- enum Status {
- kOk, // We're all good.
- kAborted, // We aborted as a result of Reset() or destruction.
- kDecodeError // A decoding error occurred.
- };
-
// Callback for VideoDecoder initialization.
typedef base::Callback<void(bool success)> InitCB;
@@ -42,7 +34,7 @@
// Callback for Decode(). Called after the decoder has accepted corresponding
// DecoderBuffer, indicating that the pipeline can send next buffer to decode.
- typedef base::Callback<void(Status)> DecodeCB;
+ typedef base::Callback<void(DecodeStatus)> DecodeCB;
AudioDecoder();
diff --git a/media/base/decode_status.cc b/media/base/decode_status.cc
new file mode 100644
index 0000000..b0156643
--- /dev/null
+++ b/media/base/decode_status.cc
@@ -0,0 +1,26 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/base/decode_status.h"
+
+#include <ostream>
+
+namespace media {
+
+std::ostream& operator<<(std::ostream& os, const DecodeStatus& status) {
+ switch (status) {
+ case DecodeStatus::OK:
+ os << "DecodeStatus::OK";
+ break;
+ case DecodeStatus::ABORTED:
+ os << "DecodeStatus::ABORTED";
+ break;
+ case DecodeStatus::DECODE_ERROR:
+ os << "DecodeStatus::DECODE_ERROR";
+ break;
+ }
+ return os;
+}
+
+} // namespace media
diff --git a/media/base/decode_status.h b/media/base/decode_status.h
new file mode 100644
index 0000000..790eb5ff
--- /dev/null
+++ b/media/base/decode_status.h
@@ -0,0 +1,27 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_BASE_DECODE_STATUS_H_
+#define MEDIA_BASE_DECODE_STATUS_H_
+
+#include <iosfwd>
+
+#include "media/base/media_export.h"
+
+namespace media {
+
+enum class DecodeStatus {
+ OK = 0, // Everything went as planned.
+ ABORTED, // Read aborted due to Reset() during pending read.
+ DECODE_ERROR, // Decoder returned decode error. Note: Prefixed by DECODE_
+ // since ERROR is a reserved name (special macro) on Windows.
+};
+
+// Helper function so that DecodeStatus can be printed easily.
+MEDIA_EXPORT std::ostream& operator<<(std::ostream& os,
+ const DecodeStatus& status);
+
+} // namespace media
+
+#endif // MEDIA_BASE_DECODE_STATUS_H_
diff --git a/media/base/video_decoder.h b/media/base/video_decoder.h
index c150bc62..d6abf03 100644
--- a/media/base/video_decoder.h
+++ b/media/base/video_decoder.h
@@ -10,6 +10,7 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "media/base/decode_status.h"
#include "media/base/media_export.h"
#include "media/base/pipeline_status.h"
#include "ui/gfx/geometry/size.h"
@@ -23,15 +24,6 @@
class MEDIA_EXPORT VideoDecoder {
public:
- // Status codes for decode operations on VideoDecoder.
- // TODO(rileya): Now that both AudioDecoder and VideoDecoder Status enums
- // match, break them into a decoder_status.h.
- enum Status {
- kOk, // Everything went as planned.
- kAborted, // Decode was aborted as a result of Reset() being called.
- kDecodeError // Decoding error happened.
- };
-
// Callback for VideoDecoder initialization.
typedef base::Callback<void(bool success)> InitCB;
@@ -42,7 +34,7 @@
// Callback type for Decode(). Called after the decoder has completed decoding
// corresponding DecoderBuffer, indicating that it's ready to accept another
// buffer to decode.
- typedef base::Callback<void(Status status)> DecodeCB;
+ typedef base::Callback<void(DecodeStatus)> DecodeCB;
VideoDecoder();
diff --git a/media/cast/sender/h264_vt_encoder_unittest.cc b/media/cast/sender/h264_vt_encoder_unittest.cc
index 45fd52d..054ec41f 100644
--- a/media/cast/sender/h264_vt_encoder_unittest.cc
+++ b/media/cast/sender/h264_vt_encoder_unittest.cc
@@ -167,9 +167,7 @@
++count_frames_checked_;
}
- void DecodeDone(VideoDecoder::Status status) {
- EXPECT_EQ(VideoDecoder::kOk, status);
- }
+ void DecodeDone(DecodeStatus status) { EXPECT_EQ(DecodeStatus::OK, status); }
int count_frames_checked() const { return count_frames_checked_; }
diff --git a/media/filters/android/media_codec_audio_decoder.cc b/media/filters/android/media_codec_audio_decoder.cc
index 76b3d3ec..c3bca6a 100644
--- a/media/filters/android/media_codec_audio_decoder.cc
+++ b/media/filters/android/media_codec_audio_decoder.cc
@@ -86,7 +86,7 @@
media_drm_bridge_cdm_context_->UnregisterPlayer(cdm_registration_id_);
}
- ClearInputQueue(kAborted);
+ ClearInputQueue(DecodeStatus::ABORTED);
}
std::string MediaCodecAudioDecoder::GetDisplayName() const {
@@ -148,7 +148,7 @@
if (!buffer->end_of_stream() && buffer->timestamp() == kNoTimestamp()) {
DVLOG(2) << __FUNCTION__ << " " << buffer->AsHumanReadableString()
<< ": no timestamp, skipping this buffer";
- bound_decode_cb.Run(kDecodeError);
+ bound_decode_cb.Run(DecodeStatus::DECODE_ERROR);
return;
}
@@ -156,8 +156,8 @@
// We get here if an error happens in DequeueOutput() or Reset().
DVLOG(2) << __FUNCTION__ << " " << buffer->AsHumanReadableString()
<< ": Error state, returning decode error for all buffers";
- ClearInputQueue(kDecodeError);
- bound_decode_cb.Run(kDecodeError);
+ ClearInputQueue(DecodeStatus::DECODE_ERROR);
+ bound_decode_cb.Run(DecodeStatus::DECODE_ERROR);
return;
}
@@ -179,7 +179,7 @@
io_timer_.Stop();
- ClearInputQueue(kAborted);
+ ClearInputQueue(DecodeStatus::ABORTED);
// Flush if we can, otherwise completely recreate and reconfigure the codec.
// Prior to JellyBean-MR2, flush() had several bugs (b/8125974, b/8347958) so
@@ -318,7 +318,7 @@
if (input_info.buf_index == kInvalidBufferIndex) {
if (state_ == STATE_ERROR)
- ClearInputQueue(kDecodeError);
+ ClearInputQueue(DecodeStatus::DECODE_ERROR);
return false;
}
@@ -330,7 +330,7 @@
switch (state_) {
case STATE_READY: {
const DecodeCB& decode_cb = input_queue_.front().second;
- decode_cb.Run(kOk);
+ decode_cb.Run(DecodeStatus::OK);
input_queue_.pop_front();
} break;
@@ -346,13 +346,13 @@
break;
case STATE_ERROR:
- ClearInputQueue(kDecodeError);
+ ClearInputQueue(DecodeStatus::DECODE_ERROR);
break;
default:
NOTREACHED() << ": internal error, unexpected state " << AsString(state_);
SetState(STATE_ERROR);
- ClearInputQueue(kDecodeError);
+ ClearInputQueue(DecodeStatus::DECODE_ERROR);
did_work = false;
break;
}
@@ -468,7 +468,7 @@
return did_work;
}
-void MediaCodecAudioDecoder::ClearInputQueue(Status decode_status) {
+void MediaCodecAudioDecoder::ClearInputQueue(DecodeStatus decode_status) {
DVLOG(2) << __FUNCTION__;
for (const auto& entry : input_queue_)
@@ -577,7 +577,7 @@
DCHECK(input_queue_.front().first->end_of_stream());
const DecodeCB& decode_cb = input_queue_.front().second;
- decode_cb.Run(kOk);
+ decode_cb.Run(DecodeStatus::OK);
// Remove the EOS buffer from the input queue.
input_queue_.pop_front();
diff --git a/media/filters/android/media_codec_audio_decoder.h b/media/filters/android/media_codec_audio_decoder.h
index e19bb0a..3e68ba4 100644
--- a/media/filters/android/media_codec_audio_decoder.h
+++ b/media/filters/android/media_codec_audio_decoder.h
@@ -190,7 +190,7 @@
// Calls DecodeCB with |decode_status| for every frame in |input_queue| and
// then clears it.
- void ClearInputQueue(Status decode_status);
+ void ClearInputQueue(DecodeStatus decode_status);
// Dequeues all output buffers from MediaCodec that are immediately available.
// Returns true if any output buffer was received from MediaCodec.
diff --git a/media/filters/audio_decoder_unittest.cc b/media/filters/audio_decoder_unittest.cc
index 70b2b6f..ec19b80 100644
--- a/media/filters/audio_decoder_unittest.cc
+++ b/media/filters/audio_decoder_unittest.cc
@@ -136,7 +136,7 @@
AudioDecoderTest()
: pending_decode_(false),
pending_reset_(false),
- last_decode_status_(AudioDecoder::kDecodeError) {
+ last_decode_status_(DecodeStatus::DECODE_ERROR) {
switch (GetParam().decoder_type) {
case FFMPEG:
decoder_.reset(new FFmpegAudioDecoder(message_loop_.task_runner(),
@@ -163,7 +163,7 @@
void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer) {
ASSERT_FALSE(pending_decode_);
pending_decode_ = true;
- last_decode_status_ = AudioDecoder::kDecodeError;
+ last_decode_status_ = DecodeStatus::DECODE_ERROR;
base::RunLoop run_loop;
decoder_->Decode(
@@ -276,8 +276,7 @@
decoded_audio_.push_back(buffer);
}
- void DecodeFinished(const base::Closure& quit_closure,
- AudioDecoder::Status status) {
+ void DecodeFinished(const base::Closure& quit_closure, DecodeStatus status) {
EXPECT_TRUE(pending_decode_);
EXPECT_FALSE(pending_reset_);
pending_decode_ = false;
@@ -365,9 +364,7 @@
const scoped_refptr<AudioBuffer>& decoded_audio(size_t i) {
return decoded_audio_[i];
}
- AudioDecoder::Status last_decode_status() const {
- return last_decode_status_;
- }
+ DecodeStatus last_decode_status() const { return last_decode_status_; }
private:
base::MessageLoop message_loop_;
@@ -378,7 +375,7 @@
scoped_ptr<AudioDecoder> decoder_;
bool pending_decode_;
bool pending_reset_;
- AudioDecoder::Status last_decode_status_;
+ DecodeStatus last_decode_status_;
std::deque<scoped_refptr<AudioBuffer> > decoded_audio_;
base::TimeDelta start_timestamp_;
@@ -408,7 +405,7 @@
// (i.e. decoding EOS).
do {
Decode();
- ASSERT_EQ(last_decode_status(), AudioDecoder::kOk);
+ ASSERT_EQ(last_decode_status(), DecodeStatus::OK);
} while (decoded_audio_size() < kDecodeRuns);
// With MediaCodecAudioDecoder the output buffers might appear after
@@ -440,7 +437,7 @@
SKIP_TEST_IF_NO_MEDIA_CODEC();
ASSERT_NO_FATAL_FAILURE(Initialize());
Decode();
- EXPECT_EQ(AudioDecoder::kOk, last_decode_status());
+ EXPECT_EQ(DecodeStatus::OK, last_decode_status());
}
TEST_P(AudioDecoderTest, Reset) {
@@ -455,7 +452,7 @@
scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(0));
buffer->set_timestamp(kNoTimestamp());
DecodeBuffer(buffer);
- EXPECT_EQ(AudioDecoder::kDecodeError, last_decode_status());
+ EXPECT_EQ(DecodeStatus::DECODE_ERROR, last_decode_status());
}
TEST_P(OpusAudioDecoderBehavioralTest, InitializeWithNoCodecDelay) {
diff --git a/media/filters/decoder_stream.cc b/media/filters/decoder_stream.cc
index 4b03587..19ae054d 100644
--- a/media/filters/decoder_stream.cc
+++ b/media/filters/decoder_stream.cc
@@ -335,7 +335,7 @@
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::OnDecodeDone(int buffer_size,
bool end_of_stream,
- typename Decoder::Status status) {
+ DecodeStatus status) {
FUNCTION_DVLOG(2) << ": " << status;
DCHECK(state_ == STATE_NORMAL || state_ == STATE_FLUSHING_DECODER ||
state_ == STATE_PENDING_DEMUXER_READ || state_ == STATE_ERROR)
@@ -362,7 +362,7 @@
return;
switch (status) {
- case Decoder::kDecodeError:
+ case DecodeStatus::DECODE_ERROR:
state_ = STATE_ERROR;
MEDIA_LOG(ERROR, media_log_) << GetStreamTypeString() << " decode error";
ready_outputs_.clear();
@@ -370,11 +370,12 @@
SatisfyRead(DECODE_ERROR, NULL);
return;
- case Decoder::kAborted:
- // Decoder can return kAborted during Reset() or during destruction.
+ case DecodeStatus::ABORTED:
+ // Decoder can return DecodeStatus::ABORTED during Reset() or during
+ // destruction.
return;
- case Decoder::kOk:
+ case DecodeStatus::OK:
// Any successful decode counts!
if (buffer_size > 0)
StreamTraits::ReportStatistics(statistics_cb_, buffer_size);
diff --git a/media/filters/decoder_stream.h b/media/filters/decoder_stream.h
index 3af3d75..a7f084f 100644
--- a/media/filters/decoder_stream.h
+++ b/media/filters/decoder_stream.h
@@ -39,7 +39,6 @@
typedef DecoderStreamTraits<StreamType> StreamTraits;
typedef typename StreamTraits::DecoderType Decoder;
typedef typename StreamTraits::OutputType Output;
- typedef typename Decoder::Status DecoderStatus;
enum Status {
OK, // Everything went as planned.
@@ -156,7 +155,7 @@
void FlushDecoder();
// Callback for Decoder::Decode().
- void OnDecodeDone(int buffer_size, bool end_of_stream, DecoderStatus status);
+ void OnDecodeDone(int buffer_size, bool end_of_stream, DecodeStatus status);
// Output callback passed to Decoder::Initialize().
void OnDecodeOutputReady(const scoped_refptr<Output>& output);
diff --git a/media/filters/decrypting_audio_decoder.cc b/media/filters/decrypting_audio_decoder.cc
index b8876dd..bc2b89d6 100644
--- a/media/filters/decrypting_audio_decoder.cc
+++ b/media/filters/decrypting_audio_decoder.cc
@@ -108,7 +108,7 @@
// Return empty (end-of-stream) frames if decoding has finished.
if (state_ == kDecodeFinished) {
output_cb_.Run(AudioBuffer::CreateEOSBuffer());
- base::ResetAndReturn(&decode_cb_).Run(kOk);
+ base::ResetAndReturn(&decode_cb_).Run(DecodeStatus::OK);
return;
}
@@ -150,7 +150,7 @@
if (state_ == kWaitingForKey) {
DCHECK(!decode_cb_.is_null());
pending_buffer_to_decode_ = NULL;
- base::ResetAndReturn(&decode_cb_).Run(kAborted);
+ base::ResetAndReturn(&decode_cb_).Run(DecodeStatus::ABORTED);
}
DCHECK(decode_cb_.is_null());
@@ -172,7 +172,7 @@
if (!init_cb_.is_null())
base::ResetAndReturn(&init_cb_).Run(false);
if (!decode_cb_.is_null())
- base::ResetAndReturn(&decode_cb_).Run(kAborted);
+ base::ResetAndReturn(&decode_cb_).Run(DecodeStatus::ABORTED);
if (!reset_cb_.is_null())
base::ResetAndReturn(&reset_cb_).Run();
}
@@ -248,7 +248,7 @@
pending_buffer_to_decode_ = NULL;
if (!reset_cb_.is_null()) {
- base::ResetAndReturn(&decode_cb_).Run(kAborted);
+ base::ResetAndReturn(&decode_cb_).Run(DecodeStatus::ABORTED);
DoReset();
return;
}
@@ -259,7 +259,7 @@
DVLOG(2) << "DeliverFrame() - kError";
MEDIA_LOG(ERROR, media_log_) << GetDisplayName() << ": decode error";
state_ = kDecodeFinished; // TODO add kError state
- base::ResetAndReturn(&decode_cb_).Run(kDecodeError);
+ base::ResetAndReturn(&decode_cb_).Run(DecodeStatus::DECODE_ERROR);
return;
}
@@ -286,7 +286,7 @@
DVLOG(2) << "DeliverFrame() - kNeedMoreData";
state_ = scoped_pending_buffer_to_decode->end_of_stream() ? kDecodeFinished
: kIdle;
- base::ResetAndReturn(&decode_cb_).Run(kOk);
+ base::ResetAndReturn(&decode_cb_).Run(DecodeStatus::OK);
return;
}
@@ -303,7 +303,7 @@
}
state_ = kIdle;
- base::ResetAndReturn(&decode_cb_).Run(kOk);
+ base::ResetAndReturn(&decode_cb_).Run(DecodeStatus::OK);
}
void DecryptingAudioDecoder::OnKeyAdded() {
diff --git a/media/filters/decrypting_audio_decoder_unittest.cc b/media/filters/decrypting_audio_decoder_unittest.cc
index 6649b68..81f2504 100644
--- a/media/filters/decrypting_audio_decoder_unittest.cc
+++ b/media/filters/decrypting_audio_decoder_unittest.cc
@@ -141,7 +141,7 @@
// Decode |buffer| and expect DecodeDone to get called with |status|.
void DecodeAndExpect(const scoped_refptr<DecoderBuffer>& buffer,
- AudioDecoder::Status status) {
+ DecodeStatus status) {
EXPECT_CALL(*this, DecodeDone(status));
decoder_->Decode(buffer,
base::Bind(&DecryptingAudioDecoderTest::DecodeDone,
@@ -175,7 +175,7 @@
Invoke(this, &DecryptingAudioDecoderTest::DecryptAndDecodeAudio));
EXPECT_CALL(*this, FrameReady(decoded_frame_));
for (int i = 0; i < kDecodingDelay + 1; ++i)
- DecodeAndExpect(encrypted_buffer_, AudioDecoder::kOk);
+ DecodeAndExpect(encrypted_buffer_, DecodeStatus::OK);
}
// Sets up expectations and actions to put DecryptingAudioDecoder in an end
@@ -185,7 +185,7 @@
// The codec in the |decryptor_| will be flushed.
EXPECT_CALL(*this, FrameReady(decoded_frame_))
.Times(kDecodingDelay);
- DecodeAndExpect(DecoderBuffer::CreateEOSBuffer(), AudioDecoder::kOk);
+ DecodeAndExpect(DecoderBuffer::CreateEOSBuffer(), DecodeStatus::OK);
EXPECT_EQ(0, num_frames_in_decryptor_);
}
@@ -251,7 +251,7 @@
}
MOCK_METHOD1(FrameReady, void(const scoped_refptr<AudioBuffer>&));
- MOCK_METHOD1(DecodeDone, void(AudioDecoder::Status));
+ MOCK_METHOD1(DecodeDone, void(DecodeStatus));
MOCK_METHOD0(OnWaitingForDecryptionKey, void(void));
@@ -335,7 +335,7 @@
.WillRepeatedly(RunCallback<1>(Decryptor::kError,
Decryptor::AudioFrames()));
- DecodeAndExpect(encrypted_buffer_, AudioDecoder::kDecodeError);
+ DecodeAndExpect(encrypted_buffer_, DecodeStatus::DECODE_ERROR);
}
// Test the case where the decryptor returns multiple decoded frames.
@@ -363,7 +363,7 @@
EXPECT_CALL(*this, FrameReady(decoded_frame_));
EXPECT_CALL(*this, FrameReady(frame_a));
EXPECT_CALL(*this, FrameReady(frame_b));
- DecodeAndExpect(encrypted_buffer_, AudioDecoder::kOk);
+ DecodeAndExpect(encrypted_buffer_, DecodeStatus::OK);
}
// Test the case where the decryptor receives end-of-stream buffer.
@@ -403,7 +403,7 @@
EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _))
.WillRepeatedly(RunCallback<1>(Decryptor::kSuccess, decoded_frame_list_));
EXPECT_CALL(*this, FrameReady(decoded_frame_));
- EXPECT_CALL(*this, DecodeDone(AudioDecoder::kOk));
+ EXPECT_CALL(*this, DecodeDone(DecodeStatus::OK));
key_added_cb_.Run();
message_loop_.RunUntilIdle();
}
@@ -417,7 +417,7 @@
EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _))
.WillRepeatedly(RunCallback<1>(Decryptor::kSuccess, decoded_frame_list_));
EXPECT_CALL(*this, FrameReady(decoded_frame_));
- EXPECT_CALL(*this, DecodeDone(AudioDecoder::kOk));
+ EXPECT_CALL(*this, DecodeDone(DecodeStatus::OK));
// The audio decode callback is returned after the correct decryption key is
// added.
key_added_cb_.Run();
@@ -446,7 +446,7 @@
Initialize();
EnterPendingDecodeState();
- EXPECT_CALL(*this, DecodeDone(AudioDecoder::kAborted));
+ EXPECT_CALL(*this, DecodeDone(DecodeStatus::ABORTED));
Reset();
}
@@ -456,7 +456,7 @@
Initialize();
EnterWaitingForKeyState();
- EXPECT_CALL(*this, DecodeDone(AudioDecoder::kAborted));
+ EXPECT_CALL(*this, DecodeDone(DecodeStatus::ABORTED));
Reset();
}
diff --git a/media/filters/decrypting_video_decoder.cc b/media/filters/decrypting_video_decoder.cc
index a639130..a03e711 100644
--- a/media/filters/decrypting_video_decoder.cc
+++ b/media/filters/decrypting_video_decoder.cc
@@ -91,13 +91,13 @@
decode_cb_ = BindToCurrentLoop(decode_cb);
if (state_ == kError) {
- base::ResetAndReturn(&decode_cb_).Run(kDecodeError);
+ base::ResetAndReturn(&decode_cb_).Run(DecodeStatus::DECODE_ERROR);
return;
}
// Return empty frames if decoding has finished.
if (state_ == kDecodeFinished) {
- base::ResetAndReturn(&decode_cb_).Run(kOk);
+ base::ResetAndReturn(&decode_cb_).Run(DecodeStatus::OK);
return;
}
@@ -133,7 +133,7 @@
if (state_ == kWaitingForKey) {
DCHECK(!decode_cb_.is_null());
pending_buffer_to_decode_ = NULL;
- base::ResetAndReturn(&decode_cb_).Run(kAborted);
+ base::ResetAndReturn(&decode_cb_).Run(DecodeStatus::ABORTED);
}
DCHECK(decode_cb_.is_null());
@@ -154,7 +154,7 @@
if (!init_cb_.is_null())
base::ResetAndReturn(&init_cb_).Run(false);
if (!decode_cb_.is_null())
- base::ResetAndReturn(&decode_cb_).Run(kAborted);
+ base::ResetAndReturn(&decode_cb_).Run(DecodeStatus::ABORTED);
if (!reset_cb_.is_null())
base::ResetAndReturn(&reset_cb_).Run();
}
@@ -225,7 +225,7 @@
pending_buffer_to_decode_ = NULL;
if (!reset_cb_.is_null()) {
- base::ResetAndReturn(&decode_cb_).Run(kAborted);
+ base::ResetAndReturn(&decode_cb_).Run(DecodeStatus::ABORTED);
DoReset();
return;
}
@@ -236,7 +236,7 @@
DVLOG(2) << "DeliverFrame() - kError";
MEDIA_LOG(ERROR, media_log_) << GetDisplayName() << ": decode error";
state_ = kError;
- base::ResetAndReturn(&decode_cb_).Run(kDecodeError);
+ base::ResetAndReturn(&decode_cb_).Run(DecodeStatus::DECODE_ERROR);
return;
}
@@ -263,7 +263,7 @@
DVLOG(2) << "DeliverFrame() - kNeedMoreData";
state_ = scoped_pending_buffer_to_decode->end_of_stream() ? kDecodeFinished
: kIdle;
- base::ResetAndReturn(&decode_cb_).Run(kOk);
+ base::ResetAndReturn(&decode_cb_).Run(DecodeStatus::OK);
return;
}
@@ -281,7 +281,7 @@
}
state_ = kIdle;
- base::ResetAndReturn(&decode_cb_).Run(kOk);
+ base::ResetAndReturn(&decode_cb_).Run(DecodeStatus::OK);
}
void DecryptingVideoDecoder::OnKeyAdded() {
diff --git a/media/filters/decrypting_video_decoder_unittest.cc b/media/filters/decrypting_video_decoder_unittest.cc
index 102a528..a3786cd 100644
--- a/media/filters/decrypting_video_decoder_unittest.cc
+++ b/media/filters/decrypting_video_decoder_unittest.cc
@@ -118,7 +118,7 @@
// Decode |buffer| and expect DecodeDone to get called with |status|.
void DecodeAndExpect(const scoped_refptr<DecoderBuffer>& buffer,
- VideoDecoder::Status status) {
+ DecodeStatus status) {
EXPECT_CALL(*this, DecodeDone(status));
decoder_->Decode(buffer,
base::Bind(&DecryptingVideoDecoderTest::DecodeDone,
@@ -152,7 +152,7 @@
Invoke(this, &DecryptingVideoDecoderTest::DecryptAndDecodeVideo));
EXPECT_CALL(*this, FrameReady(decoded_video_frame_));
for (int i = 0; i < kDecodingDelay + 1; ++i)
- DecodeAndExpect(encrypted_buffer_, VideoDecoder::kOk);
+ DecodeAndExpect(encrypted_buffer_, DecodeStatus::OK);
}
// Sets up expectations and actions to put DecryptingVideoDecoder in an end
@@ -162,7 +162,7 @@
// The codec in the |decryptor_| will be flushed.
EXPECT_CALL(*this, FrameReady(decoded_video_frame_))
.Times(kDecodingDelay);
- DecodeAndExpect(DecoderBuffer::CreateEOSBuffer(), VideoDecoder::kOk);
+ DecodeAndExpect(DecoderBuffer::CreateEOSBuffer(), DecodeStatus::OK);
EXPECT_EQ(0, num_frames_in_decryptor_);
}
@@ -227,7 +227,7 @@
}
MOCK_METHOD1(FrameReady, void(const scoped_refptr<VideoFrame>&));
- MOCK_METHOD1(DecodeDone, void(VideoDecoder::Status));
+ MOCK_METHOD1(DecodeDone, void(DecodeStatus));
MOCK_METHOD0(OnWaitingForDecryptionKey, void(void));
@@ -306,10 +306,10 @@
.WillRepeatedly(RunCallback<1>(Decryptor::kError,
scoped_refptr<VideoFrame>(NULL)));
- DecodeAndExpect(encrypted_buffer_, VideoDecoder::kDecodeError);
+ DecodeAndExpect(encrypted_buffer_, DecodeStatus::DECODE_ERROR);
- // After a decode error occurred, all following decode returns kDecodeError.
- DecodeAndExpect(encrypted_buffer_, VideoDecoder::kDecodeError);
+ // After a decode error occurred, all following decodes return DECODE_ERROR.
+ DecodeAndExpect(encrypted_buffer_, DecodeStatus::DECODE_ERROR);
}
// Test the case where the decryptor receives end-of-stream buffer.
@@ -329,7 +329,7 @@
.WillRepeatedly(RunCallback<1>(Decryptor::kSuccess,
decoded_video_frame_));
EXPECT_CALL(*this, FrameReady(decoded_video_frame_));
- EXPECT_CALL(*this, DecodeDone(VideoDecoder::kOk));
+ EXPECT_CALL(*this, DecodeDone(DecodeStatus::OK));
key_added_cb_.Run();
message_loop_.RunUntilIdle();
}
@@ -344,7 +344,7 @@
.WillRepeatedly(RunCallback<1>(Decryptor::kSuccess,
decoded_video_frame_));
EXPECT_CALL(*this, FrameReady(decoded_video_frame_));
- EXPECT_CALL(*this, DecodeDone(VideoDecoder::kOk));
+ EXPECT_CALL(*this, DecodeDone(DecodeStatus::OK));
// The video decode callback is returned after the correct decryption key is
// added.
key_added_cb_.Run();
@@ -373,7 +373,7 @@
Initialize();
EnterPendingDecodeState();
- EXPECT_CALL(*this, DecodeDone(VideoDecoder::kAborted));
+ EXPECT_CALL(*this, DecodeDone(DecodeStatus::ABORTED));
Reset();
}
@@ -383,7 +383,7 @@
Initialize();
EnterWaitingForKeyState();
- EXPECT_CALL(*this, DecodeDone(VideoDecoder::kAborted));
+ EXPECT_CALL(*this, DecodeDone(DecodeStatus::ABORTED));
Reset();
}
@@ -437,7 +437,7 @@
Initialize();
EnterPendingDecodeState();
- EXPECT_CALL(*this, DecodeDone(VideoDecoder::kAborted));
+ EXPECT_CALL(*this, DecodeDone(DecodeStatus::ABORTED));
Destroy();
}
@@ -447,7 +447,7 @@
Initialize();
EnterWaitingForKeyState();
- EXPECT_CALL(*this, DecodeDone(VideoDecoder::kAborted));
+ EXPECT_CALL(*this, DecodeDone(DecodeStatus::ABORTED));
Destroy();
}
@@ -469,7 +469,7 @@
EnterPendingDecodeState();
EXPECT_CALL(*decryptor_, ResetDecoder(Decryptor::kVideo));
- EXPECT_CALL(*this, DecodeDone(VideoDecoder::kAborted));
+ EXPECT_CALL(*this, DecodeDone(DecodeStatus::ABORTED));
decoder_->Reset(NewExpectedClosure());
Destroy();
diff --git a/media/filters/fake_video_decoder.cc b/media/filters/fake_video_decoder.cc
index f1188d00..407fdedf 100644
--- a/media/filters/fake_video_decoder.cc
+++ b/media/filters/fake_video_decoder.cc
@@ -93,7 +93,7 @@
BindToCurrentLoop(decode_cb));
if (state_ == STATE_ERROR) {
- wrapped_decode_cb.Run(kDecodeError);
+ wrapped_decode_cb.Run(DecodeStatus::DECODE_ERROR);
return;
}
@@ -180,7 +180,7 @@
state_ = STATE_ERROR;
while (!held_decode_callbacks_.empty()) {
- held_decode_callbacks_.front().Run(kDecodeError);
+ held_decode_callbacks_.front().Run(DecodeStatus::DECODE_ERROR);
held_decode_callbacks_.pop_front();
}
decoded_frames_.clear();
@@ -196,10 +196,10 @@
void FakeVideoDecoder::OnFrameDecoded(int buffer_size,
const DecodeCB& decode_cb,
- Status status) {
+ DecodeStatus status) {
DCHECK(thread_checker_.CalledOnValidThread());
- if (status == kOk) {
+ if (status == DecodeStatus::OK) {
total_bytes_decoded_ += buffer_size;
bytes_decoded_cb_.Run(buffer_size);
}
@@ -222,7 +222,7 @@
if (!reset_cb_.IsNull()) {
DCHECK(decoded_frames_.empty());
- decode_cb.Run(kAborted);
+ decode_cb.Run(DecodeStatus::ABORTED);
return;
}
@@ -247,7 +247,7 @@
}
}
- decode_cb.Run(kOk);
+ decode_cb.Run(DecodeStatus::OK);
}
void FakeVideoDecoder::DoReset() {
diff --git a/media/filters/fake_video_decoder.h b/media/filters/fake_video_decoder.h
index 637be0b..46142a1c 100644
--- a/media/filters/fake_video_decoder.h
+++ b/media/filters/fake_video_decoder.h
@@ -86,7 +86,7 @@
// Callback for updating |total_bytes_decoded_|.
void OnFrameDecoded(int buffer_size,
const DecodeCB& decode_cb,
- Status status);
+ DecodeStatus status);
// Runs |decode_cb| or puts it to |held_decode_callbacks_| depending on
// current value of |hold_decode_|.
diff --git a/media/filters/fake_video_decoder_unittest.cc b/media/filters/fake_video_decoder_unittest.cc
index 1e60171..652cd81 100644
--- a/media/filters/fake_video_decoder_unittest.cc
+++ b/media/filters/fake_video_decoder_unittest.cc
@@ -39,7 +39,7 @@
num_decoded_frames_(0),
num_bytes_decoded_(0),
total_bytes_in_buffers_(0),
- last_decode_status_(VideoDecoder::kOk),
+ last_decode_status_(DecodeStatus::OK),
pending_decode_requests_(0),
is_reset_pending_(false) {}
@@ -71,7 +71,7 @@
}
// Callback for VideoDecoder::Decode().
- void DecodeDone(VideoDecoder::Status status) {
+ void DecodeDone(DecodeStatus status) {
DCHECK_GT(pending_decode_requests_, 0);
--pending_decode_requests_;
last_decode_status_ = status;
@@ -101,17 +101,17 @@
break;
case OK:
EXPECT_EQ(0, pending_decode_requests_);
- ASSERT_EQ(VideoDecoder::kOk, last_decode_status_);
+ ASSERT_EQ(DecodeStatus::OK, last_decode_status_);
ASSERT_TRUE(last_decoded_frame_.get());
break;
case NOT_ENOUGH_DATA:
EXPECT_EQ(0, pending_decode_requests_);
- ASSERT_EQ(VideoDecoder::kOk, last_decode_status_);
+ ASSERT_EQ(DecodeStatus::OK, last_decode_status_);
ASSERT_FALSE(last_decoded_frame_.get());
break;
case ABORTED:
EXPECT_EQ(0, pending_decode_requests_);
- ASSERT_EQ(VideoDecoder::kAborted, last_decode_status_);
+ ASSERT_EQ(DecodeStatus::ABORTED, last_decode_status_);
EXPECT_FALSE(last_decoded_frame_.get());
break;
}
@@ -228,7 +228,7 @@
int total_bytes_in_buffers_;
// Callback result/status.
- VideoDecoder::Status last_decode_status_;
+ DecodeStatus last_decode_status_;
scoped_refptr<VideoFrame> last_decoded_frame_;
int pending_decode_requests_;
bool is_reset_pending_;
@@ -254,7 +254,7 @@
decoder_->SimulateFailureToInit();
InitializeWithConfigAndExpectResult(TestVideoConfig::Normal(), false);
Decode();
- EXPECT_EQ(last_decode_status_, VideoDecoder::kDecodeError);
+ EXPECT_EQ(last_decode_status_, DecodeStatus::DECODE_ERROR);
}
TEST_P(FakeVideoDecoderTest, Read_AllFrames) {
@@ -354,7 +354,7 @@
decoder_->SimulateFailureToInit();
InitializeWithConfigAndExpectResult(TestVideoConfig::Normal(), false);
Decode();
- EXPECT_EQ(last_decode_status_, VideoDecoder::kDecodeError);
+ EXPECT_EQ(last_decode_status_, DecodeStatus::DECODE_ERROR);
}
// Reinitializing the decoder during the middle of the decoding process can
diff --git a/media/filters/ffmpeg_audio_decoder.cc b/media/filters/ffmpeg_audio_decoder.cc
index bef0a86..b5dc7177 100644
--- a/media/filters/ffmpeg_audio_decoder.cc
+++ b/media/filters/ffmpeg_audio_decoder.cc
@@ -192,13 +192,13 @@
DecodeCB decode_cb_bound = BindToCurrentLoop(decode_cb);
if (state_ == kError) {
- decode_cb_bound.Run(kDecodeError);
+ decode_cb_bound.Run(DecodeStatus::DECODE_ERROR);
return;
}
// Do nothing if decoding has finished.
if (state_ == kDecodeFinished) {
- decode_cb_bound.Run(kOk);
+ decode_cb_bound.Run(DecodeStatus::OK);
return;
}
@@ -227,7 +227,7 @@
// occurs with some damaged files.
if (!buffer->end_of_stream() && buffer->timestamp() == kNoTimestamp()) {
DVLOG(1) << "Received a buffer without timestamps!";
- decode_cb.Run(kDecodeError);
+ decode_cb.Run(DecodeStatus::DECODE_ERROR);
return;
}
@@ -236,7 +236,7 @@
has_produced_frame = false;
if (!FFmpegDecode(buffer, &has_produced_frame)) {
state_ = kError;
- decode_cb.Run(kDecodeError);
+ decode_cb.Run(DecodeStatus::DECODE_ERROR);
return;
}
// Repeat to flush the decoder after receiving EOS buffer.
@@ -245,7 +245,7 @@
if (buffer->end_of_stream())
state_ = kDecodeFinished;
- decode_cb.Run(kOk);
+ decode_cb.Run(DecodeStatus::OK);
}
bool FFmpegAudioDecoder::FFmpegDecode(
diff --git a/media/filters/ffmpeg_video_decoder.cc b/media/filters/ffmpeg_video_decoder.cc
index 5438126..92028dc 100644
--- a/media/filters/ffmpeg_video_decoder.cc
+++ b/media/filters/ffmpeg_video_decoder.cc
@@ -211,12 +211,12 @@
DecodeCB decode_cb_bound = BindToCurrentLoop(decode_cb);
if (state_ == kError) {
- decode_cb_bound.Run(kDecodeError);
+ decode_cb_bound.Run(DecodeStatus::DECODE_ERROR);
return;
}
if (state_ == kDecodeFinished) {
- decode_cb_bound.Run(kOk);
+ decode_cb_bound.Run(DecodeStatus::OK);
return;
}
@@ -248,7 +248,7 @@
has_produced_frame = false;
if (!FFmpegDecode(buffer, &has_produced_frame)) {
state_ = kError;
- decode_cb_bound.Run(kDecodeError);
+ decode_cb_bound.Run(DecodeStatus::DECODE_ERROR);
return;
}
// Repeat to flush the decoder after receiving EOS buffer.
@@ -259,7 +259,7 @@
// VideoDecoderShim expects that |decode_cb| is called only after
// |output_cb_|.
- decode_cb_bound.Run(kOk);
+ decode_cb_bound.Run(DecodeStatus::OK);
}
void FFmpegVideoDecoder::Reset(const base::Closure& closure) {
diff --git a/media/filters/ffmpeg_video_decoder_unittest.cc b/media/filters/ffmpeg_video_decoder_unittest.cc
index fa91d50..a60c3353 100644
--- a/media/filters/ffmpeg_video_decoder_unittest.cc
+++ b/media/filters/ffmpeg_video_decoder_unittest.cc
@@ -101,14 +101,14 @@
// Sets up expectations and actions to put FFmpegVideoDecoder in an active
// decoding state.
void EnterDecodingState() {
- EXPECT_EQ(VideoDecoder::kOk, DecodeSingleFrame(i_frame_buffer_));
+ EXPECT_EQ(DecodeStatus::OK, DecodeSingleFrame(i_frame_buffer_));
ASSERT_EQ(1U, output_frames_.size());
}
// Sets up expectations and actions to put FFmpegVideoDecoder in an end
// of stream state.
void EnterEndOfStreamState() {
- EXPECT_EQ(VideoDecoder::kOk, DecodeSingleFrame(end_of_stream_buffer_));
+ EXPECT_EQ(DecodeStatus::OK, DecodeSingleFrame(end_of_stream_buffer_));
ASSERT_FALSE(output_frames_.empty());
}
@@ -118,30 +118,29 @@
// Decodes all buffers in |input_buffers| and push all successfully decoded
// output frames into |output_frames|.
// Returns the last decode status returned by the decoder.
- VideoDecoder::Status DecodeMultipleFrames(const InputBuffers& input_buffers) {
+ DecodeStatus DecodeMultipleFrames(const InputBuffers& input_buffers) {
for (InputBuffers::const_iterator iter = input_buffers.begin();
iter != input_buffers.end();
++iter) {
- VideoDecoder::Status status = Decode(*iter);
+ DecodeStatus status = Decode(*iter);
switch (status) {
- case VideoDecoder::kOk:
+ case DecodeStatus::OK:
break;
- case VideoDecoder::kAborted:
+ case DecodeStatus::ABORTED:
NOTREACHED();
- case VideoDecoder::kDecodeError:
+ case DecodeStatus::DECODE_ERROR:
DCHECK(output_frames_.empty());
return status;
}
}
- return VideoDecoder::kOk;
+ return DecodeStatus::OK;
}
// Decodes the single compressed frame in |buffer| and writes the
// uncompressed output to |video_frame|. This method works with single
// and multithreaded decoders. End of stream buffers are used to trigger
// the frame to be returned in the multithreaded decoder case.
- VideoDecoder::Status DecodeSingleFrame(
- const scoped_refptr<DecoderBuffer>& buffer) {
+ DecodeStatus DecodeSingleFrame(const scoped_refptr<DecoderBuffer>& buffer) {
InputBuffers input_buffers;
input_buffers.push_back(buffer);
input_buffers.push_back(end_of_stream_buffer_);
@@ -163,10 +162,9 @@
input_buffers.push_back(buffer);
input_buffers.push_back(end_of_stream_buffer_);
- VideoDecoder::Status status =
- DecodeMultipleFrames(input_buffers);
+ DecodeStatus status = DecodeMultipleFrames(input_buffers);
- EXPECT_EQ(VideoDecoder::kOk, status);
+ EXPECT_EQ(DecodeStatus::OK, status);
ASSERT_EQ(2U, output_frames_.size());
gfx::Size original_size = kVisibleRect.size();
@@ -180,8 +178,8 @@
output_frames_[1]->visible_rect().size().height());
}
- VideoDecoder::Status Decode(const scoped_refptr<DecoderBuffer>& buffer) {
- VideoDecoder::Status status;
+ DecodeStatus Decode(const scoped_refptr<DecoderBuffer>& buffer) {
+ DecodeStatus status;
EXPECT_CALL(*this, DecodeDone(_)).WillOnce(SaveArg<0>(&status));
decoder_->Decode(buffer, decode_cb_);
@@ -196,7 +194,7 @@
output_frames_.push_back(frame);
}
- MOCK_METHOD1(DecodeDone, void(VideoDecoder::Status));
+ MOCK_METHOD1(DecodeDone, void(DecodeStatus));
base::MessageLoop message_loop_;
scoped_ptr<FFmpegVideoDecoder> decoder_;
@@ -250,7 +248,7 @@
Initialize();
// Simulate decoding a single frame.
- EXPECT_EQ(VideoDecoder::kOk, DecodeSingleFrame(i_frame_buffer_));
+ EXPECT_EQ(DecodeStatus::OK, DecodeSingleFrame(i_frame_buffer_));
ASSERT_EQ(1U, output_frames_.size());
}
@@ -267,9 +265,9 @@
input_buffers.push_back(i_frame_buffer_);
input_buffers.push_back(end_of_stream_buffer_);
- VideoDecoder::Status status = DecodeMultipleFrames(input_buffers);
+ DecodeStatus status = DecodeMultipleFrames(input_buffers);
- EXPECT_EQ(VideoDecoder::kOk, status);
+ EXPECT_EQ(DecodeStatus::OK, status);
ASSERT_EQ(2U, output_frames_.size());
}
@@ -279,14 +277,14 @@
// The error is only raised on the second decode attempt, so we expect at
// least one successful decode but we don't expect valid frame to be decoded.
// During the second decode attempt an error is raised.
- EXPECT_EQ(VideoDecoder::kOk, Decode(corrupt_i_frame_buffer_));
+ EXPECT_EQ(DecodeStatus::OK, Decode(corrupt_i_frame_buffer_));
EXPECT_TRUE(output_frames_.empty());
- EXPECT_EQ(VideoDecoder::kDecodeError, Decode(i_frame_buffer_));
+ EXPECT_EQ(DecodeStatus::DECODE_ERROR, Decode(i_frame_buffer_));
EXPECT_TRUE(output_frames_.empty());
// After a decode error occurred, all following decodes will return
- // kDecodeError.
- EXPECT_EQ(VideoDecoder::kDecodeError, Decode(i_frame_buffer_));
+ // DecodeStatus::DECODE_ERROR.
+ EXPECT_EQ(DecodeStatus::DECODE_ERROR, Decode(i_frame_buffer_));
EXPECT_TRUE(output_frames_.empty());
}
@@ -294,7 +292,7 @@
TEST_F(FFmpegVideoDecoderTest, DecodeFrame_DecodeErrorAtEndOfStream) {
Initialize();
- EXPECT_EQ(VideoDecoder::kDecodeError,
+ EXPECT_EQ(DecodeStatus::DECODE_ERROR,
DecodeSingleFrame(corrupt_i_frame_buffer_));
}
diff --git a/media/filters/gpu_video_decoder.cc b/media/filters/gpu_video_decoder.cc
index f09c5da3..57d3efa 100644
--- a/media/filters/gpu_video_decoder.cc
+++ b/media/filters/gpu_video_decoder.cc
@@ -299,7 +299,7 @@
DecodeCB bound_decode_cb = BindToCurrentLoop(decode_cb);
if (state_ == kError || !vda_) {
- bound_decode_cb.Run(kDecodeError);
+ bound_decode_cb.Run(DecodeStatus::DECODE_ERROR);
return;
}
@@ -328,7 +328,7 @@
size_t size = buffer->data_size();
scoped_ptr<SHMBuffer> shm_buffer = GetSHM(size);
if (!shm_buffer) {
- bound_decode_cb.Run(kDecodeError);
+ bound_decode_cb.Run(DecodeStatus::DECODE_ERROR);
return;
}
@@ -631,7 +631,8 @@
}
PutSHM(make_scoped_ptr(it->second.shm_buffer));
- it->second.done_cb.Run(state_ == kError ? kDecodeError : kOk);
+ it->second.done_cb.Run(state_ == kError ? DecodeStatus::DECODE_ERROR
+ : DecodeStatus::OK);
bitstream_buffers_in_decoder_.erase(it);
}
@@ -657,7 +658,7 @@
bitstream_buffers_in_decoder_.begin();
it != bitstream_buffers_in_decoder_.end(); ++it) {
delete it->second.shm_buffer;
- it->second.done_cb.Run(kAborted);
+ it->second.done_cb.Run(DecodeStatus::ABORTED);
}
bitstream_buffers_in_decoder_.clear();
@@ -670,7 +671,7 @@
DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
DCHECK_EQ(state_, kDrainingDecoder);
state_ = kDecoderDrained;
- base::ResetAndReturn(&eos_decode_cb_).Run(kOk);
+ base::ResetAndReturn(&eos_decode_cb_).Run(DecodeStatus::OK);
}
void GpuVideoDecoder::NotifyResetDone() {
@@ -699,7 +700,7 @@
// won't be another decode request to report the error.
if (!bitstream_buffers_in_decoder_.empty()) {
auto it = bitstream_buffers_in_decoder_.begin();
- it->second.done_cb.Run(kDecodeError);
+ it->second.done_cb.Run(DecodeStatus::DECODE_ERROR);
bitstream_buffers_in_decoder_.erase(it);
}
diff --git a/media/filters/opus_audio_decoder.cc b/media/filters/opus_audio_decoder.cc
index bec37f36..39d38fa 100644
--- a/media/filters/opus_audio_decoder.cc
+++ b/media/filters/opus_audio_decoder.cc
@@ -196,7 +196,7 @@
// Libopus does not buffer output. Decoding is complete when an end of stream
// input buffer is received.
if (input->end_of_stream()) {
- decode_cb.Run(kOk);
+ decode_cb.Run(DecodeStatus::OK);
return;
}
@@ -204,14 +204,14 @@
// occurs with some damaged files.
if (input->timestamp() == kNoTimestamp()) {
DLOG(ERROR) << "Received a buffer without timestamps!";
- decode_cb.Run(kDecodeError);
+ decode_cb.Run(DecodeStatus::DECODE_ERROR);
return;
}
scoped_refptr<AudioBuffer> output_buffer;
if (!Decode(input, &output_buffer)) {
- decode_cb.Run(kDecodeError);
+ decode_cb.Run(DecodeStatus::DECODE_ERROR);
return;
}
@@ -219,7 +219,7 @@
output_cb_.Run(output_buffer);
}
- decode_cb.Run(kOk);
+ decode_cb.Run(DecodeStatus::OK);
}
bool OpusAudioDecoder::ConfigureDecoder() {
diff --git a/media/filters/vpx_video_decoder.cc b/media/filters/vpx_video_decoder.cc
index 8fe66250..2d60d91 100644
--- a/media/filters/vpx_video_decoder.cc
+++ b/media/filters/vpx_video_decoder.cc
@@ -401,25 +401,25 @@
<< "Called Decode() before successful Initialize()";
if (state_ == kError) {
- bound_decode_cb.Run(kDecodeError);
+ bound_decode_cb.Run(DecodeStatus::DECODE_ERROR);
return;
}
if (state_ == kDecodeFinished) {
- bound_decode_cb.Run(kOk);
+ bound_decode_cb.Run(DecodeStatus::OK);
return;
}
if (state_ == kNormal && buffer->end_of_stream()) {
state_ = kDecodeFinished;
- bound_decode_cb.Run(kOk);
+ bound_decode_cb.Run(DecodeStatus::OK);
return;
}
scoped_refptr<VideoFrame> video_frame;
if (!VpxDecode(buffer, &video_frame)) {
state_ = kError;
- bound_decode_cb.Run(kDecodeError);
+ bound_decode_cb.Run(DecodeStatus::DECODE_ERROR);
return;
}
@@ -432,7 +432,7 @@
}
// VideoDecoderShim expects |decode_cb| call after |output_cb_|.
- bound_decode_cb.Run(kOk);
+ bound_decode_cb.Run(DecodeStatus::OK);
}
void VpxVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer,
diff --git a/media/media.gyp b/media/media.gyp
index 2020514c..0ad3ab0 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -310,6 +310,8 @@
'base/data_buffer.h',
'base/data_source.cc',
'base/data_source.h',
+ 'base/decode_status.cc',
+ 'base/decode_status.h',
'base/decoder_buffer.cc',
'base/decoder_buffer.h',
'base/decoder_buffer_queue.cc',
diff --git a/media/mojo/services/mojo_audio_decoder.cc b/media/mojo/services/mojo_audio_decoder.cc
index 9a070bb..51995ea 100644
--- a/media/mojo/services/mojo_audio_decoder.cc
+++ b/media/mojo/services/mojo_audio_decoder.cc
@@ -85,7 +85,8 @@
DCHECK(task_runner_->BelongsToCurrentThread());
if (has_connection_error_) {
- task_runner_->PostTask(FROM_HERE, base::Bind(decode_cb, kDecodeError));
+ task_runner_->PostTask(FROM_HERE,
+ base::Bind(decode_cb, DecodeStatus::DECODE_ERROR));
return;
}
@@ -103,9 +104,9 @@
if (has_connection_error_) {
if (!decode_cb_.is_null()) {
- task_runner_->PostTask(
- FROM_HERE,
- base::Bind(base::ResetAndReturn(&decode_cb_), kDecodeError));
+ task_runner_->PostTask(FROM_HERE,
+ base::Bind(base::ResetAndReturn(&decode_cb_),
+ DecodeStatus::DECODE_ERROR));
}
task_runner_->PostTask(FROM_HERE, closure);
@@ -144,7 +145,7 @@
}
if (!decode_cb_.is_null())
- base::ResetAndReturn(&decode_cb_).Run(kDecodeError);
+ base::ResetAndReturn(&decode_cb_).Run(DecodeStatus::DECODE_ERROR);
if (!reset_cb_.is_null())
base::ResetAndReturn(&reset_cb_).Run();
}
@@ -162,18 +163,18 @@
task_runner_->PostTask(FROM_HERE, base::Bind(init_cb_, status));
}
-static media::AudioDecoder::Status ConvertDecodeStatus(
+static media::DecodeStatus ConvertDecodeStatus(
interfaces::AudioDecoder::DecodeStatus status) {
switch (status) {
case interfaces::AudioDecoder::DecodeStatus::OK:
- return media::AudioDecoder::kOk;
+ return media::DecodeStatus::OK;
case interfaces::AudioDecoder::DecodeStatus::ABORTED:
- return media::AudioDecoder::kAborted;
+ return media::DecodeStatus::ABORTED;
case interfaces::AudioDecoder::DecodeStatus::DECODE_ERROR:
- return media::AudioDecoder::kDecodeError;
+ return media::DecodeStatus::DECODE_ERROR;
}
NOTREACHED();
- return media::AudioDecoder::kDecodeError;
+ return media::DecodeStatus::DECODE_ERROR;
}
void MojoAudioDecoder::OnDecodeStatus(
diff --git a/media/mojo/services/mojo_audio_decoder_service.cc b/media/mojo/services/mojo_audio_decoder_service.cc
index c27b03f3..16ab502 100644
--- a/media/mojo/services/mojo_audio_decoder_service.cc
+++ b/media/mojo/services/mojo_audio_decoder_service.cc
@@ -104,22 +104,21 @@
}
static interfaces::AudioDecoder::DecodeStatus ConvertDecodeStatus(
- media::AudioDecoder::Status status) {
+ media::DecodeStatus status) {
switch (status) {
- case media::AudioDecoder::kOk:
+ case media::DecodeStatus::OK:
return interfaces::AudioDecoder::DecodeStatus::OK;
- case media::AudioDecoder::kAborted:
+ case media::DecodeStatus::ABORTED:
return interfaces::AudioDecoder::DecodeStatus::ABORTED;
- case media::AudioDecoder::kDecodeError:
+ case media::DecodeStatus::DECODE_ERROR:
return interfaces::AudioDecoder::DecodeStatus::DECODE_ERROR;
}
NOTREACHED();
return interfaces::AudioDecoder::DecodeStatus::DECODE_ERROR;
}
-void MojoAudioDecoderService::OnDecodeStatus(
- const DecodeCallback& callback,
- media::AudioDecoder::Status status) {
+void MojoAudioDecoderService::OnDecodeStatus(const DecodeCallback& callback,
+ media::DecodeStatus status) {
DVLOG(3) << __FUNCTION__ << " status:" << status;
callback.Run(ConvertDecodeStatus(status));
}
diff --git a/media/mojo/services/mojo_audio_decoder_service.h b/media/mojo/services/mojo_audio_decoder_service.h
index 23c103fd..888fb586 100644
--- a/media/mojo/services/mojo_audio_decoder_service.h
+++ b/media/mojo/services/mojo_audio_decoder_service.h
@@ -48,7 +48,7 @@
// Called by |decoder_| when DecoderBuffer is accepted or rejected.
void OnDecodeStatus(const DecodeCallback& callback,
- media::AudioDecoder::Status status);
+ media::DecodeStatus status);
// Called by |decoder_| when reset sequence is finished.
void OnResetDone(const ResetCallback& callback);
diff --git a/media/mojo/services/mojo_video_decoder.cc b/media/mojo/services/mojo_video_decoder.cc
index 6f12cfe..ab0c1228 100644
--- a/media/mojo/services/mojo_video_decoder.cc
+++ b/media/mojo/services/mojo_video_decoder.cc
@@ -44,7 +44,8 @@
NOTIMPLEMENTED();
// Actually we can't decode anything.
- task_runner_->PostTask(FROM_HERE, base::Bind(decode_cb, kDecodeError));
+ task_runner_->PostTask(FROM_HERE,
+ base::Bind(decode_cb, DecodeStatus::DECODE_ERROR));
}
void MojoVideoDecoder::Reset(const base::Closure& closure) {
diff --git a/media/renderers/audio_renderer_impl.h b/media/renderers/audio_renderer_impl.h
index a16a861..0b2d400 100644
--- a/media/renderers/audio_renderer_impl.h
+++ b/media/renderers/audio_renderer_impl.h
@@ -128,7 +128,7 @@
// Returns true if more buffers are needed.
bool HandleSplicerBuffer_Locked(const scoped_refptr<AudioBuffer>& buffer);
- // Helper functions for AudioDecoder::Status values passed to
+ // Helper functions for DecodeStatus values passed to
// DecodedAudioReady().
void HandleAbortedReadOrDecodeError(PipelineStatus status);
diff --git a/media/renderers/audio_renderer_impl_unittest.cc b/media/renderers/audio_renderer_impl_unittest.cc
index 57d5dca..474d2861 100644
--- a/media/renderers/audio_renderer_impl_unittest.cc
+++ b/media/renderers/audio_renderer_impl_unittest.cc
@@ -259,7 +259,7 @@
next_timestamp_->GetTimestamp());
next_timestamp_->AddFrames(frames.value);
- DeliverBuffer(AudioDecoder::kOk, buffer);
+ DeliverBuffer(DecodeStatus::OK, buffer);
}
void DeliverEndOfStream() {
@@ -273,13 +273,13 @@
// Satify pending |decode_cb_| to trigger a new DemuxerStream::Read().
message_loop_.PostTask(
FROM_HERE,
- base::Bind(base::ResetAndReturn(&decode_cb_), AudioDecoder::kOk));
+ base::Bind(base::ResetAndReturn(&decode_cb_), DecodeStatus::OK));
WaitForPendingRead();
message_loop_.PostTask(
FROM_HERE,
- base::Bind(base::ResetAndReturn(&decode_cb_), AudioDecoder::kOk));
+ base::Bind(base::ResetAndReturn(&decode_cb_), DecodeStatus::OK));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(last_statistics_.audio_memory_usage,
@@ -399,7 +399,7 @@
message_loop_.PostTask(FROM_HERE, reset_cb);
}
- void DeliverBuffer(AudioDecoder::Status status,
+ void DeliverBuffer(DecodeStatus status,
const scoped_refptr<AudioBuffer>& buffer) {
CHECK(!decode_cb_.is_null());
diff --git a/media/renderers/video_renderer_impl_unittest.cc b/media/renderers/video_renderer_impl_unittest.cc
index 3b0b273..af589d8 100644
--- a/media/renderers/video_renderer_impl_unittest.cc
+++ b/media/renderers/video_renderer_impl_unittest.cc
@@ -172,14 +172,14 @@
if (token == "abort") {
scoped_refptr<VideoFrame> null_frame;
decode_results_.push_back(
- std::make_pair(VideoDecoder::kAborted, null_frame));
+ std::make_pair(DecodeStatus::ABORTED, null_frame));
continue;
}
if (token == "error") {
scoped_refptr<VideoFrame> null_frame;
decode_results_.push_back(
- std::make_pair(VideoDecoder::kDecodeError, null_frame));
+ std::make_pair(DecodeStatus::DECODE_ERROR, null_frame));
continue;
}
@@ -189,7 +189,7 @@
scoped_refptr<VideoFrame> frame = VideoFrame::CreateFrame(
PIXEL_FORMAT_YV12, natural_size, gfx::Rect(natural_size),
natural_size, base::TimeDelta::FromMilliseconds(timestamp_in_ms));
- decode_results_.push_back(std::make_pair(VideoDecoder::kOk, frame));
+ decode_results_.push_back(std::make_pair(DecodeStatus::OK, frame));
continue;
}
@@ -251,13 +251,13 @@
// Satify pending |decode_cb_| to trigger a new DemuxerStream::Read().
message_loop_.PostTask(
FROM_HERE,
- base::Bind(base::ResetAndReturn(&decode_cb_), VideoDecoder::kOk));
+ base::Bind(base::ResetAndReturn(&decode_cb_), DecodeStatus::OK));
WaitForPendingRead();
message_loop_.PostTask(
FROM_HERE,
- base::Bind(base::ResetAndReturn(&decode_cb_), VideoDecoder::kOk));
+ base::Bind(base::ResetAndReturn(&decode_cb_), DecodeStatus::OK));
}
void AdvanceWallclockTimeInMs(int time_ms) {
@@ -352,8 +352,8 @@
// Run during DecodeRequested() to unblock WaitForPendingRead().
base::Closure wait_for_pending_decode_cb_;
- std::deque<std::pair<
- VideoDecoder::Status, scoped_refptr<VideoFrame> > > decode_results_;
+ std::deque<std::pair<DecodeStatus, scoped_refptr<VideoFrame>>>
+ decode_results_;
DISALLOW_COPY_AND_ASSIGN(VideoRendererImplTest);
};