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 2138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2149 return false; | 2149 return false; |
2150 | 2150 |
2151 // Disable video track only for players with audio that match the criteria for | 2151 // Disable video track only for players with audio that match the criteria for |
2152 // being optimized. | 2152 // being optimized. |
2153 return hasAudio() && IsBackgroundOptimizationCandidate(); | 2153 return hasAudio() && IsBackgroundOptimizationCandidate(); |
2154 } | 2154 } |
2155 | 2155 |
2156 bool WebMediaPlayerImpl::IsBackgroundOptimizationCandidate() const { | 2156 bool WebMediaPlayerImpl::IsBackgroundOptimizationCandidate() const { |
2157 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 2157 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
2158 | 2158 |
2159 // Don't optimize players being Cast (Android only). | |
2160 #if defined(OS_ANDROID) // WMPI_CAST | 2159 #if defined(OS_ANDROID) // WMPI_CAST |
| 2160 // Don't optimize players being Cast. |
2161 if (isRemote()) | 2161 if (isRemote()) |
2162 return false; | 2162 return false; |
| 2163 |
| 2164 // Video-only players are always optimized (paused) on Android. |
| 2165 // Don't check the keyframe distance and duration. |
| 2166 if (!hasAudio() && hasVideo()) |
| 2167 return true; |
2163 #endif // defined(OS_ANDROID) | 2168 #endif // defined(OS_ANDROID) |
2164 | 2169 |
2165 // Don't optimize audio-only or streaming players. | 2170 // Don't optimize audio-only or streaming players. |
2166 if (!hasVideo() || IsStreaming()) | 2171 if (!hasVideo() || IsStreaming()) |
2167 return false; | 2172 return false; |
2168 | 2173 |
2169 // Videos shorter than the maximum allowed keyframe distance can be optimized. | 2174 // Videos shorter than the maximum allowed keyframe distance can be optimized. |
2170 base::TimeDelta duration = GetPipelineMediaDuration(); | 2175 base::TimeDelta duration = GetPipelineMediaDuration(); |
2171 if (duration < max_keyframe_distance_to_disable_background_video_) | 2176 if (duration < max_keyframe_distance_to_disable_background_video_) |
2172 return true; | 2177 return true; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2237 UMA_HISTOGRAM_TIMES( | 2242 UMA_HISTOGRAM_TIMES( |
2238 "Media.Video.TimeFromForegroundToFirstFrame.DisableTrack", | 2243 "Media.Video.TimeFromForegroundToFirstFrame.DisableTrack", |
2239 time_to_first_frame); | 2244 time_to_first_frame); |
2240 } else { | 2245 } else { |
2241 UMA_HISTOGRAM_TIMES("Media.Video.TimeFromForegroundToFirstFrame.Paused", | 2246 UMA_HISTOGRAM_TIMES("Media.Video.TimeFromForegroundToFirstFrame.Paused", |
2242 time_to_first_frame); | 2247 time_to_first_frame); |
2243 } | 2248 } |
2244 } | 2249 } |
2245 | 2250 |
2246 } // namespace media | 2251 } // namespace media |
OLD | NEW |