Commit 1cae9396 authored by Takumi Fujimoto's avatar Takumi Fujimoto Committed by Commit Bot

[Cast MRP] Set the controller type for local mirroring sessions

Set the controller type to kMirroring so that local mirroring sessions
don't show up in Global Media Controls.

Bug: 1043302
Change-Id: Ib667dae4afc3b078b6aaa7b76618024cf0de1810
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2007318
Commit-Queue: Takumi Fujimoto <takumif@chromium.org>
Reviewed-by: default avatarmark a. foltz <mfoltz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734545}
parent 7f21d268
...@@ -86,7 +86,11 @@ void CastActivityManager::LaunchSession( ...@@ -86,7 +86,11 @@ void CastActivityManager::LaunchSession(
MediaRoute route(route_id, source, sink_id, /* description */ std::string(), MediaRoute route(route_id, source, sink_id, /* description */ std::string(),
/* is_local */ true, /* for_display */ true); /* is_local */ true, /* for_display */ true);
route.set_incognito(incognito); route.set_incognito(incognito);
route.set_controller_type(RouteControllerType::kGeneric); if (cast_source.ContainsStreamingApp()) {
route.set_controller_type(RouteControllerType::kMirroring);
} else {
route.set_controller_type(RouteControllerType::kGeneric);
}
route.set_media_sink_name(sink.sink().name()); route.set_media_sink_name(sink.sink().name());
DVLOG(1) << "LaunchSession: source_id=" << cast_source.source_id() DVLOG(1) << "LaunchSession: source_id=" << cast_source.source_id()
<< ", route_id: " << route_id << ", sink_id=" << sink_id; << ", route_id: " << route_id << ", sink_id=" << sink_id;
......
...@@ -143,7 +143,7 @@ class CastActivityManagerTest : public testing::Test, ...@@ -143,7 +143,7 @@ class CastActivityManagerTest : public testing::Test,
})); }));
activities_.push_back(activity_ptr); activities_.push_back(activity_ptr);
activity_record_callback_.Run(activity_ptr); activity_record_callback_.Run(activity_ptr);
return std::move(activity); return activity;
} }
// Run any pending events and verify expectations associated with them. This // Run any pending events and verify expectations associated with them. This
...@@ -164,18 +164,18 @@ class CastActivityManagerTest : public testing::Test, ...@@ -164,18 +164,18 @@ class CastActivityManagerTest : public testing::Test,
route_ = std::make_unique<MediaRoute>(*route); route_ = std::make_unique<MediaRoute>(*route);
} }
void CallLaunchSession(const std::string& source_id = MakeSourceId(kAppId1)) { void CallLaunchSession(const std::string& app_id = kAppId1) {
// MediaRouter is notified of new route. // MediaRouter is notified of new route.
ExpectSingleRouteUpdate(); ExpectSingleRouteUpdate();
// A launch session request is sent to the sink. // A launch session request is sent to the sink.
EXPECT_CALL(message_handler_, EXPECT_CALL(message_handler_,
LaunchSession(kChannelId, "ABCDEFGH", kDefaultLaunchTimeout, _)) LaunchSession(kChannelId, app_id, kDefaultLaunchTimeout, _))
.WillOnce(WithArg<3>([this](auto callback) { .WillOnce(WithArg<3>([this](auto callback) {
launch_session_callback_ = std::move(callback); launch_session_callback_ = std::move(callback);
})); }));
auto source = CastMediaSource::FromMediaSourceId(source_id); auto source = CastMediaSource::FromMediaSourceId(MakeSourceId(app_id));
ASSERT_TRUE(source); ASSERT_TRUE(source);
activity_record_callback_ = activity_record_callback_ =
...@@ -203,8 +203,8 @@ class CastActivityManagerTest : public testing::Test, ...@@ -203,8 +203,8 @@ class CastActivityManagerTest : public testing::Test,
return response; return response;
} }
void LaunchSession(const std::string& source_id = MakeSourceId(kAppId1)) { void LaunchCastAppSession(const std::string& app_id = kAppId1) {
CallLaunchSession(source_id); CallLaunchSession(app_id);
// 3 things will happen: // 3 things will happen:
// (1) SDK client receives new_session message. // (1) SDK client receives new_session message.
...@@ -325,8 +325,14 @@ class CastActivityManagerTest : public testing::Test, ...@@ -325,8 +325,14 @@ class CastActivityManagerTest : public testing::Test,
cast_channel::ResultCallback result_callback_; cast_channel::ResultCallback result_callback_;
}; };
TEST_F(CastActivityManagerTest, LaunchSession) { TEST_F(CastActivityManagerTest, LaunchCastAppSession) {
LaunchSession(); LaunchCastAppSession();
EXPECT_EQ(RouteControllerType::kGeneric, route_->controller_type());
}
TEST_F(CastActivityManagerTest, LaunchMirroringSession) {
CallLaunchSession(kCastStreamingAppId);
EXPECT_EQ(RouteControllerType::kMirroring, route_->controller_type());
} }
TEST_F(CastActivityManagerTest, LaunchSessionFails) { TEST_F(CastActivityManagerTest, LaunchSessionFails) {
...@@ -353,7 +359,7 @@ TEST_F(CastActivityManagerTest, LaunchSessionFails) { ...@@ -353,7 +359,7 @@ TEST_F(CastActivityManagerTest, LaunchSessionFails) {
} }
TEST_F(CastActivityManagerTest, LaunchSessionTerminatesExistingSessionOnSink) { TEST_F(CastActivityManagerTest, LaunchSessionTerminatesExistingSessionOnSink) {
LaunchSession(); LaunchCastAppSession();
EXPECT_CALL(*activities_[0], SendStopSessionMessageToClients); EXPECT_CALL(*activities_[0], SendStopSessionMessageToClients);
...@@ -396,7 +402,7 @@ TEST_F(CastActivityManagerTest, AddRemoveNonLocalActivity) { ...@@ -396,7 +402,7 @@ TEST_F(CastActivityManagerTest, AddRemoveNonLocalActivity) {
} }
TEST_F(CastActivityManagerTest, UpdateNewlyCreatedSession) { TEST_F(CastActivityManagerTest, UpdateNewlyCreatedSession) {
LaunchSession(); LaunchCastAppSession();
EXPECT_CALL(*activities_[0], SetOrUpdateSession(_, sink_, _)); EXPECT_CALL(*activities_[0], SetOrUpdateSession(_, sink_, _));
auto session = MakeSession(kAppId1); auto session = MakeSession(kAppId1);
...@@ -408,7 +414,7 @@ TEST_F(CastActivityManagerTest, UpdateNewlyCreatedSession) { ...@@ -408,7 +414,7 @@ TEST_F(CastActivityManagerTest, UpdateNewlyCreatedSession) {
} }
TEST_F(CastActivityManagerTest, OnSessionAddedOrUpdated) { TEST_F(CastActivityManagerTest, OnSessionAddedOrUpdated) {
LaunchSession(); LaunchCastAppSession();
auto session = MakeSession(kAppId1); auto session = MakeSession(kAppId1);
ExpectSingleRouteUpdate(); ExpectSingleRouteUpdate();
EXPECT_CALL(*activities_[0], SetOrUpdateSession(_, _, "theHashToken")); EXPECT_CALL(*activities_[0], SetOrUpdateSession(_, _, "theHashToken"));
...@@ -416,12 +422,12 @@ TEST_F(CastActivityManagerTest, OnSessionAddedOrUpdated) { ...@@ -416,12 +422,12 @@ TEST_F(CastActivityManagerTest, OnSessionAddedOrUpdated) {
} }
TEST_F(CastActivityManagerTest, TerminateSession) { TEST_F(CastActivityManagerTest, TerminateSession) {
LaunchSession(); LaunchCastAppSession();
TerminateSession(true); TerminateSession(true);
} }
TEST_F(CastActivityManagerTest, TerminateSessionFails) { TEST_F(CastActivityManagerTest, TerminateSessionFails) {
LaunchSession(); LaunchCastAppSession();
TerminateSession(false); TerminateSession(false);
} }
...@@ -433,7 +439,7 @@ TEST_F(CastActivityManagerTest, TerminateSessionBeforeLaunchResponse) { ...@@ -433,7 +439,7 @@ TEST_F(CastActivityManagerTest, TerminateSessionBeforeLaunchResponse) {
} }
TEST_F(CastActivityManagerTest, AppMessageFromReceiver) { TEST_F(CastActivityManagerTest, AppMessageFromReceiver) {
LaunchSession(); LaunchCastAppSession();
// Destination ID matches client ID. // Destination ID matches client ID.
cast::channel::CastMessage message = cast_channel::CreateCastMessage( cast::channel::CastMessage message = cast_channel::CreateCastMessage(
...@@ -445,7 +451,7 @@ TEST_F(CastActivityManagerTest, AppMessageFromReceiver) { ...@@ -445,7 +451,7 @@ TEST_F(CastActivityManagerTest, AppMessageFromReceiver) {
} }
TEST_F(CastActivityManagerTest, OnMediaStatusUpdated) { TEST_F(CastActivityManagerTest, OnMediaStatusUpdated) {
LaunchSession(); LaunchCastAppSession();
const char status[] = R"({"foo": "bar"})"; const char status[] = R"({"foo": "bar"})";
base::Optional<int> request_id(345); base::Optional<int> request_id(345);
......
...@@ -377,6 +377,10 @@ bool CastMediaSource::ContainsAnyAppFrom( ...@@ -377,6 +377,10 @@ bool CastMediaSource::ContainsAnyAppFrom(
[this](const std::string& app_id) { return ContainsApp(app_id); }); [this](const std::string& app_id) { return ContainsApp(app_id); });
} }
bool CastMediaSource::ContainsStreamingApp() const {
return ContainsAnyAppFrom({kCastStreamingAppId, kCastStreamingAudioAppId});
}
std::vector<std::string> CastMediaSource::GetAppIds() const { std::vector<std::string> CastMediaSource::GetAppIds() const {
std::vector<std::string> app_ids; std::vector<std::string> app_ids;
for (const auto& info : app_infos_) for (const auto& info : app_infos_)
......
...@@ -135,9 +135,11 @@ class CastMediaSource { ...@@ -135,9 +135,11 @@ class CastMediaSource {
CastMediaSource(const CastMediaSource& other); CastMediaSource(const CastMediaSource& other);
~CastMediaSource(); ~CastMediaSource();
// Returns |true| if |app_infos| contain |app_id|. // Returns true if |app_infos_| contain |app_id|.
bool ContainsApp(const std::string& app_id) const; bool ContainsApp(const std::string& app_id) const;
bool ContainsAnyAppFrom(const std::vector<std::string>& app_ids) const; bool ContainsAnyAppFrom(const std::vector<std::string>& app_ids) const;
// Returns true if |app_infos_| contain streaming or audio streaming app ID.
bool ContainsStreamingApp() const;
// Returns a list of App IDs in this CastMediaSource. // Returns a list of App IDs in this CastMediaSource.
std::vector<std::string> GetAppIds() const; std::vector<std::string> GetAppIds() const;
......
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