#include "third_party/blink/renderer/modules/mediastream/media_stream_constraints_util_video_device.h"
#include <algorithm>
#include <cmath>
#include <limits>
#include <utility>
#include "base/containers/contains.h"
#include "base/strings/stringprintf.h"
#include "media/base/limits.h"
#include "media/base/video_types.h"
#include "media/mojo/mojom/display_media_information.mojom-blink.h"
#include "media/webrtc/webrtc_features.h"
#include "third_party/blink/public/platform/modules/webrtc/webrtc_logging.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/web/modules/mediastream/media_stream_video_source.h"
#include "third_party/blink/renderer/modules/mediastream/media_constraints.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_constraints_util.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_constraints_util_sets.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "third_party/blink/renderer/platform/wtf/wtf_size_t.h"
namespace blink {
namespace {
ResolutionSet;
DoubleRangeSet;
IntRangeSet;
BoolSet;
DeviceInfo;
DistanceVector;
const int kNumDefaultDistanceEntries = …;
WebString ToWebString(mojom::blink::FacingMode facing_mode) { … }
double BoolSetFitness(const BooleanConstraint& constraint, const BoolSet& set) { … }
template <typename NumericConstraint>
double NumericValueFitness(const NumericConstraint& constraint,
decltype(constraint.Min()) value) { … }
template <typename NumericConstraint>
double NumericRangeSetFitness(
const NumericConstraint& constraint,
const media_constraints::NumericRangeSet<decltype(constraint.Min())>&
range) { … }
template <typename NumericConstraint>
double NumericRangeSupportFitness(
const NumericConstraint& constraint,
const media_constraints::NumericRangeSet<decltype(constraint.Min())>& range,
bool constraint_present,
bool constraint_supported) { … }
template <typename NumericConstraint>
double NumericRangeNativeFitness(const NumericConstraint& constraint,
decltype(constraint.Min()) min,
decltype(constraint.Min()) max,
decltype(constraint.Min()) native_value) { … }
double OptionalBoolFitness(const std::optional<bool>& value,
const BooleanConstraint& constraint) { … }
void UpdateFailedConstraintName(const BaseConstraint& constraint,
const char** failed_constraint_name) { … }
class CandidateFormat { … };
bool FacingModeSatisfiesConstraint(mojom::blink::FacingMode value,
const StringConstraint& constraint) { … }
class PTZDeviceState { … };
class ImageCaptureDeviceState { … };
bool DeviceSatisfiesConstraintSet(
const DeviceInfo& device,
const MediaTrackConstraintSetPlatform& constraint_set,
const char** failed_constraint_name = nullptr) { … }
bool OptionalBoolSatisfiesConstraint(
const std::optional<bool>& value,
const BooleanConstraint& constraint,
const char** failed_constraint_name = nullptr) { … }
double DeviceFitness(const DeviceInfo& device,
const MediaTrackConstraintSetPlatform& constraint_set) { … }
double CandidateFitness(
const DeviceInfo& device,
const PTZDeviceState& ptz_state,
const CandidateFormat& candidate_format,
const ImageCaptureDeviceState& image_capture_device_state,
const std::optional<bool>& noise_reduction,
const MediaTrackConstraintSetPlatform& constraint_set,
VideoTrackAdapterSettings* track_settings) { … }
void AppendDistancesFromDefault(
const DeviceInfo& device,
const CandidateFormat& candidate_format,
const std::optional<bool>& noise_reduction,
const VideoDeviceCaptureCapabilities& capabilities,
int default_width,
int default_height,
double default_frame_rate,
DistanceVector* distance_vector) { … }
}
VideoInputDeviceCapabilities::VideoInputDeviceCapabilities() = default;
VideoInputDeviceCapabilities::VideoInputDeviceCapabilities(
String device_id,
String group_id,
const media::VideoCaptureControlSupport& control_support,
Vector<media::VideoCaptureFormat> formats,
mojom::blink::FacingMode facing_mode)
: … { … }
VideoInputDeviceCapabilities::VideoInputDeviceCapabilities(
VideoInputDeviceCapabilities&& other) = default;
VideoInputDeviceCapabilities& VideoInputDeviceCapabilities::operator=(
VideoInputDeviceCapabilities&& other) = default;
VideoInputDeviceCapabilities::~VideoInputDeviceCapabilities() = default;
MediaStreamTrackPlatform::FacingMode ToPlatformFacingMode(
mojom::blink::FacingMode video_facing) { … }
VideoDeviceCaptureCapabilities::VideoDeviceCaptureCapabilities() = default;
VideoDeviceCaptureCapabilities::VideoDeviceCaptureCapabilities(
VideoDeviceCaptureCapabilities&& other) = default;
VideoDeviceCaptureCapabilities::~VideoDeviceCaptureCapabilities() = default;
VideoDeviceCaptureCapabilities& VideoDeviceCaptureCapabilities::operator=(
VideoDeviceCaptureCapabilities&& other) = default;
VideoCaptureSettings SelectSettingsVideoDeviceCapture(
const VideoDeviceCaptureCapabilities& capabilities,
const MediaConstraints& constraints,
int default_width,
int default_height,
double default_frame_rate) { … }
base::expected<Vector<VideoCaptureSettings>, std::string>
SelectEligibleSettingsVideoDeviceCapture(
const VideoDeviceCaptureCapabilities& capabilities,
const MediaConstraints& constraints,
int default_width,
int default_height,
double default_frame_rate) { … }
}