| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 BindToCurrentLoop(base::Bind(function, AsWeakPtr()))) | 169 BindToCurrentLoop(base::Bind(function, AsWeakPtr()))) |
| 170 | 170 |
| 171 #define BIND_TO_RENDER_LOOP1(function, arg1) \ | 171 #define BIND_TO_RENDER_LOOP1(function, arg1) \ |
| 172 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \ | 172 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \ |
| 173 BindToCurrentLoop(base::Bind(function, AsWeakPtr(), arg1))) | 173 BindToCurrentLoop(base::Bind(function, AsWeakPtr(), arg1))) |
| 174 | 174 |
| 175 WebMediaPlayerImpl::WebMediaPlayerImpl( | 175 WebMediaPlayerImpl::WebMediaPlayerImpl( |
| 176 blink::WebLocalFrame* frame, | 176 blink::WebLocalFrame* frame, |
| 177 blink::WebMediaPlayerClient* client, | 177 blink::WebMediaPlayerClient* client, |
| 178 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, | 178 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, |
| 179 base::WeakPtr<WebMediaPlayerDelegate> delegate, | 179 WebMediaPlayerDelegate* delegate, |
| 180 std::unique_ptr<RendererFactory> renderer_factory, | 180 std::unique_ptr<RendererFactory> renderer_factory, |
| 181 linked_ptr<UrlIndex> url_index, | 181 linked_ptr<UrlIndex> url_index, |
| 182 const WebMediaPlayerParams& params) | 182 const WebMediaPlayerParams& params) |
| 183 : frame_(frame), | 183 : frame_(frame), |
| 184 delegate_state_(DelegateState::GONE), | 184 delegate_state_(DelegateState::GONE), |
| 185 delegate_has_audio_(false), | 185 delegate_has_audio_(false), |
| 186 network_state_(WebMediaPlayer::NetworkStateEmpty), | 186 network_state_(WebMediaPlayer::NetworkStateEmpty), |
| 187 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), | 187 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), |
| 188 highest_ready_state_(WebMediaPlayer::ReadyStateHaveNothing), | 188 highest_ready_state_(WebMediaPlayer::ReadyStateHaveNothing), |
| 189 preload_(MultibufferDataSource::AUTO), | 189 preload_(MultibufferDataSource::AUTO), |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 suppress_destruction_errors_(false), | 240 suppress_destruction_errors_(false), |
| 241 can_suspend_state_(CanSuspendState::UNKNOWN), | 241 can_suspend_state_(CanSuspendState::UNKNOWN), |
| 242 use_fallback_path_(false), | 242 use_fallback_path_(false), |
| 243 is_encrypted_(false), | 243 is_encrypted_(false), |
| 244 underflow_count_(0), | 244 underflow_count_(0), |
| 245 preroll_attempt_pending_(false), | 245 preroll_attempt_pending_(false), |
| 246 observer_(params.media_observer()) { | 246 observer_(params.media_observer()) { |
| 247 DCHECK(!adjust_allocated_memory_cb_.is_null()); | 247 DCHECK(!adjust_allocated_memory_cb_.is_null()); |
| 248 DCHECK(renderer_factory_); | 248 DCHECK(renderer_factory_); |
| 249 DCHECK(client_); | 249 DCHECK(client_); |
| 250 DCHECK(delegate_); |
| 250 | 251 |
| 251 tick_clock_.reset(new base::DefaultTickClock()); | 252 tick_clock_.reset(new base::DefaultTickClock()); |
| 252 | 253 |
| 253 force_video_overlays_ = base::CommandLine::ForCurrentProcess()->HasSwitch( | 254 force_video_overlays_ = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 254 switches::kForceVideoOverlays); | 255 switches::kForceVideoOverlays); |
| 255 | 256 |
| 256 if (delegate_) { | 257 delegate_id_ = delegate_->AddObserver(this); |
| 257 delegate_id_ = delegate_->AddObserver(this); | 258 delegate_->SetIdle(delegate_id_, true); |
| 258 delegate_->SetIdle(delegate_id_, true); | |
| 259 } | |
| 260 | 259 |
| 261 media_log_->AddEvent( | 260 media_log_->AddEvent( |
| 262 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED)); | 261 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED)); |
| 263 | 262 |
| 264 if (params.initial_cdm()) | 263 if (params.initial_cdm()) |
| 265 SetCdm(params.initial_cdm()); | 264 SetCdm(params.initial_cdm()); |
| 266 | 265 |
| 267 // 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, |
| 268 // e.g. GetCurrentFrameFromCompositor(). See http://crbug.com/434861 | 267 // e.g. GetCurrentFrameFromCompositor(). See http://crbug.com/434861 |
| 269 audio_source_provider_ = | 268 audio_source_provider_ = |
| 270 new WebAudioSourceProviderImpl(params.audio_renderer_sink(), media_log_); | 269 new WebAudioSourceProviderImpl(params.audio_renderer_sink(), media_log_); |
| 271 } | 270 } |
| 272 | 271 |
| 273 WebMediaPlayerImpl::~WebMediaPlayerImpl() { | 272 WebMediaPlayerImpl::~WebMediaPlayerImpl() { |
| 274 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 273 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 275 | 274 |
| 276 suppress_destruction_errors_ = true; | 275 suppress_destruction_errors_ = true; |
| 277 if (delegate_) { | 276 |
| 278 delegate_->PlayerGone(delegate_id_); | 277 delegate_->PlayerGone(delegate_id_); |
| 279 delegate_->RemoveObserver(delegate_id_); | 278 delegate_->RemoveObserver(delegate_id_); |
| 280 } | |
| 281 | 279 |
| 282 // Finalize any watch time metrics before destroying the pipeline. | 280 // Finalize any watch time metrics before destroying the pipeline. |
| 283 watch_time_reporter_.reset(); | 281 watch_time_reporter_.reset(); |
| 284 | 282 |
| 285 // Pipeline must be stopped before it is destroyed. | 283 // Pipeline must be stopped before it is destroyed. |
| 286 pipeline_.Stop(); | 284 pipeline_.Stop(); |
| 287 | 285 |
| 288 if (last_reported_memory_usage_) | 286 if (last_reported_memory_usage_) |
| 289 adjust_allocated_memory_cb_.Run(-last_reported_memory_usage_); | 287 adjust_allocated_memory_cb_.Run(-last_reported_memory_usage_); |
| 290 | 288 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 DVLOG(1) << __func__; | 419 DVLOG(1) << __func__; |
| 422 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 420 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 423 | 421 |
| 424 #if defined(OS_ANDROID) // WMPI_CAST | 422 #if defined(OS_ANDROID) // WMPI_CAST |
| 425 if (isRemote()) { | 423 if (isRemote()) { |
| 426 cast_impl_.play(); | 424 cast_impl_.play(); |
| 427 return; | 425 return; |
| 428 } | 426 } |
| 429 #endif | 427 #endif |
| 430 // TODO(sandersd): Do we want to reset the idle timer here? | 428 // TODO(sandersd): Do we want to reset the idle timer here? |
| 431 if (delegate_) | 429 delegate_->SetIdle(delegate_id_, false); |
| 432 delegate_->SetIdle(delegate_id_, false); | |
| 433 paused_ = false; | 430 paused_ = false; |
| 434 pipeline_.SetPlaybackRate(playback_rate_); | 431 pipeline_.SetPlaybackRate(playback_rate_); |
| 435 background_pause_timer_.Stop(); | 432 background_pause_timer_.Stop(); |
| 436 | 433 |
| 437 if (data_source_) | 434 if (data_source_) |
| 438 data_source_->MediaIsPlaying(); | 435 data_source_->MediaIsPlaying(); |
| 439 | 436 |
| 440 if (observer_) | 437 if (observer_) |
| 441 observer_->OnPlaying(); | 438 observer_->OnPlaying(); |
| 442 | 439 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 return; | 527 return; |
| 531 } | 528 } |
| 532 | 529 |
| 533 // Call this before setting |seeking_| so that the current media time can be | 530 // Call this before setting |seeking_| so that the current media time can be |
| 534 // recorded by the reporter. | 531 // recorded by the reporter. |
| 535 if (watch_time_reporter_) | 532 if (watch_time_reporter_) |
| 536 watch_time_reporter_->OnSeeking(); | 533 watch_time_reporter_->OnSeeking(); |
| 537 | 534 |
| 538 // TODO(sandersd): Move |seeking_| to PipelineController. | 535 // TODO(sandersd): Move |seeking_| to PipelineController. |
| 539 // TODO(sandersd): Do we want to reset the idle timer here? | 536 // TODO(sandersd): Do we want to reset the idle timer here? |
| 540 if (delegate_) | 537 delegate_->SetIdle(delegate_id_, false); |
| 541 delegate_->SetIdle(delegate_id_, false); | |
| 542 ended_ = false; | 538 ended_ = false; |
| 543 seeking_ = true; | 539 seeking_ = true; |
| 544 seek_time_ = time; | 540 seek_time_ = time; |
| 545 if (paused_) | 541 if (paused_) |
| 546 paused_time_ = time; | 542 paused_time_ = time; |
| 547 pipeline_controller_.Seek(time, time_updated); | 543 pipeline_controller_.Seek(time, time_updated); |
| 548 | 544 |
| 549 // This needs to be called after Seek() so that if a resume is triggered, it | 545 // This needs to be called after Seek() so that if a resume is triggered, it |
| 550 // is to the correct time. | 546 // is to the correct time. |
| 551 UpdatePlayState(); | 547 UpdatePlayState(); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 highest_ready_state_ < ReadyState::ReadyStateHaveFutureData) { | 847 highest_ready_state_ < ReadyState::ReadyStateHaveFutureData) { |
| 852 // Reset the preroll attempt clock. | 848 // Reset the preroll attempt clock. |
| 853 preroll_attempt_pending_ = true; | 849 preroll_attempt_pending_ = true; |
| 854 preroll_attempt_start_time_ = base::TimeTicks(); | 850 preroll_attempt_start_time_ = base::TimeTicks(); |
| 855 | 851 |
| 856 // Clear any 'stale' flag and give the pipeline a chance to resume. If we | 852 // Clear any 'stale' flag and give the pipeline a chance to resume. If we |
| 857 // are already resumed, this will cause |preroll_attempt_start_time_| to be | 853 // are already resumed, this will cause |preroll_attempt_start_time_| to be |
| 858 // set. | 854 // set. |
| 859 // TODO(sandersd): Should this be on the same stack? It might be surprising | 855 // TODO(sandersd): Should this be on the same stack? It might be surprising |
| 860 // that didLoadingProgress() can synchronously change state. | 856 // that didLoadingProgress() can synchronously change state. |
| 861 if (delegate_) | 857 delegate_->ClearStaleFlag(delegate_id_); |
| 862 delegate_->ClearStaleFlag(delegate_id_); | |
| 863 UpdatePlayState(); | 858 UpdatePlayState(); |
| 864 } | 859 } |
| 865 | 860 |
| 866 return did_loading_progress; | 861 return did_loading_progress; |
| 867 } | 862 } |
| 868 | 863 |
| 869 void WebMediaPlayerImpl::paint(blink::WebCanvas* canvas, | 864 void WebMediaPlayerImpl::paint(blink::WebCanvas* canvas, |
| 870 const blink::WebRect& rect, | 865 const blink::WebRect& rect, |
| 871 SkPaint& paint) { | 866 SkPaint& paint) { |
| 872 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 867 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 EnableVideoTrackIfNeeded(); | 1450 EnableVideoTrackIfNeeded(); |
| 1456 | 1451 |
| 1457 UpdatePlayState(); | 1452 UpdatePlayState(); |
| 1458 } | 1453 } |
| 1459 | 1454 |
| 1460 void WebMediaPlayerImpl::OnIdleTimeout() { | 1455 void WebMediaPlayerImpl::OnIdleTimeout() { |
| 1461 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1456 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 1462 | 1457 |
| 1463 // If we are attempting preroll, clear the stale flag. | 1458 // If we are attempting preroll, clear the stale flag. |
| 1464 if (IsPrerollAttemptNeeded()) { | 1459 if (IsPrerollAttemptNeeded()) { |
| 1465 if (delegate_) | 1460 delegate_->ClearStaleFlag(delegate_id_); |
| 1466 delegate_->ClearStaleFlag(delegate_id_); | |
| 1467 return; | 1461 return; |
| 1468 } | 1462 } |
| 1469 | 1463 |
| 1470 UpdatePlayState(); | 1464 UpdatePlayState(); |
| 1471 } | 1465 } |
| 1472 | 1466 |
| 1473 void WebMediaPlayerImpl::OnPlay() { | 1467 void WebMediaPlayerImpl::OnPlay() { |
| 1474 play(); | 1468 play(); |
| 1475 client_->playbackStateChanged(); | 1469 client_->playbackStateChanged(); |
| 1476 } | 1470 } |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1804 bool is_backgrounded = IsBackgroundedSuspendEnabled() && IsHidden(); | 1798 bool is_backgrounded = IsBackgroundedSuspendEnabled() && IsHidden(); |
| 1805 PlayState state = UpdatePlayState_ComputePlayState( | 1799 PlayState state = UpdatePlayState_ComputePlayState( |
| 1806 is_remote, is_streaming, is_suspended, is_backgrounded); | 1800 is_remote, is_streaming, is_suspended, is_backgrounded); |
| 1807 SetDelegateState(state.delegate_state, state.is_idle); | 1801 SetDelegateState(state.delegate_state, state.is_idle); |
| 1808 SetMemoryReportingState(state.is_memory_reporting_enabled); | 1802 SetMemoryReportingState(state.is_memory_reporting_enabled); |
| 1809 SetSuspendState(state.is_suspended || pending_suspend_resume_cycle_); | 1803 SetSuspendState(state.is_suspended || pending_suspend_resume_cycle_); |
| 1810 } | 1804 } |
| 1811 | 1805 |
| 1812 void WebMediaPlayerImpl::SetDelegateState(DelegateState new_state, | 1806 void WebMediaPlayerImpl::SetDelegateState(DelegateState new_state, |
| 1813 bool is_idle) { | 1807 bool is_idle) { |
| 1814 if (!delegate_) | 1808 DCHECK(delegate_); |
| 1815 return; | |
| 1816 | 1809 |
| 1817 // Prevent duplicate delegate calls. | 1810 // Prevent duplicate delegate calls. |
| 1818 // TODO(sandersd): Move this deduplication into the delegate itself. | 1811 // TODO(sandersd): Move this deduplication into the delegate itself. |
| 1819 // TODO(sandersd): WebContentsObserverSanityChecker does not allow sending the | 1812 // TODO(sandersd): WebContentsObserverSanityChecker does not allow sending the |
| 1820 // 'playing' IPC more than once in a row, even if the metadata has changed. | 1813 // 'playing' IPC more than once in a row, even if the metadata has changed. |
| 1821 // Figure out whether it should. | 1814 // Figure out whether it should. |
| 1822 bool has_audio = hasAudio() && !client_->isAutoplayingMuted(); | 1815 bool has_audio = hasAudio() && !client_->isAutoplayingMuted(); |
| 1823 if (delegate_state_ == new_state && | 1816 if (delegate_state_ == new_state && |
| 1824 (delegate_state_ != DelegateState::PLAYING || | 1817 (delegate_state_ != DelegateState::PLAYING || |
| 1825 delegate_has_audio_ == has_audio)) { | 1818 delegate_has_audio_ == has_audio)) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1907 } | 1900 } |
| 1908 } | 1901 } |
| 1909 | 1902 |
| 1910 WebMediaPlayerImpl::PlayState | 1903 WebMediaPlayerImpl::PlayState |
| 1911 WebMediaPlayerImpl::UpdatePlayState_ComputePlayState(bool is_remote, | 1904 WebMediaPlayerImpl::UpdatePlayState_ComputePlayState(bool is_remote, |
| 1912 bool is_streaming, | 1905 bool is_streaming, |
| 1913 bool is_suspended, | 1906 bool is_suspended, |
| 1914 bool is_backgrounded) { | 1907 bool is_backgrounded) { |
| 1915 PlayState result; | 1908 PlayState result; |
| 1916 | 1909 |
| 1917 bool must_suspend = delegate_ && delegate_->IsFrameClosed(); | 1910 bool must_suspend = delegate_->IsFrameClosed(); |
| 1918 bool is_stale = delegate_ && delegate_->IsStale(delegate_id_); | 1911 bool is_stale = delegate_->IsStale(delegate_id_); |
| 1919 | 1912 |
| 1920 // This includes both data source (before pipeline startup) and pipeline | 1913 // This includes both data source (before pipeline startup) and pipeline |
| 1921 // errors. | 1914 // errors. |
| 1922 bool has_error = IsNetworkStateError(network_state_); | 1915 bool has_error = IsNetworkStateError(network_state_); |
| 1923 | 1916 |
| 1924 // After HaveMetadata, we know which tracks are present and the duration. | 1917 // After HaveMetadata, we know which tracks are present and the duration. |
| 1925 bool have_metadata = ready_state_ >= WebMediaPlayer::ReadyStateHaveMetadata; | 1918 bool have_metadata = ready_state_ >= WebMediaPlayer::ReadyStateHaveMetadata; |
| 1926 | 1919 |
| 1927 // After HaveFutureData, Blink will call play() if the state is not paused; | 1920 // After HaveFutureData, Blink will call play() if the state is not paused; |
| 1928 // prior to this point |paused_| is not accurate. | 1921 // prior to this point |paused_| is not accurate. |
| 1929 bool have_future_data = | 1922 bool have_future_data = |
| 1930 highest_ready_state_ >= WebMediaPlayer::ReadyStateHaveFutureData; | 1923 highest_ready_state_ >= WebMediaPlayer::ReadyStateHaveFutureData; |
| 1931 | 1924 |
| 1932 // Background suspend is not enabled for audio-only players unless paused, | 1925 // Background suspend is not enabled for audio-only players unless paused, |
| 1933 // though in the case of audio-only the session should be kept. | 1926 // though in the case of audio-only the session should be kept. |
| 1934 // Videos are not suspended if the user resumed the playback via the remote | 1927 // Videos are not suspended if the user resumed the playback via the remote |
| 1935 // controls earlier and it's still playing. | 1928 // controls earlier and it's still playing. |
| 1936 bool is_backgrounded_video = is_backgrounded && have_metadata && hasVideo(); | 1929 bool is_backgrounded_video = is_backgrounded && have_metadata && hasVideo(); |
| 1937 bool can_play_backgrounded = is_backgrounded_video && !is_remote && | 1930 bool can_play_backgrounded = is_backgrounded_video && !is_remote && |
| 1938 hasAudio() && IsResumeBackgroundVideosEnabled(); | 1931 hasAudio() && IsResumeBackgroundVideosEnabled(); |
| 1939 bool is_background_playing = | 1932 bool is_background_playing = delegate_->IsBackgroundVideoPlaybackUnlocked(); |
| 1940 delegate_ && delegate_->IsBackgroundVideoPlaybackUnlocked(); | |
| 1941 bool background_suspended = !is_streaming && is_backgrounded_video && | 1933 bool background_suspended = !is_streaming && is_backgrounded_video && |
| 1942 !(can_play_backgrounded && is_background_playing); | 1934 !(can_play_backgrounded && is_background_playing); |
| 1943 bool background_pause_suspended = | 1935 bool background_pause_suspended = |
| 1944 !is_streaming && is_backgrounded && paused_ && have_future_data; | 1936 !is_streaming && is_backgrounded && paused_ && have_future_data; |
| 1945 | 1937 |
| 1946 // Idle suspension is allowed prior to have future data since there exist | 1938 // Idle suspension is allowed prior to have future data since there exist |
| 1947 // mechanisms to exit the idle state when the player is capable of reaching | 1939 // mechanisms to exit the idle state when the player is capable of reaching |
| 1948 // the have future data state; see didLoadingProgress(). | 1940 // the have future data state; see didLoadingProgress(). |
| 1949 // | 1941 // |
| 1950 // TODO(sandersd): Make the delegate suspend idle players immediately when | 1942 // TODO(sandersd): Make the delegate suspend idle players immediately when |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1988 // |has_session_suspended| means the player is suspended from the media | 1980 // |has_session_suspended| means the player is suspended from the media |
| 1989 // element point of view but paused and can be resumed from the delegate point | 1981 // element point of view but paused and can be resumed from the delegate point |
| 1990 // of view. Therefore it behaves like |paused_| for the delegate. | 1982 // of view. Therefore it behaves like |paused_| for the delegate. |
| 1991 bool has_session_suspended = can_play && !must_suspend && | 1983 bool has_session_suspended = can_play && !must_suspend && |
| 1992 background_suspended && can_play_backgrounded; | 1984 background_suspended && can_play_backgrounded; |
| 1993 | 1985 |
| 1994 bool has_session = has_session_playing || has_session_suspended; | 1986 bool has_session = has_session_playing || has_session_suspended; |
| 1995 | 1987 |
| 1996 if (!has_session) { | 1988 if (!has_session) { |
| 1997 result.delegate_state = DelegateState::GONE; | 1989 result.delegate_state = DelegateState::GONE; |
| 1998 result.is_idle = delegate_ && delegate_->IsIdle(delegate_id_); | 1990 result.is_idle = delegate_->IsIdle(delegate_id_); |
| 1999 } else if (paused_ || has_session_suspended) { | 1991 } else if (paused_ || has_session_suspended) { |
| 2000 // TODO(sandersd): Is it possible to have a suspended session, be ended, | 1992 // TODO(sandersd): Is it possible to have a suspended session, be ended, |
| 2001 // and not be paused? If so we should be in a PLAYING state. | 1993 // and not be paused? If so we should be in a PLAYING state. |
| 2002 result.delegate_state = | 1994 result.delegate_state = |
| 2003 ended_ ? DelegateState::GONE : DelegateState::PAUSED; | 1995 ended_ ? DelegateState::GONE : DelegateState::PAUSED; |
| 2004 result.is_idle = !seeking_; | 1996 result.is_idle = !seeking_; |
| 2005 } else { | 1997 } else { |
| 2006 result.delegate_state = DelegateState::PLAYING; | 1998 result.delegate_state = DelegateState::PLAYING; |
| 2007 result.is_idle = false; | 1999 result.is_idle = false; |
| 2008 } | 2000 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2089 this, &WebMediaPlayerImpl::OnPause); | 2081 this, &WebMediaPlayerImpl::OnPause); |
| 2090 } | 2082 } |
| 2091 | 2083 |
| 2092 void WebMediaPlayerImpl::CreateWatchTimeReporter() { | 2084 void WebMediaPlayerImpl::CreateWatchTimeReporter() { |
| 2093 // Create the watch time reporter and synchronize its initial state. | 2085 // Create the watch time reporter and synchronize its initial state. |
| 2094 watch_time_reporter_.reset(new WatchTimeReporter( | 2086 watch_time_reporter_.reset(new WatchTimeReporter( |
| 2095 hasAudio(), hasVideo(), !!chunk_demuxer_, is_encrypted_, media_log_, | 2087 hasAudio(), hasVideo(), !!chunk_demuxer_, is_encrypted_, media_log_, |
| 2096 pipeline_metadata_.natural_size, | 2088 pipeline_metadata_.natural_size, |
| 2097 base::Bind(&GetCurrentTimeInternal, this))); | 2089 base::Bind(&GetCurrentTimeInternal, this))); |
| 2098 watch_time_reporter_->OnVolumeChange(volume_); | 2090 watch_time_reporter_->OnVolumeChange(volume_); |
| 2099 if (delegate_ && delegate_->IsFrameHidden()) | 2091 if (delegate_->IsFrameHidden()) |
| 2100 watch_time_reporter_->OnHidden(); | 2092 watch_time_reporter_->OnHidden(); |
| 2101 else | 2093 else |
| 2102 watch_time_reporter_->OnShown(); | 2094 watch_time_reporter_->OnShown(); |
| 2103 } | 2095 } |
| 2104 | 2096 |
| 2105 bool WebMediaPlayerImpl::IsHidden() const { | 2097 bool WebMediaPlayerImpl::IsHidden() const { |
| 2106 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 2098 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 2107 | 2099 |
| 2108 return delegate_ && delegate_->IsFrameHidden() && !delegate_->IsFrameClosed(); | 2100 return delegate_->IsFrameHidden() && !delegate_->IsFrameClosed(); |
| 2109 } | 2101 } |
| 2110 | 2102 |
| 2111 bool WebMediaPlayerImpl::IsStreaming() const { | 2103 bool WebMediaPlayerImpl::IsStreaming() const { |
| 2112 return data_source_ && data_source_->IsStreaming(); | 2104 return data_source_ && data_source_->IsStreaming(); |
| 2113 } | 2105 } |
| 2114 | 2106 |
| 2115 bool WebMediaPlayerImpl::DoesOverlaySupportMetadata() const { | 2107 bool WebMediaPlayerImpl::DoesOverlaySupportMetadata() const { |
| 2116 return pipeline_metadata_.video_rotation == VIDEO_ROTATION_0; | 2108 return pipeline_metadata_.video_rotation == VIDEO_ROTATION_0; |
| 2117 } | 2109 } |
| 2118 | 2110 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2185 pipeline_statistics_for_test_ = base::make_optional(stats); | 2177 pipeline_statistics_for_test_ = base::make_optional(stats); |
| 2186 } | 2178 } |
| 2187 | 2179 |
| 2188 PipelineStatistics WebMediaPlayerImpl::GetPipelineStatistics() const { | 2180 PipelineStatistics WebMediaPlayerImpl::GetPipelineStatistics() const { |
| 2189 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 2181 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 2190 | 2182 |
| 2191 return pipeline_statistics_for_test_.value_or(pipeline_.GetStatistics()); | 2183 return pipeline_statistics_for_test_.value_or(pipeline_.GetStatistics()); |
| 2192 } | 2184 } |
| 2193 | 2185 |
| 2194 } // namespace media | 2186 } // namespace media |
| OLD | NEW |