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

Unified Diff: media/remoting/remoting_controller.h

Issue 2389473002: Media Remoting: Add RemotingController. (Closed)
Patch Set: Fix bug on Android. 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 side-by-side diff with in-line comments
Download patch
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..6d85d0a7567abc9e18cadba4e8f1cd9dff3f928b
--- /dev/null
+++ b/media/remoting/remoting_controller.h
@@ -0,0 +1,98 @@
+// 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/media_observer.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) 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 {
+ public:
+ explicit RemotingController(mojom::RemotingSourceRequest source_request,
+ mojom::RemoterPtr remoter);
xhwang 2016/10/04 06:30:30 no need for "explicit" now
xjz 2016/10/04 19:21:29 Done.
+ ~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;
+
+ // MediaObserver implementation.
xhwang 2016/10/04 06:30:30 nit: You use "implementations" above but use "impl
xjz 2016/10/04 19:21:30 Done.
+ // 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 OnMetadata(const PipelineMetadata& metadata) override;
+
+ using SwitchRendererCallback = base::Callback<void()>;
+ void SetSwitchRenderCallback(const SwitchRendererCallback& cb);
xhwang 2016/10/04 06:30:30 nit: It should be SetSwitchRendererCallback
xjz 2016/10/04 19:21:29 Done.
+
+ // Tells which renderer should be used.
+ bool is_remoting() const {
+ DCHECK(task_runner_->BelongsToCurrentThread());
+ return is_remoting_;
+ }
+
+ base::WeakPtr<RemotingController> GetWeakPtr() {
+ return weak_factory_.GetWeakPtr();
+ }
+
+ private:
+ bool IsVideoConfigSupported();
+ bool IsAudioConfigSupported();
+
+ // Determines whether to enter or leave Remoting mode and switches if
+ // necessary.
+ void UpdateAndMaybeSwitch();
+
+ // 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 remoting is started.
+ bool is_remoting_;
+
+ // Current audio/video config.
+ VideoDecoderConfig video_decoder_config_;
+ AudioDecoderConfig audio_decoder_config_;
+ bool has_audio_;
+ bool has_video_;
+
+ // The callback to switch the media renderer.
+ SwitchRendererCallback switch_renderer_cb_;
+
+ mojo::Binding<mojom::RemotingSource> binding_;
+ mojom::RemoterPtr remoter_;
+
+ const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
xhwang 2016/10/04 06:30:30 forward declare base::SingleThreadTaskRunner?
xjz 2016/10/04 19:21:30 Done.
+
+ base::WeakPtrFactory<RemotingController> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(RemotingController);
+};
+
+} // namespace media
+
+#endif // MEDIA_REMOTING_REMOTING_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698