Commit 05a1b870 authored by John Williams's avatar John Williams Committed by Commit Bot

[Cast MRP] Request media status on session connection.

Bug: 1137962
Change-Id: Id19178ecc46231eef71ccb9e16d27e1aafdd1470
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2468567
Commit-Queue: John Williams <jrw@chromium.org>
Reviewed-by: default avatarTakumi Fujimoto <takumif@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824127}
parent 02cc2edd
...@@ -818,24 +818,25 @@ void CastActivityManager::HandleLaunchSessionResponse( ...@@ -818,24 +818,25 @@ void CastActivityManager::HandleLaunchSessionResponse(
} }
RecordLaunchSessionResponseAppType(session->value().FindKey("appType")); RecordLaunchSessionResponseAppType(session->value().FindKey("appType"));
const std::string& client_id = cast_source.client_id();
const auto channel_id = sink.cast_data().cast_channel_id;
const auto destination_id = session->transport_id();
// Cast SDK sessions have a |client_id|, and we ensure a virtual connection // Cast SDK sessions have a |client_id|, and we ensure a virtual connection
// for them. For mirroring sessions, we ensure a strong virtual connection for // for them. For mirroring sessions, we ensure a strong virtual connection for
// |message_handler_|. Mirroring initiated via the Cast SDK will have // |message_handler_|. Mirroring initiated via the Cast SDK will have
// EnsureConnection() called for both. // EnsureConnection() called for both.
const std::string& client_id = cast_source.client_id();
if (!client_id.empty()) { if (!client_id.empty()) {
activity_it->second->SendMessageToClient( activity_it->second->SendMessageToClient(
client_id, client_id,
CreateNewSessionMessage(*session, client_id, sink, hash_token_)); CreateNewSessionMessage(*session, client_id, sink, hash_token_));
message_handler_->EnsureConnection(sink.cast_data().cast_channel_id, message_handler_->EnsureConnection(channel_id, client_id, destination_id,
client_id, session->transport_id(),
cast_source.connection_type()); cast_source.connection_type());
// TODO(jrw): Query media status.
} }
if (cast_source.ContainsStreamingApp()) { if (cast_source.ContainsStreamingApp()) {
message_handler_->EnsureConnection( message_handler_->EnsureConnection(
sink.cast_data().cast_channel_id, message_handler_->sender_id(), channel_id, message_handler_->sender_id(), destination_id,
session->transport_id(), cast_channel::VirtualConnectionType::kStrong); cast_channel::VirtualConnectionType::kStrong);
} else if (client_id.empty()) { } else if (client_id.empty()) {
logger_->LogError( logger_->LogError(
mojom::LogCategory::kRoute, kLoggerComponent, mojom::LogCategory::kRoute, kLoggerComponent,
...@@ -845,6 +846,19 @@ void CastActivityManager::HandleLaunchSessionResponse( ...@@ -845,6 +846,19 @@ void CastActivityManager::HandleLaunchSessionResponse(
} }
activity_it->second->SetOrUpdateSession(*session, sink, hash_token_); activity_it->second->SetOrUpdateSession(*session, sink, hash_token_);
if (!client_id.empty() && base::Contains(session->message_namespaces(),
cast_channel::kMediaNamespace)) {
// Request media status from the receiver.
base::Value request(base::Value::Type::DICTIONARY);
request.SetStringKey("type",
cast_util::EnumToString<
cast_channel::V2MessageType,
cast_channel::V2MessageType::kMediaGetStatus>());
message_handler_->SendMediaRequest(channel_id, request, client_id,
destination_id);
}
NotifyAllOnRoutesUpdated(); NotifyAllOnRoutesUpdated();
logger_->LogInfo(mojom::LogCategory::kRoute, kLoggerComponent, logger_->LogInfo(mojom::LogCategory::kRoute, kLoggerComponent,
"Successfully Launched the session.", sink.id(), "Successfully Launched the session.", sink.id(),
......
...@@ -291,6 +291,12 @@ class CastActivityManagerTest : public testing::Test, ...@@ -291,6 +291,12 @@ class CastActivityManagerTest : public testing::Test,
EXPECT_CALL(message_handler_, EXPECT_CALL(message_handler_,
EnsureConnection(kChannelId, "theClientId", "theTransportId", EnsureConnection(kChannelId, "theClientId", "theTransportId",
cast_channel::VirtualConnectionType::kStrong)); cast_channel::VirtualConnectionType::kStrong));
EXPECT_CALL(message_handler_,
SendMediaRequest(kChannelId,
// NOTE: MEDIA_GET_STATUS is translated to
// GET_STATUS inside SendMediaRequest.
IsJson(R"({"type": "MEDIA_GET_STATUS"})"),
"theClientId", "theTransportId"));
auto response = GetSuccessLaunchResponse(app_id); auto response = GetSuccessLaunchResponse(app_id);
session_tracker_->SetSessionForTest( session_tracker_->SetSessionForTest(
......
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