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

/*
 * Copyright (C) 2011 Ericsson AB. All rights reserved.
 * Copyright (C) 2012 Google Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer
 *    in the documentation and/or other materials provided with the
 *    distribution.
 * 3. Neither the name of Ericsson nor the names of its contributors
 *    may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

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

#include <type_traits>

#include "base/metrics/histogram_functions.h"
#include "base/strings/stringprintf.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_metric_builder.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy.mojom-blink.h"
#include "third_party/blink/public/platform/modules/webrtc/webrtc_logging.h"
#include "third_party/blink/renderer/bindings/core/v8/dictionary.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_stream_constraints.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_constraints.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_boolean_mediatrackconstraints.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_domexception_overconstrainederror.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/dom/space_split_string.h"
#include "third_party/blink/renderer/core/frame/deprecation/deprecation.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/modules/mediastream/capture_controller.h"
#include "third_party/blink/renderer/modules/mediastream/identifiability_metrics.h"
#include "third_party/blink/renderer/modules/mediastream/media_constraints_impl.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_set.h"
#include "third_party/blink/renderer/modules/mediastream/overconstrained_error.h"
#include "third_party/blink/renderer/modules/mediastream/transferred_media_stream_track.h"
#include "third_party/blink/renderer/modules/mediastream/user_media_client.h"
#include "third_party/blink/renderer/modules/peerconnection/peer_connection_tracker.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/mediastream/media_stream_descriptor.h"
#include "third_party/blink/renderer/platform/privacy_budget/identifiability_digest_helpers.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"

namespace blink {

MediaStreamType;
Result;

namespace {

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class GetDisplayMediaIncludeExcludeConstraint {};

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class GetDisplayMediaConstraintsDisplaySurface {};

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class GetDisplayMediaBooleanConstraint {};

void RecordUma(GetDisplayMediaConstraintsDisplaySurface value) {}

template <typename NumericConstraint>
bool SetUsesNumericConstraint(
    const MediaTrackConstraintSetPlatform& set,
    NumericConstraint MediaTrackConstraintSetPlatform::*field) {}

template <typename DiscreteConstraint>
bool SetUsesDiscreteConstraint(
    const MediaTrackConstraintSetPlatform& set,
    DiscreteConstraint MediaTrackConstraintSetPlatform::*field) {}

template <typename NumericConstraint>
bool RequestUsesNumericConstraint(
    const MediaConstraints& constraints,
    NumericConstraint MediaTrackConstraintSetPlatform::*field) {}

template <typename DiscreteConstraint>
bool RequestUsesDiscreteConstraint(
    const MediaConstraints& constraints,
    DiscreteConstraint MediaTrackConstraintSetPlatform::*field) {}

class FeatureCounter {};

void CountAudioConstraintUses(ExecutionContext* context,
                              const MediaConstraints& constraints) {}

void CountVideoConstraintUses(ExecutionContext* context,
                              const MediaConstraints& constraints) {}

void RecordGetDisplayMediaIncludeExcludeConstraintUma(
    std::optional<V8DisplayMediaIncludeOrExclude::Enum> include_or_exclude,
    const std::string& histogram_name) {}

void RecordPreferredDisplaySurfaceConstraintUma(
    const mojom::blink::PreferredDisplaySurface preferred_display_surface) {}

void RecordSuppressLocalAudioPlaybackConstraintUma(
    std::optional<bool> suppress_local_audio_playback) {}

MediaConstraints ParseOptions(
    ExecutionContext* execution_context,
    const V8UnionBooleanOrMediaTrackConstraints* options,
    ExceptionState& exception_state) {}

}  // namespace

UserMediaRequest* UserMediaRequest::Create(
    ExecutionContext* context,
    UserMediaClient* client,
    UserMediaRequestType media_type,
    const MediaStreamConstraints* options,
    Callbacks* callbacks,
    ExceptionState& exception_state,
    IdentifiableSurface surface) {}

UserMediaRequest* UserMediaRequest::CreateForTesting(
    const MediaConstraints& audio,
    const MediaConstraints& video) {}

UserMediaRequest::UserMediaRequest(ExecutionContext* context,
                                   UserMediaClient* client,
                                   UserMediaRequestType media_type,
                                   MediaConstraints audio,
                                   MediaConstraints video,
                                   bool should_prefer_current_tab,
                                   bool auto_select_all_screens,
                                   CaptureController* capture_controller,
                                   Callbacks* callbacks,
                                   IdentifiableSurface surface)
    :{}

UserMediaRequest::~UserMediaRequest() = default;

UserMediaRequestType UserMediaRequest::MediaRequestType() const {}

bool UserMediaRequest::Audio() const {}

bool UserMediaRequest::Video() const {}

MediaConstraints UserMediaRequest::AudioConstraints() const {}

MediaConstraints UserMediaRequest::VideoConstraints() const {}

MediaStreamType UserMediaRequest::AudioMediaStreamType() const {}

MediaStreamType UserMediaRequest::VideoMediaStreamType() const {}

bool UserMediaRequest::ShouldDisableHardwareNoiseSuppression() const {}

bool UserMediaRequest::IsSecureContextUse(String& error_message) {}

LocalDOMWindow* UserMediaRequest::GetWindow() {}

void UserMediaRequest::Start() {}

void UserMediaRequest::Succeed(
    const MediaStreamDescriptorVector& streams_descriptors) {}

void UserMediaRequest::OnMediaStreamInitialized(MediaStream* stream) {}

void UserMediaRequest::OnMediaStreamsInitialized(MediaStreamVector streams) {}

void UserMediaRequest::FailConstraint(const String& constraint_name,
                                      const String& message) {}

void UserMediaRequest::Fail(Result error, const String& message) {}

void UserMediaRequest::ContextDestroyed() {}

void UserMediaRequest::SetTransferredTrackComponent(
    MediaStreamComponent* component) {}

void UserMediaRequest::FinalizeTransferredTrackInitialization(
    const MediaStreamDescriptorVector& streams_descriptors) {}

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

}  // namespace blink