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

/*
 * 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 Google Inc. 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/media_constraints_impl.h"

#include "build/build_config.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/renderer/bindings/core/v8/dictionary.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_string_stringsequence.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_constrain_boolean_parameters.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_constrain_dom_string_parameters.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_constrain_double_range.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_constrain_long_range.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_constraints.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_typedefs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_boolean_constrainbooleanparameters.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_boolean_constraindoublerange_double.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_constraindomstringparameters_string_stringsequence.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_constraindoublerange_double.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_constrainlongrange_long.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/deprecation/deprecation.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/inspector/console_message.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/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h"
#include "third_party/blink/renderer/platform/wtf/text/string_hash.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"

namespace blink {
namespace media_constraints_impl {

namespace {

// A naked value is treated as an "ideal" value in the basic constraints,
// but as an exact value in "advanced" constraints.
// https://w3c.github.io/mediacapture-main/#constrainable-interface
enum class NakedValueDisposition {};

// Old type/value form of constraint. Used in parsing old-style constraints.
struct NameValueStringConstraint {};

// Legal constraint names.

// Legacy getUserMedia() constraints. Sadly still in use.
const char kMinAspectRatio[] =;
const char kMaxAspectRatio[] =;
const char kMaxWidth[] =;
const char kMinWidth[] =;
const char kMaxHeight[] =;
const char kMinHeight[] =;
const char kMaxFrameRate[] =;
const char kMinFrameRate[] =;
const char kMediaStreamSource[] =;
const char kMediaStreamSourceId[] =;                           // mapped to deviceId
const char kMediaStreamSourceInfoId[] =;  // mapped to deviceId
const char kMediaStreamRenderToAssociatedSink[] =;
// RenderToAssociatedSink will be going away some time.
const char kEchoCancellation[] =;
const char kDisableLocalEcho[] =;
const char kGoogEchoCancellation[] =;
const char kGoogExperimentalEchoCancellation[] =;
const char kGoogAutoGainControl[] =;
const char kGoogNoiseSuppression[] =;
const char kGoogExperimentalNoiseSuppression[] =;
const char kGoogHighpassFilter[] =;
const char kGoogAudioMirroring[] =;
// Audio constraints.
const char kDAEchoCancellation[] =;
// Google-specific constraint keys for a local video source (getUserMedia).
const char kNoiseReduction[] =;

static bool ParseMandatoryConstraintsDictionary(
    const Dictionary& mandatory_constraints_dictionary,
    Vector<NameValueStringConstraint>& mandatory) {}

static bool ParseOptionalConstraintsVectorElement(
    const Dictionary& constraint,
    Vector<NameValueStringConstraint>& optional_constraints_vector) {}

static bool Parse(const MediaTrackConstraints* constraints_in,
                  Vector<NameValueStringConstraint>& optional,
                  Vector<NameValueStringConstraint>& mandatory) {}

static bool ToBoolean(const String& as_string) {}

static void ParseOldStyleNames(
    ExecutionContext* context,
    const Vector<NameValueStringConstraint>& old_names,
    MediaTrackConstraintSetPlatform& result) {}

static MediaConstraints CreateFromNamedConstraints(
    ExecutionContext* context,
    Vector<NameValueStringConstraint>& mandatory,
    const Vector<NameValueStringConstraint>& optional) {}

void CopyLongConstraint(const V8ConstrainLong* blink_union_form,
                        NakedValueDisposition naked_treatment,
                        LongConstraint& web_form) {}

void CopyDoubleConstraint(const V8ConstrainDouble* blink_union_form,
                          NakedValueDisposition naked_treatment,
                          DoubleConstraint& web_form) {}

void CopyBooleanOrDoubleConstraint(
    const V8UnionBooleanOrConstrainDouble* blink_union_form,
    NakedValueDisposition naked_treatment,
    DoubleConstraint& web_form) {}

bool ValidateString(const String& str, String& error_message) {}

bool ValidateStringSeq(const Vector<String>& strs, String& error_message) {}

bool ValidateStringConstraint(
    V8UnionStringOrStringSequence* string_or_string_seq,
    String& error_message) {}

bool ValidateStringConstraint(const V8ConstrainDOMString* blink_union_form,
                              String& error_message) {}

[[nodiscard]] bool ValidateAndCopyStringConstraint(
    const V8ConstrainDOMString* blink_union_form,
    NakedValueDisposition naked_treatment,
    StringConstraint& web_form,
    String& error_message) {}

void CopyBooleanConstraint(const V8ConstrainBoolean* blink_union_form,
                           NakedValueDisposition naked_treatment,
                           BooleanConstraint& web_form) {}

bool ValidateAndCopyConstraintSet(
    const MediaTrackConstraintSet* constraints_in,
    NakedValueDisposition naked_treatment,
    MediaTrackConstraintSetPlatform& constraint_buffer,
    String& error_message) {}

template <class T>
bool UseNakedNumeric(const T& input, NakedValueDisposition which) {}

template <class T>
bool UseNakedNonNumeric(const T& input, NakedValueDisposition which) {}

template <typename U, class T>
U GetNakedValue(const T& input, NakedValueDisposition which) {}

V8ConstrainLong* ConvertLong(const LongConstraint& input,
                             NakedValueDisposition naked_treatment) {}

V8ConstrainDouble* ConvertDouble(const DoubleConstraint& input,
                                 NakedValueDisposition naked_treatment) {}

V8UnionBooleanOrConstrainDouble* ConvertBooleanOrDouble(
    const DoubleConstraint& input,
    NakedValueDisposition naked_treatment) {}

V8UnionStringOrStringSequence* ConvertStringSequence(
    const Vector<String>& input) {}

V8ConstrainDOMString* ConvertString(const StringConstraint& input,
                                    NakedValueDisposition naked_treatment) {}

V8ConstrainBoolean* ConvertBoolean(const BooleanConstraint& input,
                                   NakedValueDisposition naked_treatment) {}

void ConvertConstraintSet(const MediaTrackConstraintSetPlatform& input,
                          NakedValueDisposition naked_treatment,
                          MediaTrackConstraintSet* output) {}

}  // namespace

MediaConstraints ConvertTrackConstraintsToMediaConstraints(
    const MediaTrackConstraints* constraints_in,
    String& error_message) {}

MediaConstraints Create(ExecutionContext* context,
                        const MediaTrackConstraints* constraints_in,
                        String& error_message) {}

MediaConstraints Create() {}

MediaTrackConstraints* ConvertConstraints(const MediaConstraints& input) {}

}  // namespace media_constraints_impl
}  // namespace blink