chromium/components/media_router/common/providers/cast/cast_media_source.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 "components/media_router/common/providers/cast/cast_media_source.h"

#include <string_view>
#include <utility>

#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
#include "base/ranges/algorithm.h"
#include "base/strings/escape.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "components/media_router/common/media_source.h"
#include "components/media_router/common/providers/cast/channel/cast_device_capability.h"
#include "components/media_router/common/providers/cast/channel/cast_message_util.h"
#include "components/media_router/common/providers/cast/channel/enum_table.h"
#include "net/base/url_util.h"
#include "third_party/openscreen/src/cast/common/public/cast_streaming_app_ids.h"
#include "url/gurl.h"
#include "url/url_util.h"

CastDeviceCapability;
ReceiverAppType;

namespace cast_util {

AutoJoinPolicy;
DefaultActionPolicy;

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

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

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

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

}  // namespace cast_util

namespace media_router {

// The maximum length of presentation URL is 64KB.
constexpr int kMaxCastPresentationUrlLength =;

namespace {

// A nonmember version of std::optional::value_or that works on pointers as
// well as instance of std::optional.
template <typename T>
inline auto value_or(const T& optional,
                     const std::decay_t<decltype(*optional)>& default_value)
    -> std::decay_t<decltype(*optional)> {}

// FindValue() looks up the value associated with a key |key| in a map-like
// object |map| and returns a pointer to the value if |key| is found, or nullptr
// otherwise.
//
// The type of |map| can be anything that supports a find() method like
// std::map::find, or any iterable object whose values are key/value pairs.
//
// See also FindValueOr().

// Overload for types with a find() method.
template <typename Map, typename = typename Map::key_type>
inline const typename Map::mapped_type* FindValue(
    const Map& map,
    const typename Map::key_type& key) {}

// Overload for types without a find() method.
template <typename Map, typename Key>
auto FindValue(const Map& map, const Key& key) -> const
    decltype(begin(map)->second)* {}

// Looks up the value associated with a key |key| in a map-like object |map| and
// returns a reference to the value if |key| is found, or |default_value|
// otherwise.
//
// The type of |map| can be anything that supports a find() method like
// std::map::find, or any iterable object whose values are key/value pairs.
template <typename Map, typename Key, typename T>
inline auto FindValueOr(const Map& map, const Key& key, const T& default_value)
    -> std::decay_t<decltype(*FindValue(map, key))> {}

// Creates a map from the query parameters of |url|.  If |url| contains multiple
// values for the same parameter, the last value is used.
base::flat_map<std::string, std::string> MakeQueryMap(const GURL& url) {}

// Converts a string containing a comma-separated list of capabilities into an
// EnumSet of CastDeviceCapability values.
CastDeviceCapabilitySet CastDeviceCapabilitiesFromString(std::string_view s) {}

std::vector<ReceiverAppType> SupportedAppTypesFromString(std::string_view s) {}

std::unique_ptr<CastMediaSource> CastMediaSourceForTabMirroring(
    const MediaSource::Id& source_id) {}

std::unique_ptr<CastMediaSource> CastMediaSourceForDesktopMirroring(
    const MediaSource& source) {}

std::unique_ptr<CastMediaSource> CastMediaSourceForRemotePlayback(
    const MediaSource& source) {}

// The logic shared by ParseCastUrl() and ParseLegacyCastUrl().
std::unique_ptr<CastMediaSource> CreateFromURLParams(
    const MediaSource::Id& source_id,
    const std::vector<CastAppInfo>& app_infos,
    const std::string& auto_join_policy_str,
    const std::string& default_action_policy_str,
    const std::string& client_id,
    const std::string& launch_timeout_str,
    const std::string& target_playout_delay_millis_str,
    const std::string& audio_capture_str,
    const std::vector<ReceiverAppType>& supported_app_types,
    const std::string& app_params,
    const std::string& invisible_sender) {}

std::unique_ptr<CastMediaSource> ParseCastUrl(const MediaSource::Id& source_id,
                                              const GURL& url) {}

std::unique_ptr<CastMediaSource> ParseLegacyCastUrl(
    const MediaSource::Id& source_id,
    const GURL& url) {}

}  // namespace

bool IsAutoJoinAllowed(AutoJoinPolicy policy,
                       const url::Origin& origin1,
                       int tab_id1,
                       const url::Origin& origin2,
                       int tab_id2) {}

bool IsSiteInitiatedMirroringSource(const MediaSource::Id& source_id) {}

CastAppInfo::CastAppInfo(const std::string& app_id,
                         CastDeviceCapabilitySet required_capabilities)
    :{}

CastAppInfo::~CastAppInfo() = default;

CastAppInfo::CastAppInfo(const CastAppInfo& other) = default;

// static
CastAppInfo CastAppInfo::ForCastStreaming() {}

// static
CastAppInfo CastAppInfo::ForCastStreamingAudio() {}

// static
std::unique_ptr<CastMediaSource> CastMediaSource::FromMediaSource(
    const MediaSource& source) {}

// static
std::unique_ptr<CastMediaSource> CastMediaSource::FromMediaSourceId(
    const MediaSource::Id& source_id) {}

// static
std::unique_ptr<CastMediaSource> CastMediaSource::FromAppId(
    const std::string& app_id) {}

// static
std::unique_ptr<CastMediaSource> CastMediaSource::ForSiteInitiatedMirroring() {}

CastMediaSource::CastMediaSource(const MediaSource::Id& source_id,
                                 const std::vector<CastAppInfo>& app_infos,
                                 AutoJoinPolicy auto_join_policy,
                                 DefaultActionPolicy default_action_policy)
    :{}
CastMediaSource::CastMediaSource(const CastMediaSource& other) = default;
CastMediaSource::~CastMediaSource() = default;

bool CastMediaSource::ContainsApp(const std::string& app_id) const {}

bool CastMediaSource::ContainsAnyAppFrom(
    const std::vector<std::string>& app_ids) const {}

bool CastMediaSource::ContainsStreamingApp() const {}

std::vector<std::string> CastMediaSource::GetAppIds() const {}

bool CastMediaSource::ProvidesStreamingAudioCapture() const {}

void CastMediaSource::set_supported_app_types(
    const std::vector<ReceiverAppType>& types) {}

}  // namespace media_router