Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "media/base/android/media_source_player.h" | 5 #include "media/base/android/media_source_player.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 596 // If we have a valid timestamp, start the starvation callback. Otherwise, | 596 // If we have a valid timestamp, start the starvation callback. Otherwise, |
| 597 // reset the |start_time_ticks_| so that the next frame will not suffer | 597 // reset the |start_time_ticks_| so that the next frame will not suffer |
| 598 // from the decoding delay caused by the current frame. | 598 // from the decoding delay caused by the current frame. |
| 599 if (presentation_timestamp != kNoTimestamp()) | 599 if (presentation_timestamp != kNoTimestamp()) |
| 600 StartStarvationCallback(presentation_timestamp); | 600 StartStarvationCallback(presentation_timestamp); |
| 601 else | 601 else |
| 602 start_time_ticks_ = base::TimeTicks::Now(); | 602 start_time_ticks_ = base::TimeTicks::Now(); |
| 603 } | 603 } |
| 604 | 604 |
| 605 if (is_audio) { | 605 if (is_audio) { |
| 606 DecodeMoreAudio(); | 606 DecodeMoreAudio(false); |
| 607 return; | 607 return; |
| 608 } | 608 } |
| 609 | 609 |
| 610 DecodeMoreVideo(); | 610 DecodeMoreVideo(false); |
| 611 } | 611 } |
| 612 | 612 |
| 613 void MediaSourcePlayer::DecodeMoreAudio() { | 613 void MediaSourcePlayer::DecodeMoreAudio(bool video_change_already_pending) { |
| 614 DVLOG(1) << __FUNCTION__; | 614 DVLOG(1) << __FUNCTION__; |
| 615 DCHECK(!audio_decoder_job_->is_decoding()); | 615 DCHECK(!audio_decoder_job_->is_decoding()); |
| 616 | 616 |
| 617 if (audio_decoder_job_->Decode( | 617 if (audio_decoder_job_->Decode( |
| 618 start_time_ticks_, start_presentation_timestamp_, base::Bind( | 618 start_time_ticks_, start_presentation_timestamp_, base::Bind( |
| 619 &MediaSourcePlayer::MediaDecoderCallback, | 619 &MediaSourcePlayer::MediaDecoderCallback, |
| 620 weak_this_.GetWeakPtr(), true))) { | 620 weak_this_.GetWeakPtr(), true))) { |
| 621 TRACE_EVENT_ASYNC_BEGIN0("media", "MediaSourcePlayer::DecodeMoreAudio", | 621 TRACE_EVENT_ASYNC_BEGIN0("media", "MediaSourcePlayer::DecodeMoreAudio", |
| 622 audio_decoder_job_.get()); | 622 audio_decoder_job_.get()); |
| 623 return; | 623 return; |
| 624 } | 624 } |
| 625 | 625 |
| 626 // Failed to start the next decode. | 626 // Failed to start the next decode. |
| 627 // Wait for demuxer ready message. | 627 // Wait for demuxer ready message. |
| 628 DCHECK(!reconfig_audio_decoder_); | |
| 628 reconfig_audio_decoder_ = true; | 629 reconfig_audio_decoder_ = true; |
| 630 if (video_change_already_pending) { | |
|
acolwell GONE FROM CHROMIUM
2013/11/04 18:42:07
I don't think the xxx_change_already_pending param
wolenetz
2013/11/04 19:30:25
Done. Thank you for the rapid CR :)
| |
| 631 DCHECK(reconfig_video_decoder_ && | |
| 632 IsEventPending(CONFIG_CHANGE_EVENT_PENDING)); | |
| 633 return; | |
| 634 } | |
| 635 | |
| 629 SetPendingEvent(CONFIG_CHANGE_EVENT_PENDING); | 636 SetPendingEvent(CONFIG_CHANGE_EVENT_PENDING); |
| 630 ProcessPendingEvents(); | 637 ProcessPendingEvents(); |
| 631 } | 638 } |
| 632 | 639 |
| 633 void MediaSourcePlayer::DecodeMoreVideo() { | 640 void MediaSourcePlayer::DecodeMoreVideo(bool audio_change_already_pending) { |
| 634 DVLOG(1) << __FUNCTION__; | 641 DVLOG(1) << __FUNCTION__; |
| 635 DCHECK(!video_decoder_job_->is_decoding()); | 642 DCHECK(!video_decoder_job_->is_decoding()); |
| 636 | 643 |
| 637 if (video_decoder_job_->Decode( | 644 if (video_decoder_job_->Decode( |
| 638 start_time_ticks_, start_presentation_timestamp_, base::Bind( | 645 start_time_ticks_, start_presentation_timestamp_, base::Bind( |
| 639 &MediaSourcePlayer::MediaDecoderCallback, | 646 &MediaSourcePlayer::MediaDecoderCallback, |
| 640 weak_this_.GetWeakPtr(), false))) { | 647 weak_this_.GetWeakPtr(), false))) { |
| 641 TRACE_EVENT_ASYNC_BEGIN0("media", "MediaSourcePlayer::DecodeMoreVideo", | 648 TRACE_EVENT_ASYNC_BEGIN0("media", "MediaSourcePlayer::DecodeMoreVideo", |
| 642 video_decoder_job_.get()); | 649 video_decoder_job_.get()); |
| 643 return; | 650 return; |
| 644 } | 651 } |
| 645 | 652 |
| 646 // Failed to start the next decode. | 653 // Failed to start the next decode. |
| 647 // Wait for demuxer ready message. | 654 // Wait for demuxer ready message. |
| 648 reconfig_video_decoder_ = true; | |
| 649 | 655 |
| 650 // After this detection of video config change, next video data received | 656 // After this detection of video config change, next video data received |
| 651 // will begin with I-frame. | 657 // will begin with I-frame. |
| 652 next_video_data_is_iframe_ = true; | 658 next_video_data_is_iframe_ = true; |
| 653 | 659 |
| 660 DCHECK(!reconfig_video_decoder_); | |
| 661 reconfig_video_decoder_ = true; | |
| 662 if (audio_change_already_pending) { | |
| 663 DCHECK(reconfig_audio_decoder_ && | |
| 664 IsEventPending(CONFIG_CHANGE_EVENT_PENDING)); | |
| 665 return; | |
| 666 } | |
| 667 | |
| 654 SetPendingEvent(CONFIG_CHANGE_EVENT_PENDING); | 668 SetPendingEvent(CONFIG_CHANGE_EVENT_PENDING); |
| 655 ProcessPendingEvents(); | 669 ProcessPendingEvents(); |
| 656 } | 670 } |
| 657 | 671 |
| 658 void MediaSourcePlayer::PlaybackCompleted(bool is_audio) { | 672 void MediaSourcePlayer::PlaybackCompleted(bool is_audio) { |
| 659 DVLOG(1) << __FUNCTION__ << "(" << is_audio << ")"; | 673 DVLOG(1) << __FUNCTION__ << "(" << is_audio << ")"; |
| 660 if (is_audio) | 674 if (is_audio) |
| 661 audio_finished_ = true; | 675 audio_finished_ = true; |
| 662 else | 676 else |
| 663 video_finished_ = true; | 677 video_finished_ = true; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 843 ProcessPendingEvents(); | 857 ProcessPendingEvents(); |
| 844 return; | 858 return; |
| 845 } | 859 } |
| 846 | 860 |
| 847 start_time_ticks_ = base::TimeTicks::Now(); | 861 start_time_ticks_ = base::TimeTicks::Now(); |
| 848 start_presentation_timestamp_ = GetCurrentTime(); | 862 start_presentation_timestamp_ = GetCurrentTime(); |
| 849 if (!clock_.IsPlaying()) | 863 if (!clock_.IsPlaying()) |
| 850 clock_.Play(); | 864 clock_.Play(); |
| 851 | 865 |
| 852 if (audio_decoder_job_) | 866 if (audio_decoder_job_) |
| 853 DecodeMoreAudio(); | 867 DecodeMoreAudio(false); |
| 854 if (video_decoder_job_) | 868 if (video_decoder_job_) |
| 855 DecodeMoreVideo(); | 869 DecodeMoreVideo(IsEventPending(CONFIG_CHANGE_EVENT_PENDING)); |
| 856 } | 870 } |
| 857 | 871 |
| 858 const char* MediaSourcePlayer::GetEventName(PendingEventFlags event) { | 872 const char* MediaSourcePlayer::GetEventName(PendingEventFlags event) { |
| 859 static const char* kPendingEventNames[] = { | 873 static const char* kPendingEventNames[] = { |
| 860 "SEEK", | 874 "SEEK", |
| 861 "SURFACE_CHANGE", | 875 "SURFACE_CHANGE", |
| 862 "CONFIG_CHANGE", | 876 "CONFIG_CHANGE", |
| 863 "PREFETCH_REQUEST", | 877 "PREFETCH_REQUEST", |
| 864 "PREFETCH_DONE", | 878 "PREFETCH_DONE", |
| 865 }; | 879 }; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 887 | 901 |
| 888 void MediaSourcePlayer::ClearPendingEvent(PendingEventFlags event) { | 902 void MediaSourcePlayer::ClearPendingEvent(PendingEventFlags event) { |
| 889 DVLOG(1) << __FUNCTION__ << "(" << GetEventName(event) << ")"; | 903 DVLOG(1) << __FUNCTION__ << "(" << GetEventName(event) << ")"; |
| 890 DCHECK_NE(event, NO_EVENT_PENDING); | 904 DCHECK_NE(event, NO_EVENT_PENDING); |
| 891 DCHECK(IsEventPending(event)) << GetEventName(event); | 905 DCHECK(IsEventPending(event)) << GetEventName(event); |
| 892 | 906 |
| 893 pending_event_ &= ~event; | 907 pending_event_ &= ~event; |
| 894 } | 908 } |
| 895 | 909 |
| 896 } // namespace media | 910 } // namespace media |
| OLD | NEW |