Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 2767253002: Don't GONE the unsuspended video only players (Closed)
Patch Set: Fixed logic for audible videos... Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | media/blink/webmediaplayer_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1987 matching lines...) Expand 10 before | Expand all | Expand 10 after
1998 // We do not treat |playback_rate_| == 0 as paused. For the media session, 1998 // 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 1999 // 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 2000 // case. For memory usage reporting, we just use the same definition (but we
2001 // don't have to). 2001 // don't have to).
2002 // 2002 //
2003 // Similarly, we don't consider |ended_| to be paused. Blink will immediately 2003 // Similarly, we don't consider |ended_| to be paused. Blink will immediately
2004 // call pause() or seek(), so |ended_| should not affect the computation. 2004 // call pause() or seek(), so |ended_| should not affect the computation.
2005 // Despite that, |ended_| does result in a separate paused state, to simplfy 2005 // Despite that, |ended_| does result in a separate paused state, to simplfy
2006 // the contract for SetDelegateState(). 2006 // the contract for SetDelegateState().
2007 // 2007 //
2008 // |has_remote_controls| indicates if the player can be controlled outside the 2008 // |has_remote_controls| indicates if the player can be controlled outside the
sandersd (OOO until July 31) 2017/03/23 00:02:36 This comment does not mach the code, since (for ex
whywhat 2017/03/23 01:17:24 Right. Fixed.
2009 // page (e.g. via the notification controls or by audio focus events). Idle 2009 // page (e.g. via the notification controls or by audio focus events). Idle
2010 // suspension does not destroy the media session, because we expect that the 2010 // suspension does not destroy the media session, because we expect that the
2011 // notification controls (and audio focus) remain. The following must be true 2011 // notification controls (and audio focus) remain. The following must be true
2012 // for the player to have remote controls: 2012 // for the player to have remote controls:
2013 // - |have_future_data|, since we need to know whether we are paused to 2013 // - |have_future_data|, since we need to know whether we are paused to
2014 // correctly configure the session and also because the tracks and 2014 // correctly configure the session and also because the tracks and
2015 // duration are passed to DidPlay() 2015 // duration are passed to DidPlay()
2016 // - |is_remote| is false as remote players have their own controls 2016 // - |is_remote| is false as remote players have their own controls
2017 // - |has_error| is false player should have no errors 2017 // - |has_error| is false player should have no errors
2018 // - hasAudio() (requires |have_future_data|) 2018 // - hasAudio() (requires |have_future_data|)
2019 // 2019 //
2020 // TODO(sandersd): If Blink told us the paused state sooner, we could detect 2020 // TODO(sandersd): If Blink told us the paused state sooner, we could detect
2021 // if the remote controls are available sooner. 2021 // if the remote controls are available sooner.
2022 2022
2023 // Background videos with audio don't have remote controls if background 2023 // Background videos with audio don't have remote controls if background
2024 // suspend is enabled and resuming background videos is not (original Android 2024 // suspend is enabled and resuming background videos is not (original Android
2025 // behavior). 2025 // behavior).
2026 bool backgrounded_video_has_no_remote_controls = 2026 bool backgrounded_video_has_no_remote_controls =
2027 IsBackgroundedSuspendEnabled() && !IsResumeBackgroundVideosEnabled() && 2027 IsBackgroundedSuspendEnabled() && !IsResumeBackgroundVideosEnabled() &&
2028 is_backgrounded && hasVideo(); 2028 is_backgrounded && hasVideo();
2029 bool can_play = !has_error && !is_remote && have_future_data; 2029 bool can_play = !has_error && !is_remote && have_future_data;
2030 bool has_remote_controls = can_play && !must_suspend && hasAudio() && 2030 bool has_remote_controls =
2031 !backgrounded_video_has_no_remote_controls; 2031 hasAudio() && !backgrounded_video_has_no_remote_controls;
2032 2032 bool alive = can_play && !must_suspend &&
2033 if (!has_remote_controls) { 2033 (!background_suspended || has_remote_controls);
2034 if (!alive) {
2034 result.delegate_state = DelegateState::GONE; 2035 result.delegate_state = DelegateState::GONE;
2035 result.is_idle = delegate_->IsIdle(delegate_id_); 2036 result.is_idle = delegate_->IsIdle(delegate_id_);
2036 } else if (paused_) { 2037 } else if (paused_) {
2037 // TODO(sandersd): Is it possible to have a suspended session, be ended, 2038 // TODO(sandersd): Is it possible to have a suspended session, be ended,
2038 // and not be paused? If so we should be in a PLAYING state. 2039 // and not be paused? If so we should be in a PLAYING state.
2039 result.delegate_state = 2040 result.delegate_state =
2040 ended_ ? DelegateState::GONE : DelegateState::PAUSED; 2041 ended_ ? DelegateState::GONE : DelegateState::PAUSED;
2041 result.is_idle = !seeking_; 2042 result.is_idle = !seeking_;
2042 } else { 2043 } else {
2043 result.delegate_state = DelegateState::PLAYING; 2044 result.delegate_state = DelegateState::PLAYING;
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2325 2326
2326 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { 2327 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) {
2327 DCHECK(data_source_ || chunk_demuxer_); 2328 DCHECK(data_source_ || chunk_demuxer_);
2328 if (data_source_) 2329 if (data_source_)
2329 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); 2330 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration);
2330 else 2331 else
2331 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); 2332 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration);
2332 } 2333 }
2333 2334
2334 } // namespace media 2335 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/blink/webmediaplayer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698