Index: media/remoting/remoting_controller.h |
diff --git a/media/remoting/remoting_controller.h b/media/remoting/remoting_controller.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..711e448eb8b766b5dea3089743098c4b2864321f |
--- /dev/null |
+++ b/media/remoting/remoting_controller.h |
@@ -0,0 +1,81 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef MEDIA_REMOTING_REMOTING_CONTROLLER_H_ |
+#define MEDIA_REMOTING_REMOTING_CONTROLLER_H_ |
+ |
+#include "base/callback.h" |
+#include "base/memory/weak_ptr.h" |
+#include "media/base/renderer_controller.h" |
+#include "media/mojo/interfaces/remoting.mojom.h" |
+#include "mojo/public/cpp/bindings/binding.h" |
+ |
+// This class does the following: |
+// 1) Sends/Receives messages from/to Remoter; |
+// 2) Gets info from media::WebMediaPlayerImpl; |
miu
2016/09/28 01:33:32
s/media::WebMediaPlayerImpl/media::MediaPlayer/
xjz
2016/09/29 22:54:22
Not applicable.
|
+// 3) May trigger the switch of the media renderer between local playback |
+// and remoting. |
+// |
+namespace media { |
+ |
+class MEDIA_EXPORT RemotingController final : public RendererController, |
+ public mojom::RemotingSource { |
+ public: |
+ explicit RemotingController(mojom::RemoterFactory* remoter_factory); |
+ ~RemotingController() override; |
+ |
+ // RemotingSource implementations. |
+ void OnSinkAvailable() override; |
+ void OnSinkGone() override; |
+ void OnStarted() override; |
+ void OnStartFailed(mojom::RemotingStartFailReason reason) override; |
+ void OnMessageFromSink(const std::vector<uint8_t>& message) override; |
+ void OnStopped(mojom::RemotingStopReason reson) override; |
+ |
+ // RendererController implementation. |
+ void OnEnteredFullscreen() override; |
+ void OnExitedFullscreen() override; |
+ void OnSetCdm(CdmContext* cdm_context) override; |
+ void OnSetDecoderConfig(const AudioDecoderConfig& audio_config, |
+ const VideoDecoderConfig& video_config) override; |
+ void SetSwitchRenderCallback( |
+ const RendererController::SwitchRendererCallback& cb) override; |
+ |
+ // Tells which renderer should be used. |
+ bool ShouldUseRemotingRenderer(); |
+ |
+ private: |
+ bool isVideoConfigSupported(); |
+ bool isAudioConfigSupported(); |
+ |
+ // Re-calculates |use_remoting_renderer_|. |
miu
2016/09/28 01:33:32
Suggestion: // Determines whether to enter or leav
xjz
2016/09/29 22:54:22
Done.
|
+ void Update(); |
+ |
+ // Indicates if this media element or its ancestor enters full screen. |
+ bool is_fullscreen_; |
+ |
+ // Indicates the remoting sink availablity. |
+ bool is_sink_available_; |
+ |
+ // Indicates if we should use remoting renderer. |
+ bool use_remoting_renderer_; |
miu
2016/09/28 01:33:32
naming: Looked at everywhere this is being used. I
xjz
2016/09/29 22:54:22
Renamed "is_remoting_".
|
+ |
+ // Current audio/video config. |
+ VideoDecoderConfig video_decoder_config_; |
+ AudioDecoderConfig audio_decoder_config_; |
+ |
+ // The callback to switch the media renderer. |
+ RendererController::SwitchRendererCallback switch_renderer_cb_; |
+ |
+ mojo::Binding<mojom::RemotingSource> binding_; |
+ mojom::RemoterPtr remoter_; |
+ |
+ const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(RemotingController); |
+}; |
+ |
+} // namespace media |
+ |
+#endif // MEDIA_REMOTING_REMOTING_CONTROLLER_H_ |