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 2096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2107 return false; | 2107 return false; |
2108 #else // defined(OS_ANDROID) | 2108 #else // defined(OS_ANDROID) |
2109 if (!IsBackgroundVideoTrackOptimizationEnabled()) | 2109 if (!IsBackgroundVideoTrackOptimizationEnabled()) |
2110 return false; | 2110 return false; |
2111 #endif // defined(OS_ANDROID) | 2111 #endif // defined(OS_ANDROID) |
2112 | 2112 |
2113 return hasVideo() && !hasAudio(); | 2113 return hasVideo() && !hasAudio(); |
2114 } | 2114 } |
2115 | 2115 |
2116 bool WebMediaPlayerImpl::ShouldDisableVideoWhenHidden() const { | 2116 bool WebMediaPlayerImpl::ShouldDisableVideoWhenHidden() const { |
2117 DCHECK(main_task_runner_->BelongsToCurrentThread()); | |
2117 DCHECK(IsHidden()); | 2118 DCHECK(IsHidden()); |
2119 | |
2120 PipelineStatistics stats = pipeline_.GetStatistics(); | |
2118 return IsBackgroundVideoTrackOptimizationEnabled() && hasVideo() && | 2121 return IsBackgroundVideoTrackOptimizationEnabled() && hasVideo() && |
DaleCurtis
2017/01/10 21:11:40
Early return before grabbing statistics if the res
whywhat
2017/01/10 21:51:54
Done.
| |
2119 hasAudio() && !IsStreaming(); | 2122 hasAudio() && !IsStreaming() && |
2123 stats.video_keyframe_distance_average_ms < | |
2124 max_keyframe_distance_for_fast_decode_.InMilliseconds(); | |
2120 } | 2125 } |
2121 | 2126 |
2122 void WebMediaPlayerImpl::EnableVideoTrackIfNeeded() { | 2127 void WebMediaPlayerImpl::EnableVideoTrackIfNeeded() { |
2123 DCHECK(!IsHidden()); | 2128 DCHECK(!IsHidden()); |
2124 | 2129 |
2125 // Don't change video track while the pipeline is resuming or seeking. | 2130 // Don't change video track while the pipeline is resuming or seeking. |
2126 if (is_pipeline_resuming_ || seeking_) | 2131 if (is_pipeline_resuming_ || seeking_) |
2127 return; | 2132 return; |
2128 | 2133 |
2129 if (video_track_disabled_) { | 2134 if (video_track_disabled_) { |
(...skipping 12 matching lines...) Expand all Loading... | |
2142 if (is_pipeline_resuming_ || seeking_) | 2147 if (is_pipeline_resuming_ || seeking_) |
2143 return; | 2148 return; |
2144 | 2149 |
2145 if (!video_track_disabled_ && ShouldDisableVideoWhenHidden()) { | 2150 if (!video_track_disabled_ && ShouldDisableVideoWhenHidden()) { |
2146 video_track_disabled_ = true; | 2151 video_track_disabled_ = true; |
2147 selectedVideoTrackChanged(nullptr); | 2152 selectedVideoTrackChanged(nullptr); |
2148 } | 2153 } |
2149 } | 2154 } |
2150 | 2155 |
2151 } // namespace media | 2156 } // namespace media |
OLD | NEW |