| 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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 video_weblayer_.reset(new cc_blink::WebLayerImpl( | 910 video_weblayer_.reset(new cc_blink::WebLayerImpl( |
| 911 cc::VideoLayer::Create(cc_blink::WebLayerImpl::LayerSettings(), this, | 911 cc::VideoLayer::Create(cc_blink::WebLayerImpl::LayerSettings(), this, |
| 912 media::VIDEO_ROTATION_0))); | 912 media::VIDEO_ROTATION_0))); |
| 913 client_->setWebLayer(video_weblayer_.get()); | 913 client_->setWebLayer(video_weblayer_.get()); |
| 914 } | 914 } |
| 915 } | 915 } |
| 916 | 916 |
| 917 void WebMediaPlayerAndroid::OnTimeUpdate(base::TimeDelta current_timestamp, | 917 void WebMediaPlayerAndroid::OnTimeUpdate(base::TimeDelta current_timestamp, |
| 918 base::TimeTicks current_time_ticks) { | 918 base::TimeTicks current_time_ticks) { |
| 919 DCHECK(main_thread_checker_.CalledOnValidThread()); | 919 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 920 |
| 921 if (seeking()) |
| 922 return; |
| 923 |
| 920 // Compensate the current_timestamp with the IPC latency. | 924 // Compensate the current_timestamp with the IPC latency. |
| 921 base::TimeDelta lower_bound = | 925 base::TimeDelta lower_bound = |
| 922 base::TimeTicks::Now() - current_time_ticks + current_timestamp; | 926 base::TimeTicks::Now() - current_time_ticks + current_timestamp; |
| 923 base::TimeDelta upper_bound = lower_bound; | 927 base::TimeDelta upper_bound = lower_bound; |
| 924 // We should get another time update in about |kTimeUpdateInterval| | 928 // We should get another time update in about |kTimeUpdateInterval| |
| 925 // milliseconds. | 929 // milliseconds. |
| 926 if (is_playing_) { | 930 if (is_playing_) { |
| 927 upper_bound += base::TimeDelta::FromMilliseconds( | 931 upper_bound += base::TimeDelta::FromMilliseconds( |
| 928 media::kTimeUpdateInterval); | 932 media::kTimeUpdateInterval); |
| 929 } | 933 } |
| 930 // if the lower_bound is smaller than the current time, just use the current | 934 // if the lower_bound is smaller than the current time, just use the current |
| 931 // time so that the timer is always progressing. | 935 // time so that the timer is always progressing. |
| 932 lower_bound = | 936 lower_bound = |
| 933 std::min(lower_bound, base::TimeDelta::FromSecondsD(currentTime())); | 937 std::max(lower_bound, base::TimeDelta::FromSecondsD(currentTime())); |
| 938 if (lower_bound > upper_bound) |
| 939 upper_bound = lower_bound; |
| 934 interpolator_.SetBounds(lower_bound, upper_bound); | 940 interpolator_.SetBounds(lower_bound, upper_bound); |
| 935 } | 941 } |
| 936 | 942 |
| 937 void WebMediaPlayerAndroid::OnConnectedToRemoteDevice( | 943 void WebMediaPlayerAndroid::OnConnectedToRemoteDevice( |
| 938 const std::string& remote_playback_message) { | 944 const std::string& remote_playback_message) { |
| 939 DCHECK(main_thread_checker_.CalledOnValidThread()); | 945 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 940 DCHECK(!media_source_delegate_); | 946 DCHECK(!media_source_delegate_); |
| 941 DrawRemotePlaybackText(remote_playback_message); | 947 DrawRemotePlaybackText(remote_playback_message); |
| 942 is_remote_ = true; | 948 is_remote_ = true; |
| 943 SetNeedsEstablishPeer(false); | 949 SetNeedsEstablishPeer(false); |
| (...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1888 | 1894 |
| 1889 bool is_hls = IsHLSStream(); | 1895 bool is_hls = IsHLSStream(); |
| 1890 UMA_HISTOGRAM_BOOLEAN("Media.Android.IsHttpLiveStreamingMedia", is_hls); | 1896 UMA_HISTOGRAM_BOOLEAN("Media.Android.IsHttpLiveStreamingMedia", is_hls); |
| 1891 if (is_hls) { | 1897 if (is_hls) { |
| 1892 media::RecordOriginOfHLSPlayback( | 1898 media::RecordOriginOfHLSPlayback( |
| 1893 GURL(frame_->document().securityOrigin().toString())); | 1899 GURL(frame_->document().securityOrigin().toString())); |
| 1894 } | 1900 } |
| 1895 } | 1901 } |
| 1896 | 1902 |
| 1897 } // namespace content | 1903 } // namespace content |
| OLD | NEW |