Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1264)

Unified Diff: third_party/WebKit/Source/modules/mediastream/MediaConstraintsImpl.cpp

Issue 1899943008: Macro-based constraints Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a fourth macro application Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/exported/WebMediaConstraints.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/mediastream/MediaConstraintsImpl.cpp
diff --git a/third_party/WebKit/Source/modules/mediastream/MediaConstraintsImpl.cpp b/third_party/WebKit/Source/modules/mediastream/MediaConstraintsImpl.cpp
index c1af99f6f0464683735ff434ffe33b567ae514d9..9a9c86d65190fac7fce8045ecf71eccf553c8840 100644
--- a/third_party/WebKit/Source/modules/mediastream/MediaConstraintsImpl.cpp
+++ b/third_party/WebKit/Source/modules/mediastream/MediaConstraintsImpl.cpp
@@ -507,45 +507,15 @@ void copyBooleanConstraint(const ConstrainBooleanParameters& blinkForm, BooleanC
void copyConstraints(const MediaTrackConstraintSet& constraintsIn, WebMediaTrackConstraintSet& constraintBuffer)
{
- if (constraintsIn.hasWidth()) {
- copyLongConstraint(constraintsIn.width(), constraintBuffer.width);
- }
- if (constraintsIn.hasHeight()) {
- copyLongConstraint(constraintsIn.height(), constraintBuffer.height);
- }
- if (constraintsIn.hasAspectRatio()) {
- copyDoubleConstraint(constraintsIn.aspectRatio(), constraintBuffer.aspectRatio);
- }
- if (constraintsIn.hasFrameRate()) {
- copyDoubleConstraint(constraintsIn.frameRate(), constraintBuffer.frameRate);
- }
- if (constraintsIn.hasFacingMode()) {
- copyStringConstraint(constraintsIn.facingMode(), constraintBuffer.facingMode);
- }
- if (constraintsIn.hasVolume()) {
- copyDoubleConstraint(constraintsIn.volume(), constraintBuffer.volume);
- }
- if (constraintsIn.hasSampleRate()) {
- copyLongConstraint(constraintsIn.sampleRate(), constraintBuffer.sampleRate);
- }
- if (constraintsIn.hasSampleSize()) {
- copyLongConstraint(constraintsIn.sampleSize(), constraintBuffer.sampleSize);
- }
- if (constraintsIn.hasEchoCancellation()) {
- copyBooleanConstraint(constraintsIn.echoCancellation(), constraintBuffer.echoCancellation);
- }
- if (constraintsIn.hasLatency()) {
- copyDoubleConstraint(constraintsIn.latency(), constraintBuffer.latency);
- }
- if (constraintsIn.hasChannelCount()) {
- copyLongConstraint(constraintsIn.channelCount(), constraintBuffer.channelCount);
- }
- if (constraintsIn.hasDeviceId()) {
- copyStringConstraint(constraintsIn.deviceId(), constraintBuffer.deviceId);
- }
- if (constraintsIn.hasGroupId()) {
- copyStringConstraint(constraintsIn.groupId(), constraintBuffer.groupId);
+
+#define CONSTRAINT_ITEM(lowercase, uppercase, datatype) \
+ if (constraintsIn.has##uppercase()) { \
+ copy##datatype##Constraint(constraintsIn.lowercase(), constraintBuffer.lowercase); \
}
+
+ CONSTRAINT_LIST
+
+#undef CONSTRAINT_ITEM
}
WebMediaConstraints create(ExecutionContext* context, const MediaTrackConstraints& constraintsIn, MediaErrorState& errorState)
@@ -650,35 +620,12 @@ ConstrainBooleanParameters convertBoolean(const BooleanConstraint& input)
void convertConstraintSet(const WebMediaTrackConstraintSet& input, MediaTrackConstraintSet& output)
{
- if (!input.width.isEmpty())
- output.setWidth(convertLong(input.width));
- if (!input.height.isEmpty())
- output.setHeight(convertLong(input.height));
- if (!input.aspectRatio.isEmpty())
- output.setAspectRatio(convertDouble(input.aspectRatio));
- if (!input.frameRate.isEmpty())
- output.setFrameRate(convertDouble(input.frameRate));
- if (!input.facingMode.isEmpty())
- output.setFacingMode(convertString(input.facingMode));
- if (!input.volume.isEmpty())
- output.setVolume(convertDouble(input.volume));
- if (!input.sampleRate.isEmpty())
- output.setSampleRate(convertLong(input.sampleRate));
- if (!input.sampleSize.isEmpty())
- output.setSampleSize(convertLong(input.sampleSize));
- if (!input.echoCancellation.isEmpty())
- output.setEchoCancellation(convertBoolean(input.echoCancellation));
- if (!input.latency.isEmpty())
- output.setLatency(convertDouble(input.latency));
- if (!input.channelCount.isEmpty())
- output.setChannelCount(convertLong(input.channelCount));
- if (!input.deviceId.isEmpty())
- output.setDeviceId(convertString(input.deviceId));
- if (!input.groupId.isEmpty())
- output.setGroupId(convertString(input.groupId));
- // TODO(hta): Decide the future of the nonstandard constraints.
- // If they go forward, they need to be added here.
- // https://crbug.com/605673
+#define CONSTRAINT_ITEM(lowercase, uppercase, datatype) \
+ if (!input.lowercase.isEmpty()) \
+ output.set##uppercase(convert##datatype(input.lowercase)); \
+
+ CONSTRAINT_LIST
+#undef CONSTRAINT_ITEM
}
void convertConstraints(const WebMediaConstraints& input, MediaTrackConstraints& output)
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/exported/WebMediaConstraints.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698