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 "content/renderer/media/android/webmediaplayer_android.h" | 5 #include "content/renderer/media/android/webmediaplayer_android.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 pending_seek_(false), | 127 pending_seek_(false), |
128 seeking_(false), | 128 seeking_(false), |
129 did_loading_progress_(false), | 129 did_loading_progress_(false), |
130 player_manager_(player_manager), | 130 player_manager_(player_manager), |
131 cdm_manager_(cdm_manager), | 131 cdm_manager_(cdm_manager), |
132 network_state_(WebMediaPlayer::NetworkStateEmpty), | 132 network_state_(WebMediaPlayer::NetworkStateEmpty), |
133 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), | 133 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), |
134 texture_id_(0), | 134 texture_id_(0), |
135 stream_id_(0), | 135 stream_id_(0), |
136 is_playing_(false), | 136 is_playing_(false), |
137 needs_establish_peer_(true), | 137 peer_established_(false), |
138 in_fullscreen_(false), | |
138 stream_texture_proxy_initialized_(false), | 139 stream_texture_proxy_initialized_(false), |
139 has_size_info_(false), | 140 has_size_info_(false), |
140 stream_texture_factory_(factory), | 141 stream_texture_factory_(factory), |
141 needs_external_surface_(false), | 142 needs_external_surface_(false), |
142 video_frame_provider_client_(NULL), | 143 video_frame_provider_client_(NULL), |
143 pending_playback_(false), | 144 pending_playback_(false), |
144 player_type_(MEDIA_PLAYER_TYPE_URL), | 145 player_type_(MEDIA_PLAYER_TYPE_URL), |
145 current_time_(0), | 146 current_time_(0), |
146 is_remote_(false), | 147 is_remote_(false), |
147 media_log_(media_log), | 148 media_log_(media_log), |
148 web_cdm_(NULL), | 149 web_cdm_(NULL), |
149 allow_stored_credentials_(false), | 150 allow_stored_credentials_(false), |
150 is_local_resource_(false), | 151 is_local_resource_(false), |
151 weak_factory_(this) { | 152 weak_factory_(this) { |
152 DCHECK(player_manager_); | 153 DCHECK(player_manager_); |
153 DCHECK(cdm_manager_); | 154 DCHECK(cdm_manager_); |
154 | 155 |
155 DCHECK(main_thread_checker_.CalledOnValidThread()); | 156 DCHECK(main_thread_checker_.CalledOnValidThread()); |
156 | 157 |
157 player_id_ = player_manager_->RegisterMediaPlayer(this); | 158 player_id_ = player_manager_->RegisterMediaPlayer(this); |
158 | 159 |
159 #if defined(VIDEO_HOLE) | 160 #if defined(VIDEO_HOLE) |
160 force_use_overlay_embedded_video_ = CommandLine::ForCurrentProcess()-> | 161 force_use_overlay_embedded_video_ = CommandLine::ForCurrentProcess()-> |
161 HasSwitch(switches::kForceUseOverlayEmbeddedVideo); | 162 HasSwitch(switches::kForceUseOverlayEmbeddedVideo); |
162 if (force_use_overlay_embedded_video_ || | 163 if (force_use_overlay_embedded_video_ || |
163 player_manager_->ShouldUseVideoOverlayForEmbeddedEncryptedVideo()) { | 164 player_manager_->ShouldUseVideoOverlayForEmbeddedEncryptedVideo()) { |
164 // Defer stream texture creation until we are sure it's necessary. | 165 // Defer stream texture creation until we are sure it's necessary. |
165 needs_establish_peer_ = false; | 166 needs_external_surface_ = true; |
qinmin
2014/09/09 06:39:18
why set this to true? if the video is not EME, no
boliu
2014/09/09 21:17:04
Done.
| |
166 current_frame_ = VideoFrame::CreateBlackFrame(gfx::Size(1, 1)); | 167 current_frame_ = VideoFrame::CreateBlackFrame(gfx::Size(1, 1)); |
167 } | 168 } |
168 #endif // defined(VIDEO_HOLE) | 169 #endif // defined(VIDEO_HOLE) |
169 TryCreateStreamTextureProxyIfNeeded(); | 170 TryCreateStreamTextureProxyIfNeeded(); |
170 } | 171 } |
171 | 172 |
172 WebMediaPlayerAndroid::~WebMediaPlayerAndroid() { | 173 WebMediaPlayerAndroid::~WebMediaPlayerAndroid() { |
173 DCHECK(main_thread_checker_.CalledOnValidThread()); | 174 DCHECK(main_thread_checker_.CalledOnValidThread()); |
174 SetVideoFrameProviderClient(NULL); | 175 SetVideoFrameProviderClient(NULL); |
175 client_->setWebLayer(NULL); | 176 client_->setWebLayer(NULL); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 } | 297 } |
297 | 298 |
298 void WebMediaPlayerAndroid::play() { | 299 void WebMediaPlayerAndroid::play() { |
299 DCHECK(main_thread_checker_.CalledOnValidThread()); | 300 DCHECK(main_thread_checker_.CalledOnValidThread()); |
300 | 301 |
301 // For HLS streams, some devices cannot detect the video size unless a surface | 302 // For HLS streams, some devices cannot detect the video size unless a surface |
302 // texture is bind to it. See http://crbug.com/400145. | 303 // texture is bind to it. See http://crbug.com/400145. |
303 #if defined(VIDEO_HOLE) | 304 #if defined(VIDEO_HOLE) |
304 if ((hasVideo() || IsHLSStream()) && needs_external_surface_ && | 305 if ((hasVideo() || IsHLSStream()) && needs_external_surface_ && |
305 !player_manager_->IsInFullscreen(frame_)) { | 306 !player_manager_->IsInFullscreen(frame_)) { |
306 DCHECK(!needs_establish_peer_); | |
307 player_manager_->RequestExternalSurface(player_id_, last_computed_rect_); | 307 player_manager_->RequestExternalSurface(player_id_, last_computed_rect_); |
308 } | 308 } |
309 #endif // defined(VIDEO_HOLE) | 309 #endif // defined(VIDEO_HOLE) |
310 | 310 |
311 TryCreateStreamTextureProxyIfNeeded(); | 311 TryCreateStreamTextureProxyIfNeeded(); |
312 // There is no need to establish the surface texture peer for fullscreen | |
313 // video. | |
314 if ((hasVideo() || IsHLSStream()) && needs_establish_peer_ && | |
315 !player_manager_->IsInFullscreen(frame_)) { | |
316 EstablishSurfaceTexturePeer(); | |
317 } | |
318 | 312 |
319 if (paused()) | 313 if (paused()) |
320 player_manager_->Start(player_id_); | 314 player_manager_->Start(player_id_); |
321 UpdatePlayingState(true); | 315 UpdatePlayingState(true); |
322 UpdateNetworkState(WebMediaPlayer::NetworkStateLoading); | 316 UpdateNetworkState(WebMediaPlayer::NetworkStateLoading); |
323 } | 317 } |
324 | 318 |
325 void WebMediaPlayerAndroid::pause() { | 319 void WebMediaPlayerAndroid::pause() { |
326 DCHECK(main_thread_checker_.CalledOnValidThread()); | 320 DCHECK(main_thread_checker_.CalledOnValidThread()); |
327 Pause(true); | 321 Pause(true); |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
813 has_size_info_ = true; | 807 has_size_info_ = true; |
814 if (natural_size_.width == width && natural_size_.height == height) | 808 if (natural_size_.width == width && natural_size_.height == height) |
815 return; | 809 return; |
816 | 810 |
817 #if defined(VIDEO_HOLE) | 811 #if defined(VIDEO_HOLE) |
818 // Use H/W surface for encrypted video. | 812 // Use H/W surface for encrypted video. |
819 // TODO(qinmin): Change this so that only EME needs the H/W surface | 813 // TODO(qinmin): Change this so that only EME needs the H/W surface |
820 if (force_use_overlay_embedded_video_ || | 814 if (force_use_overlay_embedded_video_ || |
821 (media_source_delegate_ && media_source_delegate_->IsVideoEncrypted() && | 815 (media_source_delegate_ && media_source_delegate_->IsVideoEncrypted() && |
822 player_manager_->ShouldUseVideoOverlayForEmbeddedEncryptedVideo())) { | 816 player_manager_->ShouldUseVideoOverlayForEmbeddedEncryptedVideo())) { |
823 needs_external_surface_ = true; | |
824 if (!paused() && !player_manager_->IsInFullscreen(frame_)) | 817 if (!paused() && !player_manager_->IsInFullscreen(frame_)) |
825 player_manager_->RequestExternalSurface(player_id_, last_computed_rect_); | 818 player_manager_->RequestExternalSurface(player_id_, last_computed_rect_); |
826 } else if (stream_texture_proxy_ && !stream_id_) { | |
827 // Do deferred stream texture creation finally. | |
828 DoCreateStreamTexture(); | |
829 SetNeedsEstablishPeer(true); | |
830 } | 819 } |
831 #endif // defined(VIDEO_HOLE) | 820 #endif // defined(VIDEO_HOLE) |
832 natural_size_.width = width; | 821 natural_size_.width = width; |
833 natural_size_.height = height; | 822 natural_size_.height = height; |
834 | 823 |
835 // When play() gets called, |natural_size_| may still be empty and | 824 // When play() gets called, |natural_size_| may still be empty and |
836 // EstablishSurfaceTexturePeer() will not get called. As a result, the video | 825 // EstablishSurfaceTexturePeerIfNeeded() will not get called. As a result, the |
qinmin
2014/09/09 06:39:18
when play is called, isn't updatePlayingState() al
boliu
2014/09/09 21:17:04
Done.
| |
837 // may play without a surface texture. When we finally get the valid video | 826 // video may play without a surface texture. When we finally get the valid |
838 // size here, we should call EstablishSurfaceTexturePeer() if it has not been | 827 // video size here, we should call EstablishSurfaceTexturePeerIfNeeded() if |
839 // previously called. | 828 // it has not been previously called. |
840 if (!paused() && needs_establish_peer_) | 829 EstablishSurfaceTexturePeerIfNeeded(); |
841 EstablishSurfaceTexturePeer(); | |
842 | 830 |
843 ReallocateVideoFrame(); | 831 ReallocateVideoFrame(); |
844 | 832 |
845 // For hidden video element (with style "display:none"), ensure the texture | 833 // For hidden video element (with style "display:none"), ensure the texture |
846 // size is set. | 834 // size is set. |
847 if (!is_remote_ && cached_stream_texture_size_ != natural_size_) { | 835 if (!is_remote_ && cached_stream_texture_size_ != natural_size_) { |
848 stream_texture_factory_->SetStreamTextureSize( | 836 stream_texture_factory_->SetStreamTextureSize( |
849 stream_id_, gfx::Size(natural_size_.width, natural_size_.height)); | 837 stream_id_, gfx::Size(natural_size_.width, natural_size_.height)); |
850 cached_stream_texture_size_ = natural_size_; | 838 cached_stream_texture_size_ = natural_size_; |
851 } | 839 } |
(...skipping 17 matching lines...) Expand all Loading... | |
869 if (is_local_resource_ && current_time_ <= duration()) | 857 if (is_local_resource_ && current_time_ <= duration()) |
870 buffered_[0].end = current_time_; | 858 buffered_[0].end = current_time_; |
871 } | 859 } |
872 | 860 |
873 void WebMediaPlayerAndroid::OnConnectedToRemoteDevice( | 861 void WebMediaPlayerAndroid::OnConnectedToRemoteDevice( |
874 const std::string& remote_playback_message) { | 862 const std::string& remote_playback_message) { |
875 DCHECK(main_thread_checker_.CalledOnValidThread()); | 863 DCHECK(main_thread_checker_.CalledOnValidThread()); |
876 DCHECK(!media_source_delegate_); | 864 DCHECK(!media_source_delegate_); |
877 DrawRemotePlaybackText(remote_playback_message); | 865 DrawRemotePlaybackText(remote_playback_message); |
878 is_remote_ = true; | 866 is_remote_ = true; |
879 SetNeedsEstablishPeer(false); | 867 peer_established_ = false; |
880 } | 868 } |
881 | 869 |
882 void WebMediaPlayerAndroid::OnDisconnectedFromRemoteDevice() { | 870 void WebMediaPlayerAndroid::OnDisconnectedFromRemoteDevice() { |
883 DCHECK(main_thread_checker_.CalledOnValidThread()); | 871 DCHECK(main_thread_checker_.CalledOnValidThread()); |
884 DCHECK(!media_source_delegate_); | 872 DCHECK(!media_source_delegate_); |
885 SetNeedsEstablishPeer(true); | |
886 if (!paused()) | |
887 EstablishSurfaceTexturePeer(); | |
888 is_remote_ = false; | 873 is_remote_ = false; |
874 EstablishSurfaceTexturePeerIfNeeded(); | |
889 ReallocateVideoFrame(); | 875 ReallocateVideoFrame(); |
890 } | 876 } |
891 | 877 |
892 void WebMediaPlayerAndroid::OnDidEnterFullscreen() { | 878 void WebMediaPlayerAndroid::OnDidEnterFullscreen() { |
893 if (!player_manager_->IsInFullscreen(frame_)) | 879 if (!player_manager_->IsInFullscreen(frame_)) |
894 player_manager_->DidEnterFullscreen(frame_); | 880 player_manager_->DidEnterFullscreen(frame_); |
881 in_fullscreen_ = true; | |
882 peer_established_ = false; | |
qinmin
2014/09/09 06:39:18
Sorry, I was confused with this call and the Fulls
boliu
2014/09/09 21:17:04
Done.
| |
895 } | 883 } |
896 | 884 |
897 void WebMediaPlayerAndroid::OnDidExitFullscreen() { | 885 void WebMediaPlayerAndroid::OnDidExitFullscreen() { |
898 // |needs_external_surface_| is always false on non-TV devices. | 886 // |needs_external_surface_| is always false on non-TV devices. |
qinmin
2014/09/09 06:39:18
why removing the if statement? And why not removin
boliu
2014/09/09 21:17:04
Done.
| |
899 if (!needs_external_surface_) | 887 in_fullscreen_ = false; |
900 SetNeedsEstablishPeer(true); | 888 EstablishSurfaceTexturePeerIfNeeded(); |
901 // We had the fullscreen surface connected to Android MediaPlayer, | |
902 // so reconnect our surface texture for embedded playback. | |
903 if (!paused() && needs_establish_peer_) | |
904 EstablishSurfaceTexturePeer(); | |
905 | 889 |
906 #if defined(VIDEO_HOLE) | 890 #if defined(VIDEO_HOLE) |
907 if (!paused() && needs_external_surface_) | 891 if (!paused() && needs_external_surface_) |
908 player_manager_->RequestExternalSurface(player_id_, last_computed_rect_); | 892 player_manager_->RequestExternalSurface(player_id_, last_computed_rect_); |
909 #endif // defined(VIDEO_HOLE) | 893 #endif // defined(VIDEO_HOLE) |
910 | 894 |
911 player_manager_->DidExitFullscreen(); | 895 player_manager_->DidExitFullscreen(); |
912 client_->repaint(); | 896 client_->repaint(); |
913 } | 897 } |
914 | 898 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
956 client_->networkStateChanged(); | 940 client_->networkStateChanged(); |
957 } | 941 } |
958 | 942 |
959 void WebMediaPlayerAndroid::UpdateReadyState( | 943 void WebMediaPlayerAndroid::UpdateReadyState( |
960 WebMediaPlayer::ReadyState state) { | 944 WebMediaPlayer::ReadyState state) { |
961 ready_state_ = state; | 945 ready_state_ = state; |
962 client_->readyStateChanged(); | 946 client_->readyStateChanged(); |
963 } | 947 } |
964 | 948 |
965 void WebMediaPlayerAndroid::OnPlayerReleased() { | 949 void WebMediaPlayerAndroid::OnPlayerReleased() { |
966 // |needs_external_surface_| is always false on non-TV devices. | 950 peer_established_ = false; // Established when this plays. |
967 if (!needs_external_surface_) | |
968 needs_establish_peer_ = true; | |
969 | 951 |
970 if (is_playing_) | 952 if (is_playing_) |
971 OnMediaPlayerPause(); | 953 OnMediaPlayerPause(); |
972 | 954 |
973 #if defined(VIDEO_HOLE) | 955 #if defined(VIDEO_HOLE) |
974 last_computed_rect_ = gfx::RectF(); | 956 last_computed_rect_ = gfx::RectF(); |
975 #endif // defined(VIDEO_HOLE) | 957 #endif // defined(VIDEO_HOLE) |
976 } | 958 } |
977 | 959 |
978 void WebMediaPlayerAndroid::ReleaseMediaResources() { | 960 void WebMediaPlayerAndroid::ReleaseMediaResources() { |
979 switch (network_state_) { | 961 switch (network_state_) { |
980 // Pause the media player and inform WebKit if the player is in a good | 962 // Pause the media player and inform WebKit if the player is in a good |
981 // shape. | 963 // shape. |
982 case WebMediaPlayer::NetworkStateIdle: | 964 case WebMediaPlayer::NetworkStateIdle: |
983 case WebMediaPlayer::NetworkStateLoading: | 965 case WebMediaPlayer::NetworkStateLoading: |
984 case WebMediaPlayer::NetworkStateLoaded: | 966 case WebMediaPlayer::NetworkStateLoaded: |
985 Pause(false); | 967 Pause(false); |
986 client_->playbackStateChanged(); | 968 client_->playbackStateChanged(); |
987 break; | 969 break; |
988 // If a WebMediaPlayer instance has entered into one of these states, | 970 // If a WebMediaPlayer instance has entered into one of these states, |
989 // the internal network state in HTMLMediaElement could be set to empty. | 971 // the internal network state in HTMLMediaElement could be set to empty. |
990 // And calling playbackStateChanged() could get this object deleted. | 972 // And calling playbackStateChanged() could get this object deleted. |
991 case WebMediaPlayer::NetworkStateEmpty: | 973 case WebMediaPlayer::NetworkStateEmpty: |
992 case WebMediaPlayer::NetworkStateFormatError: | 974 case WebMediaPlayer::NetworkStateFormatError: |
993 case WebMediaPlayer::NetworkStateNetworkError: | 975 case WebMediaPlayer::NetworkStateNetworkError: |
994 case WebMediaPlayer::NetworkStateDecodeError: | 976 case WebMediaPlayer::NetworkStateDecodeError: |
995 break; | 977 break; |
996 } | 978 } |
997 player_manager_->ReleaseResources(player_id_); | 979 player_manager_->ReleaseResources(player_id_); |
998 if (!needs_external_surface_) | 980 peer_established_ = false; // Established when this plays. |
999 SetNeedsEstablishPeer(true); | |
1000 } | 981 } |
1001 | 982 |
1002 void WebMediaPlayerAndroid::OnDestruct() { | 983 void WebMediaPlayerAndroid::OnDestruct() { |
1003 NOTREACHED() << "WebMediaPlayer should be destroyed before any " | 984 NOTREACHED() << "WebMediaPlayer should be destroyed before any " |
1004 "RenderFrameObserver::OnDestruct() gets called when " | 985 "RenderFrameObserver::OnDestruct() gets called when " |
1005 "the RenderFrame goes away."; | 986 "the RenderFrame goes away."; |
1006 } | 987 } |
1007 | 988 |
1008 void WebMediaPlayerAndroid::InitializePlayer( | 989 void WebMediaPlayerAndroid::InitializePlayer( |
1009 const GURL& url, | 990 const GURL& url, |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1233 DCHECK(main_thread_checker_.CalledOnValidThread()); | 1214 DCHECK(main_thread_checker_.CalledOnValidThread()); |
1234 // Already created. | 1215 // Already created. |
1235 if (stream_texture_proxy_) | 1216 if (stream_texture_proxy_) |
1236 return; | 1217 return; |
1237 | 1218 |
1238 // No factory to create proxy. | 1219 // No factory to create proxy. |
1239 if (!stream_texture_factory_) | 1220 if (!stream_texture_factory_) |
1240 return; | 1221 return; |
1241 | 1222 |
1242 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy()); | 1223 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy()); |
1243 if (needs_establish_peer_ && stream_texture_proxy_) { | 1224 if (stream_texture_proxy_) { |
qinmin
2014/09/09 06:39:18
why we remove the if condition? if we use external
boliu
2014/09/09 21:17:04
Done.
| |
1244 DoCreateStreamTexture(); | 1225 DoCreateStreamTexture(); |
1245 ReallocateVideoFrame(); | 1226 ReallocateVideoFrame(); |
1227 | |
1228 if (video_frame_provider_client_) | |
1229 stream_texture_proxy_->SetClient(video_frame_provider_client_); | |
1246 } | 1230 } |
1247 | |
1248 if (stream_texture_proxy_ && video_frame_provider_client_) | |
1249 stream_texture_proxy_->SetClient(video_frame_provider_client_); | |
1250 } | |
1251 | |
1252 void WebMediaPlayerAndroid::EstablishSurfaceTexturePeer() { | |
1253 DCHECK(main_thread_checker_.CalledOnValidThread()); | |
1254 if (!stream_texture_proxy_) | |
1255 return; | |
1256 | |
1257 if (stream_texture_factory_.get() && stream_id_) | |
1258 stream_texture_factory_->EstablishPeer(stream_id_, player_id_); | |
1259 | |
1260 // Set the deferred size because the size was changed in remote mode. | |
1261 if (!is_remote_ && cached_stream_texture_size_ != natural_size_) { | |
1262 stream_texture_factory_->SetStreamTextureSize( | |
1263 stream_id_, gfx::Size(natural_size_.width, natural_size_.height)); | |
1264 cached_stream_texture_size_ = natural_size_; | |
1265 } | |
1266 | |
1267 needs_establish_peer_ = false; | |
1268 } | 1231 } |
1269 | 1232 |
1270 void WebMediaPlayerAndroid::DoCreateStreamTexture() { | 1233 void WebMediaPlayerAndroid::DoCreateStreamTexture() { |
1271 DCHECK(main_thread_checker_.CalledOnValidThread()); | 1234 DCHECK(main_thread_checker_.CalledOnValidThread()); |
1272 DCHECK(!stream_id_); | 1235 DCHECK(!stream_id_); |
1273 DCHECK(!texture_id_); | 1236 DCHECK(!texture_id_); |
1274 stream_id_ = stream_texture_factory_->CreateStreamTexture( | 1237 stream_id_ = stream_texture_factory_->CreateStreamTexture( |
1275 kGLTextureExternalOES, &texture_id_, &texture_mailbox_); | 1238 kGLTextureExternalOES, &texture_id_, &texture_mailbox_); |
1276 } | 1239 } |
1277 | 1240 |
1278 void WebMediaPlayerAndroid::SetNeedsEstablishPeer(bool needs_establish_peer) { | 1241 void WebMediaPlayerAndroid::EstablishSurfaceTexturePeerIfNeeded() { |
1279 needs_establish_peer_ = needs_establish_peer; | 1242 DCHECK(main_thread_checker_.CalledOnValidThread()); |
1243 if (peer_established_ || in_fullscreen_ || needs_external_surface_ || | |
1244 is_remote_ || !is_playing_ || !stream_texture_proxy_ || | |
1245 (!hasVideo() && !IsHLSStream())) { | |
1246 return; | |
1247 } | |
1248 | |
1249 stream_texture_factory_->EstablishPeer(stream_id_, player_id_); | |
1250 if (cached_stream_texture_size_ != natural_size_) { | |
1251 stream_texture_factory_->SetStreamTextureSize( | |
1252 stream_id_, gfx::Size(natural_size_.width, natural_size_.height)); | |
1253 cached_stream_texture_size_ = natural_size_; | |
1254 } | |
1255 peer_established_ = true; | |
1280 } | 1256 } |
1281 | 1257 |
1282 void WebMediaPlayerAndroid::setPoster(const blink::WebURL& poster) { | 1258 void WebMediaPlayerAndroid::setPoster(const blink::WebURL& poster) { |
1283 player_manager_->SetPoster(player_id_, poster); | 1259 player_manager_->SetPoster(player_id_, poster); |
1284 } | 1260 } |
1285 | 1261 |
1286 void WebMediaPlayerAndroid::UpdatePlayingState(bool is_playing) { | 1262 void WebMediaPlayerAndroid::UpdatePlayingState(bool is_playing) { |
1287 is_playing_ = is_playing; | 1263 is_playing_ = is_playing; |
1264 EstablishSurfaceTexturePeerIfNeeded(); | |
qinmin
2014/09/09 06:39:18
UpdatePlayingState() can be called by 4 different
boliu
2014/09/09 21:17:04
Because contract is any states change should lead
| |
1288 if (!delegate_) | 1265 if (!delegate_) |
1289 return; | 1266 return; |
1290 if (is_playing) | 1267 if (is_playing) |
1291 delegate_->DidPlay(this); | 1268 delegate_->DidPlay(this); |
1292 else | 1269 else |
1293 delegate_->DidPause(this); | 1270 delegate_->DidPause(this); |
1294 } | 1271 } |
1295 | 1272 |
1296 #if defined(VIDEO_HOLE) | 1273 #if defined(VIDEO_HOLE) |
1297 bool WebMediaPlayerAndroid::UpdateBoundaryRectangle() { | 1274 bool WebMediaPlayerAndroid::UpdateBoundaryRectangle() { |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1747 decryptor_ready_cb.Run(web_cdm_->GetDecryptor(), base::Bind(DoNothing)); | 1724 decryptor_ready_cb.Run(web_cdm_->GetDecryptor(), base::Bind(DoNothing)); |
1748 return; | 1725 return; |
1749 } | 1726 } |
1750 | 1727 |
1751 decryptor_ready_cb_ = decryptor_ready_cb; | 1728 decryptor_ready_cb_ = decryptor_ready_cb; |
1752 } | 1729 } |
1753 | 1730 |
1754 void WebMediaPlayerAndroid::enterFullscreen() { | 1731 void WebMediaPlayerAndroid::enterFullscreen() { |
1755 if (player_manager_->CanEnterFullscreen(frame_)) { | 1732 if (player_manager_->CanEnterFullscreen(frame_)) { |
1756 player_manager_->EnterFullscreen(player_id_, frame_); | 1733 player_manager_->EnterFullscreen(player_id_, frame_); |
1757 SetNeedsEstablishPeer(false); | |
1758 } | 1734 } |
1759 } | 1735 } |
1760 | 1736 |
1761 bool WebMediaPlayerAndroid::canEnterFullscreen() const { | 1737 bool WebMediaPlayerAndroid::canEnterFullscreen() const { |
1762 return player_manager_->CanEnterFullscreen(frame_); | 1738 return player_manager_->CanEnterFullscreen(frame_); |
1763 } | 1739 } |
1764 | 1740 |
1765 bool WebMediaPlayerAndroid::IsHLSStream() const { | 1741 bool WebMediaPlayerAndroid::IsHLSStream() const { |
1766 std::string mime; | 1742 std::string mime; |
1767 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1743 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; |
1768 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) | 1744 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) |
1769 return false; | 1745 return false; |
1770 return !mime.compare("application/x-mpegurl"); | 1746 return !mime.compare("application/x-mpegurl"); |
1771 } | 1747 } |
1772 | 1748 |
1773 } // namespace content | 1749 } // namespace content |
OLD | NEW |