Skip to content

Commit

Permalink
MediaConstraint::constraintType() is unneeded
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=268978
rdar://122532646

Reviewed by Eric Carlson.

MediaConstraint::constraintType is somehow reduundant with MediaTrackConstraintSetMap member fields.
We therefore remove MediaConstraint::constraintType and instead pass the corresponding MediaConstraintType for each MediaTrackConstraintSetMap member.
We remove MediaConstraint::DataType::None since it is not needed.
Covered by existing tests.

* Source/WebCore/Modules/mediastream/MediaDevices.cpp:
(WebCore::hasInvalidGetDisplayMediaConstraint):
* Source/WebCore/Modules/mediastream/MediaTrackConstraints.cpp:
(WebCore::set):
* Source/WebCore/platform/mediastream/MediaConstraints.cpp:
(WebCore::StringConstraint::merge):
(WebCore::MediaTrackConstraintSetMap::forEach const):
(WebCore::MediaTrackConstraintSetMap::filter const):
(WebCore::MediaTrackConstraintSetMap::merge):
(WebCore::MediaTrackConstraintSetMap::size const):
(WebCore::addDefaultVideoConstraints):
(WebCore::MediaConstraints::setDefaultAudioConstraints):
(WebCore::MediaConstraint::log const):
(WebCore::BooleanConstraint::logAsBoolean const):
(WebCore::DoubleConstraint::logAsDouble const):
(WebCore::IntConstraint::logAsInt const):
(WebCore::StringConstraint::isolatedCopy const):
* Source/WebCore/platform/mediastream/MediaConstraints.h:
(WebCore::MediaConstraint::dataType const):
(WebCore::MediaConstraint::MediaConstraint):
(WebCore::NumericConstraint::NumericConstraint):
(WebCore::StringConstraint::StringConstraint):
(WebCore::MediaConstraint::constraintType const): Deleted.
* Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp:
(WebCore::RealtimeMediaSource::hasInvalidSizeFrameRateAndZoomConstraints):
(WebCore::RealtimeMediaSource::fitnessDistance):
(WebCore::RealtimeMediaSource::applyConstraint):
(WebCore::RealtimeMediaSource::selectSettings):
(WebCore::RealtimeMediaSource::supportsConstraint):
(WebCore::RealtimeMediaSource::hasAnyInvalidConstraint):
(WebCore::RealtimeMediaSource::applyConstraints):
* Source/WebCore/platform/mediastream/RealtimeMediaSource.h:
* Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp:
(WebCore::RealtimeMediaSourceCenter::validateRequestConstraintsAfterEnumeration):
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:

Canonical link: https://commits.webkit.org/274294@main
  • Loading branch information
youennf committed Feb 8, 2024
1 parent 660a9bd commit ce92687
Show file tree
Hide file tree
Showing 8 changed files with 402 additions and 364 deletions.
4 changes: 2 additions & 2 deletions Source/WebCore/Modules/mediastream/MediaDevices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ static bool hasInvalidGetDisplayMediaConstraint(const MediaConstraints& constrai
return true;

bool invalid = false;
constraints.mandatoryConstraints.filter([&invalid] (const MediaConstraint& constraint) mutable {
switch (constraint.constraintType()) {
constraints.mandatoryConstraints.filter([&invalid] (auto constraintType, const MediaConstraint& constraint) mutable {
switch (constraintType) {
case MediaConstraintType::Width:
case MediaConstraintType::Height: {
auto& intConstraint = downcast<IntConstraint>(constraint);
Expand Down
8 changes: 4 additions & 4 deletions Source/WebCore/Modules/mediastream/MediaTrackConstraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ enum class ConstraintSetType { Mandatory, Advanced };

static void set(MediaTrackConstraintSetMap& map, ConstraintSetType setType, MediaConstraintType type, const ConstrainLong& value)
{
IntConstraint constraint(type);
IntConstraint constraint;
WTF::switchOn(value,
[&] (int integer) {
if (setType == ConstraintSetType::Mandatory)
Expand All @@ -59,7 +59,7 @@ static void set(MediaTrackConstraintSetMap& map, ConstraintSetType setType, Medi

static void set(MediaTrackConstraintSetMap& map, ConstraintSetType setType, MediaConstraintType type, const ConstrainDouble& value)
{
DoubleConstraint constraint(type);
DoubleConstraint constraint;
WTF::switchOn(value,
[&] (double number) {
if (setType == ConstraintSetType::Mandatory)
Expand All @@ -83,7 +83,7 @@ static void set(MediaTrackConstraintSetMap& map, ConstraintSetType setType, Medi

static void set(MediaTrackConstraintSetMap& map, ConstraintSetType setType, MediaConstraintType type, const ConstrainBoolean& value)
{
BooleanConstraint constraint(type);
BooleanConstraint constraint;
WTF::switchOn(value,
[&] (bool boolean) {
if (setType == ConstraintSetType::Mandatory)
Expand All @@ -103,7 +103,7 @@ static void set(MediaTrackConstraintSetMap& map, ConstraintSetType setType, Medi

static void set(MediaTrackConstraintSetMap& map, ConstraintSetType setType, MediaConstraintType type, const ConstrainDOMString& value)
{
StringConstraint constraint(type);
StringConstraint constraint;
WTF::switchOn(value,
[&] (const String& string) {
if (setType == ConstraintSetType::Mandatory)
Expand Down
Loading

0 comments on commit ce92687

Please sign in to comment.