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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 123 } |
124 | 124 |
125 bool IsResumeBackgroundVideosEnabled() { | 125 bool IsResumeBackgroundVideosEnabled() { |
126 return base::FeatureList::IsEnabled(kResumeBackgroundVideo); | 126 return base::FeatureList::IsEnabled(kResumeBackgroundVideo); |
127 } | 127 } |
128 | 128 |
129 bool IsBackgroundVideoTrackOptimizationEnabled() { | 129 bool IsBackgroundVideoTrackOptimizationEnabled() { |
130 return base::FeatureList::IsEnabled(kBackgroundVideoTrackOptimization); | 130 return base::FeatureList::IsEnabled(kBackgroundVideoTrackOptimization); |
131 } | 131 } |
132 | 132 |
| 133 bool IsBackgroundVideoPauseOptimizationEnabled() { |
| 134 return base::FeatureList::IsEnabled(kBackgroundVideoPauseOptimization); |
| 135 } |
| 136 |
133 bool IsNetworkStateError(blink::WebMediaPlayer::NetworkState state) { | 137 bool IsNetworkStateError(blink::WebMediaPlayer::NetworkState state) { |
134 bool result = state == blink::WebMediaPlayer::kNetworkStateFormatError || | 138 bool result = state == blink::WebMediaPlayer::kNetworkStateFormatError || |
135 state == blink::WebMediaPlayer::kNetworkStateNetworkError || | 139 state == blink::WebMediaPlayer::kNetworkStateNetworkError || |
136 state == blink::WebMediaPlayer::kNetworkStateDecodeError; | 140 state == blink::WebMediaPlayer::kNetworkStateDecodeError; |
137 DCHECK_EQ(state > blink::WebMediaPlayer::kNetworkStateLoaded, result); | 141 DCHECK_EQ(state > blink::WebMediaPlayer::kNetworkStateLoaded, result); |
138 return result; | 142 return result; |
139 } | 143 } |
140 | 144 |
141 gfx::Size GetRotatedVideoSize(VideoRotation rotation, gfx::Size natural_size) { | 145 gfx::Size GetRotatedVideoSize(VideoRotation rotation, gfx::Size natural_size) { |
142 if (rotation == VIDEO_ROTATION_90 || rotation == VIDEO_ROTATION_270) | 146 if (rotation == VIDEO_ROTATION_90 || rotation == VIDEO_ROTATION_270) |
(...skipping 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2194 if (IsRemote()) | 2198 if (IsRemote()) |
2195 return false; | 2199 return false; |
2196 #endif | 2200 #endif |
2197 | 2201 |
2198 return !HasAudio() || (IsResumeBackgroundVideosEnabled() && | 2202 return !HasAudio() || (IsResumeBackgroundVideosEnabled() && |
2199 video_locked_when_paused_when_hidden_); | 2203 video_locked_when_paused_when_hidden_); |
2200 } | 2204 } |
2201 | 2205 |
2202 // Otherwise only pause if the optimization is on and it's a video-only | 2206 // Otherwise only pause if the optimization is on and it's a video-only |
2203 // optimization candidate. | 2207 // optimization candidate. |
2204 return IsBackgroundVideoTrackOptimizationEnabled() && !HasAudio() && | 2208 return IsBackgroundVideoPauseOptimizationEnabled() && !HasAudio() && |
2205 IsBackgroundOptimizationCandidate(); | 2209 IsBackgroundOptimizationCandidate(); |
2206 } | 2210 } |
2207 | 2211 |
2208 bool WebMediaPlayerImpl::ShouldDisableVideoWhenHidden() const { | 2212 bool WebMediaPlayerImpl::ShouldDisableVideoWhenHidden() const { |
2209 // This optimization is behind the flag on all platforms. | 2213 // This optimization is behind the flag on all platforms. |
2210 if (!IsBackgroundVideoTrackOptimizationEnabled()) | 2214 if (!IsBackgroundVideoTrackOptimizationEnabled()) |
2211 return false; | 2215 return false; |
2212 | 2216 |
2213 // Disable video track only for players with audio that match the criteria for | 2217 // Disable video track only for players with audio that match the criteria for |
2214 // being optimized. | 2218 // being optimized. |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2347 | 2351 |
2348 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { | 2352 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { |
2349 DCHECK(data_source_ || chunk_demuxer_); | 2353 DCHECK(data_source_ || chunk_demuxer_); |
2350 if (data_source_) | 2354 if (data_source_) |
2351 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); | 2355 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); |
2352 else | 2356 else |
2353 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); | 2357 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); |
2354 } | 2358 } |
2355 | 2359 |
2356 } // namespace media | 2360 } // namespace media |
OLD | NEW |