#include "third_party/blink/renderer/modules/remoteplayback/remote_playback.h"
#include <memory>
#include <utility>
#include "base/numerics/safe_conversions.h"
#include "base/strings/strcat.h"
#include "media/base/remoting_constants.h"
#include "third_party/blink/public/platform/modules/remoteplayback/remote_playback_source.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_throw_dom_exception.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_remote_playback_availability_callback.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/html/media/html_media_element.h"
#include "third_party/blink/renderer/core/html/media/html_video_element.h"
#include "third_party/blink/renderer/core/html/media/remote_playback_observer.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/probe/async_task_context.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/modules/event_target_modules.h"
#include "third_party/blink/renderer/modules/presentation/presentation_availability_state.h"
#include "third_party/blink/renderer/modules/presentation/presentation_controller.h"
#include "third_party/blink/renderer/modules/remoteplayback/availability_callback_wrapper.h"
#include "third_party/blink/renderer/modules/remoteplayback/remote_playback_metrics.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/instrumentation/memory_pressure_listener.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/base64.h"
namespace blink {
namespace {
const AtomicString& RemotePlaybackStateToString(
mojom::blink::PresentationConnectionState state) { … }
void RunRemotePlaybackTask(
ExecutionContext* context,
base::OnceClosure task,
std::unique_ptr<probe::AsyncTaskContext> task_context) { … }
KURL GetAvailabilityUrl(const WebURL& source,
bool is_source_supported,
std::optional<media::VideoCodec> video_codec,
std::optional<media::AudioCodec> audio_codec) { … }
bool IsBackgroundAvailabilityMonitoringDisabled() { … }
void RemotingStarting(HTMLMediaElement& media_element) { … }
}
RemotePlayback& RemotePlayback::From(HTMLMediaElement& element) { … }
RemotePlayback::RemotePlayback(HTMLMediaElement& element)
: … { … }
const AtomicString& RemotePlayback::InterfaceName() const { … }
ExecutionContext* RemotePlayback::GetExecutionContext() const { … }
ScriptPromise<IDLLong> RemotePlayback::watchAvailability(
ScriptState* script_state,
V8RemotePlaybackAvailabilityCallback* callback,
ExceptionState& exception_state) { … }
ScriptPromise<IDLUndefined> RemotePlayback::cancelWatchAvailability(
ScriptState* script_state,
int id,
ExceptionState& exception_state) { … }
ScriptPromise<IDLUndefined> RemotePlayback::cancelWatchAvailability(
ScriptState* script_state,
ExceptionState& exception_state) { … }
ScriptPromise<IDLUndefined> RemotePlayback::prompt(
ScriptState* script_state,
ExceptionState& exception_state) { … }
String RemotePlayback::state() const { … }
bool RemotePlayback::HasPendingActivity() const { … }
void RemotePlayback::PromptInternal() { … }
int RemotePlayback::WatchAvailabilityInternal(
AvailabilityCallbackWrapper* callback) { … }
bool RemotePlayback::CancelWatchAvailabilityInternal(int id) { … }
void RemotePlayback::NotifyInitialAvailability(int callback_id) { … }
void RemotePlayback::StateChanged(
mojom::blink::PresentationConnectionState state) { … }
void RemotePlayback::PromptCancelled() { … }
void RemotePlayback::SourceChanged(const WebURL& source,
bool is_source_supported) { … }
void RemotePlayback::UpdateAvailabilityUrlsAndStartListening() { … }
WebString RemotePlayback::GetPresentationId() { … }
void RemotePlayback::MediaMetadataChanged(
std::optional<media::VideoCodec> video_codec,
std::optional<media::AudioCodec> audio_codec) { … }
void RemotePlayback::AddObserver(RemotePlaybackObserver* observer) { … }
void RemotePlayback::RemoveObserver(RemotePlaybackObserver* observer) { … }
void RemotePlayback::AvailabilityChangedForTesting(bool screen_is_available) { … }
void RemotePlayback::StateChangedForTesting(bool is_connected) { … }
bool RemotePlayback::RemotePlaybackAvailable() const { … }
void RemotePlayback::RemotePlaybackDisabled() { … }
void RemotePlayback::CleanupConnections() { … }
void RemotePlayback::AvailabilityChanged(
mojom::blink::ScreenAvailability availability) { … }
const Vector<KURL>& RemotePlayback::Urls() const { … }
void RemotePlayback::OnConnectionSuccess(
mojom::blink::PresentationConnectionResultPtr result) { … }
void RemotePlayback::OnConnectionError(
const mojom::blink::PresentationError& error) { … }
void RemotePlayback::HandlePresentationResponse(
mojom::blink::PresentationConnectionResultPtr result,
mojom::blink::PresentationErrorPtr error) { … }
void RemotePlayback::OnMessage(
mojom::blink::PresentationConnectionMessagePtr message) { … }
void RemotePlayback::DidChangeState(
mojom::blink::PresentationConnectionState state) { … }
void RemotePlayback::DidClose(
mojom::blink::PresentationConnectionCloseReason reason) { … }
void RemotePlayback::StopListeningForAvailability() { … }
void RemotePlayback::MaybeStartListeningForAvailability() { … }
void RemotePlayback::Trace(Visitor* visitor) const { … }
}