chromium/components/media_router/common/providers/cast/channel/cast_message_util.cc

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

#include "components/media_router/common/providers/cast/channel/cast_message_util.h"

#include <memory>
#include <string_view>

#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/media_router/common/providers/cast/channel/cast_auth_util.h"
#include "components/media_router/common/providers/cast/channel/enum_table.h"
#include "third_party/openscreen/src/cast/common/channel/proto/cast_channel.pb.h"

Value;
EnumToString;
StringToEnum;

namespace cast_util {

CastMessageType;
GetAppAvailabilityResult;
AuthChallenge;
CastMessage;

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

template <>
const EnumTable<cast_channel::V2MessageType>&
EnumTable<cast_channel::V2MessageType>::GetInstance() {}

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

}  // namespace cast_util

namespace cast_channel {

namespace {

constexpr std::string_view kCastReservedNamespacePrefix =;

constexpr const char* kReservedNamespaces[] =;

// The value used for "sdkType" in a virtual connect request. Historically, this
// value is used in the Media Router extension, but here it is reused in Chrome.
constexpr int kVirtualConnectSdkType =;

// The value used for "connectionType" in a virtual connect request. This value
// stands for CONNECTION_TYPE_LOCAL, which is the only type used in Chrome.
constexpr int kVirtualConnectTypeLocal =;

// The reason code passed to the virtual connection CLOSE message indicating
// that the connection has been gracefully closed by the sender.
constexpr int kVirtualConnectionClosedByPeer =;

void FillCommonCastMessageFields(CastMessage* message,
                                 const std::string& source_id,
                                 const std::string& destination_id,
                                 const std::string& message_namespace) {}

CastMessage CreateKeepAliveMessage(std::string_view keep_alive_type) {}

// Returns the value to be set as the "platform" value in a virtual connect
// request. The value is platform-dependent and is taken from the Platform enum
// defined in third_party/metrics_proto/cast_logs.proto.
int GetVirtualConnectPlatformValue() {}

// Maps from from API-internal message types to "real" message types from the
// Cast V2 protocol.  This is necessary because the protocol defines messages
// with the same type in different namespaces, and the namespace is lost when
// messages are passed using a CastInternalMessage object.
std::string_view GetRemappedMediaRequestType(std::string_view v2_message_type) {}

}  // namespace

std::ostream& operator<<(std::ostream& lhs, const CastMessage& rhs) {}

bool IsCastMessageValid(const CastMessage& message_proto) {}

bool IsCastReservedNamespace(std::string_view message_namespace) {}

CastMessageType ParseMessageTypeFromPayload(const base::Value::Dict& payload) {}

// TODO(crbug.com/1291730): Eliminate this function.
const char* ToString(CastMessageType message_type) {}

// TODO(crbug.com/1291730): Eliminate this function.
const char* ToString(V2MessageType message_type) {}

// TODO(crbug.com/1291730): Eliminate this function.
CastMessageType CastMessageTypeFromString(const std::string& type) {}

// TODO(crbug.com/1291730): Eliminate this function.
V2MessageType V2MessageTypeFromString(const std::string& type) {}

std::string AuthMessageToString(const DeviceAuthMessage& message) {}

void CreateAuthChallengeMessage(CastMessage* message_proto,
                                const AuthContext& auth_context) {}

bool IsAuthMessage(const CastMessage& message) {}

bool IsReceiverMessage(const CastMessage& message) {}

bool IsPlatformSenderMessage(const CastMessage& message) {}

CastMessage CreateKeepAlivePingMessage() {}

CastMessage CreateKeepAlivePongMessage() {}

CastMessage CreateVirtualConnectionRequest(
    const std::string& source_id,
    const std::string& destination_id,
    VirtualConnectionType connection_type,
    const std::string& user_agent,
    const std::string& browser_version) {}

CastMessage CreateVirtualConnectionClose(const std::string& source_id,
                                         const std::string& destination_id) {}

CastMessage CreateGetAppAvailabilityRequest(const std::string& source_id,
                                            int request_id,
                                            const std::string& app_id) {}

CastMessage CreateReceiverStatusRequest(const std::string& source_id,
                                        int request_id) {}

CastMessage CreateLaunchRequest(
    const std::string& source_id,
    int request_id,
    const std::string& app_id,
    const std::string& locale,
    const std::vector<std::string>& supported_app_types,
    const std::optional<base::Value>& app_params) {}

CastMessage CreateStopRequest(const std::string& source_id,
                              int request_id,
                              const std::string& session_id) {}

CastMessage CreateCastMessage(const std::string& message_namespace,
                              const base::Value& message,
                              const std::string& source_id,
                              const std::string& destination_id) {}

CastMessage CreateMediaRequest(const base::Value::Dict& body,
                               int request_id,
                               const std::string& source_id,
                               const std::string& destination_id) {}

CastMessage CreateSetVolumeRequest(const base::Value::Dict& body,
                                   int request_id,
                                   const std::string& source_id) {}

bool IsMediaRequestMessageType(V2MessageType type) {}

// TODO(crbug.com/1291730): Eliminate this function.
const char* ToString(GetAppAvailabilityResult result) {}

std::optional<int> GetRequestIdFromResponse(const Value::Dict& payload) {}

GetAppAvailabilityResult GetAppAvailabilityResultFromResponse(
    const Value::Dict& payload,
    const std::string& app_id) {}

LaunchSessionResponse::LaunchSessionResponse() = default;
LaunchSessionResponse::LaunchSessionResponse(LaunchSessionResponse&& other) =
    default;
LaunchSessionResponse& LaunchSessionResponse::operator=(
    LaunchSessionResponse&& other) = default;
LaunchSessionResponse::~LaunchSessionResponse() = default;

LaunchSessionResponse GetLaunchSessionResponseError(std::string error_msg) {}

LaunchSessionResponse GetLaunchSessionResponse(
    const base::Value::Dict& payload) {}

VirtualConnectionType GetConnectionType(const std::string& destination_id) {}

}  // namespace cast_channel