chromium/chrome/browser/media/router/providers/cast/cast_internal_message_util.cc

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/media/router/providers/cast/cast_internal_message_util.h"

#include <string>
#include <string_view>
#include <utility>

#include "base/base64url.h"
#include "base/hash/sha1.h"
#include "base/json/json_writer.h"
#include "base/memory/ptr_util.h"
#include "base/strings/escape.h"
#include "components/media_router/common/discovery/media_sink_internal.h"
#include "components/media_router/common/providers/cast/cast_media_source.h"
#include "components/media_router/common/providers/cast/channel/cast_device_capability.h"
#include "components/media_router/common/providers/cast/channel/enum_table.h"

CastDeviceCapability;
CastDeviceCapabilitySet;

namespace cast_util {

CastInternalMessage;

template <>
const EnumTable<CastInternalMessage::Type>&
EnumTable<CastInternalMessage::Type>::GetInstance() {}

template <>
const EnumTable<CastInternalMessage::ErrorCode>&
EnumTable<CastInternalMessage::ErrorCode>::GetInstance() {}

}  // namespace cast_util

namespace media_router {

namespace {

// The ID for the backdrop app. Cast devices running the backdrop app is
// considered idle, and an active session should not be reported.
constexpr char kBackdropAppId[] =;

bool GetString(const base::Value::Dict& value,
               const std::string& key,
               std::string* out) {}

void CopyValueWithDefault(const base::Value::Dict& from,
                          const std::string& key,
                          base::Value default_value,
                          base::Value::Dict& to) {}

void CopyValue(const base::Value::Dict& from,
               const std::string& key,
               base::Value::Dict& to) {}

CastInternalMessage::Type CastInternalMessageTypeFromString(
    const std::string& type) {}

std::string CastInternalMessageTypeToString(CastInternalMessage::Type type) {}

// Possible types in a receiver_action message.
constexpr char kReceiverActionTypeCast[] =;
constexpr char kReceiverActionTypeStop[] =;

base::Value::List CapabilitiesToListValue(
    CastDeviceCapabilitySet capabilities) {}

std::string GetReceiverLabel(const MediaSinkInternal& sink,
                             const std::string& hash_token) {}

base::Value::Dict CreateReceiver(const MediaSinkInternal& sink,
                                 const std::string& hash_token) {}

blink::mojom::PresentationConnectionMessagePtr CreateMessageCommon(
    CastInternalMessage::Type type,
    base::Value::Dict payload,
    const std::string& client_id,
    std::optional<int> sequence_number = std::nullopt) {}

blink::mojom::PresentationConnectionMessagePtr CreateReceiverActionMessage(
    const std::string& client_id,
    const MediaSinkInternal& sink,
    const std::string& hash_token,
    const char* action_type) {}

base::Value::Dict CreateAppMessageBody(
    const std::string& session_id,
    const openscreen::cast::proto::CastMessage& cast_message) {}

// Creates a message with a session value in the "message" field. |type| must
// be either kNewSession or kUpdateSession.
blink::mojom::PresentationConnectionMessagePtr CreateSessionMessage(
    const CastSession& session,
    const std::string& client_id,
    const MediaSinkInternal& sink,
    const std::string& hash_token,
    CastInternalMessage::Type type) {}

}  // namespace

// static
std::unique_ptr<CastInternalMessage> CastInternalMessage::From(
    base::Value::Dict message) {}

CastInternalMessage::~CastInternalMessage() = default;

CastInternalMessage::CastInternalMessage(
    Type type,
    const std::string& client_id,
    std::optional<int> sequence_number,
    const std::string& session_id,
    const std::string& namespace_or_v2_type,
    base::Value message_body)
    :{}

// static
std::unique_ptr<CastSession> CastSession::From(
    const MediaSinkInternal& sink,
    const base::Value::Dict& receiver_status) {}

CastSession::CastSession() = default;
CastSession::~CastSession() = default;

std::string CastSession::GetRouteDescription() const {}

void CastSession::UpdateSession(std::unique_ptr<CastSession> from) {}

void CastSession::UpdateMedia(const base::Value::List& media) {}

blink::mojom::PresentationConnectionMessagePtr CreateReceiverActionCastMessage(
    const std::string& client_id,
    const MediaSinkInternal& sink,
    const std::string& hash_token) {}

blink::mojom::PresentationConnectionMessagePtr CreateReceiverActionStopMessage(
    const std::string& client_id,
    const MediaSinkInternal& sink,
    const std::string& hash_token) {}

blink::mojom::PresentationConnectionMessagePtr CreateNewSessionMessage(
    const CastSession& session,
    const std::string& client_id,
    const MediaSinkInternal& sink,
    const std::string& hash_token) {}

blink::mojom::PresentationConnectionMessagePtr CreateUpdateSessionMessage(
    const CastSession& session,
    const std::string& client_id,
    const MediaSinkInternal& sink,
    const std::string& hash_token) {}

blink::mojom::PresentationConnectionMessagePtr CreateAppMessageAck(
    const std::string& client_id,
    int sequence_number) {}

blink::mojom::PresentationConnectionMessagePtr CreateAppMessage(
    const std::string& session_id,
    const std::string& client_id,
    const openscreen::cast::proto::CastMessage& cast_message) {}

blink::mojom::PresentationConnectionMessagePtr CreateV2Message(
    const std::string& client_id,
    const base::Value::Dict& payload,
    std::optional<int> sequence_number) {}

blink::mojom::PresentationConnectionMessagePtr CreateLeaveSessionAckMessage(
    const std::string& client_id,
    std::optional<int> sequence_number) {}

blink::mojom::PresentationConnectionMessagePtr CreateErrorMessage(
    const std::string& client_id,
    base::Value::Dict error,
    std::optional<int> sequence_number) {}

base::Value::List SupportedMediaCommandsToListValue(int media_commands) {}

}  // namespace media_router