OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "content/renderer/media/rtc_video_decoder.h" | 9 #include "content/renderer/media/rtc_video_decoder.h" |
10 #include "media/base/gmock_callback_support.h" | 10 #include "media/base/gmock_callback_support.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 .WillRepeatedly(Return(mock_vda_)); | 41 .WillRepeatedly(Return(mock_vda_)); |
42 EXPECT_CALL(*mock_gpu_factories_.get(), CreateSharedMemory(_)) | 42 EXPECT_CALL(*mock_gpu_factories_.get(), CreateSharedMemory(_)) |
43 .WillRepeatedly(Return(static_cast<base::SharedMemory*>(NULL))); | 43 .WillRepeatedly(Return(static_cast<base::SharedMemory*>(NULL))); |
44 EXPECT_CALL(*mock_vda_, Initialize(_, _)) | 44 EXPECT_CALL(*mock_vda_, Initialize(_, _)) |
45 .Times(1) | 45 .Times(1) |
46 .WillRepeatedly(Return(true)); | 46 .WillRepeatedly(Return(true)); |
47 EXPECT_CALL(*mock_vda_, Destroy()).Times(1); | 47 EXPECT_CALL(*mock_vda_, Destroy()).Times(1); |
48 } | 48 } |
49 | 49 |
50 void TearDown() override { | 50 void TearDown() override { |
51 VLOG(2) << "TearDown"; | 51 DVLOG(2) << "TearDown"; |
52 EXPECT_TRUE(vda_thread_.IsRunning()); | 52 EXPECT_TRUE(vda_thread_.IsRunning()); |
53 RunUntilIdle(); // Wait until all callbascks complete. | 53 RunUntilIdle(); // Wait until all callbascks complete. |
54 vda_task_runner_->DeleteSoon(FROM_HERE, rtc_decoder_.release()); | 54 vda_task_runner_->DeleteSoon(FROM_HERE, rtc_decoder_.release()); |
55 // Make sure the decoder is released before stopping the thread. | 55 // Make sure the decoder is released before stopping the thread. |
56 RunUntilIdle(); | 56 RunUntilIdle(); |
57 vda_thread_.Stop(); | 57 vda_thread_.Stop(); |
58 } | 58 } |
59 | 59 |
60 int32_t Decoded(webrtc::I420VideoFrame& decoded_image) override { | 60 int32_t Decoded(webrtc::I420VideoFrame& decoded_image) override { |
61 VLOG(2) << "Decoded"; | 61 DVLOG(2) << "Decoded"; |
62 EXPECT_EQ(vda_task_runner_, base::MessageLoopProxy::current()); | 62 EXPECT_EQ(vda_task_runner_, base::MessageLoopProxy::current()); |
63 return WEBRTC_VIDEO_CODEC_OK; | 63 return WEBRTC_VIDEO_CODEC_OK; |
64 } | 64 } |
65 | 65 |
66 void CreateDecoder(webrtc::VideoCodecType codec_type) { | 66 void CreateDecoder(webrtc::VideoCodecType codec_type) { |
67 VLOG(2) << "CreateDecoder"; | 67 DVLOG(2) << "CreateDecoder"; |
68 codec_.codecType = codec_type; | 68 codec_.codecType = codec_type; |
69 rtc_decoder_ = | 69 rtc_decoder_ = |
70 RTCVideoDecoder::Create(codec_type, mock_gpu_factories_); | 70 RTCVideoDecoder::Create(codec_type, mock_gpu_factories_); |
71 } | 71 } |
72 | 72 |
73 void Initialize() { | 73 void Initialize() { |
74 VLOG(2) << "Initialize"; | 74 DVLOG(2) << "Initialize"; |
75 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, rtc_decoder_->InitDecode(&codec_, 1)); | 75 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, rtc_decoder_->InitDecode(&codec_, 1)); |
76 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 76 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
77 rtc_decoder_->RegisterDecodeCompleteCallback(this)); | 77 rtc_decoder_->RegisterDecodeCompleteCallback(this)); |
78 } | 78 } |
79 | 79 |
80 void NotifyResetDone() { | 80 void NotifyResetDone() { |
81 VLOG(2) << "NotifyResetDone"; | 81 DVLOG(2) << "NotifyResetDone"; |
82 vda_task_runner_->PostTask( | 82 vda_task_runner_->PostTask( |
83 FROM_HERE, | 83 FROM_HERE, |
84 base::Bind(&RTCVideoDecoder::NotifyResetDone, | 84 base::Bind(&RTCVideoDecoder::NotifyResetDone, |
85 base::Unretained(rtc_decoder_.get()))); | 85 base::Unretained(rtc_decoder_.get()))); |
86 } | 86 } |
87 | 87 |
88 void RunUntilIdle() { | 88 void RunUntilIdle() { |
89 VLOG(2) << "RunUntilIdle"; | 89 DVLOG(2) << "RunUntilIdle"; |
90 vda_task_runner_->PostTask(FROM_HERE, | 90 vda_task_runner_->PostTask(FROM_HERE, |
91 base::Bind(&base::WaitableEvent::Signal, | 91 base::Bind(&base::WaitableEvent::Signal, |
92 base::Unretained(&idle_waiter_))); | 92 base::Unretained(&idle_waiter_))); |
93 idle_waiter_.Wait(); | 93 idle_waiter_.Wait(); |
94 } | 94 } |
95 | 95 |
96 protected: | 96 protected: |
97 scoped_refptr<media::MockGpuVideoAcceleratorFactories> mock_gpu_factories_; | 97 scoped_refptr<media::MockGpuVideoAcceleratorFactories> mock_gpu_factories_; |
98 media::MockVideoDecodeAccelerator* mock_vda_; | 98 media::MockVideoDecodeAccelerator* mock_vda_; |
99 scoped_ptr<RTCVideoDecoder> rtc_decoder_; | 99 scoped_ptr<RTCVideoDecoder> rtc_decoder_; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 222 |
223 EXPECT_FALSE(rtc_decoder_->IsFirstBufferAfterReset(RTCVideoDecoder::ID_LAST, | 223 EXPECT_FALSE(rtc_decoder_->IsFirstBufferAfterReset(RTCVideoDecoder::ID_LAST, |
224 RTCVideoDecoder::ID_LAST)); | 224 RTCVideoDecoder::ID_LAST)); |
225 EXPECT_TRUE( | 225 EXPECT_TRUE( |
226 rtc_decoder_->IsFirstBufferAfterReset(0, RTCVideoDecoder::ID_LAST)); | 226 rtc_decoder_->IsFirstBufferAfterReset(0, RTCVideoDecoder::ID_LAST)); |
227 EXPECT_FALSE( | 227 EXPECT_FALSE( |
228 rtc_decoder_->IsFirstBufferAfterReset(1, RTCVideoDecoder::ID_LAST)); | 228 rtc_decoder_->IsFirstBufferAfterReset(1, RTCVideoDecoder::ID_LAST)); |
229 } | 229 } |
230 | 230 |
231 } // content | 231 } // content |
OLD | NEW |