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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // values at millisecond resolution. | 114 // values at millisecond resolution. |
115 return duration_ < | 115 return duration_ < |
116 base::TimeDelta::FromMilliseconds(std::numeric_limits<int32>::max()); | 116 base::TimeDelta::FromMilliseconds(std::numeric_limits<int32>::max()); |
117 } | 117 } |
118 | 118 |
119 void MediaSourcePlayer::Start() { | 119 void MediaSourcePlayer::Start() { |
120 DVLOG(1) << __FUNCTION__; | 120 DVLOG(1) << __FUNCTION__; |
121 | 121 |
122 playing_ = true; | 122 playing_ = true; |
123 | 123 |
124 bool request_fullscreen = IsProtectedSurfaceRequired(); | |
125 #if defined(VIDEO_HOLE) | |
126 // Skip to request fullscreen when hole-punching is used. | |
127 request_fullscreen = request_fullscreen && | |
128 !manager()->ShouldUseVideoOverlayForEmbeddedEncryptedVideo(); | |
129 #endif // defined(VIDEO_HOLE) | |
130 if (request_fullscreen) | |
131 manager()->RequestFullScreen(player_id()); | |
132 | |
133 StartInternal(); | 124 StartInternal(); |
134 } | 125 } |
135 | 126 |
136 void MediaSourcePlayer::Pause(bool is_media_related_action) { | 127 void MediaSourcePlayer::Pause(bool is_media_related_action) { |
137 DVLOG(1) << __FUNCTION__; | 128 DVLOG(1) << __FUNCTION__; |
138 | 129 |
139 // Since decoder jobs have their own thread, decoding is not fully paused | 130 // Since decoder jobs have their own thread, decoding is not fully paused |
140 // until all the decoder jobs call MediaDecoderCallback(). It is possible | 131 // until all the decoder jobs call MediaDecoderCallback(). It is possible |
141 // that Start() is called while the player is waiting for | 132 // that Start() is called while the player is waiting for |
142 // MediaDecoderCallback(). In that case, decoding will continue when | 133 // MediaDecoderCallback(). In that case, decoding will continue when |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 } | 668 } |
678 | 669 |
679 timeout = std::max(timeout, kMinStarvationTimeout); | 670 timeout = std::max(timeout, kMinStarvationTimeout); |
680 | 671 |
681 decoder_starvation_callback_.Reset( | 672 decoder_starvation_callback_.Reset( |
682 base::Bind(&MediaSourcePlayer::OnDecoderStarved, weak_this_)); | 673 base::Bind(&MediaSourcePlayer::OnDecoderStarved, weak_this_)); |
683 base::MessageLoop::current()->PostDelayedTask( | 674 base::MessageLoop::current()->PostDelayedTask( |
684 FROM_HERE, decoder_starvation_callback_.callback(), timeout); | 675 FROM_HERE, decoder_starvation_callback_.callback(), timeout); |
685 } | 676 } |
686 | 677 |
687 bool MediaSourcePlayer::IsProtectedSurfaceRequired() { | |
688 return video_decoder_job_->is_content_encrypted() && | |
689 drm_bridge_ && drm_bridge_->IsProtectedSurfaceRequired(); | |
690 } | |
691 | |
692 void MediaSourcePlayer::OnPrefetchDone() { | 678 void MediaSourcePlayer::OnPrefetchDone() { |
693 DVLOG(1) << __FUNCTION__; | 679 DVLOG(1) << __FUNCTION__; |
694 DCHECK(!audio_decoder_job_->is_decoding()); | 680 DCHECK(!audio_decoder_job_->is_decoding()); |
695 DCHECK(!video_decoder_job_->is_decoding()); | 681 DCHECK(!video_decoder_job_->is_decoding()); |
696 | 682 |
697 // A previously posted OnPrefetchDone() could race against a Release(). If | 683 // A previously posted OnPrefetchDone() could race against a Release(). If |
698 // Release() won the race, we should no longer have decoder jobs. | 684 // Release() won the race, we should no longer have decoder jobs. |
699 // TODO(qinmin/wolenetz): Maintain channel state to not double-request data | 685 // TODO(qinmin/wolenetz): Maintain channel state to not double-request data |
700 // or drop data received across Release()+Start(). See http://crbug.com/306314 | 686 // or drop data received across Release()+Start(). See http://crbug.com/306314 |
701 // and http://crbug.com/304234. | 687 // and http://crbug.com/304234. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 // support setMediaKeys(0) (see http://crbug.com/330324), or when we release | 802 // support setMediaKeys(0) (see http://crbug.com/330324), or when we release |
817 // MediaDrm when the video is paused, or when the device goes to sleep (see | 803 // MediaDrm when the video is paused, or when the device goes to sleep (see |
818 // http://crbug.com/272421). | 804 // http://crbug.com/272421). |
819 audio_decoder_job_->SetDrmBridge(NULL); | 805 audio_decoder_job_->SetDrmBridge(NULL); |
820 video_decoder_job_->SetDrmBridge(NULL); | 806 video_decoder_job_->SetDrmBridge(NULL); |
821 cdm_registration_id_ = 0; | 807 cdm_registration_id_ = 0; |
822 drm_bridge_ = NULL; | 808 drm_bridge_ = NULL; |
823 } | 809 } |
824 | 810 |
825 } // namespace media | 811 } // namespace media |
OLD | NEW |