#include "chrome/browser/media/cast_remoting_connector.h"
#include <memory>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "build/build_config.h"
#include "chrome/browser/media/router/media_router_feature.h"
#include "components/media_router/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/sessions/content/session_tab_helper.h"
#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#if defined(TOOLKIT_VIEWS)
#include "chrome/browser/ui/views/media_router/media_remoting_dialog_view.h"
#endif
BrowserThread;
RemotingSinkMetadata;
RemotingStartFailReason;
RemotingStopReason;
bool MediaRemotingDialogCoordinator::Show(
PermissionCallback permission_callback) { … }
void MediaRemotingDialogCoordinator::Hide() { … }
bool MediaRemotingDialogCoordinator::IsShowing() const { … }
class CastRemotingConnector::RemotingBridge final
: public media::mojom::Remoter { … };
const void* const CastRemotingConnector::kUserDataKey = …;
CastRemotingConnector* CastRemotingConnector::Get(
content::WebContents* contents) { … }
void CastRemotingConnector::CreateMediaRemoter(
content::RenderFrameHost* host,
mojo::PendingRemote<media::mojom::RemotingSource> source,
mojo::PendingReceiver<media::mojom::Remoter> receiver) { … }
CastRemotingConnector::CastRemotingConnector(
PrefService* pref_service,
SessionID tab_id,
std::unique_ptr<MediaRemotingDialogCoordinator> dialog_coordinator)
: … { … }
CastRemotingConnector::~CastRemotingConnector() { … }
void CastRemotingConnector::ResetRemotingPermission() { … }
void CastRemotingConnector::ConnectWithMediaRemoter(
mojo::PendingRemote<media::mojom::Remoter> remoter,
mojo::PendingReceiver<media::mojom::RemotingSource> receiver) { … }
void CastRemotingConnector::OnMirrorServiceStopped() { … }
void CastRemotingConnector::CreateBridge(
mojo::PendingRemote<media::mojom::RemotingSource> source,
mojo::PendingReceiver<media::mojom::Remoter> receiver) { … }
void CastRemotingConnector::RegisterBridge(RemotingBridge* bridge) { … }
void CastRemotingConnector::DeregisterBridge(RemotingBridge* bridge,
RemotingStopReason reason) { … }
void CastRemotingConnector::StartRemoting(RemotingBridge* bridge) { … }
void CastRemotingConnector::StartWithPermissionAlreadyGranted(
RemotingBridge* bridge) { … }
bool CastRemotingConnector::StartRemotingCommon(RemotingBridge* bridge) { … }
void CastRemotingConnector::OnDialogClosed(bool remoting_allowed) { … }
void CastRemotingConnector::StartRemotingIfPermitted() { … }
void CastRemotingConnector::StartRemotingDataStreams(
RemotingBridge* bridge,
mojo::ScopedDataPipeConsumerHandle audio_pipe,
mojo::ScopedDataPipeConsumerHandle video_pipe,
mojo::PendingReceiver<media::mojom::RemotingDataStreamSender> audio_sender,
mojo::PendingReceiver<media::mojom::RemotingDataStreamSender>
video_sender) { … }
void CastRemotingConnector::StopRemoting(RemotingBridge* bridge,
RemotingStopReason reason,
bool is_initiated_by_source) { … }
void CastRemotingConnector::OnStopped(RemotingStopReason reason) { … }
void CastRemotingConnector::SendMessageToSink(
RemotingBridge* bridge,
const std::vector<uint8_t>& message) { … }
void CastRemotingConnector::OnMessageFromSink(
const std::vector<uint8_t>& message) { … }
void CastRemotingConnector::EstimateTransmissionCapacity(
media::mojom::Remoter::EstimateTransmissionCapacityCallback callback) { … }
void CastRemotingConnector::OnSinkAvailable(
media::mojom::RemotingSinkMetadataPtr metadata) { … }
void CastRemotingConnector::OnSinkGone() { … }
void CastRemotingConnector::OnStarted() { … }
void CastRemotingConnector::OnStartFailed(RemotingStartFailReason reason) { … }
void CastRemotingConnector::OnDataSendFailed() { … }
void CastRemotingConnector::StartObservingPref() { … }
void CastRemotingConnector::OnPrefChanged() { … }
std::optional<bool> CastRemotingConnector::GetRemotingAllowedUserPref() const { … }