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

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

Issue 2389473002: Media Remoting: Add RemotingController. (Closed)
Patch Set: Rebased. 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
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | 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 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 surface_created_cb_.Cancel(); 328 surface_created_cb_.Cancel();
328 overlay_surface_id_ = SurfaceManager::kNoSurfaceID; 329 overlay_surface_id_ = SurfaceManager::kNoSurfaceID;
329 330
330 if (decoder_requires_restart_for_overlay_) 331 if (decoder_requires_restart_for_overlay_)
331 ScheduleRestart(); 332 ScheduleRestart();
332 } 333 }
333 334
334 void WebMediaPlayerImpl::enteredFullscreen() { 335 void WebMediaPlayerImpl::enteredFullscreen() {
335 if (!force_video_overlays_ && !disable_fullscreen_video_overlays_) 336 if (!force_video_overlays_ && !disable_fullscreen_video_overlays_)
336 EnableOverlay(); 337 EnableOverlay();
338 if (observer_)
339 observer_->OnEnteredFullscreen();
337 } 340 }
338 341
339 void WebMediaPlayerImpl::exitedFullscreen() { 342 void WebMediaPlayerImpl::exitedFullscreen() {
340 if (!force_video_overlays_ && !disable_fullscreen_video_overlays_) 343 if (!force_video_overlays_ && !disable_fullscreen_video_overlays_)
341 DisableOverlay(); 344 DisableOverlay();
345 if (observer_)
346 observer_->OnExitedFullscreen();
342 } 347 }
343 348
344 void WebMediaPlayerImpl::DoLoad(LoadType load_type, 349 void WebMediaPlayerImpl::DoLoad(LoadType load_type,
345 const blink::WebURL& url, 350 const blink::WebURL& url,
346 CORSMode cors_mode) { 351 CORSMode cors_mode) {
347 DVLOG(1) << __func__; 352 DVLOG(1) << __func__;
348 DCHECK(main_task_runner_->BelongsToCurrentThread()); 353 DCHECK(main_task_runner_->BelongsToCurrentThread());
349 354
350 GURL gurl(url); 355 GURL gurl(url);
351 ReportMetrics(load_type, gurl, frame_->getSecurityOrigin()); 356 ReportMetrics(load_type, gurl, frame_->getSecurityOrigin());
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 OnCdmAttached(false); 957 OnCdmAttached(false);
953 return; 958 return;
954 } 959 }
955 960
956 CdmContext* cdm_context = cdm_reference->GetCdmContext(); 961 CdmContext* cdm_context = cdm_reference->GetCdmContext();
957 if (!cdm_context) { 962 if (!cdm_context) {
958 OnCdmAttached(false); 963 OnCdmAttached(false);
959 return; 964 return;
960 } 965 }
961 966
967 if (observer_)
968 observer_->OnSetCdm(cdm_context);
969
962 // Keep the reference to the CDM, as it shouldn't be destroyed until 970 // Keep the reference to the CDM, as it shouldn't be destroyed until
963 // after the pipeline is done with the |cdm_context|. 971 // after the pipeline is done with the |cdm_context|.
964 pending_cdm_ = std::move(cdm_reference); 972 pending_cdm_ = std::move(cdm_reference);
965 pipeline_.SetCdm(cdm_context, 973 pipeline_.SetCdm(cdm_context,
966 base::Bind(&WebMediaPlayerImpl::OnCdmAttached, AsWeakPtr())); 974 base::Bind(&WebMediaPlayerImpl::OnCdmAttached, AsWeakPtr()));
967 } 975 }
968 976
969 void WebMediaPlayerImpl::OnCdmAttached(bool success) { 977 void WebMediaPlayerImpl::OnCdmAttached(bool success) {
970 DCHECK(main_task_runner_->BelongsToCurrentThread()); 978 DCHECK(main_task_runner_->BelongsToCurrentThread());
971 DCHECK(pending_cdm_); 979 DCHECK(pending_cdm_);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); 1113 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size);
1106 1114
1107 DCHECK(!video_weblayer_); 1115 DCHECK(!video_weblayer_);
1108 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( 1116 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create(
1109 compositor_, pipeline_metadata_.video_rotation))); 1117 compositor_, pipeline_metadata_.video_rotation)));
1110 video_weblayer_->layer()->SetContentsOpaque(opaque_); 1118 video_weblayer_->layer()->SetContentsOpaque(opaque_);
1111 video_weblayer_->SetContentsOpaqueIsFixed(true); 1119 video_weblayer_->SetContentsOpaqueIsFixed(true);
1112 client_->setWebLayer(video_weblayer_.get()); 1120 client_->setWebLayer(video_weblayer_.get());
1113 } 1121 }
1114 1122
1123 if (observer_)
1124 observer_->OnMetadataChanged(metadata);
1125
1115 CreateWatchTimeReporter(); 1126 CreateWatchTimeReporter();
1116 UpdatePlayState(); 1127 UpdatePlayState();
1117 } 1128 }
1118 1129
1119 void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) { 1130 void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) {
1120 DVLOG(1) << __func__ << "(" << state << ")"; 1131 DVLOG(1) << __func__ << "(" << state << ")";
1121 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1132 DCHECK(main_task_runner_->BelongsToCurrentThread());
1122 1133
1123 // Ignore buffering state changes until we've completed all outstanding 1134 // Ignore buffering state changes until we've completed all outstanding
1124 // operations. 1135 // operations.
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
1836 pipeline_metadata_.natural_size, 1847 pipeline_metadata_.natural_size,
1837 base::Bind(&GetCurrentTimeInternal, this))); 1848 base::Bind(&GetCurrentTimeInternal, this)));
1838 watch_time_reporter_->OnVolumeChange(volume_); 1849 watch_time_reporter_->OnVolumeChange(volume_);
1839 if (delegate_ && delegate_->IsHidden()) 1850 if (delegate_ && delegate_->IsHidden())
1840 watch_time_reporter_->OnHidden(); 1851 watch_time_reporter_->OnHidden();
1841 else 1852 else
1842 watch_time_reporter_->OnShown(); 1853 watch_time_reporter_->OnShown();
1843 } 1854 }
1844 1855
1845 } // namespace media 1856 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | media/blink/webmediaplayer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698