Chromium Code Reviews| 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 2099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2110 return false; | 2110 return false; |
| 2111 #else // defined(OS_ANDROID) | 2111 #else // defined(OS_ANDROID) |
| 2112 if (!IsBackgroundVideoTrackOptimizationEnabled()) | 2112 if (!IsBackgroundVideoTrackOptimizationEnabled()) |
| 2113 return false; | 2113 return false; |
| 2114 #endif // defined(OS_ANDROID) | 2114 #endif // defined(OS_ANDROID) |
| 2115 | 2115 |
| 2116 return hasVideo() && !hasAudio(); | 2116 return hasVideo() && !hasAudio(); |
| 2117 } | 2117 } |
| 2118 | 2118 |
| 2119 bool WebMediaPlayerImpl::ShouldDisableVideoWhenHidden() const { | 2119 bool WebMediaPlayerImpl::ShouldDisableVideoWhenHidden() const { |
| 2120 DCHECK(main_task_runner_->BelongsToCurrentThread()); | |
| 2120 DCHECK(IsHidden()); | 2121 DCHECK(IsHidden()); |
| 2121 return IsBackgroundVideoTrackOptimizationEnabled() && hasVideo() && | 2122 |
| 2122 hasAudio() && !IsStreaming(); | 2123 if (!IsBackgroundVideoTrackOptimizationEnabled() || !hasVideo() || |
| 2124 !hasAudio() || IsStreaming()) | |
| 2125 return false; | |
|
DaleCurtis
2017/01/11 01:14:51
Multiline if needs {}
whywhat
2017/01/11 17:17:33
Done.
| |
| 2126 | |
| 2127 PipelineStatistics stats = pipeline_.GetStatistics(); | |
| 2128 return stats.video_keyframe_distance_average < | |
| 2129 max_keyframe_distance_for_fast_decode_; | |
| 2123 } | 2130 } |
| 2124 | 2131 |
| 2125 void WebMediaPlayerImpl::EnableVideoTrackIfNeeded() { | 2132 void WebMediaPlayerImpl::EnableVideoTrackIfNeeded() { |
| 2126 DCHECK(!IsHidden()); | 2133 DCHECK(!IsHidden()); |
| 2127 | 2134 |
| 2128 // Don't change video track while the pipeline is resuming or seeking. | 2135 // Don't change video track while the pipeline is resuming or seeking. |
| 2129 if (is_pipeline_resuming_ || seeking_) | 2136 if (is_pipeline_resuming_ || seeking_) |
| 2130 return; | 2137 return; |
| 2131 | 2138 |
| 2132 if (video_track_disabled_) { | 2139 if (video_track_disabled_) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2145 if (is_pipeline_resuming_ || seeking_) | 2152 if (is_pipeline_resuming_ || seeking_) |
| 2146 return; | 2153 return; |
| 2147 | 2154 |
| 2148 if (!video_track_disabled_ && ShouldDisableVideoWhenHidden()) { | 2155 if (!video_track_disabled_ && ShouldDisableVideoWhenHidden()) { |
| 2149 video_track_disabled_ = true; | 2156 video_track_disabled_ = true; |
| 2150 selectedVideoTrackChanged(nullptr); | 2157 selectedVideoTrackChanged(nullptr); |
| 2151 } | 2158 } |
| 2152 } | 2159 } |
| 2153 | 2160 |
| 2154 } // namespace media | 2161 } // namespace media |
| OLD | NEW |