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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 arg0.Run(buffer.get() ? DemuxerStream::kOk : DemuxerStream::kAborted, buffer); | 53 arg0.Run(buffer.get() ? DemuxerStream::kOk : DemuxerStream::kAborted, buffer); |
54 } | 54 } |
55 | 55 |
56 MATCHER(ContainsInvalidDataLog, "") { | 56 MATCHER(ContainsInvalidDataLog, "") { |
57 return CONTAINS_STRING(arg, "Invalid data"); | 57 return CONTAINS_STRING(arg, "Invalid data"); |
58 } | 58 } |
59 | 59 |
60 class FFmpegVideoDecoderTest : public testing::Test { | 60 class FFmpegVideoDecoderTest : public testing::Test { |
61 public: | 61 public: |
62 FFmpegVideoDecoderTest() | 62 FFmpegVideoDecoderTest() |
63 : media_log_(new StrictMock<MockMediaLog>()), | 63 : decoder_(new FFmpegVideoDecoder(&media_log_)), |
64 decoder_(new FFmpegVideoDecoder(media_log_)), | |
65 decode_cb_(base::Bind(&FFmpegVideoDecoderTest::DecodeDone, | 64 decode_cb_(base::Bind(&FFmpegVideoDecoderTest::DecodeDone, |
66 base::Unretained(this))) { | 65 base::Unretained(this))) { |
67 FFmpegGlue::InitializeFFmpeg(); | 66 FFmpegGlue::InitializeFFmpeg(); |
68 | 67 |
69 // Initialize various test buffers. | 68 // Initialize various test buffers. |
70 frame_buffer_.reset(new uint8_t[kCodedSize.GetArea()]); | 69 frame_buffer_.reset(new uint8_t[kCodedSize.GetArea()]); |
71 end_of_stream_buffer_ = DecoderBuffer::CreateEOSBuffer(); | 70 end_of_stream_buffer_ = DecoderBuffer::CreateEOSBuffer(); |
72 i_frame_buffer_ = ReadTestDataFile("vp8-I-frame-320x240"); | 71 i_frame_buffer_ = ReadTestDataFile("vp8-I-frame-320x240"); |
73 corrupt_i_frame_buffer_ = ReadTestDataFile("vp8-corrupt-I-frame"); | 72 corrupt_i_frame_buffer_ = ReadTestDataFile("vp8-corrupt-I-frame"); |
74 } | 73 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 return status; | 197 return status; |
199 } | 198 } |
200 | 199 |
201 void FrameReady(const scoped_refptr<VideoFrame>& frame) { | 200 void FrameReady(const scoped_refptr<VideoFrame>& frame) { |
202 DCHECK(!frame->metadata()->IsTrue(VideoFrameMetadata::END_OF_STREAM)); | 201 DCHECK(!frame->metadata()->IsTrue(VideoFrameMetadata::END_OF_STREAM)); |
203 output_frames_.push_back(frame); | 202 output_frames_.push_back(frame); |
204 } | 203 } |
205 | 204 |
206 MOCK_METHOD1(DecodeDone, void(DecodeStatus)); | 205 MOCK_METHOD1(DecodeDone, void(DecodeStatus)); |
207 | 206 |
208 scoped_refptr<StrictMock<MockMediaLog>> media_log_; | 207 StrictMock<MockMediaLog> media_log_; |
209 | 208 |
210 base::MessageLoop message_loop_; | 209 base::MessageLoop message_loop_; |
211 std::unique_ptr<FFmpegVideoDecoder> decoder_; | 210 std::unique_ptr<FFmpegVideoDecoder> decoder_; |
212 | 211 |
213 VideoDecoder::DecodeCB decode_cb_; | 212 VideoDecoder::DecodeCB decode_cb_; |
214 | 213 |
215 // Various buffers for testing. | 214 // Various buffers for testing. |
216 std::unique_ptr<uint8_t[]> frame_buffer_; | 215 std::unique_ptr<uint8_t[]> frame_buffer_; |
217 scoped_refptr<DecoderBuffer> end_of_stream_buffer_; | 216 scoped_refptr<DecoderBuffer> end_of_stream_buffer_; |
218 scoped_refptr<DecoderBuffer> i_frame_buffer_; | 217 scoped_refptr<DecoderBuffer> i_frame_buffer_; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 | 370 |
372 // Test destruction when decoder has hit end of stream. | 371 // Test destruction when decoder has hit end of stream. |
373 TEST_F(FFmpegVideoDecoderTest, Destroy_EndOfStream) { | 372 TEST_F(FFmpegVideoDecoderTest, Destroy_EndOfStream) { |
374 Initialize(); | 373 Initialize(); |
375 EnterDecodingState(); | 374 EnterDecodingState(); |
376 EnterEndOfStreamState(); | 375 EnterEndOfStreamState(); |
377 Destroy(); | 376 Destroy(); |
378 } | 377 } |
379 | 378 |
380 } // namespace media | 379 } // namespace media |
OLD | NEW |