chromium/third_party/blink/renderer/modules/mediastream/capture_controller.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/modules/mediastream/capture_controller.h"

#include <cmath>
#include <optional>

#include "base/ranges/algorithm.h"
#include "base/types/expected.h"
#include "base/unguessable_token.h"
#include "build/build_config.h"
#include "third_party/blink/public/common/page/page_zoom.h"
#include "third_party/blink/renderer/bindings/core/v8/idl_types.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_captured_wheel_action.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/dom/events/native_event_listener.h"
#include "third_party/blink/renderer/core/event_type_names.h"
#include "third_party/blink/renderer/core/events/wheel_event.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/geometry/dom_rect.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_track.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_video_track.h"
#include "third_party/blink/renderer/modules/mediastream/user_media_client.h"
#include "third_party/blink/renderer/platform/bindings/exception_code.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_component.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_source.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"

CapturedSurfaceControlResult;

namespace blink {

namespace {

SurfaceType;

bool IsCaptureType(const MediaStreamTrack* track,
                   const std::vector<SurfaceType>& types) {}

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
struct ScaledCoordinates {};

// Attempt to scale the coordinates to relative coordinates based on the last
// frame emitted for the given track.
base::expected<ScaledCoordinates, String> ScaleCoordinates(
    MediaStreamTrack* track,
    CapturedWheelAction* action) {}

bool ShouldFocusCapturedSurface(V8CaptureStartFocusBehavior focus_behavior) {}

std::optional<int> GetInitialZoomLevel(MediaStreamTrack* video_track) {}

std::optional<base::UnguessableToken> GetCaptureSessionId(
    MediaStreamTrack* track) {}

DOMException* CscResultToDOMException(CapturedSurfaceControlResult result) {}

void OnCapturedSurfaceControlResult(
    ScriptPromiseResolver<IDLUndefined>* resolver,
    CapturedSurfaceControlResult result) {}
#endif  // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)

}  // namespace

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
class CaptureController::WheelEventListener : public NativeEventListener {};
#endif  // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)

CaptureController::ValidationResult::ValidationResult(DOMExceptionCode code,
                                                      String message)
    :{}

CaptureController* CaptureController::Create(ExecutionContext* context) {}

CaptureController::CaptureController(ExecutionContext* context)
    :{}

void CaptureController::setFocusBehavior(
    V8CaptureStartFocusBehavior focus_behavior,
    ExceptionState& exception_state) {}

ScriptPromise<IDLUndefined> CaptureController::sendWheel(
    ScriptState* script_state,
    CapturedWheelAction* action) {}

ScriptPromise<IDLUndefined> CaptureController::captureWheel(
    ScriptState* script_state,
    HTMLElement* element) {}

Vector<int> CaptureController::getSupportedZoomLevels() {}

int CaptureController::getZoomLevel(ExceptionState& exception_state) {}

ScriptPromise<IDLUndefined> CaptureController::setZoomLevel(
    ScriptState* script_state,
    int zoom_level) {}

void CaptureController::SetVideoTrack(MediaStreamTrack* video_track,
                                      std::string descriptor_id) {}

const AtomicString& CaptureController::InterfaceName() const {}

ExecutionContext* CaptureController::GetExecutionContext() const {}

void CaptureController::FinalizeFocusDecision() {}

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
void CaptureController::SourceChangedZoomLevel(int zoom_level) {}

void CaptureController::OnCaptureWheelPermissionResult(
    ScriptPromiseResolver<IDLUndefined>* resolver,
    HTMLElement* element,
    CapturedSurfaceControlResult result) {}

void CaptureController::SendWheel(double relative_x,
                                  double relative_y,
                                  int32_t wheel_delta_x,
                                  int32_t wheel_delta_y) {}

mojom::blink::MediaStreamDispatcherHost*
CaptureController::GetMediaStreamDispatcherHost() {}

void CaptureController::SetMediaStreamDispatcherHostForTesting(
    mojo::PendingRemote<mojom::blink::MediaStreamDispatcherHost> host) {}
#endif

void CaptureController::Trace(Visitor* visitor) const {}

CaptureController::ValidationResult
CaptureController::ValidateCapturedSurfaceControlCall() const {}

}  // namespace blink