Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Unified Diff: media/filters/ffmpeg_video_decoder_unittest.cc

Issue 10248002: Report VideoDecoder status through ReadCB instead of through FilterHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/filters/ffmpeg_video_decoder_unittest.cc
diff --git a/media/filters/ffmpeg_video_decoder_unittest.cc b/media/filters/ffmpeg_video_decoder_unittest.cc
index b111ac38a8435d17f1e2c4133155932e06d616fc..7519f647cd15e15f6ca297785e1404e13a8c78f6 100644
--- a/media/filters/ffmpeg_video_decoder_unittest.cc
+++ b/media/filters/ffmpeg_video_decoder_unittest.cc
@@ -13,7 +13,6 @@
#include "media/base/filters.h"
#include "media/base/limits.h"
#include "media/base/mock_callback.h"
-#include "media/base/mock_filter_host.h"
#include "media/base/mock_filters.h"
#include "media/base/test_data_util.h"
#include "media/base/video_frame.h"
@@ -56,8 +55,6 @@ class FFmpegVideoDecoderTest : public testing::Test {
base::Unretained(this))) {
CHECK(FFmpegGlue::GetInstance());
- decoder_->set_host(&host_);
-
// Initialize various test buffers.
frame_buffer_.reset(new uint8[kCodedSize.GetArea()]);
end_of_stream_buffer_ = new DataBuffer(0);
@@ -120,19 +117,23 @@ class FFmpegVideoDecoderTest : public testing::Test {
// decoding state.
void EnterDecodingState() {
scoped_refptr<VideoFrame> video_frame;
- DecodeSingleFrame(i_frame_buffer_, &video_frame);
+ VideoDecoder::Status status;
+ DecodeSingleFrame(i_frame_buffer_, &video_frame, &status);
ASSERT_TRUE(video_frame);
EXPECT_FALSE(video_frame->IsEndOfStream());
+ EXPECT_EQ(VideoDecoder::kOk, status);
Ami GONE FROM CHROMIUM 2012/04/27 16:49:14 order should be: actual,expected (to match thousan
xhwang 2012/04/27 23:22:30 Done.
}
// Sets up expectations and actions to put FFmpegVideoDecoder in an end
// of stream state.
void EnterEndOfStreamState() {
scoped_refptr<VideoFrame> video_frame;
- Read(&video_frame);
+ VideoDecoder::Status status;
+ Read(&video_frame, &status);
ASSERT_TRUE(video_frame);
EXPECT_TRUE(video_frame->IsEndOfStream());
+ EXPECT_EQ(VideoDecoder::kOk, status);
}
// Decodes the single compressed frame in |buffer| and writes the
@@ -140,14 +141,15 @@ class FFmpegVideoDecoderTest : public testing::Test {
// and multithreaded decoders. End of stream buffers are used to trigger
// the frame to be returned in the multithreaded decoder case.
void DecodeSingleFrame(const scoped_refptr<Buffer>& buffer,
- scoped_refptr<VideoFrame>* video_frame) {
+ scoped_refptr<VideoFrame>* video_frame,
+ VideoDecoder::Status* status) {
EXPECT_CALL(*demuxer_, Read(_))
.WillOnce(ReturnBuffer(buffer))
.WillRepeatedly(ReturnBuffer(end_of_stream_buffer_));
EXPECT_CALL(statistics_cb_, OnStatistics(_));
- Read(video_frame);
+ Read(video_frame, status);
}
// Decodes |i_frame_buffer_| and then decodes the data contained in
@@ -160,6 +162,8 @@ class FFmpegVideoDecoderTest : public testing::Test {
scoped_refptr<VideoFrame> video_frame_a;
scoped_refptr<VideoFrame> video_frame_b;
+ VideoDecoder::Status status_a;
+ VideoDecoder::Status status_b;
scoped_refptr<Buffer> buffer;
ReadTestDataFile(test_file_name, &buffer);
@@ -172,8 +176,8 @@ class FFmpegVideoDecoderTest : public testing::Test {
EXPECT_CALL(statistics_cb_, OnStatistics(_))
.Times(2);
- Read(&video_frame_a);
- Read(&video_frame_b);
+ Read(&video_frame_a, &status_a);
+ Read(&video_frame_b, &status_b);
size_t original_width = static_cast<size_t>(kVisibleRect.width());
size_t original_height = static_cast<size_t>(kVisibleRect.height());
@@ -184,24 +188,27 @@ class FFmpegVideoDecoderTest : public testing::Test {
EXPECT_EQ(original_height, video_frame_a->height());
EXPECT_EQ(expected_width, video_frame_b->width());
EXPECT_EQ(expected_height, video_frame_b->height());
+ EXPECT_EQ(VideoDecoder::kOk, status_a);
+ EXPECT_EQ(VideoDecoder::kOk, status_b);
}
- void Read(scoped_refptr<VideoFrame>* video_frame) {
- EXPECT_CALL(*this, FrameReady(_))
- .WillOnce(SaveArg<0>(video_frame));
+ void Read(scoped_refptr<VideoFrame>* video_frame,
+ VideoDecoder::Status* status) {
+ EXPECT_CALL(*this, FrameReady(_, _))
+ .WillOnce(DoAll(SaveArg<0>(video_frame), SaveArg<1>(status)));
decoder_->Read(read_cb_);
message_loop_.RunAllPending();
}
- MOCK_METHOD1(FrameReady, void(scoped_refptr<VideoFrame>));
+ MOCK_METHOD2(FrameReady, void(scoped_refptr<VideoFrame>,
+ VideoDecoder::Status));
MessageLoop message_loop_;
scoped_refptr<FFmpegVideoDecoder> decoder_;
scoped_refptr<StrictMock<MockDemuxerStream> > demuxer_;
MockStatisticsCB statistics_cb_;
- StrictMock<MockFilterHost> host_;
VideoDecoderConfig config_;
VideoDecoder::ReadCB read_cb_;
@@ -262,10 +269,12 @@ TEST_F(FFmpegVideoDecoderTest, DecodeFrame_Normal) {
// Simulate decoding a single frame.
scoped_refptr<VideoFrame> video_frame;
- DecodeSingleFrame(i_frame_buffer_, &video_frame);
+ VideoDecoder::Status status;
+ DecodeSingleFrame(i_frame_buffer_, &video_frame, &status);
ASSERT_TRUE(video_frame);
EXPECT_FALSE(video_frame->IsEndOfStream());
+ EXPECT_EQ(VideoDecoder::kOk, status);
}
// Verify current behavior for 0 byte frames. FFmpeg simply ignores
@@ -278,6 +287,9 @@ TEST_F(FFmpegVideoDecoderTest, DecodeFrame_0ByteFrame) {
scoped_refptr<VideoFrame> video_frame_a;
scoped_refptr<VideoFrame> video_frame_b;
scoped_refptr<VideoFrame> video_frame_c;
+ VideoDecoder::Status status_a;
+ VideoDecoder::Status status_b;
+ VideoDecoder::Status status_c;
EXPECT_CALL(*demuxer_, Read(_))
.WillOnce(ReturnBuffer(i_frame_buffer_))
@@ -288,9 +300,9 @@ TEST_F(FFmpegVideoDecoderTest, DecodeFrame_0ByteFrame) {
EXPECT_CALL(statistics_cb_, OnStatistics(_))
.Times(2);
- Read(&video_frame_a);
- Read(&video_frame_b);
- Read(&video_frame_c);
+ Read(&video_frame_a, &status_a);
+ Read(&video_frame_b, &status_b);
+ Read(&video_frame_c, &status_c);
ASSERT_TRUE(video_frame_a);
ASSERT_TRUE(video_frame_b);
@@ -299,6 +311,10 @@ TEST_F(FFmpegVideoDecoderTest, DecodeFrame_0ByteFrame) {
EXPECT_FALSE(video_frame_a->IsEndOfStream());
EXPECT_FALSE(video_frame_b->IsEndOfStream());
EXPECT_TRUE(video_frame_c->IsEndOfStream());
+
+ EXPECT_EQ(VideoDecoder::kOk, status_a);
+ EXPECT_EQ(VideoDecoder::kOk, status_b);
+ EXPECT_EQ(VideoDecoder::kOk, status_c);
}
TEST_F(FFmpegVideoDecoderTest, DecodeFrame_DecodeError) {
@@ -312,14 +328,14 @@ TEST_F(FFmpegVideoDecoderTest, DecodeFrame_DecodeError) {
// least one successful decode but we don't expect FrameReady() to be
// executed as an error is raised instead.
EXPECT_CALL(statistics_cb_, OnStatistics(_));
- EXPECT_CALL(host_, SetError(PIPELINE_ERROR_DECODE));
// Our read should still get satisfied with end of stream frame during an
// error.
scoped_refptr<VideoFrame> video_frame;
- Read(&video_frame);
- ASSERT_TRUE(video_frame);
- EXPECT_TRUE(video_frame->IsEndOfStream());
+ VideoDecoder::Status status;
+ Read(&video_frame, &status);
+ EXPECT_FALSE(video_frame);
+ EXPECT_EQ(VideoDecoder::kDecodeError, status);
message_loop_.RunAllPending();
}
@@ -333,10 +349,12 @@ TEST_F(FFmpegVideoDecoderTest, DecodeFrame_DecodeErrorAtEndOfStream) {
Initialize();
scoped_refptr<VideoFrame> video_frame;
- DecodeSingleFrame(corrupt_i_frame_buffer_, &video_frame);
+ VideoDecoder::Status status;
+ DecodeSingleFrame(corrupt_i_frame_buffer_, &video_frame, &status);
ASSERT_TRUE(video_frame);
EXPECT_TRUE(video_frame->IsEndOfStream());
+ EXPECT_EQ(VideoDecoder::kOk, status);
}
// Decode |i_frame_buffer_| and then a frame with a larger width and verify
@@ -372,10 +390,12 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_Normal) {
encrypted_i_frame_buffer_->SetDecryptConfig(scoped_ptr<DecryptConfig>(
new DecryptConfig(kKeyId, arraysize(kKeyId) - 1)));
scoped_refptr<VideoFrame> video_frame;
- DecodeSingleFrame(encrypted_i_frame_buffer_, &video_frame);
+ VideoDecoder::Status status;
+ DecodeSingleFrame(encrypted_i_frame_buffer_, &video_frame, &status);
ASSERT_TRUE(video_frame);
EXPECT_FALSE(video_frame->IsEndOfStream());
+ EXPECT_EQ(VideoDecoder::kOk, status);
}
// No key is provided to the decryptor and we expect to see a decrypt error.
@@ -388,14 +408,14 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_NoKey) {
EXPECT_CALL(*demuxer_, Read(_))
.WillRepeatedly(ReturnBuffer(encrypted_i_frame_buffer_));
- EXPECT_CALL(host_, SetError(PIPELINE_ERROR_DECRYPT));
// Our read should still get satisfied with end of stream frame during an
// error.
scoped_refptr<VideoFrame> video_frame;
- Read(&video_frame);
- ASSERT_TRUE(video_frame);
- EXPECT_TRUE(video_frame->IsEndOfStream());
+ VideoDecoder::Status status;
+ Read(&video_frame, &status);
+ EXPECT_FALSE(video_frame);
+ EXPECT_EQ(VideoDecoder::kDecryptError, status);
message_loop_.RunAllPending();
}
@@ -416,17 +436,19 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_WrongKey) {
// attempts to decode the content, however we're unable to distinguish between
// the two (see http://crbug.com/124434).
EXPECT_CALL(statistics_cb_, OnStatistics(_));
- EXPECT_CALL(host_, SetError(PIPELINE_ERROR_DECODE));
-#else
- EXPECT_CALL(host_, SetError(PIPELINE_ERROR_DECRYPT));
#endif
// Our read should still get satisfied with end of stream frame during an
// error.
scoped_refptr<VideoFrame> video_frame;
- Read(&video_frame);
- ASSERT_TRUE(video_frame);
- EXPECT_TRUE(video_frame->IsEndOfStream());
+ VideoDecoder::Status status;
+ Read(&video_frame, &status);
+ EXPECT_FALSE(video_frame);
+#if defined(OS_LINUX)
+ EXPECT_EQ(VideoDecoder::kDecodeError, status);
+#else
+ EXPECT_EQ(VideoDecoder::kDecryptError, status);
+#endif
message_loop_.RunAllPending();
}
@@ -491,7 +513,8 @@ TEST_F(FFmpegVideoDecoderTest, Flush_DuringPendingRead) {
// Flush the decoder.
Flush();
- EXPECT_CALL(*this, FrameReady(scoped_refptr<VideoFrame>()));
+ EXPECT_CALL(*this, FrameReady(scoped_refptr<VideoFrame>(),
+ VideoDecoder::kOk));
read_cb.Run(i_frame_buffer_);
message_loop_.RunAllPending();
@@ -549,8 +572,11 @@ TEST_F(FFmpegVideoDecoderTest, AbortPendingRead) {
.WillOnce(ReturnBuffer(scoped_refptr<Buffer>()));
scoped_refptr<VideoFrame> video_frame;
- Read(&video_frame);
+ VideoDecoder::Status status;
+
+ Read(&video_frame, &status);
EXPECT_FALSE(video_frame);
+ EXPECT_EQ(VideoDecoder::kOk, status);
}
// Test aborted read on the demuxer stream.
@@ -576,7 +602,7 @@ TEST_F(FFmpegVideoDecoderTest, AbortPendingReadDuringFlush) {
// Make sure we get a NULL video frame returned.
scoped_refptr<VideoFrame> video_frame;
- EXPECT_CALL(*this, FrameReady(_))
+ EXPECT_CALL(*this, FrameReady(_, VideoDecoder::kOk))
.WillOnce(SaveArg<0>(&video_frame));
message_loop_.RunAllPending();

Powered by Google App Engine
This is Rietveld 408576698