| 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 "content/renderer/media/rtc_video_decoder.h" | 5 #include "content/renderer/media/rtc_video_decoder.h" |
| 6 | 6 |
| 7 #include <deque> | 7 #include <deque> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 class RTCVideoDecoderTest : public testing::Test { | 107 class RTCVideoDecoderTest : public testing::Test { |
| 108 protected: | 108 protected: |
| 109 static const int kWidth; | 109 static const int kWidth; |
| 110 static const int kHeight; | 110 static const int kHeight; |
| 111 static const char* kUrl; | 111 static const char* kUrl; |
| 112 static const PipelineStatistics kStatistics; | 112 static const PipelineStatistics kStatistics; |
| 113 | 113 |
| 114 RTCVideoDecoderTest() { | 114 RTCVideoDecoderTest() { |
| 115 decoder_ = new RTCVideoDecoder(&message_loop_, kUrl); | 115 decoder_ = new RTCVideoDecoder(&message_loop_, kUrl); |
| 116 renderer_ = new MockVideoRenderer(); | 116 renderer_ = new MockVideoRenderer(); |
| 117 read_cb_ = base::Bind(&RTCVideoDecoderTest::FrameReady, |
| 118 base::Unretained(this)); |
| 117 | 119 |
| 118 DCHECK(decoder_); | 120 DCHECK(decoder_); |
| 119 | 121 |
| 120 // Inject mocks and prepare a demuxer stream. | 122 // Inject mocks and prepare a demuxer stream. |
| 121 decoder_->set_host(&host_); | 123 decoder_->set_host(&host_); |
| 122 | 124 |
| 123 EXPECT_CALL(stats_callback_object_, OnStatistics(_)) | 125 EXPECT_CALL(stats_callback_object_, OnStatistics(_)) |
| 124 .Times(AnyNumber()); | 126 .Times(AnyNumber()); |
| 125 } | 127 } |
| 126 | 128 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 142 } | 144 } |
| 143 | 145 |
| 144 MOCK_METHOD1(FrameReady, void(scoped_refptr<media::VideoFrame>)); | 146 MOCK_METHOD1(FrameReady, void(scoped_refptr<media::VideoFrame>)); |
| 145 | 147 |
| 146 // Fixture members. | 148 // Fixture members. |
| 147 scoped_refptr<RTCVideoDecoder> decoder_; | 149 scoped_refptr<RTCVideoDecoder> decoder_; |
| 148 scoped_refptr<MockVideoRenderer> renderer_; | 150 scoped_refptr<MockVideoRenderer> renderer_; |
| 149 MockStatisticsCallback stats_callback_object_; | 151 MockStatisticsCallback stats_callback_object_; |
| 150 StrictMock<MockFilterHost> host_; | 152 StrictMock<MockFilterHost> host_; |
| 151 MessageLoop message_loop_; | 153 MessageLoop message_loop_; |
| 154 media::VideoDecoder::ReadCB read_cb_; |
| 152 | 155 |
| 153 private: | 156 private: |
| 154 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoderTest); | 157 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoderTest); |
| 155 }; | 158 }; |
| 156 | 159 |
| 157 const int RTCVideoDecoderTest::kWidth = 176; | 160 const int RTCVideoDecoderTest::kWidth = 176; |
| 158 const int RTCVideoDecoderTest::kHeight = 144; | 161 const int RTCVideoDecoderTest::kHeight = 144; |
| 159 const char* RTCVideoDecoderTest::kUrl = "media://remote/0"; | 162 const char* RTCVideoDecoderTest::kUrl = "media://remote/0"; |
| 160 const PipelineStatistics RTCVideoDecoderTest::kStatistics; | 163 const PipelineStatistics RTCVideoDecoderTest::kStatistics; |
| 161 | 164 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 173 | 176 |
| 174 InitializeDecoderSuccessfully(); | 177 InitializeDecoderSuccessfully(); |
| 175 | 178 |
| 176 // Expect seek and verify the results. | 179 // Expect seek and verify the results. |
| 177 decoder_->Seek(kZero, NewExpectedStatusCB(PIPELINE_OK)); | 180 decoder_->Seek(kZero, NewExpectedStatusCB(PIPELINE_OK)); |
| 178 | 181 |
| 179 message_loop_.RunAllPending(); | 182 message_loop_.RunAllPending(); |
| 180 EXPECT_EQ(RTCVideoDecoder::kNormal, decoder_->state_); | 183 EXPECT_EQ(RTCVideoDecoder::kNormal, decoder_->state_); |
| 181 } | 184 } |
| 182 | 185 |
| 186 TEST_F(RTCVideoDecoderTest, DoFlush) { |
| 187 const base::TimeDelta kZero; |
| 188 |
| 189 InitializeDecoderSuccessfully(); |
| 190 |
| 191 EXPECT_CALL(*this, FrameReady(_)); |
| 192 decoder_->Read(read_cb_); |
| 193 decoder_->Pause(media::NewExpectedClosure()); |
| 194 decoder_->Flush(media::NewExpectedClosure()); |
| 195 |
| 196 message_loop_.RunAllPending(); |
| 197 EXPECT_EQ(RTCVideoDecoder::kPaused, decoder_->state_); |
| 198 } |
| 199 |
| 183 TEST_F(RTCVideoDecoderTest, DoRenderFrame) { | 200 TEST_F(RTCVideoDecoderTest, DoRenderFrame) { |
| 184 const base::TimeDelta kZero; | 201 const base::TimeDelta kZero; |
| 185 EXPECT_CALL(host_, GetTime()).WillRepeatedly(Return(base::TimeDelta())); | 202 EXPECT_CALL(host_, GetTime()).WillRepeatedly(Return(base::TimeDelta())); |
| 186 | 203 |
| 187 InitializeDecoderSuccessfully(); | 204 InitializeDecoderSuccessfully(); |
| 188 | 205 |
| 189 NullVideoFrame video_frame; | 206 NullVideoFrame video_frame; |
| 190 | 207 |
| 191 for (size_t i = 0; i < Limits::kMaxVideoFrames; ++i) { | 208 for (size_t i = 0; i < Limits::kMaxVideoFrames; ++i) { |
| 192 decoder_->RenderFrame(&video_frame); | 209 decoder_->RenderFrame(&video_frame); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 207 EXPECT_CALL(host_, | 224 EXPECT_CALL(host_, |
| 208 SetNaturalVideoSize(new_natural_size)).WillRepeatedly(Return()); | 225 SetNaturalVideoSize(new_natural_size)).WillRepeatedly(Return()); |
| 209 | 226 |
| 210 decoder_->SetSize(new_width, new_height, new_reserved); | 227 decoder_->SetSize(new_width, new_height, new_reserved); |
| 211 | 228 |
| 212 EXPECT_EQ(new_width, decoder_->natural_size().width()); | 229 EXPECT_EQ(new_width, decoder_->natural_size().width()); |
| 213 EXPECT_EQ(new_height, decoder_->natural_size().height()); | 230 EXPECT_EQ(new_height, decoder_->natural_size().height()); |
| 214 | 231 |
| 215 message_loop_.RunAllPending(); | 232 message_loop_.RunAllPending(); |
| 216 } | 233 } |
| OLD | NEW |