#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 {
enum class NakedValueDisposition { … };
struct NameValueStringConstraint { … };
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[] = …;
const char kMediaStreamSourceInfoId[] = …;
const char kMediaStreamRenderToAssociatedSink[] = …;
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[] = …;
const char kDAEchoCancellation[] = …;
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) { … }
}
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) { … }
}
}