| 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 "media/blink/webmediaplayer_impl.h" | 5 #include "media/blink/webmediaplayer_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 2135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2146 bool WebMediaPlayerImpl::DoesOverlaySupportMetadata() const { | 2146 bool WebMediaPlayerImpl::DoesOverlaySupportMetadata() const { |
| 2147 return pipeline_metadata_.video_rotation == VIDEO_ROTATION_0; | 2147 return pipeline_metadata_.video_rotation == VIDEO_ROTATION_0; |
| 2148 } | 2148 } |
| 2149 | 2149 |
| 2150 void WebMediaPlayerImpl::ActivateViewportIntersectionMonitoring(bool activate) { | 2150 void WebMediaPlayerImpl::ActivateViewportIntersectionMonitoring(bool activate) { |
| 2151 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 2151 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 2152 | 2152 |
| 2153 client_->activateViewportIntersectionMonitoring(activate); | 2153 client_->activateViewportIntersectionMonitoring(activate); |
| 2154 } | 2154 } |
| 2155 | 2155 |
| 2156 // TODO(avayvod): Revert after merging into 58 so we keep getting data on the |
| 2157 // background video pause behavior on desktop. See https://crbug.com/699106. |
| 2158 #if !defined(OS_ANDROID) |
| 2159 |
| 2160 bool WebMediaPlayerImpl::ShouldPauseVideoWhenHidden() const { |
| 2161 return false; |
| 2162 } |
| 2163 |
| 2164 #else // !defined(OS_ANDROID) |
| 2165 |
| 2156 bool WebMediaPlayerImpl::ShouldPauseVideoWhenHidden() const { | 2166 bool WebMediaPlayerImpl::ShouldPauseVideoWhenHidden() const { |
| 2157 // If suspending background video, pause any video that's not remoted or | 2167 // If suspending background video, pause any video that's not remoted or |
| 2158 // not unlocked to play in the background. | 2168 // not unlocked to play in the background. |
| 2159 if (IsBackgroundedSuspendEnabled()) { | 2169 if (IsBackgroundedSuspendEnabled()) { |
| 2160 if (!hasVideo()) | 2170 if (!hasVideo()) |
| 2161 return false; | 2171 return false; |
| 2162 | 2172 |
| 2163 #if defined(OS_ANDROID) | 2173 #if defined(OS_ANDROID) |
| 2164 if (isRemote()) | 2174 if (isRemote()) |
| 2165 return false; | 2175 return false; |
| 2166 #endif | 2176 #endif |
| 2167 | 2177 |
| 2168 return !hasAudio() || | 2178 return !hasAudio() || |
| 2169 (IsResumeBackgroundVideosEnabled() && | 2179 (IsResumeBackgroundVideosEnabled() && |
| 2170 video_locked_when_paused_when_hidden_); | 2180 video_locked_when_paused_when_hidden_); |
| 2171 } | 2181 } |
| 2172 | 2182 |
| 2173 // Otherwise only pause if the optimization is on and it's a video-only | 2183 // Otherwise only pause if the optimization is on and it's a video-only |
| 2174 // optimization candidate. | 2184 // optimization candidate. |
| 2175 return IsBackgroundVideoTrackOptimizationEnabled() && !hasAudio() && | 2185 return IsBackgroundVideoTrackOptimizationEnabled() && !hasAudio() && |
| 2176 IsBackgroundOptimizationCandidate(); | 2186 IsBackgroundOptimizationCandidate(); |
| 2177 } | 2187 } |
| 2178 | 2188 |
| 2189 #endif // !defined(OS_ANDROID) |
| 2190 |
| 2179 bool WebMediaPlayerImpl::ShouldDisableVideoWhenHidden() const { | 2191 bool WebMediaPlayerImpl::ShouldDisableVideoWhenHidden() const { |
| 2180 // This optimization is behind the flag on all platforms. | 2192 // This optimization is behind the flag on all platforms. |
| 2181 if (!IsBackgroundVideoTrackOptimizationEnabled()) | 2193 if (!IsBackgroundVideoTrackOptimizationEnabled()) |
| 2182 return false; | 2194 return false; |
| 2183 | 2195 |
| 2184 // Disable video track only for players with audio that match the criteria for | 2196 // Disable video track only for players with audio that match the criteria for |
| 2185 // being optimized. | 2197 // being optimized. |
| 2186 return hasAudio() && IsBackgroundOptimizationCandidate(); | 2198 return hasAudio() && IsBackgroundOptimizationCandidate(); |
| 2187 } | 2199 } |
| 2188 | 2200 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2315 | 2327 |
| 2316 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { | 2328 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { |
| 2317 DCHECK(data_source_ || chunk_demuxer_); | 2329 DCHECK(data_source_ || chunk_demuxer_); |
| 2318 if (data_source_) | 2330 if (data_source_) |
| 2319 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); | 2331 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); |
| 2320 else | 2332 else |
| 2321 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); | 2333 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); |
| 2322 } | 2334 } |
| 2323 | 2335 |
| 2324 } // namespace media | 2336 } // namespace media |
| OLD | NEW |