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

Unified Diff: media/remoting/remoting_controller.h

Issue 2204673004: WIP - WebMediaPlayer switch media renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments. Created 4 years, 3 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..6e9b776af20ee7c8a5be1153f86c1e16449c52f3
--- /dev/null
+++ b/media/remoting/remoting_controller.h
@@ -0,0 +1,82 @@
+// 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/mediaplayer_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) Gets info from media::WebMediaPlayerImpl;
miu 2016/09/30 08:12:10 For #2, WMPI is not known in media/remoting code.
xjz 2016/10/01 00:28:41 Done.
+// 3) May trigger the switch of the media renderer between local playback
+// and remoting.
+//
+namespace media {
+
+class MEDIA_EXPORT RemotingController final : public MediaPlayerObserver,
+ public mojom::RemotingSource {
+ public:
+ explicit RemotingController(mojom::RemoterFactory* remoter_factory);
miu 2016/09/30 08:12:10 This looks like you're injecting a RemoterFactory
xjz 2016/10/01 00:28:41 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 reson) override;
+
+ // MediaPlayerObserver implementation.
+ void OnEnteredFullscreen() override;
+ void OnExitedFullscreen() override;
+ void OnSetCdm(CdmContext* cdm_context) override;
+ void OnDecoderConfigChanged(const AudioDecoderConfig& audio_config,
+ const VideoDecoderConfig& video_config) override;
+ void SetSwitchRenderCallback(
+ const MediaPlayerObserver::SwitchRendererCallback& cb) override;
+
+ // Tells which renderer should be used.
+ bool is_remoting();
miu 2016/09/30 08:12:10 Simple accessors should be defined inline (and con
xjz 2016/10/01 00:28:41 Done.
+
+ private:
+ bool isVideoConfigSupported();
+ bool isAudioConfigSupported();
+
+ // Determines whether to enter or leave Remoting mode and switches if
+ // necessary.
+ 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 remoting is started.
+ bool is_remoting_;
+
+ // Current audio/video config.
+ VideoDecoderConfig video_decoder_config_;
+ AudioDecoderConfig audio_decoder_config_;
+
+ // The callback to switch the media renderer.
+ MediaPlayerObserver::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_

Powered by Google App Engine
This is Rietveld 408576698