summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrileya@chromium.org <rileya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-06 20:57:35 +0000
committerrileya@chromium.org <rileya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-06 20:57:35 +0000
commitdfa3958aaaefc7e77ef56803ba14b7c3524f56c3 (patch)
treeaf3a86b266146f3c09d075079cc8b2973a4e215b
parente4f45cd40fb1a778ed93c0fa2b1eadd6914e992b (diff)
downloadchromium_src-dfa3958aaaefc7e77ef56803ba14b7c3524f56c3.zip
chromium_src-dfa3958aaaefc7e77ef56803ba14b7c3524f56c3.tar.gz
chromium_src-dfa3958aaaefc7e77ef56803ba14b7c3524f56c3.tar.bz2
Make VideoDecoder use (kAborted, NULL) to signify an aborted decode, instead of (kOk, NULL).
This makes it match its sibling, AudioDecoder. BUG=329379 Review URL: https://codereview.chromium.org/123213006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243163 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--media/base/video_decoder.h3
-rw-r--r--media/filters/decrypting_video_decoder.cc6
-rw-r--r--media/filters/decrypting_video_decoder_unittest.cc10
-rw-r--r--media/filters/ffmpeg_video_decoder.cc2
-rw-r--r--media/filters/ffmpeg_video_decoder_unittest.cc2
-rw-r--r--media/filters/video_frame_stream.cc3
-rw-r--r--media/filters/video_renderer_impl_unittest.cc2
-rw-r--r--media/filters/vpx_video_decoder.cc2
8 files changed, 15 insertions, 15 deletions
diff --git a/media/base/video_decoder.h b/media/base/video_decoder.h
index 63f63e5..66abc8c 100644
--- a/media/base/video_decoder.h
+++ b/media/base/video_decoder.h
@@ -22,6 +22,7 @@ class MEDIA_EXPORT VideoDecoder {
// Status codes for decode operations on VideoDecoder.
enum Status {
kOk, // Everything went as planned.
+ kAborted, // Decode was aborted as a result of Reset() being called.
kNotEnoughData, // Not enough data to produce a video frame.
kDecodeError, // Decoding error happened.
kDecryptError // Decrypting error happened.
@@ -52,8 +53,6 @@ class MEDIA_EXPORT VideoDecoder {
// If the returned status is kOk:
// - Non-EOS (end of stream) frame contains decoded video data.
// - EOS frame indicates the end of the stream.
- // - NULL frame indicates an aborted decode. This can happen if Reset() or
- // Stop() is called during the decoding process.
// Otherwise the returned frame must be NULL.
typedef base::Callback<void(Status,
const scoped_refptr<VideoFrame>&)> DecodeCB;
diff --git a/media/filters/decrypting_video_decoder.cc b/media/filters/decrypting_video_decoder.cc
index 589b0a5..977d88d 100644
--- a/media/filters/decrypting_video_decoder.cc
+++ b/media/filters/decrypting_video_decoder.cc
@@ -116,7 +116,7 @@ void DecryptingVideoDecoder::Reset(const base::Closure& closure) {
if (state_ == kWaitingForKey) {
DCHECK(!decode_cb_.is_null());
pending_buffer_to_decode_ = NULL;
- base::ResetAndReturn(&decode_cb_).Run(kOk, NULL);
+ base::ResetAndReturn(&decode_cb_).Run(kAborted, NULL);
}
DCHECK(decode_cb_.is_null());
@@ -142,7 +142,7 @@ void DecryptingVideoDecoder::Stop(const base::Closure& closure) {
if (!init_cb_.is_null())
base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED);
if (!decode_cb_.is_null())
- base::ResetAndReturn(&decode_cb_).Run(kOk, NULL);
+ base::ResetAndReturn(&decode_cb_).Run(kAborted, NULL);
if (!reset_cb_.is_null())
base::ResetAndReturn(&reset_cb_).Run();
state_ = kStopped;
@@ -247,7 +247,7 @@ void DecryptingVideoDecoder::DeliverFrame(
pending_buffer_to_decode_ = NULL;
if (!reset_cb_.is_null()) {
- base::ResetAndReturn(&decode_cb_).Run(kOk, NULL);
+ base::ResetAndReturn(&decode_cb_).Run(kAborted, NULL);
DoReset();
return;
}
diff --git a/media/filters/decrypting_video_decoder_unittest.cc b/media/filters/decrypting_video_decoder_unittest.cc
index 1e8bee9..1d6296b 100644
--- a/media/filters/decrypting_video_decoder_unittest.cc
+++ b/media/filters/decrypting_video_decoder_unittest.cc
@@ -363,7 +363,7 @@ TEST_F(DecryptingVideoDecoderTest, Reset_DuringPendingDecode) {
Initialize();
EnterPendingDecodeState();
- EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull()));
+ EXPECT_CALL(*this, FrameReady(VideoDecoder::kAborted, IsNull()));
Reset();
}
@@ -373,7 +373,7 @@ TEST_F(DecryptingVideoDecoderTest, Reset_DuringWaitingForKey) {
Initialize();
EnterWaitingForKeyState();
- EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull()));
+ EXPECT_CALL(*this, FrameReady(VideoDecoder::kAborted, IsNull()));
Reset();
}
@@ -446,7 +446,7 @@ TEST_F(DecryptingVideoDecoderTest, Stop_DuringPendingDecode) {
Initialize();
EnterPendingDecodeState();
- EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull()));
+ EXPECT_CALL(*this, FrameReady(VideoDecoder::kAborted, IsNull()));
Stop();
}
@@ -456,7 +456,7 @@ TEST_F(DecryptingVideoDecoderTest, Stop_DuringWaitingForKey) {
Initialize();
EnterWaitingForKeyState();
- EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull()));
+ EXPECT_CALL(*this, FrameReady(VideoDecoder::kAborted, IsNull()));
Stop();
}
@@ -478,7 +478,7 @@ TEST_F(DecryptingVideoDecoderTest, Stop_DuringPendingReset) {
EnterPendingDecodeState();
EXPECT_CALL(*decryptor_, ResetDecoder(Decryptor::kVideo));
- EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull()));
+ EXPECT_CALL(*this, FrameReady(VideoDecoder::kAborted, IsNull()));
decoder_->Reset(NewExpectedClosure());
Stop();
diff --git a/media/filters/ffmpeg_video_decoder.cc b/media/filters/ffmpeg_video_decoder.cc
index fe0d75fa..38e59ea 100644
--- a/media/filters/ffmpeg_video_decoder.cc
+++ b/media/filters/ffmpeg_video_decoder.cc
@@ -199,7 +199,7 @@ void FFmpegVideoDecoder::Stop(const base::Closure& closure) {
return;
if (!decode_cb_.is_null()) {
- base::ResetAndReturn(&decode_cb_).Run(kOk, NULL);
+ base::ResetAndReturn(&decode_cb_).Run(kAborted, NULL);
// Reset is pending only when decode is pending.
if (!reset_cb_.is_null())
base::ResetAndReturn(&reset_cb_).Run();
diff --git a/media/filters/ffmpeg_video_decoder_unittest.cc b/media/filters/ffmpeg_video_decoder_unittest.cc
index 9663dd1..2ce067c 100644
--- a/media/filters/ffmpeg_video_decoder_unittest.cc
+++ b/media/filters/ffmpeg_video_decoder_unittest.cc
@@ -149,6 +149,8 @@ class FFmpegVideoDecoderTest : public testing::Test {
case VideoDecoder::kNotEnoughData:
DCHECK(!frame);
continue;
+ case VideoDecoder::kAborted:
+ NOTREACHED();
case VideoDecoder::kDecodeError:
case VideoDecoder::kDecryptError:
DCHECK(!frame);
diff --git a/media/filters/video_frame_stream.cc b/media/filters/video_frame_stream.cc
index 0c7ccf3..67adb72 100644
--- a/media/filters/video_frame_stream.cc
+++ b/media/filters/video_frame_stream.cc
@@ -245,18 +245,17 @@ void VideoFrameStream::OnFrameReady(int buffer_size,
DCHECK(state_ == STATE_NORMAL || state_ == STATE_FLUSHING_DECODER) << state_;
DCHECK(!read_cb_.is_null());
DCHECK(stop_cb_.is_null());
+ DCHECK_EQ(status == VideoDecoder::kOk, frame != NULL);
TRACE_EVENT_ASYNC_END0("media", "VideoFrameStream::Decode", this);
if (status == VideoDecoder::kDecodeError) {
- DCHECK(!frame.get());
state_ = STATE_ERROR;
SatisfyRead(DECODE_ERROR, NULL);
return;
}
if (status == VideoDecoder::kDecryptError) {
- DCHECK(!frame.get());
state_ = STATE_ERROR;
SatisfyRead(DECRYPT_ERROR, NULL);
return;
diff --git a/media/filters/video_renderer_impl_unittest.cc b/media/filters/video_renderer_impl_unittest.cc
index 0b07a75..c5b1e44 100644
--- a/media/filters/video_renderer_impl_unittest.cc
+++ b/media/filters/video_renderer_impl_unittest.cc
@@ -211,7 +211,7 @@ class VideoRendererImplTest : public ::testing::Test {
DCHECK_EQ(&message_loop_, base::MessageLoop::current());
scoped_refptr<VideoFrame> null_frame;
decode_results_.push_back(std::make_pair(
- VideoDecoder::kOk, null_frame));
+ VideoDecoder::kAborted, null_frame));
}
void QueuePrerollFrames(int timestamp_ms) {
diff --git a/media/filters/vpx_video_decoder.cc b/media/filters/vpx_video_decoder.cc
index 0feaa09..1d6d517 100644
--- a/media/filters/vpx_video_decoder.cc
+++ b/media/filters/vpx_video_decoder.cc
@@ -207,7 +207,7 @@ void VpxVideoDecoder::Stop(const base::Closure& closure) {
return;
if (!decode_cb_.is_null()) {
- base::ResetAndReturn(&decode_cb_).Run(kOk, NULL);
+ base::ResetAndReturn(&decode_cb_).Run(kAborted, NULL);
// Reset is pending only when decode is pending.
if (!reset_cb_.is_null())
base::ResetAndReturn(&reset_cb_).Run();