summaryrefslogtreecommitdiff
path: root/chromium/media/remoting/receiver_controller.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/media/remoting/receiver_controller.h
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/media/remoting/receiver_controller.h')
-rw-r--r--chromium/media/remoting/receiver_controller.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/chromium/media/remoting/receiver_controller.h b/chromium/media/remoting/receiver_controller.h
new file mode 100644
index 00000000000..1071de2760a
--- /dev/null
+++ b/chromium/media/remoting/receiver_controller.h
@@ -0,0 +1,70 @@
+// Copyright 2020 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_RECEIVER_CONTROLLER_H_
+#define MEDIA_REMOTING_RECEIVER_CONTROLLER_H_
+
+#include <memory>
+
+#include "base/no_destructor.h"
+#include "media/mojo/mojom/remoting.mojom.h"
+#include "media/remoting/rpc_broker.h"
+#include "mojo/public/cpp/bindings/pending_remote.h"
+#include "mojo/public/cpp/bindings/receiver.h"
+#include "mojo/public/cpp/bindings/remote.h"
+
+namespace media {
+namespace remoting {
+
+// ReceiverController is the bridge that owns |rpc_broker_| to allow Receivers
+// and StreamProvider::MediaStreams to communicate with the sender via RPC
+// calls.
+//
+// It also forwards calls to a |media_remotee_| instance, which will be
+// implemented the browser process. Currently, the only use case will be on
+// Chromecast, the Remotee implementation will be implemented in the browser
+// code on Chromecast.
+//
+// NOTE: ReceiverController is a singleton per process.
+class ReceiverController : mojom::RemotingSink {
+ public:
+ static ReceiverController* GetInstance();
+ void Initialize(mojo::PendingRemote<mojom::Remotee> remotee);
+
+ // Proxy functions to |media_remotee_|.
+ void OnRendererFlush(uint32_t audio_count, uint32_t video_count);
+ void OnVideoNaturalSizeChange(const gfx::Size& size);
+ void StartDataStreams(
+ mojo::PendingRemote<mojom::RemotingDataStreamReceiver> audio_stream,
+ mojo::PendingRemote<mojom::RemotingDataStreamReceiver> video_stream);
+
+ // The reference of |rpc_broker_|.
+ media::remoting::RpcBroker* rpc_broker() { return &rpc_broker_; }
+
+ private:
+ friend base::NoDestructor<ReceiverController>;
+ friend class MockReceiverController;
+ friend void ResetForTesting(ReceiverController* controller);
+
+ ReceiverController();
+ ~ReceiverController() override;
+
+ // media::mojom::RemotingSink implementation.
+ void OnMessageFromSource(const std::vector<uint8_t>& message) override;
+
+ // Callback for |rpc_broker_| to send messages.
+ void OnSendRpc(std::unique_ptr<std::vector<uint8_t>> message);
+
+ RpcBroker rpc_broker_;
+
+ const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
+
+ mojo::Remote<media::mojom::Remotee> media_remotee_;
+ mojo::Receiver<media::mojom::RemotingSink> receiver_{this};
+};
+
+} // namespace remoting
+} // namespace media
+
+#endif // MEDIA_REMOTING_RECEIVER_CONTROLLER_H_