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

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

Issue 2389473002: Media Remoting: Add RemotingController. (Closed)
Patch Set: Use BUILDFLAG. Created 4 years, 2 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
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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 cast_impl_(this, client_, params.context_3d_cb()), 220 cast_impl_(this, client_, params.context_3d_cb()),
221 #endif 221 #endif
222 volume_(1.0), 222 volume_(1.0),
223 volume_multiplier_(1.0), 223 volume_multiplier_(1.0),
224 renderer_factory_(std::move(renderer_factory)), 224 renderer_factory_(std::move(renderer_factory)),
225 surface_manager_(params.surface_manager()), 225 surface_manager_(params.surface_manager()),
226 overlay_surface_id_(SurfaceManager::kNoSurfaceID), 226 overlay_surface_id_(SurfaceManager::kNoSurfaceID),
227 suppress_destruction_errors_(false), 227 suppress_destruction_errors_(false),
228 can_suspend_state_(CanSuspendState::UNKNOWN), 228 can_suspend_state_(CanSuspendState::UNKNOWN),
229 is_encrypted_(false), 229 is_encrypted_(false),
230 underflow_count_(0) { 230 underflow_count_(0),
231 observer_(params.media_observer()) {
231 DCHECK(!adjust_allocated_memory_cb_.is_null()); 232 DCHECK(!adjust_allocated_memory_cb_.is_null());
232 DCHECK(renderer_factory_); 233 DCHECK(renderer_factory_);
233 DCHECK(client_); 234 DCHECK(client_);
234 235
235 force_video_overlays_ = base::CommandLine::ForCurrentProcess()->HasSwitch( 236 force_video_overlays_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
236 switches::kForceVideoOverlays); 237 switches::kForceVideoOverlays);
237 238
238 disable_fullscreen_video_overlays_ = 239 disable_fullscreen_video_overlays_ =
239 !base::FeatureList::IsEnabled(media::kOverlayFullscreenVideo); 240 !base::FeatureList::IsEnabled(media::kOverlayFullscreenVideo);
240 241
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 surface_created_cb_.Cancel(); 331 surface_created_cb_.Cancel();
331 overlay_surface_id_ = SurfaceManager::kNoSurfaceID; 332 overlay_surface_id_ = SurfaceManager::kNoSurfaceID;
332 333
333 if (decoder_requires_restart_for_overlay_) 334 if (decoder_requires_restart_for_overlay_)
334 ScheduleRestart(); 335 ScheduleRestart();
335 } 336 }
336 337
337 void WebMediaPlayerImpl::enteredFullscreen() { 338 void WebMediaPlayerImpl::enteredFullscreen() {
338 if (!force_video_overlays_ && !disable_fullscreen_video_overlays_) 339 if (!force_video_overlays_ && !disable_fullscreen_video_overlays_)
339 EnableOverlay(); 340 EnableOverlay();
341 if (observer_)
342 observer_->OnEnteredFullscreen();
340 } 343 }
341 344
342 void WebMediaPlayerImpl::exitedFullscreen() { 345 void WebMediaPlayerImpl::exitedFullscreen() {
343 if (!force_video_overlays_ && !disable_fullscreen_video_overlays_) 346 if (!force_video_overlays_ && !disable_fullscreen_video_overlays_)
344 DisableOverlay(); 347 DisableOverlay();
348 if (observer_)
349 observer_->OnExitedFullscreen();
345 } 350 }
346 351
347 void WebMediaPlayerImpl::DoLoad(LoadType load_type, 352 void WebMediaPlayerImpl::DoLoad(LoadType load_type,
348 const blink::WebURL& url, 353 const blink::WebURL& url,
349 CORSMode cors_mode) { 354 CORSMode cors_mode) {
350 DVLOG(1) << __func__; 355 DVLOG(1) << __func__;
351 DCHECK(main_task_runner_->BelongsToCurrentThread()); 356 DCHECK(main_task_runner_->BelongsToCurrentThread());
352 357
353 GURL gurl(url); 358 GURL gurl(url);
354 ReportMetrics(load_type, gurl, frame_->getSecurityOrigin()); 359 ReportMetrics(load_type, gurl, frame_->getSecurityOrigin());
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 } 951 }
947 } 952 }
948 953
949 void WebMediaPlayerImpl::SetCdm(const CdmAttachedCB& cdm_attached_cb, 954 void WebMediaPlayerImpl::SetCdm(const CdmAttachedCB& cdm_attached_cb,
950 CdmContext* cdm_context) { 955 CdmContext* cdm_context) {
951 if (!cdm_context) { 956 if (!cdm_context) {
952 cdm_attached_cb.Run(false); 957 cdm_attached_cb.Run(false);
953 return; 958 return;
954 } 959 }
955 960
961 if (observer_)
962 observer_->OnSetCdm(cdm_context);
963
956 // If CDM initialization succeeded, tell the pipeline about it. 964 // If CDM initialization succeeded, tell the pipeline about it.
957 pipeline_.SetCdm(cdm_context, cdm_attached_cb); 965 pipeline_.SetCdm(cdm_context, cdm_attached_cb);
958 } 966 }
959 967
960 void WebMediaPlayerImpl::OnCdmAttached(bool success) { 968 void WebMediaPlayerImpl::OnCdmAttached(bool success) {
961 if (success) { 969 if (success) {
962 set_cdm_result_->complete(); 970 set_cdm_result_->complete();
963 set_cdm_result_.reset(); 971 set_cdm_result_.reset();
964 is_cdm_attached_ = true; 972 is_cdm_attached_ = true;
965 return; 973 return;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); 1092 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size);
1085 1093
1086 DCHECK(!video_weblayer_); 1094 DCHECK(!video_weblayer_);
1087 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( 1095 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create(
1088 compositor_, pipeline_metadata_.video_rotation))); 1096 compositor_, pipeline_metadata_.video_rotation)));
1089 video_weblayer_->layer()->SetContentsOpaque(opaque_); 1097 video_weblayer_->layer()->SetContentsOpaque(opaque_);
1090 video_weblayer_->SetContentsOpaqueIsFixed(true); 1098 video_weblayer_->SetContentsOpaqueIsFixed(true);
1091 client_->setWebLayer(video_weblayer_.get()); 1099 client_->setWebLayer(video_weblayer_.get());
1092 } 1100 }
1093 1101
1102 if (observer_)
1103 observer_->OnMetadata(metadata);
miu 2016/10/05 19:13:57 naming nit: OnMetadataChanged()
xjz 2016/10/05 23:39:02 Done.
1104
1094 CreateWatchTimeReporter(); 1105 CreateWatchTimeReporter();
1095 UpdatePlayState(); 1106 UpdatePlayState();
1096 } 1107 }
1097 1108
1098 void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) { 1109 void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) {
1099 DVLOG(1) << __func__ << "(" << state << ")"; 1110 DVLOG(1) << __func__ << "(" << state << ")";
1100 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1111 DCHECK(main_task_runner_->BelongsToCurrentThread());
1101 1112
1102 // Ignore buffering state changes until we've completed all outstanding 1113 // Ignore buffering state changes until we've completed all outstanding
1103 // operations. 1114 // operations.
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
1814 hasAudio(), hasVideo(), !!chunk_demuxer_, is_encrypted_, media_log_, 1825 hasAudio(), hasVideo(), !!chunk_demuxer_, is_encrypted_, media_log_,
1815 pipeline_metadata_.natural_size, 1826 pipeline_metadata_.natural_size,
1816 base::Bind(&GetCurrentTimeInternal, this))); 1827 base::Bind(&GetCurrentTimeInternal, this)));
1817 watch_time_reporter_->OnVolumeChange(volume_); 1828 watch_time_reporter_->OnVolumeChange(volume_);
1818 if (delegate_ && delegate_->IsHidden()) 1829 if (delegate_ && delegate_->IsHidden())
1819 watch_time_reporter_->OnHidden(); 1830 watch_time_reporter_->OnHidden();
1820 else 1831 else
1821 watch_time_reporter_->OnShown(); 1832 watch_time_reporter_->OnShown();
1822 } 1833 }
1823 1834
1835 void WebMediaPlayerImpl::ancestorEnteredFullscreen() {
1836 if (observer_)
1837 observer_->OnEnteredFullscreen();
1838 }
1839
1840 void WebMediaPlayerImpl::ancestorExitedFullscreen() {
1841 if (observer_)
1842 observer_->OnExitedFullscreen();
1843 }
1844
1824 } // namespace media 1845 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698