Create FlingingRenderer on RemotePlayback start

After successfully creating a CastSession via the presentation service,
we do not switch to using the FlingingRenderer.

This CL adds the signals to switch to/from using the FlingingRenderer.
This is done by asking WMPI to pick a new media::Renderer, by going
through a suspend/resume cycle. The RendererFactorySelector should
automatically choose the FlingingRendererClientFactory, based on the
fact that the RemotePlaybackClientWrapper has a valid presentation ID.

Bug: 790766
Change-Id: Ibab887c8a1791620ad1dcd92406c7ee618eec36d
Reviewed-on: https://chromium-review.googlesource.com/1043279
Reviewed-by: Dan Sanders <[email protected]>
Reviewed-by: Kent Tamura <[email protected]>
Commit-Queue: Thomas Guilbert <[email protected]>
Cr-Commit-Position: refs/heads/master@{#557016}
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc
index 254366a..8d22210 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -2124,6 +2124,29 @@
   client_->TimeChanged();
 }
 
+void WebMediaPlayerImpl::FlingingStarted() {
+  DCHECK(main_task_runner_->BelongsToCurrentThread());
+  DCHECK(!disable_pipeline_auto_suspend_);
+  disable_pipeline_auto_suspend_ = true;
+
+  // Capabilities reporting should only be performed for local playbacks.
+  video_decode_stats_reporter_.reset();
+
+  // Requests to restart media pipeline. A flinging renderer will be created via
+  // the |renderer_factory_selector_|.
+  ScheduleRestart();
+}
+
+void WebMediaPlayerImpl::FlingingStopped() {
+  DCHECK(main_task_runner_->BelongsToCurrentThread());
+  DCHECK(disable_pipeline_auto_suspend_);
+  disable_pipeline_auto_suspend_ = false;
+
+  CreateVideoDecodeStatsReporter();
+
+  ScheduleRestart();
+}
+
 void WebMediaPlayerImpl::OnDisconnectedFromRemoteDevice(double t) {
   DoSeek(base::TimeDelta::FromSecondsD(t), false);
 
@@ -3061,6 +3084,7 @@
 void WebMediaPlayerImpl::SwitchToRemoteRenderer(
     const std::string& remote_device_friendly_name) {
   DCHECK(main_task_runner_->BelongsToCurrentThread());
+  DCHECK(!disable_pipeline_auto_suspend_);
   disable_pipeline_auto_suspend_ = true;
 
   // Capabilities reporting should only be performed for local playbacks.
@@ -3078,6 +3102,7 @@
 void WebMediaPlayerImpl::SwitchToLocalRenderer(
     MediaObserverClient::ReasonToSwitchToLocal reason) {
   DCHECK(main_task_runner_->BelongsToCurrentThread());
+  DCHECK(disable_pipeline_auto_suspend_);
   disable_pipeline_auto_suspend_ = false;
 
   // Capabilities reporting may resume now that playback is local.