| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "media/base/data_buffer.h" | 7 #include "media/base/data_buffer.h" |
| 8 #include "media/base/pipeline.h" | 8 #include "media/base/pipeline.h" |
| 9 #include "media/base/test_data_util.h" | 9 #include "media/base/test_data_util.h" |
| 10 #include "media/filters/ffmpeg_glue.h" | 10 #include "media/filters/ffmpeg_glue.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 end_of_stream_buffer_ = new DataBuffer(0); | 55 end_of_stream_buffer_ = new DataBuffer(0); |
| 56 } | 56 } |
| 57 | 57 |
| 58 ~FFmpegVideoDecodeEngineTest() { | 58 ~FFmpegVideoDecodeEngineTest() { |
| 59 test_engine_.reset(); | 59 test_engine_.reset(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void Initialize() { | 62 void Initialize() { |
| 63 EXPECT_CALL(*this, OnInitializeComplete(true)); | 63 EXPECT_CALL(*this, OnInitializeComplete(true)); |
| 64 test_engine_->Initialize(MessageLoop::current(), this, NULL, config_); | 64 test_engine_->Initialize(this, config_); |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Decodes the single compressed frame in |buffer| and writes the | 67 // Decodes the single compressed frame in |buffer| and writes the |
| 68 // uncompressed output to |video_frame|. This method works with single | 68 // uncompressed output to |video_frame|. This method works with single |
| 69 // and multithreaded decoders. End of stream buffers are used to trigger | 69 // and multithreaded decoders. End of stream buffers are used to trigger |
| 70 // the frame to be returned in the multithreaded decoder case. | 70 // the frame to be returned in the multithreaded decoder case. |
| 71 void DecodeASingleFrame(const scoped_refptr<Buffer>& buffer, | 71 void DecodeASingleFrame(const scoped_refptr<Buffer>& buffer, |
| 72 scoped_refptr<VideoFrame>* video_frame) { | 72 scoped_refptr<VideoFrame>* video_frame) { |
| 73 EXPECT_CALL(*this, ProduceVideoSample(_)) | 73 EXPECT_CALL(*this, ProduceVideoSample(_)) |
| 74 .WillOnce(DemuxComplete(test_engine_.get(), buffer)) | 74 .WillOnce(DemuxComplete(test_engine_.get(), buffer)) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_FindDecoderFails) { | 148 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_FindDecoderFails) { |
| 149 VideoDecoderConfig config(kUnknownVideoCodec, kVideoFormat, | 149 VideoDecoderConfig config(kUnknownVideoCodec, kVideoFormat, |
| 150 kCodedSize, kVisibleRect, | 150 kCodedSize, kVisibleRect, |
| 151 kFrameRate.num, kFrameRate.den, | 151 kFrameRate.num, kFrameRate.den, |
| 152 kAspectRatio.num, kAspectRatio.den, | 152 kAspectRatio.num, kAspectRatio.den, |
| 153 NULL, 0); | 153 NULL, 0); |
| 154 | 154 |
| 155 // Test avcodec_find_decoder() returning NULL. | 155 // Test avcodec_find_decoder() returning NULL. |
| 156 EXPECT_CALL(*this, OnInitializeComplete(false)); | 156 EXPECT_CALL(*this, OnInitializeComplete(false)); |
| 157 test_engine_->Initialize(MessageLoop::current(), this, NULL, config); | 157 test_engine_->Initialize(this, config); |
| 158 } | 158 } |
| 159 | 159 |
| 160 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) { | 160 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) { |
| 161 // Specify Theora w/o extra data so that avcodec_open() fails. | 161 // Specify Theora w/o extra data so that avcodec_open() fails. |
| 162 VideoDecoderConfig config(kCodecTheora, kVideoFormat, | 162 VideoDecoderConfig config(kCodecTheora, kVideoFormat, |
| 163 kCodedSize, kVisibleRect, | 163 kCodedSize, kVisibleRect, |
| 164 kFrameRate.num, kFrameRate.den, | 164 kFrameRate.num, kFrameRate.den, |
| 165 kAspectRatio.num, kAspectRatio.den, | 165 kAspectRatio.num, kAspectRatio.den, |
| 166 NULL, 0); | 166 NULL, 0); |
| 167 EXPECT_CALL(*this, OnInitializeComplete(false)); | 167 EXPECT_CALL(*this, OnInitializeComplete(false)); |
| 168 test_engine_->Initialize(MessageLoop::current(), this, NULL, config); | 168 test_engine_->Initialize(this, config); |
| 169 } | 169 } |
| 170 | 170 |
| 171 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_Normal) { | 171 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_Normal) { |
| 172 Initialize(); | 172 Initialize(); |
| 173 | 173 |
| 174 // Simulate decoding a single frame. | 174 // Simulate decoding a single frame. |
| 175 scoped_refptr<VideoFrame> video_frame; | 175 scoped_refptr<VideoFrame> video_frame; |
| 176 DecodeASingleFrame(i_frame_buffer_, &video_frame); | 176 DecodeASingleFrame(i_frame_buffer_, &video_frame); |
| 177 | 177 |
| 178 // |video_frame| timestamp is 0 because we set the timestamp based off | 178 // |video_frame| timestamp is 0 because we set the timestamp based off |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 // DecodeIFrameThenTestFile("vp8-I-frame-320x480"); | 266 // DecodeIFrameThenTestFile("vp8-I-frame-320x480"); |
| 267 //} | 267 //} |
| 268 | 268 |
| 269 // Decode |i_frame_buffer_| and then a frame with a smaller height and verify | 269 // Decode |i_frame_buffer_| and then a frame with a smaller height and verify |
| 270 // the output size didn't change. | 270 // the output size didn't change. |
| 271 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_SmallerHeight) { | 271 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_SmallerHeight) { |
| 272 DecodeIFrameThenTestFile("vp8-I-frame-320x120"); | 272 DecodeIFrameThenTestFile("vp8-I-frame-320x120"); |
| 273 } | 273 } |
| 274 | 274 |
| 275 } // namespace media | 275 } // namespace media |
| OLD | NEW |