| 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 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 // size here, we should call EstablishSurfaceTexturePeer() if it has not been | 912 // size here, we should call EstablishSurfaceTexturePeer() if it has not been |
| 913 // previously called. | 913 // previously called. |
| 914 if (!paused() && needs_establish_peer_) | 914 if (!paused() && needs_establish_peer_) |
| 915 EstablishSurfaceTexturePeer(); | 915 EstablishSurfaceTexturePeer(); |
| 916 | 916 |
| 917 ReallocateVideoFrame(); | 917 ReallocateVideoFrame(); |
| 918 | 918 |
| 919 // For hidden video element (with style "display:none"), ensure the texture | 919 // For hidden video element (with style "display:none"), ensure the texture |
| 920 // size is set. | 920 // size is set. |
| 921 if (!is_remote_ && cached_stream_texture_size_ != natural_size_) { | 921 if (!is_remote_ && cached_stream_texture_size_ != natural_size_) { |
| 922 stream_texture_factory_->SetStreamTextureSize( | 922 UpdateStreamTextureSize(); |
| 923 stream_id_, gfx::Size(natural_size_.width, natural_size_.height)); | |
| 924 cached_stream_texture_size_ = natural_size_; | |
| 925 } | 923 } |
| 926 | 924 |
| 927 // Lazily allocate compositing layer. | 925 // Lazily allocate compositing layer. |
| 928 if (!video_weblayer_) { | 926 if (!video_weblayer_) { |
| 929 video_weblayer_.reset(new cc_blink::WebLayerImpl( | 927 video_weblayer_.reset(new cc_blink::WebLayerImpl( |
| 930 cc::VideoLayer::Create(cc_blink::WebLayerImpl::LayerSettings(), this, | 928 cc::VideoLayer::Create(cc_blink::WebLayerImpl::LayerSettings(), this, |
| 931 media::VIDEO_ROTATION_0))); | 929 media::VIDEO_ROTATION_0))); |
| 932 client_->setWebLayer(video_weblayer_.get()); | 930 client_->setWebLayer(video_weblayer_.get()); |
| 933 } | 931 } |
| 934 } | 932 } |
| 935 | 933 |
| 934 void WebMediaPlayerAndroid::UpdateStreamTextureSize() { |
| 935 if (!stream_id_) |
| 936 return; |
| 937 |
| 938 DCHECK(cached_stream_texture_size_ != natural_size_); |
| 939 cached_stream_texture_size_ = natural_size_; |
| 940 |
| 941 GLES2Interface* gl = stream_texture_factory_->ContextGL(); |
| 942 DCHECK(texture_id_); |
| 943 gl->SetStreamTextureSizeCHROMIUM(texture_id_, stream_id_, natural_size_.width, |
| 944 natural_size_.height); |
| 945 } |
| 946 |
| 936 void WebMediaPlayerAndroid::OnTimeUpdate(base::TimeDelta current_timestamp, | 947 void WebMediaPlayerAndroid::OnTimeUpdate(base::TimeDelta current_timestamp, |
| 937 base::TimeTicks current_time_ticks) { | 948 base::TimeTicks current_time_ticks) { |
| 938 DCHECK(main_thread_checker_.CalledOnValidThread()); | 949 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 939 | 950 |
| 940 if (seeking()) | 951 if (seeking()) |
| 941 return; | 952 return; |
| 942 | 953 |
| 943 // Compensate the current_timestamp with the IPC latency. | 954 // Compensate the current_timestamp with the IPC latency. |
| 944 base::TimeDelta lower_bound = | 955 base::TimeDelta lower_bound = |
| 945 base::TimeTicks::Now() - current_time_ticks + current_timestamp; | 956 base::TimeTicks::Now() - current_time_ticks + current_timestamp; |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1387 void WebMediaPlayerAndroid::EstablishSurfaceTexturePeer() { | 1398 void WebMediaPlayerAndroid::EstablishSurfaceTexturePeer() { |
| 1388 DCHECK(main_thread_checker_.CalledOnValidThread()); | 1399 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 1389 if (!stream_texture_proxy_) | 1400 if (!stream_texture_proxy_) |
| 1390 return; | 1401 return; |
| 1391 | 1402 |
| 1392 if (stream_texture_factory_.get() && stream_id_) | 1403 if (stream_texture_factory_.get() && stream_id_) |
| 1393 stream_texture_factory_->EstablishPeer(stream_id_, player_id_); | 1404 stream_texture_factory_->EstablishPeer(stream_id_, player_id_); |
| 1394 | 1405 |
| 1395 // Set the deferred size because the size was changed in remote mode. | 1406 // Set the deferred size because the size was changed in remote mode. |
| 1396 if (!is_remote_ && cached_stream_texture_size_ != natural_size_) { | 1407 if (!is_remote_ && cached_stream_texture_size_ != natural_size_) { |
| 1397 stream_texture_factory_->SetStreamTextureSize( | 1408 UpdateStreamTextureSize(); |
| 1398 stream_id_, gfx::Size(natural_size_.width, natural_size_.height)); | |
| 1399 cached_stream_texture_size_ = natural_size_; | |
| 1400 } | 1409 } |
| 1401 | 1410 |
| 1402 needs_establish_peer_ = false; | 1411 needs_establish_peer_ = false; |
| 1403 } | 1412 } |
| 1404 | 1413 |
| 1405 void WebMediaPlayerAndroid::DoCreateStreamTexture() { | 1414 void WebMediaPlayerAndroid::DoCreateStreamTexture() { |
| 1406 DCHECK(main_thread_checker_.CalledOnValidThread()); | 1415 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 1407 DCHECK(!stream_id_); | 1416 DCHECK(!stream_id_); |
| 1408 DCHECK(!texture_id_); | 1417 DCHECK(!texture_id_); |
| 1409 stream_id_ = stream_texture_factory_->CreateStreamTexture( | 1418 stream_id_ = stream_texture_factory_->CreateStreamTexture( |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1922 | 1931 |
| 1923 bool is_hls = IsHLSStream(); | 1932 bool is_hls = IsHLSStream(); |
| 1924 UMA_HISTOGRAM_BOOLEAN("Media.Android.IsHttpLiveStreamingMedia", is_hls); | 1933 UMA_HISTOGRAM_BOOLEAN("Media.Android.IsHttpLiveStreamingMedia", is_hls); |
| 1925 if (is_hls) { | 1934 if (is_hls) { |
| 1926 media::RecordOriginOfHLSPlayback( | 1935 media::RecordOriginOfHLSPlayback( |
| 1927 GURL(frame_->document().securityOrigin().toString())); | 1936 GURL(frame_->document().securityOrigin().toString())); |
| 1928 } | 1937 } |
| 1929 } | 1938 } |
| 1930 | 1939 |
| 1931 } // namespace content | 1940 } // namespace content |
| OLD | NEW |