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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 media_log_->AddEvent( | 260 media_log_->AddEvent( |
261 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED)); | 261 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED)); |
262 | 262 |
263 if (params.initial_cdm()) | 263 if (params.initial_cdm()) |
264 SetCdm(params.initial_cdm()); | 264 SetCdm(params.initial_cdm()); |
265 | 265 |
266 // TODO(xhwang): When we use an external Renderer, many methods won't work, | 266 // TODO(xhwang): When we use an external Renderer, many methods won't work, |
267 // e.g. GetCurrentFrameFromCompositor(). See http://crbug.com/434861 | 267 // e.g. GetCurrentFrameFromCompositor(). See http://crbug.com/434861 |
268 audio_source_provider_ = | 268 audio_source_provider_ = |
269 new WebAudioSourceProviderImpl(params.audio_renderer_sink(), media_log_); | 269 new WebAudioSourceProviderImpl(params.audio_renderer_sink(), media_log_); |
270 | |
271 if (observer_) | |
272 observer_->SetClient(this); | |
270 } | 273 } |
271 | 274 |
272 WebMediaPlayerImpl::~WebMediaPlayerImpl() { | 275 WebMediaPlayerImpl::~WebMediaPlayerImpl() { |
273 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 276 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
274 | 277 |
275 suppress_destruction_errors_ = true; | 278 suppress_destruction_errors_ = true; |
276 | 279 |
277 delegate_->PlayerGone(delegate_id_); | 280 delegate_->PlayerGone(delegate_id_); |
278 delegate_->RemoveObserver(delegate_id_); | 281 delegate_->RemoveObserver(delegate_id_); |
279 | 282 |
(...skipping 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1831 } | 1834 } |
1832 | 1835 |
1833 void WebMediaPlayerImpl::UpdatePlayState() { | 1836 void WebMediaPlayerImpl::UpdatePlayState() { |
1834 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1837 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1835 | 1838 |
1836 #if defined(OS_ANDROID) // WMPI_CAST | 1839 #if defined(OS_ANDROID) // WMPI_CAST |
1837 bool is_remote = isRemote(); | 1840 bool is_remote = isRemote(); |
1838 bool is_streaming = false; | 1841 bool is_streaming = false; |
1839 #else | 1842 #else |
1840 bool is_remote = false; | 1843 bool is_remote = false; |
1841 bool is_streaming = IsStreaming(); | 1844 bool is_streaming = IsStreaming() || disable_pipeline_auto_suspend_; |
miu
2017/02/13 23:36:08
This |is_streaming| variable should probably be re
xjz
2017/02/14 01:46:10
Done.
| |
1842 #endif | 1845 #endif |
1843 | 1846 |
1844 bool is_suspended = pipeline_controller_.IsSuspended(); | 1847 bool is_suspended = pipeline_controller_.IsSuspended(); |
1845 bool is_backgrounded = IsBackgroundedSuspendEnabled() && IsHidden(); | 1848 bool is_backgrounded = IsBackgroundedSuspendEnabled() && IsHidden(); |
1846 PlayState state = UpdatePlayState_ComputePlayState( | 1849 PlayState state = UpdatePlayState_ComputePlayState( |
1847 is_remote, is_streaming, is_suspended, is_backgrounded); | 1850 is_remote, is_streaming, is_suspended, is_backgrounded); |
1848 SetDelegateState(state.delegate_state, state.is_idle); | 1851 SetDelegateState(state.delegate_state, state.is_idle); |
1849 SetMemoryReportingState(state.is_memory_reporting_enabled); | 1852 SetMemoryReportingState(state.is_memory_reporting_enabled); |
1850 SetSuspendState(state.is_suspended || pending_suspend_resume_cycle_); | 1853 SetSuspendState(state.is_suspended || pending_suspend_resume_cycle_); |
1851 } | 1854 } |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2280 if (hasAudio()) { | 2283 if (hasAudio()) { |
2281 UMA_HISTOGRAM_TIMES( | 2284 UMA_HISTOGRAM_TIMES( |
2282 "Media.Video.TimeFromForegroundToFirstFrame.DisableTrack", | 2285 "Media.Video.TimeFromForegroundToFirstFrame.DisableTrack", |
2283 time_to_first_frame); | 2286 time_to_first_frame); |
2284 } else { | 2287 } else { |
2285 UMA_HISTOGRAM_TIMES("Media.Video.TimeFromForegroundToFirstFrame.Paused", | 2288 UMA_HISTOGRAM_TIMES("Media.Video.TimeFromForegroundToFirstFrame.Paused", |
2286 time_to_first_frame); | 2289 time_to_first_frame); |
2287 } | 2290 } |
2288 } | 2291 } |
2289 | 2292 |
2293 void WebMediaPlayerImpl::SwitchRenderer() { | |
2294 DCHECK(main_task_runner_->BelongsToCurrentThread()); | |
2295 ScheduleRestart(); | |
2296 } | |
2297 | |
2298 void WebMediaPlayerImpl::DisablePipelineAutoSuspend(bool disable) { | |
2299 DCHECK(main_task_runner_->BelongsToCurrentThread()); | |
2300 disable_pipeline_auto_suspend_ = disable; | |
2301 } | |
2302 | |
2290 } // namespace media | 2303 } // namespace media |
OLD | NEW |