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 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 ReallocateVideoFrame(); | 945 ReallocateVideoFrame(); |
946 client_->disconnectedFromRemoteDevice(); | 946 client_->disconnectedFromRemoteDevice(); |
947 } | 947 } |
948 | 948 |
949 void WebMediaPlayerAndroid::OnDidExitFullscreen() { | 949 void WebMediaPlayerAndroid::OnDidExitFullscreen() { |
950 // |needs_external_surface_| is always false on non-TV devices. | 950 // |needs_external_surface_| is always false on non-TV devices. |
951 if (!needs_external_surface_) | 951 if (!needs_external_surface_) |
952 SetNeedsEstablishPeer(true); | 952 SetNeedsEstablishPeer(true); |
953 // We had the fullscreen surface connected to Android MediaPlayer, | 953 // We had the fullscreen surface connected to Android MediaPlayer, |
954 // so reconnect our surface texture for embedded playback. | 954 // so reconnect our surface texture for embedded playback. |
955 if (!paused() && needs_establish_peer_) | 955 if (!paused() && needs_establish_peer_) { |
| 956 TryCreateStreamTextureProxyIfNeeded(); |
956 EstablishSurfaceTexturePeer(); | 957 EstablishSurfaceTexturePeer(); |
| 958 } |
957 | 959 |
958 #if defined(VIDEO_HOLE) | 960 #if defined(VIDEO_HOLE) |
959 if (!paused() && needs_external_surface_) | 961 if (!paused() && needs_external_surface_) |
960 player_manager_->RequestExternalSurface(player_id_, last_computed_rect_); | 962 player_manager_->RequestExternalSurface(player_id_, last_computed_rect_); |
961 #endif // defined(VIDEO_HOLE) | 963 #endif // defined(VIDEO_HOLE) |
962 is_fullscreen_ = false; | 964 is_fullscreen_ = false; |
963 client_->repaint(); | 965 client_->repaint(); |
964 } | 966 } |
965 | 967 |
966 void WebMediaPlayerAndroid::OnMediaPlayerPlay() { | 968 void WebMediaPlayerAndroid::OnMediaPlayerPlay() { |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1205 } | 1207 } |
1206 | 1208 |
1207 void WebMediaPlayerAndroid::ReallocateVideoFrame() { | 1209 void WebMediaPlayerAndroid::ReallocateVideoFrame() { |
1208 DCHECK(main_thread_checker_.CalledOnValidThread()); | 1210 DCHECK(main_thread_checker_.CalledOnValidThread()); |
1209 if (needs_external_surface_) { | 1211 if (needs_external_surface_) { |
1210 // VideoFrame::CreateHoleFrame is only defined under VIDEO_HOLE. | 1212 // VideoFrame::CreateHoleFrame is only defined under VIDEO_HOLE. |
1211 #if defined(VIDEO_HOLE) | 1213 #if defined(VIDEO_HOLE) |
1212 if (!natural_size_.isEmpty()) { | 1214 if (!natural_size_.isEmpty()) { |
1213 // Now we finally know that "stream texture" and "video frame" won't | 1215 // Now we finally know that "stream texture" and "video frame" won't |
1214 // be needed. EME uses "external surface" and "video hole" instead. | 1216 // be needed. EME uses "external surface" and "video hole" instead. |
1215 ResetStreamTextureProxy(); | 1217 RemoveSurfaceTextureAndProxy(); |
1216 scoped_refptr<VideoFrame> new_frame = | 1218 scoped_refptr<VideoFrame> new_frame = |
1217 VideoFrame::CreateHoleFrame(natural_size_); | 1219 VideoFrame::CreateHoleFrame(natural_size_); |
1218 SetCurrentFrameInternal(new_frame); | 1220 SetCurrentFrameInternal(new_frame); |
1219 // Force the client to grab the hole frame. | 1221 // Force the client to grab the hole frame. |
1220 client_->repaint(); | 1222 client_->repaint(); |
1221 } | 1223 } |
1222 #else | 1224 #else |
1223 NOTIMPLEMENTED() << "Hole punching not supported without VIDEO_HOLE flag"; | 1225 NOTIMPLEMENTED() << "Hole punching not supported without VIDEO_HOLE flag"; |
1224 #endif // defined(VIDEO_HOLE) | 1226 #endif // defined(VIDEO_HOLE) |
1225 } else if (!is_remote_ && texture_id_) { | 1227 } else if (!is_remote_ && texture_id_) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 | 1286 |
1285 return video_frame; | 1287 return video_frame; |
1286 } | 1288 } |
1287 | 1289 |
1288 void WebMediaPlayerAndroid::PutCurrentFrame() { | 1290 void WebMediaPlayerAndroid::PutCurrentFrame() { |
1289 } | 1291 } |
1290 | 1292 |
1291 void WebMediaPlayerAndroid::ResetStreamTextureProxy() { | 1293 void WebMediaPlayerAndroid::ResetStreamTextureProxy() { |
1292 DCHECK(main_thread_checker_.CalledOnValidThread()); | 1294 DCHECK(main_thread_checker_.CalledOnValidThread()); |
1293 | 1295 |
| 1296 RemoveSurfaceTextureAndProxy(); |
| 1297 |
| 1298 TryCreateStreamTextureProxyIfNeeded(); |
| 1299 if (needs_establish_peer_ && is_playing_) |
| 1300 EstablishSurfaceTexturePeer(); |
| 1301 } |
| 1302 |
| 1303 void WebMediaPlayerAndroid::RemoveSurfaceTextureAndProxy() { |
| 1304 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 1305 |
1294 if (stream_id_) { | 1306 if (stream_id_) { |
1295 GLES2Interface* gl = stream_texture_factory_->ContextGL(); | 1307 GLES2Interface* gl = stream_texture_factory_->ContextGL(); |
1296 gl->DeleteTextures(1, &texture_id_); | 1308 gl->DeleteTextures(1, &texture_id_); |
1297 // Flush to ensure that the stream texture gets deleted in a timely fashion. | 1309 // Flush to ensure that the stream texture gets deleted in a timely fashion. |
1298 gl->ShallowFlushCHROMIUM(); | 1310 gl->ShallowFlushCHROMIUM(); |
1299 texture_id_ = 0; | 1311 texture_id_ = 0; |
1300 texture_mailbox_ = gpu::Mailbox(); | 1312 texture_mailbox_ = gpu::Mailbox(); |
1301 stream_id_ = 0; | 1313 stream_id_ = 0; |
1302 } | 1314 } |
1303 stream_texture_proxy_.reset(); | 1315 stream_texture_proxy_.reset(); |
1304 needs_establish_peer_ = !needs_external_surface_ && !is_remote_ && | 1316 needs_establish_peer_ = !needs_external_surface_ && !is_remote_ && |
1305 !is_fullscreen_ && | 1317 !is_fullscreen_ && |
1306 (hasVideo() || IsHLSStream()); | 1318 (hasVideo() || IsHLSStream()); |
1307 | |
1308 TryCreateStreamTextureProxyIfNeeded(); | |
1309 if (needs_establish_peer_ && is_playing_) | |
1310 EstablishSurfaceTexturePeer(); | |
1311 } | 1319 } |
1312 | 1320 |
1313 void WebMediaPlayerAndroid::TryCreateStreamTextureProxyIfNeeded() { | 1321 void WebMediaPlayerAndroid::TryCreateStreamTextureProxyIfNeeded() { |
1314 DCHECK(main_thread_checker_.CalledOnValidThread()); | 1322 DCHECK(main_thread_checker_.CalledOnValidThread()); |
1315 // Already created. | 1323 // Already created. |
1316 if (stream_texture_proxy_) | 1324 if (stream_texture_proxy_) |
1317 return; | 1325 return; |
1318 | 1326 |
1319 // No factory to create proxy. | 1327 // No factory to create proxy. |
1320 if (!stream_texture_factory_.get()) | 1328 if (!stream_texture_factory_.get()) |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1857 | 1865 |
1858 bool WebMediaPlayerAndroid::IsHLSStream() const { | 1866 bool WebMediaPlayerAndroid::IsHLSStream() const { |
1859 std::string mime; | 1867 std::string mime; |
1860 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1868 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; |
1861 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) | 1869 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) |
1862 return false; | 1870 return false; |
1863 return !mime.compare("application/x-mpegurl"); | 1871 return !mime.compare("application/x-mpegurl"); |
1864 } | 1872 } |
1865 | 1873 |
1866 } // namespace content | 1874 } // namespace content |
OLD | NEW |