| 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 | |
| 2166 bool WebMediaPlayerImpl::ShouldPauseVideoWhenHidden() const { | 2156 bool WebMediaPlayerImpl::ShouldPauseVideoWhenHidden() const { |
| 2167 // If suspending background video, pause any video that's not remoted or | 2157 // If suspending background video, pause any video that's not remoted or |
| 2168 // not unlocked to play in the background. | 2158 // not unlocked to play in the background. |
| 2169 if (IsBackgroundedSuspendEnabled()) { | 2159 if (IsBackgroundedSuspendEnabled()) { |
| 2170 if (!hasVideo()) | 2160 if (!hasVideo()) |
| 2171 return false; | 2161 return false; |
| 2172 | 2162 |
| 2173 #if defined(OS_ANDROID) | 2163 #if defined(OS_ANDROID) |
| 2174 if (isRemote()) | 2164 if (isRemote()) |
| 2175 return false; | 2165 return false; |
| 2176 #endif | 2166 #endif |
| 2177 | 2167 |
| 2178 return !hasAudio() || | 2168 return !hasAudio() || |
| 2179 (IsResumeBackgroundVideosEnabled() && | 2169 (IsResumeBackgroundVideosEnabled() && |
| 2180 video_locked_when_paused_when_hidden_); | 2170 video_locked_when_paused_when_hidden_); |
| 2181 } | 2171 } |
| 2182 | 2172 |
| 2183 // Otherwise only pause if the optimization is on and it's a video-only | 2173 // Otherwise only pause if the optimization is on and it's a video-only |
| 2184 // optimization candidate. | 2174 // optimization candidate. |
| 2185 return IsBackgroundVideoTrackOptimizationEnabled() && !hasAudio() && | 2175 return IsBackgroundVideoTrackOptimizationEnabled() && !hasAudio() && |
| 2186 IsBackgroundOptimizationCandidate(); | 2176 IsBackgroundOptimizationCandidate(); |
| 2187 } | 2177 } |
| 2188 | 2178 |
| 2189 #endif // !defined(OS_ANDROID) | |
| 2190 | |
| 2191 bool WebMediaPlayerImpl::ShouldDisableVideoWhenHidden() const { | 2179 bool WebMediaPlayerImpl::ShouldDisableVideoWhenHidden() const { |
| 2192 // This optimization is behind the flag on all platforms. | 2180 // This optimization is behind the flag on all platforms. |
| 2193 if (!IsBackgroundVideoTrackOptimizationEnabled()) | 2181 if (!IsBackgroundVideoTrackOptimizationEnabled()) |
| 2194 return false; | 2182 return false; |
| 2195 | 2183 |
| 2196 // Disable video track only for players with audio that match the criteria for | 2184 // Disable video track only for players with audio that match the criteria for |
| 2197 // being optimized. | 2185 // being optimized. |
| 2198 return hasAudio() && IsBackgroundOptimizationCandidate(); | 2186 return hasAudio() && IsBackgroundOptimizationCandidate(); |
| 2199 } | 2187 } |
| 2200 | 2188 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2327 | 2315 |
| 2328 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { | 2316 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { |
| 2329 DCHECK(data_source_ || chunk_demuxer_); | 2317 DCHECK(data_source_ || chunk_demuxer_); |
| 2330 if (data_source_) | 2318 if (data_source_) |
| 2331 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); | 2319 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); |
| 2332 else | 2320 else |
| 2333 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); | 2321 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); |
| 2334 } | 2322 } |
| 2335 | 2323 |
| 2336 } // namespace media | 2324 } // namespace media |
| OLD | NEW |