#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 media_router {
constexpr int kMaxCastPresentationUrlLength = …;
namespace {
template <typename T>
inline auto value_or(const T& optional,
const std::decay_t<decltype(*optional)>& default_value)
-> std::decay_t<decltype(*optional)> { … }
template <typename Map, typename = typename Map::key_type>
inline const typename Map::mapped_type* FindValue(
const Map& map,
const typename Map::key_type& key) { … }
template <typename Map, typename Key>
auto FindValue(const Map& map, const Key& key) -> const
decltype(begin(map)->second)* { … }
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))> { … }
base::flat_map<std::string, std::string> MakeQueryMap(const GURL& url) { … }
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) { … }
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) { … }
}
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;
CastAppInfo CastAppInfo::ForCastStreaming() { … }
CastAppInfo CastAppInfo::ForCastStreamingAudio() { … }
std::unique_ptr<CastMediaSource> CastMediaSource::FromMediaSource(
const MediaSource& source) { … }
std::unique_ptr<CastMediaSource> CastMediaSource::FromMediaSourceId(
const MediaSource::Id& source_id) { … }
std::unique_ptr<CastMediaSource> CastMediaSource::FromAppId(
const std::string& app_id) { … }
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) { … }
}