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

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

Issue 2979893002: media: Allow suspend on HTTP 200 videos (Closed)
Patch Set: Created 3 years, 5 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 | « media/blink/resource_multibuffer_data_provider.cc ('k') | no next file » | 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 1780 matching lines...) Expand 10 before | Expand all | Expand 10 after
1791 if (!success) { 1791 if (!success) {
1792 SetNetworkState(WebMediaPlayer::kNetworkStateFormatError); 1792 SetNetworkState(WebMediaPlayer::kNetworkStateFormatError);
1793 1793
1794 // Not really necessary, since the pipeline was never started, but it at 1794 // Not really necessary, since the pipeline was never started, but it at
1795 // least this makes sure that the error handling code is in sync. 1795 // least this makes sure that the error handling code is in sync.
1796 UpdatePlayState(); 1796 UpdatePlayState();
1797 1797
1798 return; 1798 return;
1799 } 1799 }
1800 1800
1801 // No point in preloading data as we'll probably just throw it away anyways.
1802 if (IsStreaming() && preload_ > MultibufferDataSource::METADATA) {
1803 data_source_->SetPreload(MultibufferDataSource::METADATA);
1804 }
1805
1801 StartPipeline(); 1806 StartPipeline();
1802 } 1807 }
1803 1808
1804 void WebMediaPlayerImpl::NotifyDownloading(bool is_downloading) { 1809 void WebMediaPlayerImpl::NotifyDownloading(bool is_downloading) {
1805 DVLOG(1) << __func__ << "(" << is_downloading << ")"; 1810 DVLOG(1) << __func__ << "(" << is_downloading << ")";
1806 if (!is_downloading && network_state_ == WebMediaPlayer::kNetworkStateLoading) 1811 if (!is_downloading && network_state_ == WebMediaPlayer::kNetworkStateLoading)
1807 SetNetworkState(WebMediaPlayer::kNetworkStateIdle); 1812 SetNetworkState(WebMediaPlayer::kNetworkStateIdle);
1808 else if (is_downloading && 1813 else if (is_downloading &&
1809 network_state_ == WebMediaPlayer::kNetworkStateIdle) 1814 network_state_ == WebMediaPlayer::kNetworkStateIdle)
1810 SetNetworkState(WebMediaPlayer::kNetworkStateLoading); 1815 SetNetworkState(WebMediaPlayer::kNetworkStateLoading);
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
2070 return video_frame; 2075 return video_frame;
2071 } 2076 }
2072 2077
2073 void WebMediaPlayerImpl::UpdatePlayState() { 2078 void WebMediaPlayerImpl::UpdatePlayState() {
2074 DCHECK(main_task_runner_->BelongsToCurrentThread()); 2079 DCHECK(main_task_runner_->BelongsToCurrentThread());
2075 2080
2076 #if defined(OS_ANDROID) // WMPI_CAST 2081 #if defined(OS_ANDROID) // WMPI_CAST
2077 bool is_remote = IsRemote(); 2082 bool is_remote = IsRemote();
2078 bool can_auto_suspend = true; 2083 bool can_auto_suspend = true;
2079 #else 2084 #else
2085 int64_t size;
sandersd (OOO until July 31) 2017/07/12 21:19:20 nit: move after comment (and possibly rename to |u
hubbe 2017/07/12 21:28:47 Done.
2080 bool is_remote = false; 2086 bool is_remote = false;
2081 bool can_auto_suspend = !disable_pipeline_auto_suspend_ && !IsStreaming(); 2087 bool can_auto_suspend = !disable_pipeline_auto_suspend_;
2088 // For streaming videos, we only allow suspending at the very beginning of the
2089 // video, and only if we know the length of the video. (If we don't know the
sandersd (OOO until July 31) 2017/07/12 21:19:19 length -> size
hubbe 2017/07/12 21:28:47 size seems confusing how about "file size" ?
sandersd (OOO until July 31) 2017/07/12 21:37:05 sgtm
2090 // length, it might be a dynamically generated video, and suspending will
2091 // not work at all.)
2092 if (IsStreaming() && ready_state_ != WebMediaPlayer::kReadyStateHaveNothing &&
2093 CurrentTime() != 0.0 && data_source_ && data_source_->GetSize(&size)) {
sandersd (OOO until July 31) 2017/07/12 21:19:20 What's the reasoning for kReadyStateHaveNothing? I
hubbe 2017/07/12 21:28:47 Not allowed to call CurrentTime() if ready_state_
sandersd (OOO until July 31) 2017/07/12 21:37:05 Isn't that the same as saying that we can skip the
hubbe 2017/07/12 22:04:23 I think I had some of this logic wrong. Changed it
2094 can_auto_suspend = false;
2095 }
2082 #endif 2096 #endif
2083 2097
2084 bool is_suspended = pipeline_controller_.IsSuspended(); 2098 bool is_suspended = pipeline_controller_.IsSuspended();
2085 bool is_backgrounded = IsBackgroundedSuspendEnabled() && IsHidden(); 2099 bool is_backgrounded = IsBackgroundedSuspendEnabled() && IsHidden();
2086 PlayState state = UpdatePlayState_ComputePlayState( 2100 PlayState state = UpdatePlayState_ComputePlayState(
2087 is_remote, can_auto_suspend, is_suspended, is_backgrounded); 2101 is_remote, can_auto_suspend, is_suspended, is_backgrounded);
2088 SetDelegateState(state.delegate_state, state.is_idle); 2102 SetDelegateState(state.delegate_state, state.is_idle);
2089 SetMemoryReportingState(state.is_memory_reporting_enabled); 2103 SetMemoryReportingState(state.is_memory_reporting_enabled);
2090 SetSuspendState(state.is_suspended || pending_suspend_resume_cycle_); 2104 SetSuspendState(state.is_suspended || pending_suspend_resume_cycle_);
2091 } 2105 }
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
2633 } 2647 }
2634 2648
2635 #undef UMA_HISTOGRAM_VIDEO_HEIGHT 2649 #undef UMA_HISTOGRAM_VIDEO_HEIGHT
2636 2650
2637 void WebMediaPlayerImpl::SetTickClockForTest(base::TickClock* tick_clock) { 2651 void WebMediaPlayerImpl::SetTickClockForTest(base::TickClock* tick_clock) {
2638 tick_clock_.reset(tick_clock); 2652 tick_clock_.reset(tick_clock);
2639 buffered_data_source_host_.SetTickClockForTest(tick_clock); 2653 buffered_data_source_host_.SetTickClockForTest(tick_clock);
2640 } 2654 }
2641 2655
2642 } // namespace media 2656 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/resource_multibuffer_data_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698