OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 static const gfx::Rect kInitVisibleRect(100, 100); | 43 static const gfx::Rect kInitVisibleRect(100, 100); |
44 static const gfx::Size kInitNaturalSize(100, 100); | 44 static const gfx::Size kInitNaturalSize(100, 100); |
45 | 45 |
46 ACTION_P(ReturnBuffer, buffer) { | 46 ACTION_P(ReturnBuffer, buffer) { |
47 arg0.Run(buffer ? DemuxerStream::kOk : DemuxerStream::kAborted, buffer); | 47 arg0.Run(buffer ? DemuxerStream::kOk : DemuxerStream::kAborted, buffer); |
48 } | 48 } |
49 | 49 |
50 class FFmpegVideoDecoderTest : public testing::Test { | 50 class FFmpegVideoDecoderTest : public testing::Test { |
51 public: | 51 public: |
52 FFmpegVideoDecoderTest() | 52 FFmpegVideoDecoderTest() |
53 : decoder_(NULL), | 53 : decoder_(new FFmpegVideoDecoder(message_loop_.message_loop_proxy())), |
54 demuxer_(new StrictMock<MockDemuxerStream>()), | 54 demuxer_(new StrictMock<MockDemuxerStream>()), |
55 read_cb_(base::Bind(&FFmpegVideoDecoderTest::FrameReady, | 55 read_cb_(base::Bind(&FFmpegVideoDecoderTest::FrameReady, |
56 base::Unretained(this))) { | 56 base::Unretained(this))) { |
57 FFmpegGlue::InitializeFFmpeg(); | 57 FFmpegGlue::InitializeFFmpeg(); |
58 | 58 |
59 decoder_ = new FFmpegVideoDecoder(message_loop_.message_loop_proxy()); | |
60 | |
61 // Initialize various test buffers. | 59 // Initialize various test buffers. |
62 frame_buffer_.reset(new uint8[kCodedSize.GetArea()]); | 60 frame_buffer_.reset(new uint8[kCodedSize.GetArea()]); |
63 end_of_stream_buffer_ = DecoderBuffer::CreateEOSBuffer(); | 61 end_of_stream_buffer_ = DecoderBuffer::CreateEOSBuffer(); |
64 i_frame_buffer_ = ReadTestDataFile("vp8-I-frame-320x240"); | 62 i_frame_buffer_ = ReadTestDataFile("vp8-I-frame-320x240"); |
65 corrupt_i_frame_buffer_ = ReadTestDataFile("vp8-corrupt-I-frame"); | 63 corrupt_i_frame_buffer_ = ReadTestDataFile("vp8-corrupt-I-frame"); |
66 } | 64 } |
67 | 65 |
68 virtual ~FFmpegVideoDecoderTest() { | 66 virtual ~FFmpegVideoDecoderTest() { |
69 Stop(); | 67 Stop(); |
70 } | 68 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 192 |
195 decoder_->Read(read_cb_); | 193 decoder_->Read(read_cb_); |
196 | 194 |
197 message_loop_.RunUntilIdle(); | 195 message_loop_.RunUntilIdle(); |
198 } | 196 } |
199 | 197 |
200 MOCK_METHOD2(FrameReady, void(VideoDecoder::Status, | 198 MOCK_METHOD2(FrameReady, void(VideoDecoder::Status, |
201 const scoped_refptr<VideoFrame>&)); | 199 const scoped_refptr<VideoFrame>&)); |
202 | 200 |
203 MessageLoop message_loop_; | 201 MessageLoop message_loop_; |
204 scoped_refptr<FFmpegVideoDecoder> decoder_; | 202 scoped_ptr<FFmpegVideoDecoder> decoder_; |
205 scoped_refptr<StrictMock<MockDemuxerStream> > demuxer_; | 203 scoped_refptr<StrictMock<MockDemuxerStream> > demuxer_; |
206 MockStatisticsCB statistics_cb_; | 204 MockStatisticsCB statistics_cb_; |
207 VideoDecoderConfig config_; | 205 VideoDecoderConfig config_; |
208 | 206 |
209 VideoDecoder::ReadCB read_cb_; | 207 VideoDecoder::ReadCB read_cb_; |
210 | 208 |
211 // Various buffers for testing. | 209 // Various buffers for testing. |
212 scoped_ptr<uint8_t[]> frame_buffer_; | 210 scoped_ptr<uint8_t[]> frame_buffer_; |
213 scoped_refptr<DecoderBuffer> end_of_stream_buffer_; | 211 scoped_refptr<DecoderBuffer> end_of_stream_buffer_; |
214 scoped_refptr<DecoderBuffer> i_frame_buffer_; | 212 scoped_refptr<DecoderBuffer> i_frame_buffer_; |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 .Times(AtLeast(1)) | 660 .Times(AtLeast(1)) |
663 .WillRepeatedly(ReturnRef(invalid_config)); | 661 .WillRepeatedly(ReturnRef(invalid_config)); |
664 EXPECT_CALL(*this, FrameReady(VideoDecoder::kDecodeError, IsNull())); | 662 EXPECT_CALL(*this, FrameReady(VideoDecoder::kDecodeError, IsNull())); |
665 | 663 |
666 // Signal a config change. | 664 // Signal a config change. |
667 base::ResetAndReturn(&read_cb).Run(DemuxerStream::kConfigChanged, NULL); | 665 base::ResetAndReturn(&read_cb).Run(DemuxerStream::kConfigChanged, NULL); |
668 message_loop_.RunUntilIdle(); | 666 message_loop_.RunUntilIdle(); |
669 } | 667 } |
670 | 668 |
671 } // namespace media | 669 } // namespace media |
OLD | NEW |