| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 TryCreateStreamTextureProxyIfNeeded(); | 1039 TryCreateStreamTextureProxyIfNeeded(); |
| 1040 EstablishSurfaceTexturePeer(); | 1040 EstablishSurfaceTexturePeer(); |
| 1041 suppress_deleting_texture_ = true; | 1041 suppress_deleting_texture_ = true; |
| 1042 } | 1042 } |
| 1043 | 1043 |
| 1044 #if defined(VIDEO_HOLE) | 1044 #if defined(VIDEO_HOLE) |
| 1045 if (!paused() && needs_external_surface_) | 1045 if (!paused() && needs_external_surface_) |
| 1046 player_manager_->RequestExternalSurface(player_id_, last_computed_rect_); | 1046 player_manager_->RequestExternalSurface(player_id_, last_computed_rect_); |
| 1047 #endif // defined(VIDEO_HOLE) | 1047 #endif // defined(VIDEO_HOLE) |
| 1048 is_fullscreen_ = false; | 1048 is_fullscreen_ = false; |
| 1049 ReallocateVideoFrame(); |
| 1049 client_->repaint(); | 1050 client_->repaint(); |
| 1050 } | 1051 } |
| 1051 | 1052 |
| 1052 void WebMediaPlayerAndroid::OnMediaPlayerPlay() { | 1053 void WebMediaPlayerAndroid::OnMediaPlayerPlay() { |
| 1053 // The MediaPlayer might request the video to be played after it lost its | 1054 // The MediaPlayer might request the video to be played after it lost its |
| 1054 // stream texture proxy or the peer connection, for example, if the video was | 1055 // stream texture proxy or the peer connection, for example, if the video was |
| 1055 // paused while fullscreen then fullscreen state was left. | 1056 // paused while fullscreen then fullscreen state was left. |
| 1056 TryCreateStreamTextureProxyIfNeeded(); | 1057 TryCreateStreamTextureProxyIfNeeded(); |
| 1057 if (needs_establish_peer_) | 1058 if (needs_establish_peer_) |
| 1058 EstablishSurfaceTexturePeer(); | 1059 EstablishSurfaceTexturePeer(); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1199 canvas_size, | 1200 canvas_size, |
| 1200 base::Bind(&StreamTextureFactory::ContextGL, | 1201 base::Bind(&StreamTextureFactory::ContextGL, |
| 1201 stream_texture_factory_))); | 1202 stream_texture_factory_))); |
| 1202 if (!new_frame) | 1203 if (!new_frame) |
| 1203 return; | 1204 return; |
| 1204 SetCurrentFrameInternal(new_frame); | 1205 SetCurrentFrameInternal(new_frame); |
| 1205 } | 1206 } |
| 1206 | 1207 |
| 1207 void WebMediaPlayerAndroid::ReallocateVideoFrame() { | 1208 void WebMediaPlayerAndroid::ReallocateVideoFrame() { |
| 1208 DCHECK(main_thread_checker_.CalledOnValidThread()); | 1209 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 1210 |
| 1211 if (is_fullscreen_) return; |
| 1209 if (needs_external_surface_) { | 1212 if (needs_external_surface_) { |
| 1210 // VideoFrame::CreateHoleFrame is only defined under VIDEO_HOLE. | 1213 // VideoFrame::CreateHoleFrame is only defined under VIDEO_HOLE. |
| 1211 #if defined(VIDEO_HOLE) | 1214 #if defined(VIDEO_HOLE) |
| 1212 if (!natural_size_.isEmpty()) { | 1215 if (!natural_size_.isEmpty()) { |
| 1213 // Now we finally know that "stream texture" and "video frame" won't | 1216 // Now we finally know that "stream texture" and "video frame" won't |
| 1214 // be needed. EME uses "external surface" and "video hole" instead. | 1217 // be needed. EME uses "external surface" and "video hole" instead. |
| 1215 RemoveSurfaceTextureAndProxy(); | 1218 RemoveSurfaceTextureAndProxy(); |
| 1216 scoped_refptr<VideoFrame> new_frame = | 1219 scoped_refptr<VideoFrame> new_frame = |
| 1217 VideoFrame::CreateHoleFrame(natural_size_); | 1220 VideoFrame::CreateHoleFrame(natural_size_); |
| 1218 SetCurrentFrameInternal(new_frame); | 1221 SetCurrentFrameInternal(new_frame); |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1629 bool WebMediaPlayerAndroid::supportsOverlayFullscreenVideo() { | 1632 bool WebMediaPlayerAndroid::supportsOverlayFullscreenVideo() { |
| 1630 return true; | 1633 return true; |
| 1631 } | 1634 } |
| 1632 | 1635 |
| 1633 void WebMediaPlayerAndroid::enteredFullscreen() { | 1636 void WebMediaPlayerAndroid::enteredFullscreen() { |
| 1634 if (is_player_initialized_) | 1637 if (is_player_initialized_) |
| 1635 player_manager_->EnterFullscreen(player_id_); | 1638 player_manager_->EnterFullscreen(player_id_); |
| 1636 SetNeedsEstablishPeer(false); | 1639 SetNeedsEstablishPeer(false); |
| 1637 is_fullscreen_ = true; | 1640 is_fullscreen_ = true; |
| 1638 suppress_deleting_texture_ = false; | 1641 suppress_deleting_texture_ = false; |
| 1642 |
| 1643 // Create a transparent video frame. Blink will already have made the |
| 1644 // background transparent because we returned true from |
| 1645 // supportsOverlayFullscreenVideo(). By making the video frame transparent, |
| 1646 // as well, everything in the LayerTreeView will be transparent except for |
| 1647 // media controls. The video will be on visible on the underlaid surface. |
| 1648 if (!fullscreen_frame_) |
| 1649 fullscreen_frame_ = VideoFrame::CreateTransparentFrame(gfx::Size(1, 1)); |
| 1650 SetCurrentFrameInternal(fullscreen_frame_); |
| 1651 client_->repaint(); |
| 1639 } | 1652 } |
| 1640 | 1653 |
| 1641 bool WebMediaPlayerAndroid::IsHLSStream() const { | 1654 bool WebMediaPlayerAndroid::IsHLSStream() const { |
| 1642 const GURL& url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1655 const GURL& url = redirected_url_.is_empty() ? url_ : redirected_url_; |
| 1643 return media::MediaCodecUtil::IsHLSURL(url); | 1656 return media::MediaCodecUtil::IsHLSURL(url); |
| 1644 } | 1657 } |
| 1645 | 1658 |
| 1646 void WebMediaPlayerAndroid::ReportHLSMetrics() const { | 1659 void WebMediaPlayerAndroid::ReportHLSMetrics() const { |
| 1647 if (player_type_ != MEDIA_PLAYER_TYPE_URL) | 1660 if (player_type_ != MEDIA_PLAYER_TYPE_URL) |
| 1648 return; | 1661 return; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1664 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER; | 1677 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER; |
| 1665 } else if (is_hls_url == is_hls) { | 1678 } else if (is_hls_url == is_hls) { |
| 1666 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER; | 1679 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER; |
| 1667 } | 1680 } |
| 1668 UMA_HISTOGRAM_ENUMERATION( | 1681 UMA_HISTOGRAM_ENUMERATION( |
| 1669 "Media.Android.IsHttpLiveStreamingMediaPredictionResult", | 1682 "Media.Android.IsHttpLiveStreamingMediaPredictionResult", |
| 1670 result, PREDICTION_RESULT_MAX); | 1683 result, PREDICTION_RESULT_MAX); |
| 1671 } | 1684 } |
| 1672 | 1685 |
| 1673 } // namespace content | 1686 } // namespace content |
| OLD | NEW |