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

Unified Diff: media/filters/ffmpeg_video_decoder_unittest.cc

Issue 160005: Implemented proper pause-then-seek behaviour for the media pipeline. (Closed)
Patch Set: yay Created 11 years, 5 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
« no previous file with comments | « media/filters/ffmpeg_video_decoder.cc ('k') | media/filters/video_renderer_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9102b6c3fed266db652038aec7a7029b16ba6216..2063fe8eb870007386adc4df8e6975626501be07 100644
--- a/media/filters/ffmpeg_video_decoder_unittest.cc
+++ b/media/filters/ffmpeg_video_decoder_unittest.cc
@@ -271,21 +271,6 @@ TEST_F(FFmpegVideoDecoderTest, DecodeFrame_Normal) {
EXPECT_TRUE(decoder->DecodeFrame(*buffer_, &codec_context_, &yuv_frame_));
}
-TEST_F(FFmpegVideoDecoderTest, DecodeFrame_DiscontinuousBuffer) {
- buffer_->SetDiscontinuous(true);
-
- // Expect a bunch of avcodec calls.
- EXPECT_CALL(mock_ffmpeg_, AVCodecFlushBuffers(&codec_context_));
- EXPECT_CALL(mock_ffmpeg_, AVInitPacket(_));
- EXPECT_CALL(mock_ffmpeg_,
- AVCodecDecodeVideo2(&codec_context_, &yuv_frame_, _, _))
- .WillOnce(DoAll(SetArgumentPointee<2>(1), // Simulate 1 byte frame.
- Return(0)));
-
- scoped_refptr<FFmpegVideoDecoder> decoder = new FFmpegVideoDecoder();
- EXPECT_TRUE(decoder->DecodeFrame(*buffer_, &codec_context_, &yuv_frame_));
-}
-
TEST_F(FFmpegVideoDecoderTest, DecodeFrame_0ByteFrame) {
// Expect a bunch of avcodec calls.
EXPECT_CALL(mock_ffmpeg_, AVInitPacket(_));
@@ -527,6 +512,38 @@ TEST_F(FFmpegVideoDecoderTest, OnDecode_FinishEnqueuesEmptyFrames) {
EXPECT_EQ(FFmpegVideoDecoder::kDecodeFinished, mock_decoder->state_);
}
+TEST_F(FFmpegVideoDecoderTest, OnSeek) {
+ // Simulates receiving a call to OnSeek() while in every possible state. In
+ // every case, it should clear the timestamp queue, flush the decoder and
+ // reset the state to kNormal.
+ scoped_refptr<DecoderPrivateMock> mock_decoder =
+ new StrictMock<DecoderPrivateMock>();
+ mock_decoder->codec_context_ = &codec_context_;
+
+ const base::TimeDelta kZero;
+ const FFmpegVideoDecoder::DecoderState kStates[] = {
+ FFmpegVideoDecoder::kNormal,
+ FFmpegVideoDecoder::kFlushCodec,
+ FFmpegVideoDecoder::kDecodeFinished,
+ };
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kStates); ++i) {
+ // Push in some timestamps.
+ mock_decoder->pts_queue_.push(kTestPts1.timestamp);
+ mock_decoder->pts_queue_.push(kTestPts2.timestamp);
+ mock_decoder->pts_queue_.push(kTestPts1.timestamp);
+
+ // Expect a flush.
+ mock_decoder->state_ = kStates[i];
+ EXPECT_CALL(mock_ffmpeg_, AVCodecFlushBuffers(&codec_context_));
+
+ // Seek and verify the results.
+ mock_decoder->OnSeek(kZero);
+ EXPECT_TRUE(mock_decoder->pts_queue_.empty());
+ EXPECT_EQ(FFmpegVideoDecoder::kNormal, mock_decoder->state_);
+ }
+}
+
TEST_F(FFmpegVideoDecoderTest, TimeQueue_Ordering) {
FFmpegVideoDecoder::TimeQueue queue;
queue.push(kTestPts1.timestamp);
« no previous file with comments | « media/filters/ffmpeg_video_decoder.cc ('k') | media/filters/video_renderer_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698