| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <string.h> | 6 #include <string.h> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 134 } |
| 135 | 135 |
| 136 void RunUntilIdle() { | 136 void RunUntilIdle() { |
| 137 DVLOG(2) << "RunUntilIdle"; | 137 DVLOG(2) << "RunUntilIdle"; |
| 138 vda_task_runner_->PostTask(FROM_HERE, | 138 vda_task_runner_->PostTask(FROM_HERE, |
| 139 base::Bind(&base::WaitableEvent::Signal, | 139 base::Bind(&base::WaitableEvent::Signal, |
| 140 base::Unretained(&idle_waiter_))); | 140 base::Unretained(&idle_waiter_))); |
| 141 idle_waiter_.Wait(); | 141 idle_waiter_.Wait(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 bool CreateMockTextures(int32_t count, |
| 145 const gfx::Size& size, |
| 146 std::vector<uint32_t>* texture_ids, |
| 147 std::vector<gpu::Mailbox>* texture_mailboxes, |
| 148 uint32_t texture_target) { |
| 149 texture_ids->resize(count, 0); |
| 150 texture_mailboxes->resize(count, gpu::Mailbox()); |
| 151 return true; |
| 152 } |
| 153 |
| 154 void ProvidePictureBuffers(uint32_t buffer_count, |
| 155 media::VideoPixelFormat format, |
| 156 uint32_t textures_per_buffer, |
| 157 const gfx::Size& size, |
| 158 uint32_t texture_target) { |
| 159 vda_task_runner_->PostTask( |
| 160 FROM_HERE, |
| 161 base::Bind(&RTCVideoDecoder::ProvidePictureBuffers, |
| 162 base::Unretained(rtc_decoder_.get()), buffer_count, format, |
| 163 textures_per_buffer, size, texture_target)); |
| 164 RunUntilIdle(); |
| 165 } |
| 166 |
| 144 void SetUpResetVDA() { | 167 void SetUpResetVDA() { |
| 145 mock_vda_after_reset_ = new media::MockVideoDecodeAccelerator; | 168 mock_vda_after_reset_ = new media::MockVideoDecodeAccelerator; |
| 146 EXPECT_CALL(*mock_gpu_factories_.get(), DoCreateVideoDecodeAccelerator()) | 169 EXPECT_CALL(*mock_gpu_factories_.get(), DoCreateVideoDecodeAccelerator()) |
| 147 .WillRepeatedly(Return(mock_vda_after_reset_)); | 170 .WillRepeatedly(Return(mock_vda_after_reset_)); |
| 148 EXPECT_CALL(*mock_vda_after_reset_, Initialize(_, _)) | 171 EXPECT_CALL(*mock_vda_after_reset_, Initialize(_, _)) |
| 149 .Times(1) | 172 .Times(1) |
| 150 .WillRepeatedly(Return(true)); | 173 .WillRepeatedly(Return(true)); |
| 151 EXPECT_CALL(*mock_vda_after_reset_, Destroy()).Times(1); | 174 EXPECT_CALL(*mock_vda_after_reset_, Destroy()).Times(1); |
| 152 } | 175 } |
| 153 | 176 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 RTCVideoDecoder::ID_HALF + 2, RTCVideoDecoder::ID_HALF)); | 292 RTCVideoDecoder::ID_HALF + 2, RTCVideoDecoder::ID_HALF)); |
| 270 | 293 |
| 271 EXPECT_FALSE(rtc_decoder_->IsFirstBufferAfterReset(RTCVideoDecoder::ID_LAST, | 294 EXPECT_FALSE(rtc_decoder_->IsFirstBufferAfterReset(RTCVideoDecoder::ID_LAST, |
| 272 RTCVideoDecoder::ID_LAST)); | 295 RTCVideoDecoder::ID_LAST)); |
| 273 EXPECT_TRUE( | 296 EXPECT_TRUE( |
| 274 rtc_decoder_->IsFirstBufferAfterReset(0, RTCVideoDecoder::ID_LAST)); | 297 rtc_decoder_->IsFirstBufferAfterReset(0, RTCVideoDecoder::ID_LAST)); |
| 275 EXPECT_FALSE( | 298 EXPECT_FALSE( |
| 276 rtc_decoder_->IsFirstBufferAfterReset(1, RTCVideoDecoder::ID_LAST)); | 299 rtc_decoder_->IsFirstBufferAfterReset(1, RTCVideoDecoder::ID_LAST)); |
| 277 } | 300 } |
| 278 | 301 |
| 302 TEST_F(RTCVideoDecoderTest, MultipleTexturesPerBuffer) { |
| 303 CreateDecoder(webrtc::kVideoCodecVP8); |
| 304 const uint32_t kBufferCount = 5; |
| 305 const uint32_t kTexturesPerBuffer = 3; |
| 306 const gfx::Size kSize(48, 48); |
| 307 |
| 308 EXPECT_CALL(*mock_gpu_factories_.get(), CreateTextures(_, _, _, _, _)) |
| 309 .WillRepeatedly(Invoke(this, &RTCVideoDecoderTest::CreateMockTextures)); |
| 310 EXPECT_CALL(*mock_gpu_factories_.get(), DeleteTexture(_)) |
| 311 .Times(kBufferCount * kTexturesPerBuffer); |
| 312 |
| 313 std::vector<media::PictureBuffer> pbs; |
| 314 EXPECT_CALL(*mock_vda_, AssignPictureBuffers(_)).WillOnce(SaveArg<0>(&pbs)); |
| 315 ProvidePictureBuffers(kBufferCount, media::PIXEL_FORMAT_UNKNOWN, |
| 316 kTexturesPerBuffer, kSize, 0); |
| 317 EXPECT_EQ(kBufferCount, pbs.size()); |
| 318 for (const auto pb : pbs) { |
| 319 EXPECT_EQ(kSize, pb.size()); |
| 320 EXPECT_EQ(kTexturesPerBuffer, pb.client_texture_ids().size()); |
| 321 } |
| 322 } |
| 323 |
| 279 // Tests/Verifies that |rtc_encoder_| drops incoming frames and its error | 324 // Tests/Verifies that |rtc_encoder_| drops incoming frames and its error |
| 280 // counter is increased when in an error condition. | 325 // counter is increased when in an error condition. |
| 281 TEST_P(RTCVideoDecoderTest, GetVDAErrorCounterForTesting) { | 326 TEST_P(RTCVideoDecoderTest, GetVDAErrorCounterForTesting) { |
| 282 const webrtc::VideoCodecType codec_type = GetParam(); | 327 const webrtc::VideoCodecType codec_type = GetParam(); |
| 283 CreateDecoder(codec_type); | 328 CreateDecoder(codec_type); |
| 284 Initialize(); | 329 Initialize(); |
| 285 | 330 |
| 286 webrtc::EncodedImage input_image; | 331 webrtc::EncodedImage input_image; |
| 287 input_image._completeFrame = true; | 332 input_image._completeFrame = true; |
| 288 input_image._encodedWidth = 0; | 333 input_image._encodedWidth = 0; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 379 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
| 335 rtc_decoder_->Decode(input_image, false, nullptr, nullptr, 0)); | 380 rtc_decoder_->Decode(input_image, false, nullptr, nullptr, 0)); |
| 336 } | 381 } |
| 337 | 382 |
| 338 INSTANTIATE_TEST_CASE_P(CodecProfiles, | 383 INSTANTIATE_TEST_CASE_P(CodecProfiles, |
| 339 RTCVideoDecoderTest, | 384 RTCVideoDecoderTest, |
| 340 Values(webrtc::kVideoCodecVP8, | 385 Values(webrtc::kVideoCodecVP8, |
| 341 webrtc::kVideoCodecH264)); | 386 webrtc::kVideoCodecH264)); |
| 342 | 387 |
| 343 } // content | 388 } // content |
| OLD | NEW |