// Copyright 2017 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASTREAM_MEDIA_STREAM_CONSTRAINTS_UTIL_SETS_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASTREAM_MEDIA_STREAM_CONSTRAINTS_UTIL_SETS_H_ #include <algorithm> #include <limits> #include <optional> #include <string> #include <utility> #include "base/check_op.h" #include "base/containers/contains.h" #include "base/gtest_prod_util.h" #include "third_party/blink/renderer/modules/mediastream/media_constraints.h" #include "third_party/blink/renderer/modules/modules_export.h" #include "third_party/blink/renderer/platform/wtf/vector.h" namespace blink { struct MediaTrackConstraintSetPlatform; template <typename ConstraintType> bool ConstraintHasMax(const ConstraintType& constraint) { … } template <typename ConstraintType> bool ConstraintHasMin(const ConstraintType& constraint) { … } template <typename ConstraintType> auto ConstraintMax(const ConstraintType& constraint) -> decltype(constraint.Max()) { … } template <typename ConstraintType> auto ConstraintMin(const ConstraintType& constraint) -> decltype(constraint.Min()) { … } namespace media_constraints { // This class template represents a set of candidates suitable for a numeric // range-based constraint. template <typename T> class NumericRangeSet { … }; // This class defines a set of discrete elements suitable for resolving // constraints with a countable number of choices not suitable to be constrained // by range. Examples are strings, booleans and certain constraints of type // long. A DiscreteSet can be empty, have their elements explicitly stated, or // be the universal set. The universal set is a set that contains all possible // elements. The specific definition of what elements are in the universal set // is application defined (e.g., it could be all possible boolean values, all // possible strings of length N, or anything that suits a particular // application). // TODO(guidou): Rename this class. https://crbug.com/731166 template <typename T> class DiscreteSet { … }; // Special case for DiscreteSet<bool> where it is easy to produce an explicit // set that contains all possible elements. template <> inline bool DiscreteSet<bool>::is_universal() const { … } MODULES_EXPORT DiscreteSet<std::string> StringSetFromConstraint( const StringConstraint& constraint); MODULES_EXPORT DiscreteSet<bool> BoolSetFromConstraint( const BooleanConstraint& constraint); // This class represents a set of (height, width) screen resolution candidates // determined by width, height and aspect-ratio constraints. // This class supports widths and heights from 0 to kMaxDimension, both // inclusive and aspect ratios from 0.0 to positive infinity, both inclusive. class MODULES_EXPORT ResolutionSet { … }; // Scalar multiplication for Points. MODULES_EXPORT ResolutionSet::Point operator*(double d, const ResolutionSet::Point& p); // This function returns a set of bools from a resizeMode StringConstraint. // If |resize_mode_constraint| includes // WebMediaStreamTrack::kResizeModeNone, false is included in the // returned value. If |resize_mode_constraint| includes // WebMediaStreamTrack::kResizeModeRescale, true is included in the // returned value. MODULES_EXPORT DiscreteSet<bool> RescaleSetFromConstraint( const StringConstraint& resize_mode_constraint); } // namespace media_constraints } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASTREAM_MEDIA_STREAM_CONSTRAINTS_UTIL_SETS_H_