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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 RTCVideoDecoder::ID_HALF + 2, RTCVideoDecoder::ID_HALF)); | 275 RTCVideoDecoder::ID_HALF + 2, RTCVideoDecoder::ID_HALF)); |
276 | 276 |
277 EXPECT_FALSE(rtc_decoder_->IsFirstBufferAfterReset(RTCVideoDecoder::ID_LAST, | 277 EXPECT_FALSE(rtc_decoder_->IsFirstBufferAfterReset(RTCVideoDecoder::ID_LAST, |
278 RTCVideoDecoder::ID_LAST)); | 278 RTCVideoDecoder::ID_LAST)); |
279 EXPECT_TRUE( | 279 EXPECT_TRUE( |
280 rtc_decoder_->IsFirstBufferAfterReset(0, RTCVideoDecoder::ID_LAST)); | 280 rtc_decoder_->IsFirstBufferAfterReset(0, RTCVideoDecoder::ID_LAST)); |
281 EXPECT_FALSE( | 281 EXPECT_FALSE( |
282 rtc_decoder_->IsFirstBufferAfterReset(1, RTCVideoDecoder::ID_LAST)); | 282 rtc_decoder_->IsFirstBufferAfterReset(1, RTCVideoDecoder::ID_LAST)); |
283 } | 283 } |
284 | 284 |
285 | 285 // Tests/Verifies that |rtc_encoder_| drops incoming frames and its error |
| 286 // counter is increased when in an error condition. |
286 TEST_P(RTCVideoDecoderTest, GetVDAErrorCounterForTesting) { | 287 TEST_P(RTCVideoDecoderTest, GetVDAErrorCounterForTesting) { |
287 const webrtc::VideoCodecType codec_type = GetParam(); | 288 const webrtc::VideoCodecType codec_type = GetParam(); |
288 CreateDecoder(codec_type); | 289 CreateDecoder(codec_type); |
289 Initialize(); | 290 Initialize(); |
290 | 291 |
291 webrtc::EncodedImage input_image; | 292 webrtc::EncodedImage input_image; |
292 input_image._completeFrame = true; | 293 input_image._completeFrame = true; |
293 input_image._encodedWidth = kMinResolutionWidth; | 294 input_image._encodedWidth = kMinResolutionWidth; |
294 input_image._encodedHeight = kMaxResolutionHeight; | 295 input_image._encodedHeight = kMaxResolutionHeight; |
295 input_image._frameType = webrtc::kVideoFrameDelta; | 296 input_image._frameType = webrtc::kVideoFrameDelta; |
| 297 input_image._length = kMinResolutionWidth * kMaxResolutionHeight; |
296 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, | 298 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, |
297 rtc_decoder_->Decode(input_image, false, nullptr, nullptr, 0)); | 299 rtc_decoder_->Decode(input_image, false, nullptr, nullptr, 0)); |
298 RunUntilIdle(); | 300 RunUntilIdle(); |
299 | 301 |
300 // Notify the decoder about a platform error. | 302 // Notify the decoder about a platform error. |
301 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 303 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
302 RunUntilIdle(); | 304 RunUntilIdle(); |
303 EXPECT_EQ(1, rtc_decoder_->GetVDAErrorCounterForTesting()); | 305 EXPECT_EQ(1, rtc_decoder_->GetVDAErrorCounterForTesting()); |
304 | 306 |
305 // Expect decode call to reset decoder, and set up a new VDA to track it. | 307 // Expect decode call to reset decoder, and set up a new VDA to track it. |
306 SetUpResetVDA(); | 308 SetUpResetVDA(); |
307 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, | 309 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, |
308 rtc_decoder_->Decode(input_image, false, nullptr, nullptr, 0)); | 310 rtc_decoder_->Decode(input_image, false, nullptr, nullptr, 0)); |
309 EXPECT_EQ(1, rtc_decoder_->GetVDAErrorCounterForTesting()); | 311 EXPECT_EQ(1, rtc_decoder_->GetVDAErrorCounterForTesting()); |
310 | 312 |
311 // Decoder expects a keyframe after reset, so drops any other frames. | 313 // Decoder expects a keyframe after reset, so drops any other frames. However, |
| 314 // we should still increment the error counter. |
312 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, | 315 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, |
313 rtc_decoder_->Decode(input_image, false, nullptr, nullptr, 0)); | 316 rtc_decoder_->Decode(input_image, false, nullptr, nullptr, 0)); |
314 EXPECT_EQ(1, rtc_decoder_->GetVDAErrorCounterForTesting()); | 317 EXPECT_EQ(2, rtc_decoder_->GetVDAErrorCounterForTesting()); |
315 | |
316 // Decoder resets error counter after a successfull decode. | |
317 input_image._frameType = webrtc::kVideoFrameKey; | |
318 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | |
319 rtc_decoder_->Decode(input_image, false, nullptr, nullptr, 10)); | |
320 EXPECT_EQ(0, rtc_decoder_->GetVDAErrorCounterForTesting()); | |
321 } | 318 } |
322 | 319 |
323 INSTANTIATE_TEST_CASE_P(CodecProfiles, | 320 INSTANTIATE_TEST_CASE_P(CodecProfiles, |
324 RTCVideoDecoderTest, | 321 RTCVideoDecoderTest, |
325 Values(webrtc::kVideoCodecVP8, | 322 Values(webrtc::kVideoCodecVP8, |
326 webrtc::kVideoCodecH264)); | 323 webrtc::kVideoCodecH264)); |
327 | 324 |
328 } // content | 325 } // content |
OLD | NEW |