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

Unified Diff: media/blink/webmediaplayer_impl.cc

Issue 2204673004: WIP - WebMediaPlayer switch media renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add switching of CdmFactory. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: media/blink/webmediaplayer_impl.cc
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc
index 0b76251098e5f95c5021d7f3586a3a9f60e17ea1..2dba1773b8594bc6466e91ca45b0e80c88c848b3 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -207,7 +207,11 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
surface_manager_(params.surface_manager()),
overlay_surface_id_(SurfaceManager::kNoSurfaceID),
suppress_destruction_errors_(false),
- can_suspend_state_(CanSuspendState::UNKNOWN) {
+ can_suspend_state_(CanSuspendState::UNKNOWN),
+ is_media_remoting_(false),
+ is_remote_sink_available_(false),
+ is_encrypted_content_(false),
+ is_remote_cdm_cb_(params.is_remote_cdm_cb()) {
DCHECK(!adjust_allocated_memory_cb_.is_null());
DCHECK(renderer_factory_);
DCHECK(client_);
@@ -311,11 +315,13 @@ void WebMediaPlayerImpl::DisableOverlay() {
void WebMediaPlayerImpl::enteredFullscreen() {
if (!force_video_overlays_)
EnableOverlay();
+ videoEnteredFullscreen();
}
void WebMediaPlayerImpl::exitedFullscreen() {
if (!force_video_overlays_)
DisableOverlay();
+ videoExitedFullscreen();
}
void WebMediaPlayerImpl::DoLoad(LoadType load_type,
@@ -864,6 +870,16 @@ void WebMediaPlayerImpl::OnEncryptedMediaInitData(
// TODO(xhwang): Update this UMA name. https://crbug.com/589251
UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1);
+ is_encrypted_content_ = true;
+ // Check whether we can switch to remoting for encrypted video. Once switching
+ // happens, it is not able to switch back to local media renderer without
+ // refreshing the page.
+ if (is_remote_sink_available_ && !is_media_remoting_ &&
+ !is_remote_cdm_cb_.is_null() && is_remote_cdm_cb_.Run()) {
+ is_media_remoting_ = true;
+ SwitchMediaRenderer();
+ }
+
encrypted_client_->encrypted(
ConvertToWebInitDataType(init_data_type), init_data.data(),
base::saturated_cast<unsigned int>(init_data.size()));
@@ -1725,4 +1741,45 @@ void WebMediaPlayerImpl::ScheduleIdlePauseTimer() {
this, &WebMediaPlayerImpl::OnPause);
}
+void WebMediaPlayerImpl::videoEnteredFullscreen() {
+ if (is_encrypted_content_ || is_media_remoting_ || !is_remote_sink_available_)
+ return;
+
+ is_media_remoting_ = true;
+ SwitchMediaRenderer();
+}
+
+void WebMediaPlayerImpl::videoExitedFullscreen() {
+ if (is_encrypted_content_ || !is_media_remoting_)
+ return;
+
+ is_media_remoting_ = false;
+ SwitchMediaRenderer();
+}
+
+void WebMediaPlayerImpl::OnSinkAvailable() {
liberato (no reviews please) 2016/08/29 16:49:12 would it be clearer if these things were pulled ou
xjz 2016/09/09 23:13:06 Yes. Done.
+ is_remote_sink_available_ = true;
+}
+
+void WebMediaPlayerImpl::OnSinkGone() {
+ is_remote_sink_available_ = false;
+ if (is_media_remoting_) {
+ is_media_remoting_ = false;
+ if (!is_encrypted_content_) {
+ SwitchMediaRenderer();
+ } else {
+ // TODO(xjz): Need to tell the user to refresh the page.
+ }
+ }
+}
+
+// Switch media renderer between local playing back and remoting media renderer
liberato (no reviews please) 2016/08/29 16:49:12 please move this to the .h (good comment, by the w
xjz 2016/09/09 23:13:06 Done.
+// according to |is_media_remoting_|.
+// Note: Always set |is_media_remoting_| accordingly before calling this method.
+void WebMediaPlayerImpl::SwitchMediaRenderer() {
liberato (no reviews please) 2016/08/29 16:49:12 maybe take the new value of is_media_remoting_ as
xjz 2016/09/09 23:13:06 Done.
+ VLOG(2) << "Switch to: " << (is_media_remoting_ ? "Remoting" : "Local");
+ pipeline_controller_.Suspend();
+ pipeline_controller_.Resume();
liberato (no reviews please) 2016/08/29 16:49:12 how does this switch to remote playback? is there
xjz 2016/09/09 23:13:06 Yes. The implementation will be in the upcoming CL
+}
+
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698