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 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 720 | 720 |
| 721 void MediaSourcePlayer::ConfigureVideoDecoderJob() { | 721 void MediaSourcePlayer::ConfigureVideoDecoderJob() { |
| 722 if (!HasVideo() || surface_.IsEmpty()) { | 722 if (!HasVideo() || surface_.IsEmpty()) { |
| 723 video_decoder_job_.reset(); | 723 video_decoder_job_.reset(); |
| 724 if (IsEventPending(SURFACE_CHANGE_EVENT_PENDING)) | 724 if (IsEventPending(SURFACE_CHANGE_EVENT_PENDING)) |
| 725 ClearPendingEvent(SURFACE_CHANGE_EVENT_PENDING); | 725 ClearPendingEvent(SURFACE_CHANGE_EVENT_PENDING); |
| 726 return; | 726 return; |
| 727 } | 727 } |
| 728 | 728 |
| 729 // Create video decoder job only if config changes or we don't have a job. | 729 // Create video decoder job only if config changes or we don't have a job. |
| 730 if (video_decoder_job_ && !reconfig_video_decoder_) | 730 if (video_decoder_job_ && !reconfig_video_decoder_) { |
| 731 DCHECK(!IsEventPending(SURFACE_CHANGE_EVENT_PENDING)); | |
| 731 return; | 732 return; |
| 733 } | |
| 732 | 734 |
| 733 if (reconfig_video_decoder_) { | 735 if (reconfig_video_decoder_) { |
| 734 // No hack browser seek should be required. I-Frame must be next. | 736 // No hack browser seek should be required. I-Frame must be next. |
| 735 DCHECK(next_video_data_is_iframe_) << "Received video data between " | 737 DCHECK(next_video_data_is_iframe_) << "Received video data between " |
| 736 << "detecting video config change and reconfiguring video decoder"; | 738 << "detecting video config change and reconfiguring video decoder"; |
| 737 } | 739 } |
| 738 | 740 |
| 741 DCHECK(!video_decoder_job_ || !video_decoder_job_->is_decoding()); | |
| 742 | |
| 743 // Release the old VideoDecoderJob first so the surface can get released. | |
| 744 // Android does not allow 2 MediaCodec instances use the same surface. | |
| 745 video_decoder_job_.reset(); | |
|
wolenetz
2013/10/31 03:03:09
Note, if is_video_encrypted but there is no valid
qinmin
2013/10/31 16:35:52
Should be ok. If there is no media_crypto, the job
acolwell GONE FROM CHROMIUM
2013/10/31 18:11:28
ISTM that we should create a helper function for r
wolenetz
2013/10/31 18:12:07
Could there be a regression here, too: Could we pr
qinmin
2013/10/31 18:32:37
we always need to reset the vide_decoder_job if me
wolenetz
2013/10/31 20:34:24
Done, added helper MSP::ResetVideoDecoderJob().
| |
| 746 | |
| 747 if (IsEventPending(SURFACE_CHANGE_EVENT_PENDING)) | |
|
qinmin
2013/10/31 16:35:52
i think all this should happen after the next if s
wolenetz
2013/10/31 18:12:07
Done. In combination with eventual landing of http
| |
| 748 ClearPendingEvent(SURFACE_CHANGE_EVENT_PENDING); | |
| 749 | |
| 739 // If uncertain that video I-frame data is next and there is no seek already | 750 // If uncertain that video I-frame data is next and there is no seek already |
| 740 // in process, request browser demuxer seek so the new decoder will decode | 751 // in process, request browser demuxer seek so the new decoder will decode |
| 741 // an I-frame first. Otherwise, the new MediaCodec might crash. See b/8950387. | 752 // an I-frame first. Otherwise, the new MediaCodec might crash. See b/8950387. |
| 742 // TODO(wolenetz): Instead of doing hack browser seek, replay cached data | 753 // TODO(wolenetz): Instead of doing hack browser seek, replay cached data |
| 743 // since last keyframe. See http://crbug.com/304234. | 754 // since last keyframe. See http://crbug.com/304234. |
| 744 if (!next_video_data_is_iframe_ && !IsEventPending(SEEK_EVENT_PENDING)) { | 755 if (!next_video_data_is_iframe_ && !IsEventPending(SEEK_EVENT_PENDING)) { |
| 745 BrowserSeekToCurrentTime(); | 756 BrowserSeekToCurrentTime(); |
| 746 return; | 757 return; |
| 747 } | 758 } |
| 748 | 759 |
| 749 base::android::ScopedJavaLocalRef<jobject> media_crypto = GetMediaCrypto(); | 760 base::android::ScopedJavaLocalRef<jobject> media_crypto = GetMediaCrypto(); |
| 750 if (is_video_encrypted_ && media_crypto.is_null()) | 761 if (is_video_encrypted_ && media_crypto.is_null()) |
| 751 return; | 762 return; |
| 752 | 763 |
| 753 DCHECK(!video_decoder_job_ || !video_decoder_job_->is_decoding()); | |
| 754 | |
| 755 DVLOG(1) << __FUNCTION__ << " : creating new video decoder job"; | 764 DVLOG(1) << __FUNCTION__ << " : creating new video decoder job"; |
| 756 | 765 |
| 757 // Release the old VideoDecoderJob first so the surface can get released. | |
| 758 // Android does not allow 2 MediaCodec instances use the same surface. | |
| 759 video_decoder_job_.reset(); | |
| 760 // Create the new VideoDecoderJob. | 766 // Create the new VideoDecoderJob. |
| 761 bool is_secure = IsProtectedSurfaceRequired(); | 767 bool is_secure = IsProtectedSurfaceRequired(); |
| 762 video_decoder_job_.reset( | 768 video_decoder_job_.reset( |
| 763 VideoDecoderJob::Create(video_codec_, | 769 VideoDecoderJob::Create(video_codec_, |
| 764 is_secure, | 770 is_secure, |
| 765 gfx::Size(width_, height_), | 771 gfx::Size(width_, height_), |
| 766 surface_.j_surface().obj(), | 772 surface_.j_surface().obj(), |
| 767 media_crypto.obj(), | 773 media_crypto.obj(), |
| 768 base::Bind(&DemuxerAndroid::RequestDemuxerData, | 774 base::Bind(&DemuxerAndroid::RequestDemuxerData, |
| 769 base::Unretained(demuxer_.get()), | 775 base::Unretained(demuxer_.get()), |
| 770 DemuxerStream::VIDEO))); | 776 DemuxerStream::VIDEO))); |
| 771 if (video_decoder_job_) { | 777 if (video_decoder_job_) { |
| 772 video_decoder_job_->BeginPrerolling(preroll_timestamp_); | 778 video_decoder_job_->BeginPrerolling(preroll_timestamp_); |
| 773 reconfig_video_decoder_ = false; | 779 reconfig_video_decoder_ = false; |
| 774 } | 780 } |
| 775 | 781 |
| 776 if (IsEventPending(SURFACE_CHANGE_EVENT_PENDING)) | |
| 777 ClearPendingEvent(SURFACE_CHANGE_EVENT_PENDING); | |
| 778 | |
| 779 // Inform the fullscreen view the player is ready. | 782 // Inform the fullscreen view the player is ready. |
| 780 // TODO(qinmin): refactor MediaPlayerBridge so that we have a better way | 783 // TODO(qinmin): refactor MediaPlayerBridge so that we have a better way |
| 781 // to inform ContentVideoView. | 784 // to inform ContentVideoView. |
| 782 manager()->OnMediaMetadataChanged( | 785 manager()->OnMediaMetadataChanged( |
|
acolwell GONE FROM CHROMIUM
2013/10/31 18:11:28
Why do we blindly notify the manager even when the
qinmin
2013/10/31 18:32:37
If the decoder job is created, this is to let the
wolenetz
2013/10/31 20:34:24
Done.
| |
| 783 player_id(), duration_, width_, height_, true); | 786 player_id(), duration_, width_, height_, true); |
| 784 } | 787 } |
| 785 | 788 |
| 786 void MediaSourcePlayer::OnDecoderStarved() { | 789 void MediaSourcePlayer::OnDecoderStarved() { |
| 787 DVLOG(1) << __FUNCTION__; | 790 DVLOG(1) << __FUNCTION__; |
| 788 SetPendingEvent(PREFETCH_REQUEST_EVENT_PENDING); | 791 SetPendingEvent(PREFETCH_REQUEST_EVENT_PENDING); |
| 789 ProcessPendingEvents(); | 792 ProcessPendingEvents(); |
| 790 } | 793 } |
| 791 | 794 |
| 792 void MediaSourcePlayer::StartStarvationCallback( | 795 void MediaSourcePlayer::StartStarvationCallback( |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 887 | 890 |
| 888 void MediaSourcePlayer::ClearPendingEvent(PendingEventFlags event) { | 891 void MediaSourcePlayer::ClearPendingEvent(PendingEventFlags event) { |
| 889 DVLOG(1) << __FUNCTION__ << "(" << GetEventName(event) << ")"; | 892 DVLOG(1) << __FUNCTION__ << "(" << GetEventName(event) << ")"; |
| 890 DCHECK_NE(event, NO_EVENT_PENDING); | 893 DCHECK_NE(event, NO_EVENT_PENDING); |
| 891 DCHECK(IsEventPending(event)) << GetEventName(event); | 894 DCHECK(IsEventPending(event)) << GetEventName(event); |
| 892 | 895 |
| 893 pending_event_ &= ~event; | 896 pending_event_ &= ~event; |
| 894 } | 897 } |
| 895 | 898 |
| 896 } // namespace media | 899 } // namespace media |
| OLD | NEW |