Commit cfb91d0d authored by Jordan Bayles's avatar Jordan Bayles Committed by Commit Bot

Remove MirrorServiceRemote, RemotingSource

Now that the mirroring service has launched, the deprecated
MirrorServiceRemoter and MirrorServiceRemotingSource interfaces can be
removed. This patch removes these interfaces and associated usages, and
adds a new failure reason for remoting start failures.

Bug: 1015486
Change-Id: I65f68487acc92afd45402b193be51225592c2cf2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2265456Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
Reviewed-by: default avatarMike Pinkerton <pinkerton@chromium.org>
Reviewed-by: default avatarBrandon Tolsch <btolsch@chromium.org>
Commit-Queue: Jordan Bayles <jophba@chromium.org>
Cr-Commit-Position: refs/heads/master@{#784525}
parent 294609cf
...@@ -2069,7 +2069,6 @@ static_library("browser") { ...@@ -2069,7 +2069,6 @@ static_library("browser") {
"//media/midi", "//media/midi",
"//media/mojo:buildflags", "//media/mojo:buildflags",
"//media/mojo/common", "//media/mojo/common",
"//media/mojo/mojom:mirror_service_remoting",
"//media/mojo/mojom:remoting", "//media/mojo/mojom:remoting",
"//media/mojo/services", "//media/mojo/services",
"//media/webrtc", "//media/webrtc",
......
...@@ -209,22 +209,6 @@ CastRemotingConnector::~CastRemotingConnector() { ...@@ -209,22 +209,6 @@ CastRemotingConnector::~CastRemotingConnector() {
} }
} }
void CastRemotingConnector::ConnectToService(
mojo::PendingReceiver<media::mojom::MirrorServiceRemotingSource>
source_receiver,
mojo::PendingRemote<media::mojom::MirrorServiceRemoter> remoter) {
DCHECK(!deprecated_remoter_);
DCHECK(remoter);
DCHECK_CURRENTLY_ON(BrowserThread::UI);
deprecated_receiver_.Bind(std::move(source_receiver));
deprecated_receiver_.set_disconnect_handler(base::BindOnce(
&CastRemotingConnector::OnMirrorServiceStopped, base::Unretained(this)));
deprecated_remoter_.Bind(std::move(remoter));
deprecated_remoter_.set_disconnect_handler(base::BindOnce(
&CastRemotingConnector::OnMirrorServiceStopped, base::Unretained(this)));
}
void CastRemotingConnector::ResetRemotingPermission() { void CastRemotingConnector::ResetRemotingPermission() {
remoting_allowed_.reset(); remoting_allowed_.reset();
} }
...@@ -249,8 +233,6 @@ void CastRemotingConnector::OnMirrorServiceStopped() { ...@@ -249,8 +233,6 @@ void CastRemotingConnector::OnMirrorServiceStopped() {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
DVLOG(2) << __func__; DVLOG(2) << __func__;
deprecated_receiver_.reset();
deprecated_remoter_.reset();
receiver_.reset(); receiver_.reset();
remoter_.reset(); remoter_.reset();
...@@ -274,8 +256,7 @@ void CastRemotingConnector::RegisterBridge(RemotingBridge* bridge) { ...@@ -274,8 +256,7 @@ void CastRemotingConnector::RegisterBridge(RemotingBridge* bridge) {
DCHECK(bridges_.find(bridge) == bridges_.end()); DCHECK(bridges_.find(bridge) == bridges_.end());
bridges_.insert(bridge); bridges_.insert(bridge);
if ((deprecated_remoter_ || remoter_) && !active_bridge_ && if (remoter_ && !active_bridge_ && remoting_allowed_.value_or(true))
remoting_allowed_.value_or(true))
bridge->OnSinkAvailable(sink_metadata_); bridge->OnSinkAvailable(sink_metadata_);
} }
...@@ -295,7 +276,7 @@ void CastRemotingConnector::StartRemoting(RemotingBridge* bridge) { ...@@ -295,7 +276,7 @@ void CastRemotingConnector::StartRemoting(RemotingBridge* bridge) {
// Refuse to start if there is no remoting route available, or if remoting is // Refuse to start if there is no remoting route available, or if remoting is
// already active. // already active.
if (!deprecated_remoter_ && !remoter_) { if (!remoter_) {
DVLOG(2) << "Remoting start failed: Invalid ANSWER message."; DVLOG(2) << "Remoting start failed: Invalid ANSWER message.";
bridge->OnStartFailed(RemotingStartFailReason::INVALID_ANSWER_MESSAGE); bridge->OnStartFailed(RemotingStartFailReason::INVALID_ANSWER_MESSAGE);
return; return;
...@@ -345,20 +326,11 @@ void CastRemotingConnector::StartRemotingIfPermitted() { ...@@ -345,20 +326,11 @@ void CastRemotingConnector::StartRemotingIfPermitted() {
return; return;
if (remoting_allowed_.value()) { if (remoting_allowed_.value()) {
if (deprecated_remoter_) { DCHECK(remoter_);
DCHECK(!remoter_); remoter_->Start();
deprecated_remoter_->Start();
// Assume the remoting session is always started successfully. If any
// failure occurs, OnError() will be called.
active_bridge_->OnStarted();
} else {
DCHECK(remoter_);
remoter_->Start();
}
} else { } else {
// TODO(crbug.com/1015486): Add an extra reason for this failure. active_bridge_->OnStartFailed(
active_bridge_->OnStartFailed(RemotingStartFailReason::ROUTE_TERMINATED); RemotingStartFailReason::REMOTING_NOT_PERMITTED);
active_bridge_->OnSinkGone(); active_bridge_->OnSinkGone();
active_bridge_ = nullptr; active_bridge_ = nullptr;
} }
...@@ -375,7 +347,7 @@ void CastRemotingConnector::StartRemotingDataStreams( ...@@ -375,7 +347,7 @@ void CastRemotingConnector::StartRemotingDataStreams(
// Refuse to start if there is no remoting route available, or if remoting is // Refuse to start if there is no remoting route available, or if remoting is
// not active for this |bridge|. // not active for this |bridge|.
if ((!deprecated_remoter_ && !remoter_) || active_bridge_ != bridge) if (!remoter_ || active_bridge_ != bridge)
return; return;
// Also, if neither audio nor video pipe was provided, or if a receiver for a // Also, if neither audio nor video pipe was provided, or if a receiver for a
// RemotingDataStreamSender was not provided for a data pipe, error-out early. // RemotingDataStreamSender was not provided for a data pipe, error-out early.
...@@ -386,52 +358,10 @@ void CastRemotingConnector::StartRemotingDataStreams( ...@@ -386,52 +358,10 @@ void CastRemotingConnector::StartRemotingDataStreams(
return; return;
} }
if (deprecated_remoter_) {
DCHECK(!remoter_);
const bool want_audio = audio_sender.is_valid();
const bool want_video = video_sender.is_valid();
deprecated_remoter_->StartDataStreams(
want_audio, want_video,
base::BindOnce(&CastRemotingConnector::OnDataStreamsStarted,
weak_factory_.GetWeakPtr(), std::move(audio_pipe),
std::move(video_pipe), std::move(audio_sender),
std::move(video_sender)));
} else {
DCHECK(remoter_); DCHECK(remoter_);
remoter_->StartDataStreams(std::move(audio_pipe), std::move(video_pipe), remoter_->StartDataStreams(std::move(audio_pipe), std::move(video_pipe),
std::move(audio_sender), std::move(audio_sender),
std::move(video_sender)); std::move(video_sender));
}
}
void CastRemotingConnector::OnDataStreamsStarted(
mojo::ScopedDataPipeConsumerHandle audio_pipe,
mojo::ScopedDataPipeConsumerHandle video_pipe,
mojo::PendingReceiver<media::mojom::RemotingDataStreamSender> audio_sender,
mojo::PendingReceiver<media::mojom::RemotingDataStreamSender> video_sender,
int32_t audio_stream_id,
int32_t video_stream_id) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(deprecated_remoter_);
DCHECK(!remoter_);
if (!active_bridge_) {
deprecated_remoter_->Stop(media::mojom::RemotingStopReason::SOURCE_GONE);
return;
}
if (audio_sender && audio_stream_id > -1) {
mirroring::CastRemotingSender::FindAndBind(
audio_stream_id, std::move(audio_pipe), std::move(audio_sender),
base::BindOnce(&CastRemotingConnector::OnDataSendFailed,
weak_factory_.GetWeakPtr()));
}
if (video_sender && video_stream_id > -1) {
mirroring::CastRemotingSender::FindAndBind(
video_stream_id, std::move(video_pipe), std::move(video_sender),
base::BindOnce(&CastRemotingConnector::OnDataSendFailed,
weak_factory_.GetWeakPtr()));
}
} }
void CastRemotingConnector::StopRemoting(RemotingBridge* bridge, void CastRemotingConnector::StopRemoting(RemotingBridge* bridge,
...@@ -469,12 +399,7 @@ void CastRemotingConnector::StopRemoting(RemotingBridge* bridge, ...@@ -469,12 +399,7 @@ void CastRemotingConnector::StopRemoting(RemotingBridge* bridge,
bridge->OnSinkGone(); bridge->OnSinkGone();
// Note: At this point, all sources should think the sink is gone. // Note: At this point, all sources should think the sink is gone.
if (deprecated_remoter_) {
DCHECK(!remoter_);
deprecated_remoter_->Stop(reason);
}
if (remoter_) { if (remoter_) {
DCHECK(!deprecated_remoter_);
remoter_->Stop(reason); remoter_->Stop(reason);
} }
...@@ -503,15 +428,9 @@ void CastRemotingConnector::SendMessageToSink( ...@@ -503,15 +428,9 @@ void CastRemotingConnector::SendMessageToSink(
// During an active remoting session, simply pass all binary messages through // During an active remoting session, simply pass all binary messages through
// to the sink. // to the sink.
if ((!deprecated_remoter_ && !remoter_) || active_bridge_ != bridge) if (!remoter_ || active_bridge_ != bridge)
return; return;
if (deprecated_remoter_) { remoter_->SendMessageToSink(message);
DCHECK(!remoter_);
deprecated_remoter_->SendMessageToSink(message);
} else {
DCHECK(!deprecated_remoter_);
remoter_->SendMessageToSink(message);
}
} }
void CastRemotingConnector::OnMessageFromSink( void CastRemotingConnector::OnMessageFromSink(
...@@ -527,9 +446,6 @@ void CastRemotingConnector::OnMessageFromSink( ...@@ -527,9 +446,6 @@ void CastRemotingConnector::OnMessageFromSink(
void CastRemotingConnector::EstimateTransmissionCapacity( void CastRemotingConnector::EstimateTransmissionCapacity(
media::mojom::Remoter::EstimateTransmissionCapacityCallback callback) { media::mojom::Remoter::EstimateTransmissionCapacityCallback callback) {
if (deprecated_remoter_)
deprecated_remoter_->EstimateTransmissionCapacity(std::move(callback));
else
std::move(callback).Run(0); std::move(callback).Run(0);
} }
...@@ -557,13 +473,6 @@ void CastRemotingConnector::OnSinkAvailable( ...@@ -557,13 +473,6 @@ void CastRemotingConnector::OnSinkAvailable(
} }
} }
void CastRemotingConnector::OnError() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (active_bridge_)
StopRemoting(active_bridge_, RemotingStopReason::UNEXPECTED_FAILURE, false);
}
void CastRemotingConnector::OnSinkGone() { void CastRemotingConnector::OnSinkGone() {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
DVLOG(2) << __func__; DVLOG(2) << __func__;
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "base/supports_user_data.h" #include "base/supports_user_data.h"
#include "components/prefs/pref_change_registrar.h" #include "components/prefs/pref_change_registrar.h"
#include "components/sessions/core/session_id.h" #include "components/sessions/core/session_id.h"
#include "media/mojo/mojom/mirror_service_remoting.mojom.h"
#include "media/mojo/mojom/remoting.mojom.h" #include "media/mojo/mojom/remoting.mojom.h"
#include "media/mojo/mojom/remoting_common.mojom.h" #include "media/mojo/mojom/remoting_common.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
...@@ -38,9 +37,8 @@ class MediaRouter; ...@@ -38,9 +37,8 @@ class MediaRouter;
// service instance. The sink is represented by a MediaRemoter in the Cast Media // service instance. The sink is represented by a MediaRemoter in the Cast Media
// Router Provider that handles the communication with the remote device. The // Router Provider that handles the communication with the remote device. The
// CastRemotingConnector and the MediaRemoter can communicate with each other // CastRemotingConnector and the MediaRemoter can communicate with each other
// through the media::mojom::MirrorServiceRemoter and // through the media::mojom::Remoter and media::mojom::RemotingSource interfaces
// media::mojom::MirrorServiceRemotingSource interfaces when a sink that is // when a sink that is capable of remoting is available.
// capable of remoting is available.
// //
// Whenever a candidate media source is created in a render frame, // Whenever a candidate media source is created in a render frame,
// ChromeContentBrowserClient will call CreateMediaRemoter() to instantiate a // ChromeContentBrowserClient will call CreateMediaRemoter() to instantiate a
...@@ -77,11 +75,7 @@ class MediaRouter; ...@@ -77,11 +75,7 @@ class MediaRouter;
// Please see the unit tests in cast_remoting_connector_unittest.cc as a // Please see the unit tests in cast_remoting_connector_unittest.cc as a
// reference for how CastRemotingConnector and a MediaRemoter interact to // reference for how CastRemotingConnector and a MediaRemoter interact to
// start/execute/stop remoting sessions. // start/execute/stop remoting sessions.
//
// TODO(crbug.com/1015486): Remove media::mojom::MirrorServiceRemotingSource
// interface and implementation after Mirroring Service is launched.
class CastRemotingConnector : public base::SupportsUserData::Data, class CastRemotingConnector : public base::SupportsUserData::Data,
public media::mojom::MirrorServiceRemotingSource,
public media::mojom::RemotingSource { public media::mojom::RemotingSource {
public: public:
~CastRemotingConnector() final; ~CastRemotingConnector() final;
...@@ -98,14 +92,6 @@ class CastRemotingConnector : public base::SupportsUserData::Data, ...@@ -98,14 +92,6 @@ class CastRemotingConnector : public base::SupportsUserData::Data,
mojo::PendingRemote<media::mojom::RemotingSource> source, mojo::PendingRemote<media::mojom::RemotingSource> source,
mojo::PendingReceiver<media::mojom::Remoter> receiver); mojo::PendingReceiver<media::mojom::Remoter> receiver);
// Called when a MediaRemoter is created and started in the Cast MRP. This
// call connects the CastRemotingConnector with the MediaRemoter. Remoting
// sessions can only be started after this is called.
void ConnectToService(
mojo::PendingReceiver<media::mojom::MirrorServiceRemotingSource>
source_receiver,
mojo::PendingRemote<media::mojom::MirrorServiceRemoter> remoter);
// Called at the start of mirroring to reset the permission. // Called at the start of mirroring to reset the permission.
void ResetRemotingPermission(); void ResetRemotingPermission();
...@@ -158,9 +144,6 @@ class CastRemotingConnector : public base::SupportsUserData::Data, ...@@ -158,9 +144,6 @@ class CastRemotingConnector : public base::SupportsUserData::Data,
void OnMessageFromSink(const std::vector<uint8_t>& message) override; void OnMessageFromSink(const std::vector<uint8_t>& message) override;
void OnStopped(media::mojom::RemotingStopReason reason) override; void OnStopped(media::mojom::RemotingStopReason reason) override;
// media::mojom::MirrorServiceRemotingSource implementation.
void OnError() override;
// media::mojom::RemotingSource implementation. // media::mojom::RemotingSource implementation.
void OnSinkGone() override; void OnSinkGone() override;
void OnStarted() override; void OnStarted() override;
...@@ -238,11 +221,6 @@ class CastRemotingConnector : public base::SupportsUserData::Data, ...@@ -238,11 +221,6 @@ class CastRemotingConnector : public base::SupportsUserData::Data,
// pointing to the RemotingBridge being used to communicate with the source. // pointing to the RemotingBridge being used to communicate with the source.
RemotingBridge* active_bridge_; RemotingBridge* active_bridge_;
// TODO(crbug.com/1015486): Remove these after Mirroring Service is launched.
mojo::Receiver<media::mojom::MirrorServiceRemotingSource>
deprecated_receiver_{this};
mojo::Remote<media::mojom::MirrorServiceRemoter> deprecated_remoter_;
mojo::Receiver<media::mojom::RemotingSource> receiver_{this}; mojo::Receiver<media::mojom::RemotingSource> receiver_{this};
mojo::Remote<media::mojom::Remoter> remoter_; mojo::Remote<media::mojom::Remoter> remoter_;
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "components/sync_preferences/testing_pref_service_syncable.h" #include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/test/browser_task_environment.h" #include "content/public/test/browser_task_environment.h"
#include "media/mojo/mojom/mirror_service_remoting.mojom.h"
#include "media/mojo/mojom/remoting.mojom.h" #include "media/mojo/mojom/remoting.mojom.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -70,19 +69,6 @@ class FakeMediaRouter : public media_router::MockMediaRouter { ...@@ -70,19 +69,6 @@ class FakeMediaRouter : public media_router::MockMediaRouter {
connector_ = nullptr; connector_ = nullptr;
} }
void OnMediaRemoterCreated(
SessionID tab_id,
mojo::PendingRemote<media::mojom::MirrorServiceRemoter> remoter,
mojo::PendingReceiver<media::mojom::MirrorServiceRemotingSource>
remoting_source) {
if (tab_id != tab_id_)
return;
EXPECT_TRUE(connector_);
connector_->ConnectToService(std::move(remoting_source),
std::move(remoter));
}
// Get the registered tab ID. // Get the registered tab ID.
SessionID tab_id() const { return tab_id_; } SessionID tab_id() const { return tab_id_; }
...@@ -116,21 +102,8 @@ class MockRemotingSource : public media::mojom::RemotingSource { ...@@ -116,21 +102,8 @@ class MockRemotingSource : public media::mojom::RemotingSource {
mojo::Receiver<media::mojom::RemotingSource> receiver_{this}; mojo::Receiver<media::mojom::RemotingSource> receiver_{this};
}; };
// TODO(crbug.com/1015486): Remove the media::mojom::MirrorServiceRemoter class MockMediaRemoter final : public media::mojom::Remoter {
// implementation after Mirroring Service is launched.
class MockMediaRemoter final : public media::mojom::MirrorServiceRemoter,
public media::mojom::Remoter {
public: public:
// TODO(crbug.com/1015486): Remove this ctor after Mirroring Service is
// launched.
explicit MockMediaRemoter(FakeMediaRouter* media_router) {
mojo::PendingRemote<media::mojom::MirrorServiceRemoter> pending_remoter;
deprecated_receiver_.Bind(pending_remoter.InitWithNewPipeAndPassReceiver());
media_router->OnMediaRemoterCreated(
kRemotingTabId, std::move(pending_remoter),
deprecated_source_.BindNewPipeAndPassReceiver());
}
explicit MockMediaRemoter(CastRemotingConnector* connector) { explicit MockMediaRemoter(CastRemotingConnector* connector) {
connector->ConnectWithMediaRemoter(receiver_.BindNewPipeAndPassRemote(), connector->ConnectWithMediaRemoter(receiver_.BindNewPipeAndPassRemote(),
source_.BindNewPipeAndPassReceiver()); source_.BindNewPipeAndPassReceiver());
...@@ -139,46 +112,25 @@ class MockMediaRemoter final : public media::mojom::MirrorServiceRemoter, ...@@ -139,46 +112,25 @@ class MockMediaRemoter final : public media::mojom::MirrorServiceRemoter,
~MockMediaRemoter() final {} ~MockMediaRemoter() final {}
void OnSinkAvailable() { void OnSinkAvailable() {
if (deprecated_source_) { EXPECT_TRUE(source_);
EXPECT_FALSE(source_); source_->OnSinkAvailable(GetDefaultSinkMetadata());
deprecated_source_->OnSinkAvailable(GetDefaultSinkMetadata());
} else {
EXPECT_TRUE(source_);
source_->OnSinkAvailable(GetDefaultSinkMetadata());
}
} }
void SendMessageToSource(const std::vector<uint8_t>& message) { void SendMessageToSource(const std::vector<uint8_t>& message) {
if (deprecated_source_) { EXPECT_TRUE(source_);
EXPECT_FALSE(source_); source_->OnMessageFromSink(message);
deprecated_source_->OnMessageFromSink(message);
} else {
EXPECT_TRUE(source_);
source_->OnMessageFromSink(message);
}
} }
void OnStopped(RemotingStopReason reason) { void OnStopped(RemotingStopReason reason) {
if (deprecated_source_) { EXPECT_TRUE(source_);
EXPECT_FALSE(source_); source_->OnStopped(reason);
deprecated_source_->OnStopped(reason);
} else {
EXPECT_TRUE(source_);
source_->OnStopped(reason);
}
} }
void OnError() { void OnError() {
if (deprecated_source_) { EXPECT_TRUE(source_);
EXPECT_FALSE(source_); source_->OnStopped(RemotingStopReason::UNEXPECTED_FAILURE);
deprecated_source_->OnError();
} else {
EXPECT_TRUE(source_);
source_->OnStopped(RemotingStopReason::UNEXPECTED_FAILURE);
}
} }
// media::mojom::MirrorServiceRemoter implementation.
// media::mojom::Remoter implementation. // media::mojom::Remoter implementation.
MOCK_METHOD0(RequestStart, void()); MOCK_METHOD0(RequestStart, void());
MOCK_METHOD1(Stop, void(RemotingStopReason)); MOCK_METHOD1(Stop, void(RemotingStopReason));
...@@ -192,11 +144,6 @@ class MockMediaRemoter final : public media::mojom::MirrorServiceRemoter, ...@@ -192,11 +144,6 @@ class MockMediaRemoter final : public media::mojom::MirrorServiceRemoter,
source_->OnStarted(); source_->OnStarted();
} }
// media::mojom::MirrorServiceRemoter implementation.
void StartDataStreams(bool audio,
bool video,
StartDataStreamsCallback callback) override {}
// media::mojom::Remoter implementation. // media::mojom::Remoter implementation.
MOCK_METHOD4( MOCK_METHOD4(
StartDataStreams, StartDataStreams,
...@@ -208,10 +155,6 @@ class MockMediaRemoter final : public media::mojom::MirrorServiceRemoter, ...@@ -208,10 +155,6 @@ class MockMediaRemoter final : public media::mojom::MirrorServiceRemoter,
video_sender_receiver)); video_sender_receiver));
private: private:
// TODO(crbug.com/1015486): Remove these after Mirroring Service is launched.
mojo::Receiver<media::mojom::MirrorServiceRemoter> deprecated_receiver_{this};
mojo::Remote<media::mojom::MirrorServiceRemotingSource> deprecated_source_;
mojo::Receiver<media::mojom::Remoter> receiver_{this}; mojo::Receiver<media::mojom::Remoter> receiver_{this};
mojo::Remote<media::mojom::RemotingSource> source_; mojo::Remote<media::mojom::RemotingSource> source_;
}; };
...@@ -392,7 +335,8 @@ TEST_F(CastRemotingConnectorTest, NoPermissionToStart) { ...@@ -392,7 +335,8 @@ TEST_F(CastRemotingConnectorTest, NoPermissionToStart) {
std::unique_ptr<MockMediaRemoter> media_remoter = std::unique_ptr<MockMediaRemoter> media_remoter =
std::make_unique<MockMediaRemoter>(GetConnector()); std::make_unique<MockMediaRemoter>(GetConnector());
EXPECT_CALL(source, OnStartFailed(RemotingStartFailReason::ROUTE_TERMINATED)) EXPECT_CALL(source,
OnStartFailed(RemotingStartFailReason::REMOTING_NOT_PERMITTED))
.Times(1); .Times(1);
remoter->Start(); remoter->Start();
RunUntilIdle(); RunUntilIdle();
......
...@@ -929,19 +929,6 @@ void MediaRouterMojoImpl::OnProviderConnectionError( ...@@ -929,19 +929,6 @@ void MediaRouterMojoImpl::OnProviderConnectionError(
media_route_providers_.erase(provider_id); media_route_providers_.erase(provider_id);
} }
void MediaRouterMojoImpl::OnMediaRemoterCreated(
int32_t tab_id,
mojo::PendingRemote<media::mojom::MirrorServiceRemoter> remoter,
mojo::PendingReceiver<media::mojom::MirrorServiceRemotingSource>
source_receiver) {
auto it = remoting_sources_.find(SessionID::FromSerializedValue(tab_id));
if (it == remoting_sources_.end()) {
return;
}
CastRemotingConnector* connector = it->second;
connector->ConnectToService(std::move(source_receiver), std::move(remoter));
}
void MediaRouterMojoImpl::GetLogger( void MediaRouterMojoImpl::GetLogger(
mojo::PendingReceiver<mojom::Logger> receiver) { mojo::PendingReceiver<mojom::Logger> receiver) {
logger_.Bind(std::move(receiver)); logger_.Bind(std::move(receiver));
......
...@@ -333,11 +333,6 @@ class MediaRouterMojoImpl : public MediaRouterBase, public mojom::MediaRouter { ...@@ -333,11 +333,6 @@ class MediaRouterMojoImpl : public MediaRouterBase, public mojom::MediaRouter {
void OnRouteMessagesReceived( void OnRouteMessagesReceived(
const std::string& route_id, const std::string& route_id,
std::vector<mojom::RouteMessagePtr> messages) override; std::vector<mojom::RouteMessagePtr> messages) override;
void OnMediaRemoterCreated(
int32_t tab_id,
mojo::PendingRemote<media::mojom::MirrorServiceRemoter> remoter,
mojo::PendingReceiver<media::mojom::MirrorServiceRemotingSource>
source_receiver) override;
void GetLogger(mojo::PendingReceiver<mojom::Logger> receiver) override; void GetLogger(mojo::PendingReceiver<mojom::Logger> receiver) override;
void GetLogsAsString(GetLogsAsStringCallback callback) override; void GetLogsAsString(GetLogsAsStringCallback callback) override;
void GetMediaSinkServiceStatus( void GetMediaSinkServiceStatus(
......
...@@ -59,20 +59,6 @@ class MockMojoMediaRouter : public MockMediaRouter, public mojom::MediaRouter { ...@@ -59,20 +59,6 @@ class MockMojoMediaRouter : public MockMediaRouter, public mojom::MediaRouter {
MOCK_METHOD2(OnRouteMessagesReceived, MOCK_METHOD2(OnRouteMessagesReceived,
void(const std::string& route_id, void(const std::string& route_id,
std::vector<mojom::RouteMessagePtr> messages)); std::vector<mojom::RouteMessagePtr> messages));
void OnMediaRemoterCreated(
int32_t tab_id,
mojo::PendingRemote<media::mojom::MirrorServiceRemoter> remoter,
mojo::PendingReceiver<media::mojom::MirrorServiceRemotingSource>
source_receiver) override {
OnMediaRemoterCreatedInternal(tab_id, std::move(remoter),
std::move(source_receiver));
}
MOCK_METHOD3(
OnMediaRemoterCreatedInternal,
void(int32_t tab_id,
mojo::PendingRemote<media::mojom::MirrorServiceRemoter> remoter,
mojo::PendingReceiver<media::mojom::MirrorServiceRemotingSource>
source_receiver));
MOCK_METHOD1(GetLogger, void(mojo::PendingReceiver<mojom::Logger> receiver)); MOCK_METHOD1(GetLogger, void(mojo::PendingReceiver<mojom::Logger> receiver));
MOCK_METHOD1(GetLogsAsString, void(GetLogsAsStringCallback callback)); MOCK_METHOD1(GetLogsAsString, void(GetLogsAsStringCallback callback));
void GetMediaSinkServiceStatus( void GetMediaSinkServiceStatus(
......
...@@ -29,7 +29,7 @@ mojom("media_router") { ...@@ -29,7 +29,7 @@ mojom("media_router") {
":logger", ":logger",
":media_controller", ":media_controller",
"//components/mirroring/mojom:host", "//components/mirroring/mojom:host",
"//media/mojo/mojom:mirror_service_remoting", "//media/mojo/mojom:remoting",
"//mojo/public/mojom/base", "//mojo/public/mojom/base",
"//services/network/public/mojom:mojom_ip_address", "//services/network/public/mojom:mojom_ip_address",
"//third_party/blink/public/mojom:mojom_platform", "//third_party/blink/public/mojom:mojom_platform",
......
...@@ -8,7 +8,6 @@ import "chrome/common/media_router/mojom/logger.mojom"; ...@@ -8,7 +8,6 @@ import "chrome/common/media_router/mojom/logger.mojom";
import "chrome/common/media_router/mojom/media_controller.mojom"; import "chrome/common/media_router/mojom/media_controller.mojom";
import "chrome/common/media_router/mojom/media_status.mojom"; import "chrome/common/media_router/mojom/media_status.mojom";
import "components/mirroring/mojom/mirroring_service_host.mojom"; import "components/mirroring/mojom/mirroring_service_host.mojom";
import "media/mojo/mojom/mirror_service_remoting.mojom";
import "mojo/public/mojom/base/time.mojom"; import "mojo/public/mojom/base/time.mojom";
import "services/network/public/mojom/ip_address.mojom"; import "services/network/public/mojom/ip_address.mojom";
import "services/network/public/mojom/ip_endpoint.mojom"; import "services/network/public/mojom/ip_endpoint.mojom";
...@@ -586,16 +585,6 @@ interface MediaRouter { ...@@ -586,16 +585,6 @@ interface MediaRouter {
OnRouteMessagesReceived(string route_id, OnRouteMessagesReceived(string route_id,
array<RouteMessage> messages); array<RouteMessage> messages);
// Called when a MediaRemoter for a tab with |tab_id| is started. |remoter|
// can be used to access the MediaRemoter to control a media remoting session
// and send RPC messages to the remote device. |remoting_source| is bound to
// receive the updates/messages from MediaRemoter.
OnMediaRemoterCreated(
int32 tab_id,
pending_remote<media.mojom.MirrorServiceRemoter> remoter,
pending_receiver<media.mojom.MirrorServiceRemotingSource>
remoting_source);
// Returns current status of media sink service in JSON format. // Returns current status of media sink service in JSON format.
GetMediaSinkServiceStatus() => (string status); GetMediaSinkServiceStatus() => (string status);
......
...@@ -215,9 +215,6 @@ void ChromeExtensionsDispatcherDelegate::PopulateSourceMap( ...@@ -215,9 +215,6 @@ void ChromeExtensionsDispatcherDelegate::PopulateSourceMap(
source_map->RegisterSource("url/mojom/url.mojom", IDR_MOJO_URL_MOJOM_JS); source_map->RegisterSource("url/mojom/url.mojom", IDR_MOJO_URL_MOJOM_JS);
source_map->RegisterSource("media/mojo/mojom/remoting_common.mojom", source_map->RegisterSource("media/mojo/mojom/remoting_common.mojom",
IDR_REMOTING_COMMON_JS); IDR_REMOTING_COMMON_JS);
source_map->RegisterSource(
"media/mojo/mojom/mirror_service_remoting.mojom",
IDR_MEDIA_REMOTING_JS);
source_map->RegisterSource( source_map->RegisterSource(
"components/mirroring/mojom/mirroring_service_host.mojom", "components/mirroring/mojom/mirroring_service_host.mojom",
IDR_MIRRORING_SERVICE_HOST_MOJOM_JS); IDR_MIRRORING_SERVICE_HOST_MOJOM_JS);
......
...@@ -17,7 +17,6 @@ loadScript('components/mirroring/mojom/mirroring_service_host.mojom'); ...@@ -17,7 +17,6 @@ loadScript('components/mirroring/mojom/mirroring_service_host.mojom');
loadScript('components/mirroring/mojom/session_observer.mojom'); loadScript('components/mirroring/mojom/session_observer.mojom');
loadScript('components/mirroring/mojom/session_parameters.mojom'); loadScript('components/mirroring/mojom/session_parameters.mojom');
loadScript('extensions/common/mojom/keep_alive.mojom'); loadScript('extensions/common/mojom/keep_alive.mojom');
loadScript('media/mojo/mojom/mirror_service_remoting.mojom');
loadScript('media/mojo/mojom/remoting_common.mojom'); loadScript('media/mojo/mojom/remoting_common.mojom');
loadScript('mojo/public/mojom/base/time.mojom'); loadScript('mojo/public/mojom/base/time.mojom');
loadScript('mojo/public/mojom/base/unguessable_token.mojom'); loadScript('mojo/public/mojom/base/unguessable_token.mojom');
...@@ -351,100 +350,6 @@ MediaSinkExtraDataAdapter.prototype.toNewVersion = function() { ...@@ -351,100 +350,6 @@ MediaSinkExtraDataAdapter.prototype.toNewVersion = function() {
} }
}; };
/**
* Adapter for media.mojom.MirrorServiceRemoterPtr.
* @constructor
*/
function MirrorServiceRemoterPtrAdapter(handleOrPtrInfo) {
this.ptr = new mojo.InterfacePtrController(MirrorServiceRemoterAdapter,
handleOrPtrInfo);
}
MirrorServiceRemoterPtrAdapter.prototype =
Object.create(media.mojom.MirrorServiceRemoterPtr.prototype);
MirrorServiceRemoterPtrAdapter.prototype.constructor =
MirrorServiceRemoterPtrAdapter;
MirrorServiceRemoterPtrAdapter.prototype.startDataStreams = function() {
return MirrorServiceRemoterProxy.prototype.startDataStreams
.apply(this.ptr.getProxy(), arguments).then(function(response) {
return Promise.resolve({
'audio_stream_id': response.audioStreamId,
'video_stream_id': response.videoStreamId,
});
});
};
/**
* Adapter for media.mojom.MirrorServiceRemoter.stubclass.
* @constructor
*/
function MirrorServiceRemoterStubAdapter(delegate) {
this.delegate_ = delegate;
}
MirrorServiceRemoterStubAdapter.prototype = Object.create(
media.mojom.MirrorServiceRemoter.stubClass.prototype);
MirrorServiceRemoterStubAdapter.prototype.constructor =
MirrorServiceRemoterStubAdapter;
MirrorServiceRemoterStubAdapter.prototype.startDataStreams =
function(hasAudio, hasVideo) {
return this.delegate_ && this.delegate_.startDataStreams &&
this.delegate_.startDataStreams(hasAudio, hasVideo).then(
function(response) {
return {
'audioStreamId': response.audio_stream_id,
'videoStreamId': response.video_stream_id,
};
});
};
/**
* Adapter for media.mojom.MirrorServiceRemoter.
*/
var MirrorServiceRemoterAdapter = {
name: 'media.mojom.MirrorServiceRemoter',
kVersion: 0,
ptrClass: MirrorServiceRemoterPtrAdapter,
proxyClass: media.mojom.MirrorServiceRemoter.proxyClass,
stubClass: MirrorServiceRemoterStubAdapter,
validateRequest: media.mojom.MirrorServiceRemoter.validateRequest,
validateResponse: media.mojom.MirrorServiceRemoter.validateResponse,
};
/**
* Adapter for media.mojom.MirrorServiceRemotingSourcePtr.
* @constructor
*/
function MirrorServiceRemotingSourcePtrAdapter(handleOrPtrInfo) {
this.ptr = new mojo.InterfacePtrController(MirrorServiceRemotingSourceAdapter,
handleOrPtrInfo);
}
MirrorServiceRemotingSourcePtrAdapter.prototype =
Object.create(media.mojom.MirrorServiceRemotingSourcePtr.prototype);
MirrorServiceRemotingSourcePtrAdapter.prototype.constructor =
MirrorServiceRemotingSourcePtrAdapter;
MirrorServiceRemotingSourcePtrAdapter.prototype.onSinkAvailable =
function(metadata) {
return this.ptr.getProxy().onSinkAvailable(metadata.toNewVersion());
};
/**
* Adapter for media.mojom.MirrorServiceRemotingSource.
*/
var MirrorServiceRemotingSourceAdapter = {
name: 'media.mojom.MirrorServiceRemotingSource',
kVersion: 0,
ptrClass: MirrorServiceRemotingSourcePtrAdapter,
proxyClass: media.mojom.MirrorServiceRemotingSource.proxyClass,
stubClass: null,
validateRequest: media.mojom.MirrorServiceRemotingSource.validateRequest,
validateResponse: null,
};
/** /**
* Adapter for mediaRouter.mojom.MediaStatusObserver. * Adapter for mediaRouter.mojom.MediaStatusObserver.
* @constructor * @constructor
...@@ -749,9 +654,6 @@ MediaRouter.prototype.getMojoExports = function() { ...@@ -749,9 +654,6 @@ MediaRouter.prototype.getMojoExports = function() {
MirroringSessionType: mirroring.mojom.SessionType, MirroringSessionType: mirroring.mojom.SessionType,
MirroringRemotingNamespace: mirroring.mojom.REMOTING_NAMESPACE, MirroringRemotingNamespace: mirroring.mojom.REMOTING_NAMESPACE,
MirroringWebRtcNamespace: mirroring.mojom.WEB_RTC_NAMESPACE, MirroringWebRtcNamespace: mirroring.mojom.WEB_RTC_NAMESPACE,
MirrorServiceRemoter: MirrorServiceRemoterAdapter,
MirrorServiceRemoterPtr: MirrorServiceRemoterPtrAdapter,
MirrorServiceRemotingSourcePtr: MirrorServiceRemotingSourcePtrAdapter,
RemotingStopReason: media.mojom.RemotingStopReason, RemotingStopReason: media.mojom.RemotingStopReason,
RemotingStartFailReason: media.mojom.RemotingStartFailReason, RemotingStartFailReason: media.mojom.RemotingStartFailReason,
RemotingSinkFeature: media.mojom.RemotingSinkFeature, RemotingSinkFeature: media.mojom.RemotingSinkFeature,
...@@ -951,19 +853,6 @@ MediaRouter.prototype.onRouteMessagesReceived = function(routeId, messages) { ...@@ -951,19 +853,6 @@ MediaRouter.prototype.onRouteMessagesReceived = function(routeId, messages) {
routeId, messages.map(messageToMojo_)); routeId, messages.map(messageToMojo_));
}; };
/**
* @param {number} tabId
* @param {!media.mojom.MirrorServiceRemoterPtr} remoter
* @param {!mojo.InterfaceRequest} remotingSource
*/
MediaRouter.prototype.onMediaRemoterCreated = function(tabId, remoter,
remotingSource) {
this.service_.onMediaRemoterCreated(
tabId,
new media.mojom.MirrorServiceRemoterPtr(remoter.ptr.passInterface()),
remotingSource);
}
/** /**
* Returns current status of media sink service in JSON format. * Returns current status of media sink service in JSON format.
* @return {!Promise<!{status: string}>} * @return {!Promise<!{status: string}>}
......
...@@ -83,7 +83,6 @@ ...@@ -83,7 +83,6 @@
<include name="IDR_MOJO_IP_ENDPOINT_MOJOM_JS" file="${mojom_root}\services\network\public\mojom\ip_endpoint.mojom.js" use_base_dir="false" type="BINDATA" /> <include name="IDR_MOJO_IP_ENDPOINT_MOJOM_JS" file="${mojom_root}\services\network\public\mojom\ip_endpoint.mojom.js" use_base_dir="false" type="BINDATA" />
<include name="IDR_ORIGIN_MOJOM_JS" file="${mojom_root}\url\mojom\origin.mojom.js" use_base_dir="false" type="BINDATA" /> <include name="IDR_ORIGIN_MOJOM_JS" file="${mojom_root}\url\mojom\origin.mojom.js" use_base_dir="false" type="BINDATA" />
<include name="IDR_MOJO_URL_MOJOM_JS" file="${mojom_root}\url\mojom\url.mojom.js" use_base_dir="false" type="BINDATA" /> <include name="IDR_MOJO_URL_MOJOM_JS" file="${mojom_root}\url\mojom\url.mojom.js" use_base_dir="false" type="BINDATA" />
<include name="IDR_MEDIA_REMOTING_JS" file="${mojom_root}\media\mojo\mojom\mirror_service_remoting.mojom.js" use_base_dir="false" type="BINDATA" />
<include name="IDR_REMOTING_COMMON_JS" file="${mojom_root}\media\mojo\mojom\remoting_common.mojom.js" use_base_dir="false" type="BINDATA" /> <include name="IDR_REMOTING_COMMON_JS" file="${mojom_root}\media\mojo\mojom\remoting_common.mojom.js" use_base_dir="false" type="BINDATA" />
</if> </if>
</includes> </includes>
......
...@@ -290,12 +290,6 @@ mojom("remoting_common") { ...@@ -290,12 +290,6 @@ mojom("remoting_common") {
sources = [ "remoting_common.mojom" ] sources = [ "remoting_common.mojom" ]
} }
mojom("mirror_service_remoting") {
sources = [ "mirror_service_remoting.mojom" ]
public_deps = [ ":remoting_common" ]
}
mojom("remoting") { mojom("remoting") {
sources = [ "remoting.mojom" ] sources = [ "remoting.mojom" ]
......
// Copyright 2017 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.
module media.mojom;
import "media/mojo/mojom/remoting_common.mojom";
// Interface used by the source to start/stop remoting and send data to the
// sink.
interface MirrorServiceRemoter {
// Starts a remoting session. Always assumes the remoting session will be
// stared successfully. If any failure happens,
// MirrorServiceRemotingSource::OnError() will be called.
Start();
// Starts remoting the media data streams. This is called after Start() to
// indicate audio/video bitstream data is ready to be consumed. Returns
// audio/video stream IDs. A valid stream ID should be greater than 0. When
// there is no audio/video, or if the data stream is not successfully started,
// the returned stream ID is -1.
StartDataStreams(bool has_audio, bool has_video)
=> (int32 audio_stream_id, int32 video_stream_id);
// Stops remoting media. Messages in both directions will be dropped after
// this point as well as any pending or in-transit media bitstream data.
Stop(RemotingStopReason reason);
// Sends|message| to the sink. |message| is a serialized protobuf from
// src/media/remoting/proto.
SendMessageToSink(array<uint8> message);
// Estimates the transmission capacity. Returns the result in
// bytes per second.
EstimateTransmissionCapacity() => (double rate);
};
// Interface used for sending notifications back to the source's control logic,
// and to pass messages from the sink back to the source.
interface MirrorServiceRemotingSource {
// Notifies the source that the sink is now available to start remoting and
// passes the receiver's metadata. It is up to the source's control logic
// to decide whether/when to start remoting.
OnSinkAvailable(RemotingSinkMetadata metadata);
// Passes a |message| from the sink back to the source. The |message| consists
// of a serialized protobuf from src/media/remoting/proto. This will only be
// called after OnStarted() and before OnStopped().
OnMessageFromSink(array<uint8> message);
// Notifies the source that remoting has terminated. This may or may not be in
// response to a MirrorServiceRemoter.Stop() call, as other events (possibly
// external) may have caused remoting to end.
OnStopped(RemotingStopReason reason);
// Notifies the source that a fatal error has occurred. Remoting session will
// be stopped immediately once this is called.
// TODO(xjz): Add error codes in future to indicate different errors.
OnError();
};
...@@ -19,6 +19,7 @@ enum RemotingStartFailReason { ...@@ -19,6 +19,7 @@ enum RemotingStartFailReason {
CANNOT_START_MULTIPLE, // Remoting was already active. CANNOT_START_MULTIPLE, // Remoting was already active.
ROUTE_TERMINATED, // User-initated disconnect while starting remoting. ROUTE_TERMINATED, // User-initated disconnect while starting remoting.
INVALID_ANSWER_MESSAGE, // Invalid ANSWER message. INVALID_ANSWER_MESSAGE, // Invalid ANSWER message.
REMOTING_NOT_PERMITTED, // Remoter does not have dialog permission.
}; };
enum RemotingSinkFeature { enum RemotingSinkFeature {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment