#include "chrome/browser/media/router/providers/wired_display/wired_display_media_route_provider.h"
#include <string>
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/i18n/number_formatting.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/media/router/media_router_feature.h"
#include "chrome/browser/media/router/providers/wired_display/wired_display_presentation_receiver_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/grit/generated_resources.h"
#include "components/media_router/common/media_source.h"
#include "components/media_router/common/route_request_result.h"
#include "third_party/abseil-cpp/absl/utility/utility.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
Display;
namespace media_router {
namespace {
MediaSinkInternal CreateSinkForDisplay(const Display& display,
int display_index) { … }
bool CompareDisplays(int64_t primary_id,
const Display& display1,
const Display& display2) { … }
}
const mojom::MediaRouteProviderId WiredDisplayMediaRouteProvider::kProviderId = …;
std::string WiredDisplayMediaRouteProvider::GetSinkIdForDisplay(
const Display& display) { … }
std::string WiredDisplayMediaRouteProvider::GetRouteDescription(
const std::string& media_source) { … }
WiredDisplayMediaRouteProvider::WiredDisplayMediaRouteProvider(
mojo::PendingReceiver<mojom::MediaRouteProvider> receiver,
mojo::PendingRemote<mojom::MediaRouter> media_router,
Profile* profile)
: … { … }
WiredDisplayMediaRouteProvider::~WiredDisplayMediaRouteProvider() = default;
void WiredDisplayMediaRouteProvider::CreateRoute(
const std::string& media_source,
const std::string& sink_id,
const std::string& presentation_id,
const url::Origin& origin,
int32_t frame_tree_node_id,
base::TimeDelta timeout,
CreateRouteCallback callback) { … }
void WiredDisplayMediaRouteProvider::JoinRoute(
const std::string& media_source,
const std::string& presentation_id,
const url::Origin& origin,
int32_t frame_tree_node_id,
base::TimeDelta timeout,
JoinRouteCallback callback) { … }
void WiredDisplayMediaRouteProvider::TerminateRoute(
const std::string& route_id,
TerminateRouteCallback callback) { … }
void WiredDisplayMediaRouteProvider::SendRouteMessage(
const std::string& media_route_id,
const std::string& message) { … }
void WiredDisplayMediaRouteProvider::SendRouteBinaryMessage(
const std::string& media_route_id,
const std::vector<uint8_t>& data) { … }
void WiredDisplayMediaRouteProvider::StartObservingMediaSinks(
const std::string& media_source) { … }
void WiredDisplayMediaRouteProvider::StopObservingMediaSinks(
const std::string& media_source) { … }
void WiredDisplayMediaRouteProvider::StartObservingMediaRoutes() { … }
void WiredDisplayMediaRouteProvider::DetachRoute(const std::string& route_id) { … }
void WiredDisplayMediaRouteProvider::EnableMdnsDiscovery() { … }
void WiredDisplayMediaRouteProvider::DiscoverSinksNow() { … }
void WiredDisplayMediaRouteProvider::BindMediaController(
const std::string& route_id,
mojo::PendingReceiver<mojom::MediaController> media_controller,
mojo::PendingRemote<mojom::MediaStatusObserver> observer,
BindMediaControllerCallback callback) { … }
void WiredDisplayMediaRouteProvider::GetState(GetStateCallback callback) { … }
void WiredDisplayMediaRouteProvider::OnDisplayAdded(
const Display& new_display) { … }
void WiredDisplayMediaRouteProvider::OnDisplaysRemoved(
const display::Displays& removed_displays) { … }
void WiredDisplayMediaRouteProvider::OnDisplayMetricsChanged(
const Display& display,
uint32_t changed_metrics) { … }
std::vector<Display> WiredDisplayMediaRouteProvider::GetAllDisplays() const { … }
Display WiredDisplayMediaRouteProvider::GetPrimaryDisplay() const { … }
WiredDisplayMediaRouteProvider::Presentation::Presentation(
const MediaRoute& route)
: … { … }
WiredDisplayMediaRouteProvider::Presentation::Presentation(
Presentation&& other) = default;
WiredDisplayMediaRouteProvider::Presentation::~Presentation() = default;
void WiredDisplayMediaRouteProvider::Presentation::UpdatePresentationTitle(
const std::string& title) { … }
void WiredDisplayMediaRouteProvider::Presentation::SetMojoConnections(
mojo::PendingReceiver<mojom::MediaController> media_controller,
mojo::PendingRemote<mojom::MediaStatusObserver> observer) { … }
void WiredDisplayMediaRouteProvider::Presentation::ResetMojoConnections() { … }
void WiredDisplayMediaRouteProvider::NotifyRouteObservers() const { … }
void WiredDisplayMediaRouteProvider::NotifySinkObservers() { … }
std::vector<MediaSinkInternal> WiredDisplayMediaRouteProvider::GetSinks()
const { … }
std::vector<Display> WiredDisplayMediaRouteProvider::GetAvailableDisplays()
const { … }
void WiredDisplayMediaRouteProvider::RemovePresentationById(
const std::string& presentation_id) { … }
std::unique_ptr<WiredDisplayPresentationReceiver>
WiredDisplayMediaRouteProvider::CreatePresentationReceiver(
const std::string& presentation_id,
Presentation* presentation,
const Display& display) { … }
void WiredDisplayMediaRouteProvider::TerminatePresentationsOnDisplay(
const display::Display& display) { … }
std::optional<Display> WiredDisplayMediaRouteProvider::GetDisplayBySinkId(
const std::string& sink_id) const { … }
}