OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/logging.h" | 6 #include "base/logging.h" |
7 #include "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
8 #include "base/timer/timer.h" | 8 #include "base/timer/timer.h" |
9 #include "media/base/android/media_codec_audio_decoder.h" | 9 #include "media/base/android/media_codec_audio_decoder.h" |
10 #include "media/base/android/media_codec_bridge.h" | 10 #include "media/base/android/media_codec_bridge.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 void SetVideoSurface(); | 176 void SetVideoSurface(); |
177 void SetStopRequestAtTime(const base::TimeDelta& time) { | 177 void SetStopRequestAtTime(const base::TimeDelta& time) { |
178 stop_request_time_ = time; | 178 stop_request_time_ = time; |
179 } | 179 } |
180 | 180 |
181 // Decoder callbacks. | 181 // Decoder callbacks. |
182 void OnDataRequested(); | 182 void OnDataRequested(); |
183 void OnStarvation() { is_starved_ = true; } | 183 void OnStarvation() { is_starved_ = true; } |
184 void OnDecoderDrained() {} | 184 void OnDecoderDrained() {} |
185 void OnStopDone() { is_stopped_ = true; } | 185 void OnStopDone() { is_stopped_ = true; } |
| 186 void OnKeyRequired() {} |
186 void OnError() { DVLOG(0) << "MediaCodecDecoderTest::" << __FUNCTION__; } | 187 void OnError() { DVLOG(0) << "MediaCodecDecoderTest::" << __FUNCTION__; } |
187 void OnUpdateCurrentTime(base::TimeDelta now_playing, | 188 void OnUpdateCurrentTime(base::TimeDelta now_playing, |
188 base::TimeDelta last_buffered, | 189 base::TimeDelta last_buffered, |
189 bool postpone) { | 190 bool postpone) { |
190 // Add the |last_buffered| value for PTS. For video it is the same as | 191 // Add the |last_buffered| value for PTS. For video it is the same as |
191 // |now_playing| and is equal to PTS, for audio |last_buffered| should | 192 // |now_playing| and is equal to PTS, for audio |last_buffered| should |
192 // exceed PTS. | 193 // exceed PTS. |
193 if (postpone) | 194 if (postpone) |
194 return; | 195 return; |
195 | 196 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 } | 269 } |
269 | 270 |
270 void MediaCodecDecoderTest::CreateAudioDecoder() { | 271 void MediaCodecDecoderTest::CreateAudioDecoder() { |
271 decoder_ = scoped_ptr<MediaCodecDecoder>(new MediaCodecAudioDecoder( | 272 decoder_ = scoped_ptr<MediaCodecDecoder>(new MediaCodecAudioDecoder( |
272 task_runner_, base::Bind(&MediaCodecDecoderTest::OnDataRequested, | 273 task_runner_, base::Bind(&MediaCodecDecoderTest::OnDataRequested, |
273 base::Unretained(this)), | 274 base::Unretained(this)), |
274 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)), | 275 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)), |
275 base::Bind(&MediaCodecDecoderTest::OnDecoderDrained, | 276 base::Bind(&MediaCodecDecoderTest::OnDecoderDrained, |
276 base::Unretained(this)), | 277 base::Unretained(this)), |
277 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)), | 278 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)), |
| 279 base::Bind(&MediaCodecDecoderTest::OnKeyRequired, base::Unretained(this)), |
278 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)), | 280 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)), |
279 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime, | 281 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime, |
280 base::Unretained(this)))); | 282 base::Unretained(this)))); |
281 | 283 |
282 data_available_cb_ = base::Bind(&MediaCodecDecoder::OnDemuxerDataAvailable, | 284 data_available_cb_ = base::Bind(&MediaCodecDecoder::OnDemuxerDataAvailable, |
283 base::Unretained(decoder_.get())); | 285 base::Unretained(decoder_.get())); |
284 } | 286 } |
285 | 287 |
286 void MediaCodecDecoderTest::CreateVideoDecoder() { | 288 void MediaCodecDecoderTest::CreateVideoDecoder() { |
287 decoder_ = scoped_ptr<MediaCodecDecoder>(new MediaCodecVideoDecoder( | 289 decoder_ = scoped_ptr<MediaCodecDecoder>(new MediaCodecVideoDecoder( |
288 task_runner_, base::Bind(&MediaCodecDecoderTest::OnDataRequested, | 290 task_runner_, base::Bind(&MediaCodecDecoderTest::OnDataRequested, |
289 base::Unretained(this)), | 291 base::Unretained(this)), |
290 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)), | 292 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)), |
291 base::Bind(&MediaCodecDecoderTest::OnDecoderDrained, | 293 base::Bind(&MediaCodecDecoderTest::OnDecoderDrained, |
292 base::Unretained(this)), | 294 base::Unretained(this)), |
293 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)), | 295 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)), |
| 296 base::Bind(&MediaCodecDecoderTest::OnKeyRequired, base::Unretained(this)), |
294 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)), | 297 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)), |
295 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime, | 298 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime, |
296 base::Unretained(this)), | 299 base::Unretained(this)), |
297 base::Bind(&MediaCodecDecoderTest::OnVideoSizeChanged, | 300 base::Bind(&MediaCodecDecoderTest::OnVideoSizeChanged, |
298 base::Unretained(this)), | 301 base::Unretained(this)), |
299 base::Bind(&MediaCodecDecoderTest::OnVideoCodecCreated, | 302 base::Bind(&MediaCodecDecoderTest::OnVideoCodecCreated, |
300 base::Unretained(this)))); | 303 base::Unretained(this)))); |
301 | 304 |
302 data_available_cb_ = base::Bind(&MediaCodecDecoder::OnDemuxerDataAvailable, | 305 data_available_cb_ = base::Bind(&MediaCodecDecoder::OnDemuxerDataAvailable, |
303 base::Unretained(decoder_.get())); | 306 base::Unretained(decoder_.get())); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, | 353 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, |
351 base::Unretained(this)))); | 354 base::Unretained(this)))); |
352 } | 355 } |
353 | 356 |
354 TEST_F(MediaCodecDecoderTest, AudioConfigureNoParams) { | 357 TEST_F(MediaCodecDecoderTest, AudioConfigureNoParams) { |
355 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 358 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
356 | 359 |
357 CreateAudioDecoder(); | 360 CreateAudioDecoder(); |
358 | 361 |
359 // Cannot configure without config parameters. | 362 // Cannot configure without config parameters. |
360 EXPECT_EQ(MediaCodecDecoder::kConfigFailure, decoder_->Configure()); | 363 EXPECT_EQ(MediaCodecDecoder::kConfigFailure, decoder_->Configure(nullptr)); |
361 } | 364 } |
362 | 365 |
363 TEST_F(MediaCodecDecoderTest, AudioConfigureValidParams) { | 366 TEST_F(MediaCodecDecoderTest, AudioConfigureValidParams) { |
364 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 367 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
365 | 368 |
366 CreateAudioDecoder(); | 369 CreateAudioDecoder(); |
367 | 370 |
368 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); | 371 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); |
369 scoped_ptr<AudioFactory> factory(new AudioFactory(duration)); | 372 scoped_ptr<AudioFactory> factory(new AudioFactory(duration)); |
370 decoder_->SetDemuxerConfigs(factory->GetConfigs()); | 373 decoder_->SetDemuxerConfigs(factory->GetConfigs()); |
371 | 374 |
372 EXPECT_EQ(MediaCodecDecoder::kConfigOk, decoder_->Configure()); | 375 EXPECT_EQ(MediaCodecDecoder::kConfigOk, decoder_->Configure(nullptr)); |
373 } | 376 } |
374 | 377 |
375 TEST_F(MediaCodecDecoderTest, VideoConfigureNoParams) { | 378 TEST_F(MediaCodecDecoderTest, VideoConfigureNoParams) { |
376 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 379 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
377 | 380 |
378 CreateVideoDecoder(); | 381 CreateVideoDecoder(); |
379 | 382 |
380 // decoder_->Configure() searches back for the key frame. | 383 // decoder_->Configure() searches back for the key frame. |
381 // We have to prefetch decoder. | 384 // We have to prefetch decoder. |
382 | 385 |
383 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); | 386 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); |
384 SetDataFactory(scoped_ptr<VideoFactory>(new VideoFactory(duration))); | 387 SetDataFactory(scoped_ptr<VideoFactory>(new VideoFactory(duration))); |
385 | 388 |
386 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, | 389 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, |
387 base::Unretained(this), true)); | 390 base::Unretained(this), true)); |
388 | 391 |
389 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, | 392 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, |
390 base::Unretained(this)))); | 393 base::Unretained(this)))); |
391 | 394 |
392 SetVideoSurface(); | 395 SetVideoSurface(); |
393 | 396 |
394 // Cannot configure without config parameters. | 397 // Cannot configure without config parameters. |
395 EXPECT_EQ(MediaCodecDecoder::kConfigFailure, decoder_->Configure()); | 398 EXPECT_EQ(MediaCodecDecoder::kConfigFailure, decoder_->Configure(nullptr)); |
396 } | 399 } |
397 | 400 |
398 TEST_F(MediaCodecDecoderTest, VideoConfigureNoSurface) { | 401 TEST_F(MediaCodecDecoderTest, VideoConfigureNoSurface) { |
399 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 402 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
400 | 403 |
401 CreateVideoDecoder(); | 404 CreateVideoDecoder(); |
402 | 405 |
403 // decoder_->Configure() searches back for the key frame. | 406 // decoder_->Configure() searches back for the key frame. |
404 // We have to prefetch decoder. | 407 // We have to prefetch decoder. |
405 | 408 |
406 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); | 409 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); |
407 SetDataFactory(scoped_ptr<VideoFactory>(new VideoFactory(duration))); | 410 SetDataFactory(scoped_ptr<VideoFactory>(new VideoFactory(duration))); |
408 | 411 |
409 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, | 412 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, |
410 base::Unretained(this), true)); | 413 base::Unretained(this), true)); |
411 | 414 |
412 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, | 415 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, |
413 base::Unretained(this)))); | 416 base::Unretained(this)))); |
414 | 417 |
415 decoder_->SetDemuxerConfigs(GetConfigs()); | 418 decoder_->SetDemuxerConfigs(GetConfigs()); |
416 | 419 |
417 // Surface is not set, Configure() should fail. | 420 // Surface is not set, Configure() should fail. |
418 | 421 |
419 EXPECT_EQ(MediaCodecDecoder::kConfigFailure, decoder_->Configure()); | 422 EXPECT_EQ(MediaCodecDecoder::kConfigFailure, decoder_->Configure(nullptr)); |
420 } | 423 } |
421 | 424 |
422 TEST_F(MediaCodecDecoderTest, VideoConfigureInvalidSurface) { | 425 TEST_F(MediaCodecDecoderTest, VideoConfigureInvalidSurface) { |
423 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 426 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
424 | 427 |
425 CreateVideoDecoder(); | 428 CreateVideoDecoder(); |
426 | 429 |
427 // decoder_->Configure() searches back for the key frame. | 430 // decoder_->Configure() searches back for the key frame. |
428 // We have to prefetch decoder. | 431 // We have to prefetch decoder. |
429 | 432 |
(...skipping 13 matching lines...) Expand all Loading... |
443 gfx::SurfaceTexture::Create(0)); | 446 gfx::SurfaceTexture::Create(0)); |
444 gfx::ScopedJavaSurface surface(surface_texture.get()); | 447 gfx::ScopedJavaSurface surface(surface_texture.get()); |
445 | 448 |
446 // Release the surface texture. | 449 // Release the surface texture. |
447 surface_texture = NULL; | 450 surface_texture = NULL; |
448 | 451 |
449 MediaCodecVideoDecoder* video_decoder = | 452 MediaCodecVideoDecoder* video_decoder = |
450 static_cast<MediaCodecVideoDecoder*>(decoder_.get()); | 453 static_cast<MediaCodecVideoDecoder*>(decoder_.get()); |
451 video_decoder->SetVideoSurface(surface.Pass()); | 454 video_decoder->SetVideoSurface(surface.Pass()); |
452 | 455 |
453 EXPECT_EQ(MediaCodecDecoder::kConfigFailure, decoder_->Configure()); | 456 EXPECT_EQ(MediaCodecDecoder::kConfigFailure, decoder_->Configure(nullptr)); |
454 } | 457 } |
455 | 458 |
456 TEST_F(MediaCodecDecoderTest, VideoConfigureValidParams) { | 459 TEST_F(MediaCodecDecoderTest, VideoConfigureValidParams) { |
457 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 460 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
458 | 461 |
459 CreateVideoDecoder(); | 462 CreateVideoDecoder(); |
460 | 463 |
461 // decoder_->Configure() searches back for the key frame. | 464 // decoder_->Configure() searches back for the key frame. |
462 // We have to prefetch decoder. | 465 // We have to prefetch decoder. |
463 | 466 |
464 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); | 467 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); |
465 SetDataFactory(scoped_ptr<VideoFactory>(new VideoFactory(duration))); | 468 SetDataFactory(scoped_ptr<VideoFactory>(new VideoFactory(duration))); |
466 | 469 |
467 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, | 470 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, |
468 base::Unretained(this), true)); | 471 base::Unretained(this), true)); |
469 | 472 |
470 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, | 473 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, |
471 base::Unretained(this)))); | 474 base::Unretained(this)))); |
472 | 475 |
473 decoder_->SetDemuxerConfigs(GetConfigs()); | 476 decoder_->SetDemuxerConfigs(GetConfigs()); |
474 | 477 |
475 SetVideoSurface(); | 478 SetVideoSurface(); |
476 | 479 |
477 // Now we can expect Configure() to succeed. | 480 // Now we can expect Configure() to succeed. |
478 | 481 |
479 EXPECT_EQ(MediaCodecDecoder::kConfigOk, decoder_->Configure()); | 482 EXPECT_EQ(MediaCodecDecoder::kConfigOk, decoder_->Configure(nullptr)); |
480 } | 483 } |
481 | 484 |
482 TEST_F(MediaCodecDecoderTest, AudioStartWithoutConfigure) { | 485 TEST_F(MediaCodecDecoderTest, AudioStartWithoutConfigure) { |
483 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 486 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
484 | 487 |
485 CreateAudioDecoder(); | 488 CreateAudioDecoder(); |
486 | 489 |
487 // Decoder has to be prefetched and configured before the start. | 490 // Decoder has to be prefetched and configured before the start. |
488 | 491 |
489 // Wrong state: not prefetched | 492 // Wrong state: not prefetched |
(...skipping 29 matching lines...) Expand all Loading... |
519 | 522 |
520 // Prefetch to avoid starvation at the beginning of playback. | 523 // Prefetch to avoid starvation at the beginning of playback. |
521 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, | 524 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, |
522 base::Unretained(this), true)); | 525 base::Unretained(this), true)); |
523 | 526 |
524 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, | 527 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, |
525 base::Unretained(this)))); | 528 base::Unretained(this)))); |
526 | 529 |
527 decoder_->SetDemuxerConfigs(GetConfigs()); | 530 decoder_->SetDemuxerConfigs(GetConfigs()); |
528 | 531 |
529 EXPECT_EQ(MediaCodecDecoder::kConfigOk, decoder_->Configure()); | 532 EXPECT_EQ(MediaCodecDecoder::kConfigOk, decoder_->Configure(nullptr)); |
530 | 533 |
531 EXPECT_TRUE(decoder_->Start(base::TimeDelta::FromMilliseconds(0))); | 534 EXPECT_TRUE(decoder_->Start(base::TimeDelta::FromMilliseconds(0))); |
532 | 535 |
533 EXPECT_TRUE(WaitForCondition( | 536 EXPECT_TRUE(WaitForCondition( |
534 base::Bind(&MediaCodecDecoderTest::is_stopped, base::Unretained(this)), | 537 base::Bind(&MediaCodecDecoderTest::is_stopped, base::Unretained(this)), |
535 timeout)); | 538 timeout)); |
536 | 539 |
537 EXPECT_TRUE(decoder_->IsStopped()); | 540 EXPECT_TRUE(decoder_->IsStopped()); |
538 EXPECT_TRUE(decoder_->IsCompleted()); | 541 EXPECT_TRUE(decoder_->IsCompleted()); |
539 | 542 |
(...skipping 23 matching lines...) Expand all Loading... |
563 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, | 566 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, |
564 base::Unretained(this), true)); | 567 base::Unretained(this), true)); |
565 | 568 |
566 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, | 569 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, |
567 base::Unretained(this)))); | 570 base::Unretained(this)))); |
568 | 571 |
569 decoder_->SetDemuxerConfigs(GetConfigs()); | 572 decoder_->SetDemuxerConfigs(GetConfigs()); |
570 | 573 |
571 SetVideoSurface(); | 574 SetVideoSurface(); |
572 | 575 |
573 EXPECT_EQ(MediaCodecDecoder::kConfigOk, decoder_->Configure()); | 576 EXPECT_EQ(MediaCodecDecoder::kConfigOk, decoder_->Configure(nullptr)); |
574 | 577 |
575 EXPECT_TRUE(decoder_->Start(base::TimeDelta::FromMilliseconds(0))); | 578 EXPECT_TRUE(decoder_->Start(base::TimeDelta::FromMilliseconds(0))); |
576 | 579 |
577 EXPECT_TRUE(WaitForCondition( | 580 EXPECT_TRUE(WaitForCondition( |
578 base::Bind(&MediaCodecDecoderTest::is_stopped, base::Unretained(this)), | 581 base::Bind(&MediaCodecDecoderTest::is_stopped, base::Unretained(this)), |
579 timeout)); | 582 timeout)); |
580 | 583 |
581 EXPECT_TRUE(decoder_->IsStopped()); | 584 EXPECT_TRUE(decoder_->IsStopped()); |
582 EXPECT_TRUE(decoder_->IsCompleted()); | 585 EXPECT_TRUE(decoder_->IsCompleted()); |
583 | 586 |
(...skipping 17 matching lines...) Expand all Loading... |
601 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, | 604 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, |
602 base::Unretained(this), true)); | 605 base::Unretained(this), true)); |
603 | 606 |
604 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, | 607 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, |
605 base::Unretained(this)))); | 608 base::Unretained(this)))); |
606 | 609 |
607 decoder_->SetDemuxerConfigs(GetConfigs()); | 610 decoder_->SetDemuxerConfigs(GetConfigs()); |
608 | 611 |
609 SetVideoSurface(); | 612 SetVideoSurface(); |
610 | 613 |
611 EXPECT_EQ(MediaCodecDecoder::kConfigOk, decoder_->Configure()); | 614 EXPECT_EQ(MediaCodecDecoder::kConfigOk, decoder_->Configure(nullptr)); |
612 | 615 |
613 SetStopRequestAtTime(stop_request_time); | 616 SetStopRequestAtTime(stop_request_time); |
614 | 617 |
615 // Start from the beginning. | 618 // Start from the beginning. |
616 EXPECT_TRUE(decoder_->Start(base::TimeDelta::FromMilliseconds(0))); | 619 EXPECT_TRUE(decoder_->Start(base::TimeDelta::FromMilliseconds(0))); |
617 | 620 |
618 EXPECT_TRUE(WaitForCondition( | 621 EXPECT_TRUE(WaitForCondition( |
619 base::Bind(&MediaCodecDecoderTest::is_stopped, base::Unretained(this)), | 622 base::Bind(&MediaCodecDecoderTest::is_stopped, base::Unretained(this)), |
620 timeout)); | 623 timeout)); |
621 | 624 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 // Prefetch. | 674 // Prefetch. |
672 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, | 675 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, |
673 base::Unretained(this), true)); | 676 base::Unretained(this), true)); |
674 | 677 |
675 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, | 678 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, |
676 base::Unretained(this)))); | 679 base::Unretained(this)))); |
677 | 680 |
678 // Configure. | 681 // Configure. |
679 decoder_->SetDemuxerConfigs(GetConfigs()); | 682 decoder_->SetDemuxerConfigs(GetConfigs()); |
680 | 683 |
681 EXPECT_EQ(MediaCodecDecoder::kConfigOk, decoder_->Configure()); | 684 EXPECT_EQ(MediaCodecDecoder::kConfigOk, decoder_->Configure(nullptr)); |
682 | 685 |
683 // Start. | 686 // Start. |
684 EXPECT_TRUE(decoder_->Start(base::TimeDelta::FromMilliseconds(0))); | 687 EXPECT_TRUE(decoder_->Start(base::TimeDelta::FromMilliseconds(0))); |
685 | 688 |
686 // Wait for starvation. | 689 // Wait for starvation. |
687 EXPECT_TRUE(WaitForCondition( | 690 EXPECT_TRUE(WaitForCondition( |
688 base::Bind(&MediaCodecDecoderTest::is_starved, base::Unretained(this)), | 691 base::Bind(&MediaCodecDecoderTest::is_starved, base::Unretained(this)), |
689 timeout)); | 692 timeout)); |
690 | 693 |
691 EXPECT_FALSE(decoder_->IsStopped()); | 694 EXPECT_FALSE(decoder_->IsStopped()); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, | 736 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, |
734 base::Unretained(this)))); | 737 base::Unretained(this)))); |
735 | 738 |
736 // Current implementation reports the new video size after | 739 // Current implementation reports the new video size after |
737 // SetDemuxerConfigs(), verify that it is alt size. | 740 // SetDemuxerConfigs(), verify that it is alt size. |
738 EXPECT_EQ(alt_configs.video_size, video_size_); | 741 EXPECT_EQ(alt_configs.video_size, video_size_); |
739 | 742 |
740 SetVideoSurface(); | 743 SetVideoSurface(); |
741 | 744 |
742 // Configure. | 745 // Configure. |
743 EXPECT_EQ(MediaCodecDecoder::kConfigOk, decoder_->Configure()); | 746 EXPECT_EQ(MediaCodecDecoder::kConfigOk, decoder_->Configure(nullptr)); |
744 | 747 |
745 // Start. | 748 // Start. |
746 EXPECT_TRUE(decoder_->Start(base::TimeDelta::FromMilliseconds(0))); | 749 EXPECT_TRUE(decoder_->Start(base::TimeDelta::FromMilliseconds(0))); |
747 | 750 |
748 // Wait for completion. | 751 // Wait for completion. |
749 EXPECT_TRUE(WaitForCondition( | 752 EXPECT_TRUE(WaitForCondition( |
750 base::Bind(&MediaCodecDecoderTest::is_stopped, base::Unretained(this)), | 753 base::Bind(&MediaCodecDecoderTest::is_stopped, base::Unretained(this)), |
751 timeout)); | 754 timeout)); |
752 | 755 |
753 EXPECT_TRUE(decoder_->IsStopped()); | 756 EXPECT_TRUE(decoder_->IsStopped()); |
754 EXPECT_TRUE(decoder_->IsCompleted()); | 757 EXPECT_TRUE(decoder_->IsCompleted()); |
755 EXPECT_EQ(data_factory_->last_pts(), pts_stat_.max()); | 758 EXPECT_EQ(data_factory_->last_pts(), pts_stat_.max()); |
756 | 759 |
757 // Check that the reported video size is the one from the in-stream configs. | 760 // Check that the reported video size is the one from the in-stream configs. |
758 EXPECT_EQ(data_factory_->GetConfigs().video_size, video_size_); | 761 EXPECT_EQ(data_factory_->GetConfigs().video_size, video_size_); |
759 } | 762 } |
760 | 763 |
761 } // namespace media | 764 } // namespace media |
OLD | NEW |