| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/run_loop.h" |
| 16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 17 #include "media/base/decoder_buffer.h" | 18 #include "media/base/decoder_buffer.h" |
| 18 #include "media/base/gmock_callback_support.h" | 19 #include "media/base/gmock_callback_support.h" |
| 19 #include "media/base/limits.h" | 20 #include "media/base/limits.h" |
| 20 #include "media/base/media_util.h" | 21 #include "media/base/media_util.h" |
| 21 #include "media/base/mock_filters.h" | 22 #include "media/base/mock_filters.h" |
| 22 #include "media/base/test_data_util.h" | 23 #include "media/base/test_data_util.h" |
| 23 #include "media/base/test_helpers.h" | 24 #include "media/base/test_helpers.h" |
| 24 #include "media/base/video_decoder.h" | 25 #include "media/base/video_decoder.h" |
| 25 #include "media/base/video_frame.h" | 26 #include "media/base/video_frame.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 71 |
| 71 void Initialize() { | 72 void Initialize() { |
| 72 InitializeWithConfig(TestVideoConfig::Normal()); | 73 InitializeWithConfig(TestVideoConfig::Normal()); |
| 73 } | 74 } |
| 74 | 75 |
| 75 void InitializeWithConfigWithResult(const VideoDecoderConfig& config, | 76 void InitializeWithConfigWithResult(const VideoDecoderConfig& config, |
| 76 bool success) { | 77 bool success) { |
| 77 decoder_->Initialize(config, false, nullptr, NewExpectedBoolCB(success), | 78 decoder_->Initialize(config, false, nullptr, NewExpectedBoolCB(success), |
| 78 base::Bind(&FFmpegVideoDecoderTest::FrameReady, | 79 base::Bind(&FFmpegVideoDecoderTest::FrameReady, |
| 79 base::Unretained(this))); | 80 base::Unretained(this))); |
| 80 message_loop_.RunUntilIdle(); | 81 base::RunLoop().RunUntilIdle(); |
| 81 } | 82 } |
| 82 | 83 |
| 83 void InitializeWithConfig(const VideoDecoderConfig& config) { | 84 void InitializeWithConfig(const VideoDecoderConfig& config) { |
| 84 InitializeWithConfigWithResult(config, true); | 85 InitializeWithConfigWithResult(config, true); |
| 85 } | 86 } |
| 86 | 87 |
| 87 void Reinitialize() { | 88 void Reinitialize() { |
| 88 InitializeWithConfig(TestVideoConfig::Large()); | 89 InitializeWithConfig(TestVideoConfig::Large()); |
| 89 } | 90 } |
| 90 | 91 |
| 91 void Reset() { | 92 void Reset() { |
| 92 decoder_->Reset(NewExpectedClosure()); | 93 decoder_->Reset(NewExpectedClosure()); |
| 93 message_loop_.RunUntilIdle(); | 94 base::RunLoop().RunUntilIdle(); |
| 94 } | 95 } |
| 95 | 96 |
| 96 void Destroy() { | 97 void Destroy() { |
| 97 decoder_.reset(); | 98 decoder_.reset(); |
| 98 message_loop_.RunUntilIdle(); | 99 base::RunLoop().RunUntilIdle(); |
| 99 } | 100 } |
| 100 | 101 |
| 101 // Sets up expectations and actions to put FFmpegVideoDecoder in an active | 102 // Sets up expectations and actions to put FFmpegVideoDecoder in an active |
| 102 // decoding state. | 103 // decoding state. |
| 103 void EnterDecodingState() { | 104 void EnterDecodingState() { |
| 104 EXPECT_EQ(DecodeStatus::OK, DecodeSingleFrame(i_frame_buffer_)); | 105 EXPECT_EQ(DecodeStatus::OK, DecodeSingleFrame(i_frame_buffer_)); |
| 105 ASSERT_EQ(1U, output_frames_.size()); | 106 ASSERT_EQ(1U, output_frames_.size()); |
| 106 } | 107 } |
| 107 | 108 |
| 108 // Sets up expectations and actions to put FFmpegVideoDecoder in an end | 109 // Sets up expectations and actions to put FFmpegVideoDecoder in an end |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 EXPECT_EQ(expected_height, | 178 EXPECT_EQ(expected_height, |
| 178 output_frames_[1]->visible_rect().size().height()); | 179 output_frames_[1]->visible_rect().size().height()); |
| 179 } | 180 } |
| 180 | 181 |
| 181 DecodeStatus Decode(const scoped_refptr<DecoderBuffer>& buffer) { | 182 DecodeStatus Decode(const scoped_refptr<DecoderBuffer>& buffer) { |
| 182 DecodeStatus status; | 183 DecodeStatus status; |
| 183 EXPECT_CALL(*this, DecodeDone(_)).WillOnce(SaveArg<0>(&status)); | 184 EXPECT_CALL(*this, DecodeDone(_)).WillOnce(SaveArg<0>(&status)); |
| 184 | 185 |
| 185 decoder_->Decode(buffer, decode_cb_); | 186 decoder_->Decode(buffer, decode_cb_); |
| 186 | 187 |
| 187 message_loop_.RunUntilIdle(); | 188 base::RunLoop().RunUntilIdle(); |
| 188 | 189 |
| 189 return status; | 190 return status; |
| 190 } | 191 } |
| 191 | 192 |
| 192 void FrameReady(const scoped_refptr<VideoFrame>& frame) { | 193 void FrameReady(const scoped_refptr<VideoFrame>& frame) { |
| 193 DCHECK(!frame->metadata()->IsTrue(VideoFrameMetadata::END_OF_STREAM)); | 194 DCHECK(!frame->metadata()->IsTrue(VideoFrameMetadata::END_OF_STREAM)); |
| 194 output_frames_.push_back(frame); | 195 output_frames_.push_back(frame); |
| 195 } | 196 } |
| 196 | 197 |
| 197 MOCK_METHOD1(DecodeDone, void(DecodeStatus)); | 198 MOCK_METHOD1(DecodeDone, void(DecodeStatus)); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 357 |
| 357 // Test destruction when decoder has hit end of stream. | 358 // Test destruction when decoder has hit end of stream. |
| 358 TEST_F(FFmpegVideoDecoderTest, Destroy_EndOfStream) { | 359 TEST_F(FFmpegVideoDecoderTest, Destroy_EndOfStream) { |
| 359 Initialize(); | 360 Initialize(); |
| 360 EnterDecodingState(); | 361 EnterDecodingState(); |
| 361 EnterEndOfStreamState(); | 362 EnterEndOfStreamState(); |
| 362 Destroy(); | 363 Destroy(); |
| 363 } | 364 } |
| 364 | 365 |
| 365 } // namespace media | 366 } // namespace media |
| OLD | NEW |