| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 #if !defined(OS_ANDROID) | 114 #if !defined(OS_ANDROID) |
| 115 // Suspend/Resume is only enabled by default on Android. | 115 // Suspend/Resume is only enabled by default on Android. |
| 116 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 116 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 117 switches::kEnableMediaSuspend); | 117 switches::kEnableMediaSuspend); |
| 118 #else | 118 #else |
| 119 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | 119 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 120 switches::kDisableMediaSuspend); | 120 switches::kDisableMediaSuspend); |
| 121 #endif | 121 #endif |
| 122 } | 122 } |
| 123 | 123 |
| 124 bool IsResumeBackgroundVideosEnabled() { | |
| 125 return base::FeatureList::IsEnabled(kResumeBackgroundVideo); | |
| 126 } | |
| 127 | |
| 128 bool IsBackgroundVideoTrackOptimizationEnabled() { | 124 bool IsBackgroundVideoTrackOptimizationEnabled() { |
| 129 return base::FeatureList::IsEnabled(kBackgroundVideoTrackOptimization); | 125 return base::FeatureList::IsEnabled(kBackgroundVideoTrackOptimization); |
| 130 } | 126 } |
| 131 | 127 |
| 132 bool IsNetworkStateError(blink::WebMediaPlayer::NetworkState state) { | 128 bool IsNetworkStateError(blink::WebMediaPlayer::NetworkState state) { |
| 133 bool result = state == blink::WebMediaPlayer::NetworkStateFormatError || | 129 bool result = state == blink::WebMediaPlayer::NetworkStateFormatError || |
| 134 state == blink::WebMediaPlayer::NetworkStateNetworkError || | 130 state == blink::WebMediaPlayer::NetworkStateNetworkError || |
| 135 state == blink::WebMediaPlayer::NetworkStateDecodeError; | 131 state == blink::WebMediaPlayer::NetworkStateDecodeError; |
| 136 DCHECK_EQ(state > blink::WebMediaPlayer::NetworkStateLoaded, result); | 132 DCHECK_EQ(state > blink::WebMediaPlayer::NetworkStateLoaded, result); |
| 137 return result; | 133 return result; |
| (...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1430 void WebMediaPlayerImpl::OnVideoAverageKeyframeDistanceUpdate() { | 1426 void WebMediaPlayerImpl::OnVideoAverageKeyframeDistanceUpdate() { |
| 1431 UpdateBackgroundVideoOptimizationState(); | 1427 UpdateBackgroundVideoOptimizationState(); |
| 1432 } | 1428 } |
| 1433 | 1429 |
| 1434 void WebMediaPlayerImpl::OnFrameHidden() { | 1430 void WebMediaPlayerImpl::OnFrameHidden() { |
| 1435 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1431 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 1436 | 1432 |
| 1437 if (watch_time_reporter_) | 1433 if (watch_time_reporter_) |
| 1438 watch_time_reporter_->OnHidden(); | 1434 watch_time_reporter_->OnHidden(); |
| 1439 | 1435 |
| 1440 // OnFrameHidden() can be called when frame is closed, then IsHidden() will | 1436 UpdateBackgroundVideoOptimizationState(); |
| 1441 // return false, so check explicitly. | |
| 1442 if (IsHidden()) { | |
| 1443 if (ShouldPauseVideoWhenHidden()) { | |
| 1444 PauseVideoIfNeeded(); | |
| 1445 return; | |
| 1446 } else { | |
| 1447 DisableVideoTrackIfNeeded(); | |
| 1448 } | |
| 1449 } | |
| 1450 | |
| 1451 UpdatePlayState(); | 1437 UpdatePlayState(); |
| 1452 | 1438 |
| 1453 // Schedule suspended playing media to be paused if the user doesn't come back | 1439 // Schedule suspended playing media to be paused if the user doesn't come back |
| 1454 // to it within some timeout period to avoid any autoplay surprises. | 1440 // to it within some timeout period to avoid any autoplay surprises. |
| 1455 ScheduleIdlePauseTimer(); | 1441 ScheduleIdlePauseTimer(); |
| 1456 } | 1442 } |
| 1457 | 1443 |
| 1458 void WebMediaPlayerImpl::OnFrameClosed() { | 1444 void WebMediaPlayerImpl::OnFrameClosed() { |
| 1459 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1445 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 1460 UpdatePlayState(); | 1446 UpdatePlayState(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1475 VideoFrameCompositor::OnNewProcessedFrameCB new_processed_frame_cb = | 1461 VideoFrameCompositor::OnNewProcessedFrameCB new_processed_frame_cb = |
| 1476 BindToCurrentLoop(base::Bind( | 1462 BindToCurrentLoop(base::Bind( |
| 1477 &WebMediaPlayerImpl::ReportTimeFromForegroundToFirstFrame, | 1463 &WebMediaPlayerImpl::ReportTimeFromForegroundToFirstFrame, |
| 1478 AsWeakPtr(), base::TimeTicks::Now())); | 1464 AsWeakPtr(), base::TimeTicks::Now())); |
| 1479 compositor_task_runner_->PostTask( | 1465 compositor_task_runner_->PostTask( |
| 1480 FROM_HERE, | 1466 FROM_HERE, |
| 1481 base::Bind(&VideoFrameCompositor::SetOnNewProcessedFrameCallback, | 1467 base::Bind(&VideoFrameCompositor::SetOnNewProcessedFrameCallback, |
| 1482 base::Unretained(compositor_), new_processed_frame_cb)); | 1468 base::Unretained(compositor_), new_processed_frame_cb)); |
| 1483 } | 1469 } |
| 1484 | 1470 |
| 1471 EnableVideoTrackIfNeeded(); |
| 1472 |
| 1485 if (paused_when_hidden_) { | 1473 if (paused_when_hidden_) { |
| 1486 paused_when_hidden_ = false; | 1474 paused_when_hidden_ = false; |
| 1475 client_->wasResumedWhenForegrounded(); |
| 1487 OnPlay(); // Calls UpdatePlayState() so return afterwards. | 1476 OnPlay(); // Calls UpdatePlayState() so return afterwards. |
| 1488 return; | 1477 return; |
| 1489 } | 1478 } |
| 1490 | 1479 |
| 1491 EnableVideoTrackIfNeeded(); | |
| 1492 | |
| 1493 UpdatePlayState(); | 1480 UpdatePlayState(); |
| 1494 } | 1481 } |
| 1495 | 1482 |
| 1496 void WebMediaPlayerImpl::OnIdleTimeout() { | 1483 void WebMediaPlayerImpl::OnIdleTimeout() { |
| 1497 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1484 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 1498 | 1485 |
| 1499 // If we are attempting preroll, clear the stale flag. | 1486 // If we are attempting preroll, clear the stale flag. |
| 1500 if (IsPrerollAttemptNeeded()) { | 1487 if (IsPrerollAttemptNeeded()) { |
| 1501 delegate_->ClearStaleFlag(delegate_id_); | 1488 delegate_->ClearStaleFlag(delegate_id_); |
| 1502 return; | 1489 return; |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1947 bool is_backgrounded) { | 1934 bool is_backgrounded) { |
| 1948 PlayState result; | 1935 PlayState result; |
| 1949 | 1936 |
| 1950 bool must_suspend = delegate_->IsFrameClosed(); | 1937 bool must_suspend = delegate_->IsFrameClosed(); |
| 1951 bool is_stale = delegate_->IsStale(delegate_id_); | 1938 bool is_stale = delegate_->IsStale(delegate_id_); |
| 1952 | 1939 |
| 1953 // This includes both data source (before pipeline startup) and pipeline | 1940 // This includes both data source (before pipeline startup) and pipeline |
| 1954 // errors. | 1941 // errors. |
| 1955 bool has_error = IsNetworkStateError(network_state_); | 1942 bool has_error = IsNetworkStateError(network_state_); |
| 1956 | 1943 |
| 1957 // After HaveMetadata, we know which tracks are present and the duration. | |
| 1958 bool have_metadata = ready_state_ >= WebMediaPlayer::ReadyStateHaveMetadata; | |
| 1959 | |
| 1960 // After HaveFutureData, Blink will call play() if the state is not paused; | 1944 // After HaveFutureData, Blink will call play() if the state is not paused; |
| 1961 // prior to this point |paused_| is not accurate. | 1945 // prior to this point |paused_| is not accurate. |
| 1962 bool have_future_data = | 1946 bool have_future_data = |
| 1963 highest_ready_state_ >= WebMediaPlayer::ReadyStateHaveFutureData; | 1947 highest_ready_state_ >= WebMediaPlayer::ReadyStateHaveFutureData; |
| 1964 | 1948 |
| 1965 // Background suspend is not enabled for audio-only players unless paused, | 1949 // Background suspend is only enabled for paused players. |
| 1966 // though in the case of audio-only the session should be kept. | 1950 // In the case of players with audio the session should be kept. |
| 1967 // Videos are not suspended if the user resumed the playback via the remote | 1951 bool background_suspended = |
| 1968 // controls earlier and it's still playing. | |
| 1969 bool is_backgrounded_video = is_backgrounded && have_metadata && hasVideo(); | |
| 1970 bool can_play_backgrounded = is_backgrounded_video && !is_remote && | |
| 1971 hasAudio() && IsResumeBackgroundVideosEnabled(); | |
| 1972 bool is_background_playing = delegate_->IsBackgroundVideoPlaybackUnlocked(); | |
| 1973 bool background_suspended = can_auto_suspend && is_backgrounded_video && | |
| 1974 !(can_play_backgrounded && is_background_playing); | |
| 1975 bool background_pause_suspended = | |
| 1976 can_auto_suspend && is_backgrounded && paused_ && have_future_data; | 1952 can_auto_suspend && is_backgrounded && paused_ && have_future_data; |
| 1977 | 1953 |
| 1978 // Idle suspension is allowed prior to have future data since there exist | 1954 // Idle suspension is allowed prior to have future data since there exist |
| 1979 // mechanisms to exit the idle state when the player is capable of reaching | 1955 // mechanisms to exit the idle state when the player is capable of reaching |
| 1980 // the have future data state; see didLoadingProgress(). | 1956 // the have future data state; see didLoadingProgress(). |
| 1981 // | 1957 // |
| 1982 // TODO(sandersd): Make the delegate suspend idle players immediately when | 1958 // TODO(sandersd): Make the delegate suspend idle players immediately when |
| 1983 // hidden. | 1959 // hidden. |
| 1984 bool idle_suspended = | 1960 bool idle_suspended = |
| 1985 can_auto_suspend && is_stale && paused_ && !seeking_ && !overlay_enabled_; | 1961 can_auto_suspend && is_stale && paused_ && !seeking_ && !overlay_enabled_; |
| 1986 | 1962 |
| 1987 // If we're already suspended, see if we can wait for user interaction. Prior | 1963 // If we're already suspended, see if we can wait for user interaction. Prior |
| 1988 // to HaveFutureData, we require |is_stale| to remain suspended. |is_stale| | 1964 // to HaveFutureData, we require |is_stale| to remain suspended. |is_stale| |
| 1989 // will be cleared when we receive data which may take us to HaveFutureData. | 1965 // will be cleared when we receive data which may take us to HaveFutureData. |
| 1990 bool can_stay_suspended = | 1966 bool can_stay_suspended = |
| 1991 (is_stale || have_future_data) && is_suspended && paused_ && !seeking_; | 1967 (is_stale || have_future_data) && is_suspended && paused_ && !seeking_; |
| 1992 | 1968 |
| 1993 // Combined suspend state. | 1969 // Combined suspend state. |
| 1994 result.is_suspended = is_remote || must_suspend || idle_suspended || | 1970 result.is_suspended = is_remote || must_suspend || idle_suspended || |
| 1995 background_suspended || background_pause_suspended || | 1971 background_suspended || can_stay_suspended; |
| 1996 can_stay_suspended; | |
| 1997 | 1972 |
| 1998 // We do not treat |playback_rate_| == 0 as paused. For the media session, | 1973 // We do not treat |playback_rate_| == 0 as paused. For the media session, |
| 1999 // being paused implies displaying a play button, which is incorrect in this | 1974 // being paused implies displaying a play button, which is incorrect in this |
| 2000 // case. For memory usage reporting, we just use the same definition (but we | 1975 // case. For memory usage reporting, we just use the same definition (but we |
| 2001 // don't have to). | 1976 // don't have to). |
| 2002 // | 1977 // |
| 2003 // Similarly, we don't consider |ended_| to be paused. Blink will immediately | 1978 // Similarly, we don't consider |ended_| to be paused. Blink will immediately |
| 2004 // call pause() or seek(), so |ended_| should not affect the computation. | 1979 // call pause() or seek(), so |ended_| should not affect the computation. |
| 2005 // Despite that, |ended_| does result in a separate paused state, to simplfy | 1980 // Despite that, |ended_| does result in a separate paused state, to simplfy |
| 2006 // the contract for SetDelegateState(). | 1981 // the contract for SetDelegateState(). |
| 2007 // | 1982 // |
| 2008 // |has_session| is used to decide when to create a media session. Idle | 1983 // |has_session| is used to decide when to create a media session. Idle |
| 2009 // suspension does not destroy the media session, because we expect that the | 1984 // suspension does not destroy the media session, because we expect that the |
| 2010 // notification controls (and audio focus) remain. We also require: | 1985 // notification controls (and audio focus) remain. We also require: |
| 2011 // - |have_metadata|, since the tracks and duration are passed to DidPlay(). | 1986 // - |have_metadata|, since the tracks and duration are passed to DidPlay(). |
| 2012 // - |have_future_data|, since we need to know whether we are paused to | 1987 // - |have_future_data|, since we need to know whether we are paused to |
| 2013 // correctly configure the session. | 1988 // correctly configure the session. |
| 2014 // | 1989 // |
| 2015 // TODO(sandersd): If Blink told us the paused state sooner, we could create | 1990 // TODO(sandersd): If Blink told us the paused state sooner, we could create |
| 2016 // the media session sooner. | 1991 // the media session sooner. |
| 2017 bool can_play = !has_error && !is_remote && have_future_data; | 1992 bool can_play = !has_error && !is_remote && have_future_data; |
| 2018 bool has_session_playing = can_play && !must_suspend && !background_suspended; | 1993 bool has_session = |
| 2019 | 1994 can_play && !must_suspend && hasAudio() && |
| 2020 // |has_session_suspended| means the player is suspended from the media | 1995 (!hasVideo() || !is_backgrounded || !IsBackgroundedSuspendEnabled() || |
| 2021 // element point of view but paused and can be resumed from the delegate point | 1996 base::FeatureList::IsEnabled(kResumeBackgroundVideo)); |
| 2022 // of view. Therefore it behaves like |paused_| for the delegate. | |
| 2023 bool has_session_suspended = can_play && !must_suspend && | |
| 2024 background_suspended && can_play_backgrounded; | |
| 2025 | |
| 2026 bool has_session = has_session_playing || has_session_suspended; | |
| 2027 | 1997 |
| 2028 if (!has_session) { | 1998 if (!has_session) { |
| 2029 result.delegate_state = DelegateState::GONE; | 1999 result.delegate_state = DelegateState::GONE; |
| 2030 result.is_idle = delegate_->IsIdle(delegate_id_); | 2000 result.is_idle = delegate_->IsIdle(delegate_id_); |
| 2031 } else if (paused_ || has_session_suspended) { | 2001 } else if (paused_) { |
| 2032 // TODO(sandersd): Is it possible to have a suspended session, be ended, | 2002 // TODO(sandersd): Is it possible to have a suspended session, be ended, |
| 2033 // and not be paused? If so we should be in a PLAYING state. | 2003 // and not be paused? If so we should be in a PLAYING state. |
| 2034 result.delegate_state = | 2004 result.delegate_state = |
| 2035 ended_ ? DelegateState::GONE : DelegateState::PAUSED; | 2005 ended_ ? DelegateState::GONE : DelegateState::PAUSED; |
| 2036 result.is_idle = !seeking_; | 2006 result.is_idle = !seeking_; |
| 2037 } else { | 2007 } else { |
| 2038 result.delegate_state = DelegateState::PLAYING; | 2008 result.delegate_state = DelegateState::PLAYING; |
| 2039 result.is_idle = false; | 2009 result.is_idle = false; |
| 2040 } | 2010 } |
| 2041 | 2011 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2099 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.DataSource", | 2069 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.DataSource", |
| 2100 data_source_memory_usage / 1024); | 2070 data_source_memory_usage / 1024); |
| 2101 } | 2071 } |
| 2102 if (demuxer_) { | 2072 if (demuxer_) { |
| 2103 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.Demuxer", | 2073 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.Demuxer", |
| 2104 demuxer_memory_usage / 1024); | 2074 demuxer_memory_usage / 1024); |
| 2105 } | 2075 } |
| 2106 } | 2076 } |
| 2107 | 2077 |
| 2108 void WebMediaPlayerImpl::ScheduleIdlePauseTimer() { | 2078 void WebMediaPlayerImpl::ScheduleIdlePauseTimer() { |
| 2109 // Only schedule the pause timer if we're playing and are suspended. | 2079 // Only schedule the pause timer if we're not paused or paused but going to |
| 2110 if (paused_ || !pipeline_controller_.IsSuspended()) | 2080 // resume when foregrounded, and are suspended. |
| 2081 if ((paused_ && !paused_when_hidden_) || !pipeline_controller_.IsSuspended()) |
| 2111 return; | 2082 return; |
| 2112 | 2083 |
| 2113 #if defined(OS_ANDROID) | 2084 #if defined(OS_ANDROID) |
| 2114 // Remote players will be suspended and locally paused. | 2085 // Remote players will be suspended and locally paused. |
| 2115 if (isRemote()) | 2086 if (isRemote()) |
| 2116 return; | 2087 return; |
| 2117 #endif | 2088 #endif |
| 2118 | 2089 |
| 2119 // Idle timeout chosen arbitrarily. | 2090 // Idle timeout chosen arbitrarily. |
| 2120 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5), | 2091 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2148 return pipeline_metadata_.video_rotation == VIDEO_ROTATION_0; | 2119 return pipeline_metadata_.video_rotation == VIDEO_ROTATION_0; |
| 2149 } | 2120 } |
| 2150 | 2121 |
| 2151 void WebMediaPlayerImpl::ActivateViewportIntersectionMonitoring(bool activate) { | 2122 void WebMediaPlayerImpl::ActivateViewportIntersectionMonitoring(bool activate) { |
| 2152 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 2123 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 2153 | 2124 |
| 2154 client_->activateViewportIntersectionMonitoring(activate); | 2125 client_->activateViewportIntersectionMonitoring(activate); |
| 2155 } | 2126 } |
| 2156 | 2127 |
| 2157 bool WebMediaPlayerImpl::ShouldPauseVideoWhenHidden() const { | 2128 bool WebMediaPlayerImpl::ShouldPauseVideoWhenHidden() const { |
| 2158 #if !defined(OS_ANDROID) | 2129 // If suspending background video, pause any video that's not remoted or |
| 2159 // On desktop, this behavior is behind the feature flag. | 2130 // not unlocked to play in the background. |
| 2160 if (!IsBackgroundVideoTrackOptimizationEnabled()) | 2131 if (IsBackgroundedSuspendEnabled()) { |
| 2161 return false; | 2132 if (!hasVideo()) |
| 2133 return false; |
| 2134 |
| 2135 #if defined(OS_ANDROID) |
| 2136 if (isRemote()) |
| 2137 return false; |
| 2162 #endif | 2138 #endif |
| 2163 | 2139 |
| 2164 // Pause video-only players that match the criteria for being optimized. | 2140 return !hasAudio() || !client_->isBackgroundVideoPlaybackUnlocked(); |
| 2165 return !hasAudio() && IsBackgroundOptimizationCandidate(); | 2141 } |
| 2142 |
| 2143 // Otherwise only pause if the optimization is on and it's a video-only |
| 2144 // optimization candidate. |
| 2145 return IsBackgroundVideoTrackOptimizationEnabled() && !hasAudio() && |
| 2146 IsBackgroundOptimizationCandidate(); |
| 2166 } | 2147 } |
| 2167 | 2148 |
| 2168 bool WebMediaPlayerImpl::ShouldDisableVideoWhenHidden() const { | 2149 bool WebMediaPlayerImpl::ShouldDisableVideoWhenHidden() const { |
| 2169 // This optimization is behind the flag on all platforms. | 2150 // This optimization is behind the flag on all platforms. |
| 2170 if (!IsBackgroundVideoTrackOptimizationEnabled()) | 2151 if (!IsBackgroundVideoTrackOptimizationEnabled()) |
| 2171 return false; | 2152 return false; |
| 2172 | 2153 |
| 2173 // Disable video track only for players with audio that match the criteria for | 2154 // Disable video track only for players with audio that match the criteria for |
| 2174 // being optimized. | 2155 // being optimized. |
| 2175 return hasAudio() && IsBackgroundOptimizationCandidate(); | 2156 return hasAudio() && IsBackgroundOptimizationCandidate(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2220 | 2201 |
| 2221 // Don't pause video while the pipeline is stopped, resuming or seeking. | 2202 // Don't pause video while the pipeline is stopped, resuming or seeking. |
| 2222 // Also if the video is paused already. | 2203 // Also if the video is paused already. |
| 2223 if (!pipeline_.IsRunning() || is_pipeline_resuming_ || seeking_ || paused_) | 2204 if (!pipeline_.IsRunning() || is_pipeline_resuming_ || seeking_ || paused_) |
| 2224 return; | 2205 return; |
| 2225 | 2206 |
| 2226 // OnPause() will set |paused_when_hidden_| to false and call | 2207 // OnPause() will set |paused_when_hidden_| to false and call |
| 2227 // UpdatePlayState(), so set the flag to true after and then return. | 2208 // UpdatePlayState(), so set the flag to true after and then return. |
| 2228 OnPause(); | 2209 OnPause(); |
| 2229 paused_when_hidden_ = true; | 2210 paused_when_hidden_ = true; |
| 2211 client_->wasPausedWhenBackgrounded(); |
| 2230 } | 2212 } |
| 2231 | 2213 |
| 2232 void WebMediaPlayerImpl::EnableVideoTrackIfNeeded() { | 2214 void WebMediaPlayerImpl::EnableVideoTrackIfNeeded() { |
| 2233 // Don't change video track while the pipeline is stopped, resuming or | 2215 // Don't change video track while the pipeline is stopped, resuming or |
| 2234 // seeking. | 2216 // seeking. |
| 2235 if (!pipeline_.IsRunning() || is_pipeline_resuming_ || seeking_) | 2217 if (!pipeline_.IsRunning() || is_pipeline_resuming_ || seeking_) |
| 2236 return; | 2218 return; |
| 2237 | 2219 |
| 2238 if (video_track_disabled_) { | 2220 if (video_track_disabled_) { |
| 2239 video_track_disabled_ = false; | 2221 video_track_disabled_ = false; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2286 base::TimeDelta time_to_first_frame = new_frame_time - foreground_time; | 2268 base::TimeDelta time_to_first_frame = new_frame_time - foreground_time; |
| 2287 if (hasAudio()) { | 2269 if (hasAudio()) { |
| 2288 UMA_HISTOGRAM_TIMES( | 2270 UMA_HISTOGRAM_TIMES( |
| 2289 "Media.Video.TimeFromForegroundToFirstFrame.DisableTrack", | 2271 "Media.Video.TimeFromForegroundToFirstFrame.DisableTrack", |
| 2290 time_to_first_frame); | 2272 time_to_first_frame); |
| 2291 } else { | 2273 } else { |
| 2292 UMA_HISTOGRAM_TIMES("Media.Video.TimeFromForegroundToFirstFrame.Paused", | 2274 UMA_HISTOGRAM_TIMES("Media.Video.TimeFromForegroundToFirstFrame.Paused", |
| 2293 time_to_first_frame); | 2275 time_to_first_frame); |
| 2294 } | 2276 } |
| 2295 } | 2277 } |
| 2296 | |
| 2297 void WebMediaPlayerImpl::SwitchRenderer(bool disable_pipeline_auto_suspend) { | 2278 void WebMediaPlayerImpl::SwitchRenderer(bool disable_pipeline_auto_suspend) { |
| 2298 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 2279 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 2299 disable_pipeline_auto_suspend_ = disable_pipeline_auto_suspend; | 2280 disable_pipeline_auto_suspend_ = disable_pipeline_auto_suspend; |
| 2300 ScheduleRestart(); | 2281 ScheduleRestart(); |
| 2301 } | 2282 } |
| 2302 | 2283 |
| 2303 } // namespace media | 2284 } // namespace media |
| OLD | NEW |