Index: media/remoting/remoting_renderer_controller.h |
diff --git a/media/remoting/remoting_controller.h b/media/remoting/remoting_renderer_controller.h |
similarity index 38% |
rename from media/remoting/remoting_controller.h |
rename to media/remoting/remoting_renderer_controller.h |
index 01604d681da8677ce6cd6ff2e092a9bea3a451b3..3c7d561f79f0bf84085123b7f637a544c6defaf1 100644 |
--- a/media/remoting/remoting_controller.h |
+++ b/media/remoting/remoting_renderer_controller.h |
@@ -2,63 +2,59 @@ |
// 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_ |
+#ifndef MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_ |
+#define MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_ |
#include "base/callback.h" |
#include "base/memory/weak_ptr.h" |
#include "media/base/media_observer.h" |
-#include "media/mojo/interfaces/remoting.mojom.h" |
-#include "mojo/public/cpp/bindings/binding.h" |
+#include "media/remoting/remoting_source_impl.h" |
-namespace base { |
-class SingleThreadTaskRunner; |
+namespace media { |
+struct PipelineMetadata; |
} |
-// This class does the following: |
-// 1) Sends/Receives messages from/to Remoter; |
+namespace media { |
+ |
+// This class: |
+// 1) Implements the RemotingSourceImpl::Client; |
// 2) Monitors player events as a MediaObserver; |
// 3) May trigger the switch of the media renderer between local playback |
// and remoting. |
-// |
-namespace media { |
- |
-class RemotingController final : public MediaObserver, |
- public mojom::RemotingSource { |
+class RemotingRendererController final : public RemotingSourceImpl::Client, |
+ public MediaObserver { |
public: |
- RemotingController(mojom::RemotingSourceRequest source_request, |
- mojom::RemoterPtr remoter); |
- ~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 reason) override; |
+ explicit RemotingRendererController( |
+ scoped_refptr<RemotingSourceImpl> remoting_source); |
+ ~RemotingRendererController() override; |
+ |
+ // RemotingSourceImpl::Client implemenations. |
+ void OnStarted(bool success) override; |
+ void OnSessionStateChanged() override; |
// MediaObserver implementations. |
- // This is called when the video element or its ancestor enters full screen. |
- // We currently use this as an indicator for immersive playback. May add other |
- // criteria (e.g. the actual display width/height of the video element) in |
- // future. |
void OnEnteredFullscreen() override; |
void OnExitedFullscreen() override; |
void OnSetCdm(CdmContext* cdm_context) override; |
void OnMetadataChanged(const PipelineMetadata& metadata) override; |
- using SwitchRendererCallback = base::Callback<void()>; |
- void SetSwitchRendererCallback(const SwitchRendererCallback& cb); |
+ void SetSwitchRendererCallback(const base::Closure& cb); |
- // Tells which renderer should be used. |
- bool is_remoting() const { |
- DCHECK(task_runner_->BelongsToCurrentThread()); |
- return is_remoting_; |
+ base::WeakPtr<RemotingRendererController> GetWeakPtr() { |
+ return weak_factory_.GetWeakPtr(); |
} |
- base::WeakPtr<RemotingController> GetWeakPtr() { |
- return weak_factory_.GetWeakPtr(); |
+ // Used by RemotingRendererFactory to query whether to create Media Remoting |
+ // Renderer. |
+ bool remote_rendering_started() const { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ return remote_rendering_started_; |
+ } |
+ |
+ // Used by RemotingRendererImpl to query the session state. |
+ RemotingSourceImpl* remoting_source() const { |
xhwang
2016/11/01 08:21:29
ditto about passing raw pointer around...
xjz
2016/11/01 21:55:53
Please see my reply to the first comment on this.
|
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ return remoting_source_.get(); |
} |
private: |
@@ -72,14 +68,11 @@ class RemotingController final : public MediaObserver, |
// necessary. |
void UpdateAndMaybeSwitch(); |
- // Indicates if this media element or its ancestor enters full screen. |
+ // Indicates whether this media element or its ancestor is in full screen. |
bool is_fullscreen_ = false; |
- // Indicates the remoting sink availablity. |
- bool is_sink_available_ = false; |
- |
- // Indicates if remoting is started. |
- bool is_remoting_ = false; |
+ // Indicates whether remoting is started. |
+ bool remote_rendering_started_ = false; |
// Indicates whether audio or video is encrypted. |
bool is_encrypted_ = false; |
@@ -91,20 +84,21 @@ class RemotingController final : public MediaObserver, |
bool has_video_ = false; |
// The callback to switch the media renderer. |
- SwitchRendererCallback switch_renderer_cb_; |
+ base::Closure switch_renderer_cb_; |
- mojo::Binding<mojom::RemotingSource> binding_; |
- mojom::RemoterPtr remoter_; |
+ // This is initially the RemotingSourceImpl passed to the ctor, and might be |
+ // replaced with a different instance later if OnSetCdm() is called. |
+ scoped_refptr<RemotingSourceImpl> remoting_source_; |
- // TODO(xjz): Add a media thread task runner for the received RPC messages for |
- // remoting media renderer in the up-coming change. |
- const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
+ // This is used to check all the methods are called on the current thread in |
+ // debug builds. |
+ base::ThreadChecker thread_checker_; |
- base::WeakPtrFactory<RemotingController> weak_factory_; |
+ base::WeakPtrFactory<RemotingRendererController> weak_factory_; |
- DISALLOW_COPY_AND_ASSIGN(RemotingController); |
+ DISALLOW_COPY_AND_ASSIGN(RemotingRendererController); |
}; |
} // namespace media |
-#endif // MEDIA_REMOTING_REMOTING_CONTROLLER_H_ |
+#endif // MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_ |