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

Side by Side Diff: third_party/WebKit/Source/modules/mediastream/MediaConstraintsImpl.cpp

Issue 1910463002: Implement MediaStreamTrack.getConstraints (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments on layout test Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 22 matching lines...) Expand all
33 #include "bindings/core/v8/ArrayValue.h" 33 #include "bindings/core/v8/ArrayValue.h"
34 #include "bindings/core/v8/Dictionary.h" 34 #include "bindings/core/v8/Dictionary.h"
35 #include "bindings/core/v8/ExceptionState.h" 35 #include "bindings/core/v8/ExceptionState.h"
36 #include "core/dom/ExceptionCode.h" 36 #include "core/dom/ExceptionCode.h"
37 #include "core/dom/ExecutionContext.h" 37 #include "core/dom/ExecutionContext.h"
38 #include "core/frame/UseCounter.h" 38 #include "core/frame/UseCounter.h"
39 #include "core/inspector/ConsoleMessage.h" 39 #include "core/inspector/ConsoleMessage.h"
40 #include "modules/mediastream/MediaTrackConstraints.h" 40 #include "modules/mediastream/MediaTrackConstraints.h"
41 #include "platform/Logging.h" 41 #include "platform/Logging.h"
42 #include "platform/RuntimeEnabledFeatures.h" 42 #include "platform/RuntimeEnabledFeatures.h"
43 #include "wtf/Assertions.h"
43 #include "wtf/HashMap.h" 44 #include "wtf/HashMap.h"
44 #include "wtf/Vector.h" 45 #include "wtf/Vector.h"
45 #include "wtf/text/StringHash.h" 46 #include "wtf/text/StringHash.h"
46 47
47 namespace blink { 48 namespace blink {
48 49
49 50
50 namespace MediaConstraintsImpl { 51 namespace MediaConstraintsImpl {
51 52
52 // Old type/value form of constraint. Used in parsing old-style constraints. 53 // Old type/value form of constraint. Used in parsing old-style constraints.
53 struct WebMediaConstraint { 54 struct NameValueStringConstraint {
54 WebMediaConstraint() 55 NameValueStringConstraint()
55 { 56 {
56 } 57 }
57 58
58 WebMediaConstraint(WebString name, WebString value) 59 NameValueStringConstraint(WebString name, WebString value)
59 : m_name(name) 60 : m_name(name)
60 , m_value(value) 61 , m_value(value)
61 { 62 {
62 } 63 }
63 64
64 WebString m_name; 65 WebString m_name;
65 WebString m_value; 66 WebString m_value;
66 }; 67 };
67 68
68 69
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // End of names from libjingle 150 // End of names from libjingle
150 // Names that have been used in the past, but should now be ignored. 151 // Names that have been used in the past, but should now be ignored.
151 // Kept around for backwards compatibility. 152 // Kept around for backwards compatibility.
152 // https://crbug.com/579729 153 // https://crbug.com/579729
153 const char kGoogLeakyBucket[] = "googLeakyBucket"; 154 const char kGoogLeakyBucket[] = "googLeakyBucket";
154 const char kPowerLineFrequency[] = "googPowerLineFrequency"; 155 const char kPowerLineFrequency[] = "googPowerLineFrequency";
155 // Names used for testing. 156 // Names used for testing.
156 const char kTestConstraint1[] = "valid_and_supported_1"; 157 const char kTestConstraint1[] = "valid_and_supported_1";
157 const char kTestConstraint2[] = "valid_and_supported_2"; 158 const char kTestConstraint2[] = "valid_and_supported_2";
158 159
159 static bool parseMandatoryConstraintsDictionary(const Dictionary& mandatoryConst raintsDictionary, WebVector<WebMediaConstraint>& mandatory) 160 static bool parseMandatoryConstraintsDictionary(const Dictionary& mandatoryConst raintsDictionary, Vector<NameValueStringConstraint>& mandatory)
160 { 161 {
161 Vector<WebMediaConstraint> mandatoryConstraintsVector;
162 HashMap<String, String> mandatoryConstraintsHashMap; 162 HashMap<String, String> mandatoryConstraintsHashMap;
163 bool ok = mandatoryConstraintsDictionary.getOwnPropertiesAsStringHashMap(man datoryConstraintsHashMap); 163 bool ok = mandatoryConstraintsDictionary.getOwnPropertiesAsStringHashMap(man datoryConstraintsHashMap);
164 if (!ok) 164 if (!ok)
165 return false; 165 return false;
166 166
167 for (const auto& iter : mandatoryConstraintsHashMap) 167 for (const auto& iter : mandatoryConstraintsHashMap)
168 mandatoryConstraintsVector.append(WebMediaConstraint(iter.key, iter.valu e)); 168 mandatory.append(NameValueStringConstraint(iter.key, iter.value));
169 mandatory.assign(mandatoryConstraintsVector);
170 return true; 169 return true;
171 } 170 }
172 171
173 static bool parseOptionalConstraintsVectorElement(const Dictionary& constraint, Vector<WebMediaConstraint>& optionalConstraintsVector) 172 static bool parseOptionalConstraintsVectorElement(const Dictionary& constraint, Vector<NameValueStringConstraint>& optionalConstraintsVector)
174 { 173 {
175 Vector<String> localNames; 174 Vector<String> localNames;
176 bool ok = constraint.getPropertyNames(localNames); 175 bool ok = constraint.getPropertyNames(localNames);
177 if (!ok) 176 if (!ok)
178 return false; 177 return false;
179 if (localNames.size() != 1) 178 if (localNames.size() != 1)
180 return false; 179 return false;
181 const String& key = localNames[0]; 180 const String& key = localNames[0];
182 String value; 181 String value;
183 ok = DictionaryHelper::get(constraint, key, value); 182 ok = DictionaryHelper::get(constraint, key, value);
184 if (!ok) 183 if (!ok)
185 return false; 184 return false;
186 optionalConstraintsVector.append(WebMediaConstraint(key, value)); 185 optionalConstraintsVector.append(NameValueStringConstraint(key, value));
187 return true; 186 return true;
188 } 187 }
189 188
190 // Old style parser. Deprecated. 189 // Old style parser. Deprecated.
191 static bool parse(const Dictionary& constraintsDictionary, WebVector<WebMediaCon straint>& optional, WebVector<WebMediaConstraint>& mandatory) 190 static bool parse(const Dictionary& constraintsDictionary, Vector<NameValueStrin gConstraint>& optional, Vector<NameValueStringConstraint>& mandatory)
192 { 191 {
193 if (constraintsDictionary.isUndefinedOrNull()) 192 if (constraintsDictionary.isUndefinedOrNull())
194 return true; 193 return true;
195 194
196 Vector<String> names; 195 Vector<String> names;
197 bool ok = constraintsDictionary.getPropertyNames(names); 196 bool ok = constraintsDictionary.getPropertyNames(names);
198 if (!ok) 197 if (!ok)
199 return false; 198 return false;
200 199
201 String mandatoryName("mandatory"); 200 String mandatoryName("mandatory");
202 String optionalName("optional"); 201 String optionalName("optional");
203 202
204 for (Vector<String>::iterator it = names.begin(); it != names.end(); ++it) { 203 for (Vector<String>::iterator it = names.begin(); it != names.end(); ++it) {
205 if (*it != mandatoryName && *it != optionalName) 204 if (*it != mandatoryName && *it != optionalName)
206 return false; 205 return false;
207 } 206 }
208 207
209 if (names.contains(mandatoryName)) { 208 if (names.contains(mandatoryName)) {
210 Dictionary mandatoryConstraintsDictionary; 209 Dictionary mandatoryConstraintsDictionary;
211 bool ok = constraintsDictionary.get(mandatoryName, mandatoryConstraintsD ictionary); 210 bool ok = constraintsDictionary.get(mandatoryName, mandatoryConstraintsD ictionary);
212 if (!ok || mandatoryConstraintsDictionary.isUndefinedOrNull()) 211 if (!ok || mandatoryConstraintsDictionary.isUndefinedOrNull())
213 return false; 212 return false;
214 ok = parseMandatoryConstraintsDictionary(mandatoryConstraintsDictionary, mandatory); 213 ok = parseMandatoryConstraintsDictionary(mandatoryConstraintsDictionary, mandatory);
215 if (!ok) 214 if (!ok)
216 return false; 215 return false;
217 } 216 }
218 217
219 Vector<WebMediaConstraint> optionalConstraintsVector;
220 if (names.contains(optionalName)) { 218 if (names.contains(optionalName)) {
221 ArrayValue optionalConstraints; 219 ArrayValue optionalConstraints;
222 bool ok = DictionaryHelper::get(constraintsDictionary, optionalName, opt ionalConstraints); 220 bool ok = DictionaryHelper::get(constraintsDictionary, optionalName, opt ionalConstraints);
223 if (!ok || optionalConstraints.isUndefinedOrNull()) 221 if (!ok || optionalConstraints.isUndefinedOrNull())
224 return false; 222 return false;
225 223
226 size_t numberOfConstraints; 224 size_t numberOfConstraints;
227 ok = optionalConstraints.length(numberOfConstraints); 225 ok = optionalConstraints.length(numberOfConstraints);
228 if (!ok) 226 if (!ok)
229 return false; 227 return false;
230 228
231 for (size_t i = 0; i < numberOfConstraints; ++i) { 229 for (size_t i = 0; i < numberOfConstraints; ++i) {
232 Dictionary constraint; 230 Dictionary constraint;
233 ok = optionalConstraints.get(i, constraint); 231 ok = optionalConstraints.get(i, constraint);
234 if (!ok || constraint.isUndefinedOrNull()) 232 if (!ok || constraint.isUndefinedOrNull())
235 return false; 233 return false;
236 ok = parseOptionalConstraintsVectorElement(constraint, optionalConst raintsVector); 234 ok = parseOptionalConstraintsVectorElement(constraint, optional);
237 if (!ok) 235 if (!ok)
238 return false; 236 return false;
239 } 237 }
240 optional.assign(optionalConstraintsVector);
241 } 238 }
242 239
243 return true; 240 return true;
244 } 241 }
245 242
246 static bool parse(const MediaTrackConstraints& constraintsIn, WebVector<WebMedia Constraint>& optional, WebVector<WebMediaConstraint>& mandatory) 243 static bool parse(const MediaTrackConstraints& constraintsIn, Vector<NameValueSt ringConstraint>& optional, Vector<NameValueStringConstraint>& mandatory)
247 { 244 {
248 Vector<WebMediaConstraint> mandatoryConstraintsVector; 245 Vector<NameValueStringConstraint> mandatoryConstraintsVector;
249 if (constraintsIn.hasMandatory()) { 246 if (constraintsIn.hasMandatory()) {
250 bool ok = parseMandatoryConstraintsDictionary(constraintsIn.mandatory(), mandatory); 247 bool ok = parseMandatoryConstraintsDictionary(constraintsIn.mandatory(), mandatory);
251 if (!ok) 248 if (!ok)
252 return false; 249 return false;
253 } 250 }
254 251
255 Vector<WebMediaConstraint> optionalConstraintsVector;
256 if (constraintsIn.hasOptional()) { 252 if (constraintsIn.hasOptional()) {
257 const Vector<Dictionary>& optionalConstraints = constraintsIn.optional() ; 253 const Vector<Dictionary>& optionalConstraints = constraintsIn.optional() ;
258 254
259 for (const auto& constraint : optionalConstraints) { 255 for (const auto& constraint : optionalConstraints) {
260 if (constraint.isUndefinedOrNull()) 256 if (constraint.isUndefinedOrNull())
261 return false; 257 return false;
262 bool ok = parseOptionalConstraintsVectorElement(constraint, optional ConstraintsVector); 258 bool ok = parseOptionalConstraintsVectorElement(constraint, optional );
263 if (!ok) 259 if (!ok)
264 return false; 260 return false;
265 } 261 }
266 optional.assign(optionalConstraintsVector);
267 } 262 }
268 return true; 263 return true;
269 } 264 }
270 265
271 static bool toBoolean(const WebString& asWebString) 266 static bool toBoolean(const WebString& asWebString)
272 { 267 {
273 return asWebString.equals("true"); 268 return asWebString.equals("true");
274 // TODO(hta): Check against "false" and return error if it's neither. 269 // TODO(hta): Check against "false" and return error if it's neither.
275 // https://crbug.com/576582 270 // https://crbug.com/576582
276 } 271 }
277 272
278 static void parseOldStyleNames(ExecutionContext* context, const WebVector<WebMed iaConstraint>& oldNames, bool reportUnknownNames, WebMediaTrackConstraintSet& re sult, MediaErrorState& errorState) 273 static void parseOldStyleNames(ExecutionContext* context, const Vector<NameValue StringConstraint>& oldNames, bool reportUnknownNames, WebMediaTrackConstraintSet & result, MediaErrorState& errorState)
279 { 274 {
280 for (const WebMediaConstraint& constraint : oldNames) { 275 for (const NameValueStringConstraint& constraint : oldNames) {
281 if (constraint.m_name.equals(kMinAspectRatio)) { 276 if (constraint.m_name.equals(kMinAspectRatio)) {
282 result.aspectRatio.setMin(atof(constraint.m_value.utf8().c_str())); 277 result.aspectRatio.setMin(atof(constraint.m_value.utf8().c_str()));
283 } else if (constraint.m_name.equals(kMaxAspectRatio)) { 278 } else if (constraint.m_name.equals(kMaxAspectRatio)) {
284 result.aspectRatio.setMax(atof(constraint.m_value.utf8().c_str())); 279 result.aspectRatio.setMax(atof(constraint.m_value.utf8().c_str()));
285 } else if (constraint.m_name.equals(kMaxWidth)) { 280 } else if (constraint.m_name.equals(kMaxWidth)) {
286 result.width.setMax(atoi(constraint.m_value.utf8().c_str())); 281 result.width.setMax(atoi(constraint.m_value.utf8().c_str()));
287 } else if (constraint.m_name.equals(kMinWidth)) { 282 } else if (constraint.m_name.equals(kMinWidth)) {
288 result.width.setMin(atoi(constraint.m_value.utf8().c_str())); 283 result.width.setMin(atoi(constraint.m_value.utf8().c_str()));
289 } else if (constraint.m_name.equals(kMaxHeight)) { 284 } else if (constraint.m_name.equals(kMaxHeight)) {
290 result.height.setMax(atoi(constraint.m_value.utf8().c_str())); 285 result.height.setMax(atoi(constraint.m_value.utf8().c_str()));
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 DeprecationMessageSource, 412 DeprecationMessageSource,
418 WarningMessageLevel, 413 WarningMessageLevel,
419 "Unknown constraint named " 414 "Unknown constraint named "
420 + String(constraint.m_name) + " rejected")); 415 + String(constraint.m_name) + " rejected"));
421 errorState.throwConstraintError("Unknown name of constraint dete cted", constraint.m_name); 416 errorState.throwConstraintError("Unknown name of constraint dete cted", constraint.m_name);
422 } 417 }
423 } 418 }
424 } 419 }
425 } 420 }
426 421
427 static WebMediaConstraints createFromNamedConstraints(ExecutionContext* context, WebVector<WebMediaConstraint>& mandatory, const WebVector<WebMediaConstraint>& optional, MediaErrorState& errorState) 422 static WebMediaConstraints createFromNamedConstraints(ExecutionContext* context, Vector<NameValueStringConstraint>& mandatory, const Vector<NameValueStringConst raint>& optional, MediaErrorState& errorState)
428 { 423 {
429 WebMediaTrackConstraintSet basic; 424 WebMediaTrackConstraintSet basic;
430 WebMediaTrackConstraintSet advanced; 425 WebMediaTrackConstraintSet advanced;
431 WebMediaConstraints constraints; 426 WebMediaConstraints constraints;
432 parseOldStyleNames(context, mandatory, true, basic, errorState); 427 parseOldStyleNames(context, mandatory, true, basic, errorState);
433 if (errorState.hadException()) 428 if (errorState.hadException())
434 return constraints; 429 return constraints;
435 // We ignore unknow names and syntax errors in optional constraints. 430 // We ignore unknow names and syntax errors in optional constraints.
436 MediaErrorState ignoredErrorState; 431 MediaErrorState ignoredErrorState;
437 Vector<WebMediaTrackConstraintSet> advancedVector; 432 Vector<WebMediaTrackConstraintSet> advancedVector;
438 for (const auto& optionalConstraint : optional) { 433 for (const auto& optionalConstraint : optional) {
439 WebMediaTrackConstraintSet advancedElement; 434 WebMediaTrackConstraintSet advancedElement;
440 WebVector<WebMediaConstraint> elementAsList(&optionalConstraint, 1); 435 Vector<NameValueStringConstraint> elementAsList(1, optionalConstraint);
441 parseOldStyleNames(context, elementAsList, false, advancedElement, ignor edErrorState); 436 parseOldStyleNames(context, elementAsList, false, advancedElement, ignor edErrorState);
442 if (!advancedElement.isEmpty()) 437 if (!advancedElement.isEmpty())
443 advancedVector.append(advancedElement); 438 advancedVector.append(advancedElement);
444 } 439 }
445 constraints.initialize(basic, advancedVector); 440 constraints.initialize(basic, advancedVector);
446 return constraints; 441 return constraints;
447 } 442 }
448 443
449 // Deprecated. 444 // Deprecated.
450 WebMediaConstraints create(ExecutionContext* context, const Dictionary& constrai ntsDictionary, MediaErrorState& errorState) 445 WebMediaConstraints create(ExecutionContext* context, const Dictionary& constrai ntsDictionary, MediaErrorState& errorState)
451 { 446 {
452 WebVector<WebMediaConstraint> optional; 447 Vector<NameValueStringConstraint> optional;
453 WebVector<WebMediaConstraint> mandatory; 448 Vector<NameValueStringConstraint> mandatory;
454 if (!parse(constraintsDictionary, optional, mandatory)) { 449 if (!parse(constraintsDictionary, optional, mandatory)) {
455 errorState.throwTypeError("Malformed constraints object."); 450 errorState.throwTypeError("Malformed constraints object.");
456 return WebMediaConstraints(); 451 return WebMediaConstraints();
457 } 452 }
458 UseCounter::count(context, UseCounter::MediaStreamConstraintsFromDictionary) ; 453 UseCounter::count(context, UseCounter::MediaStreamConstraintsFromDictionary) ;
459 return createFromNamedConstraints(context, mandatory, optional, errorState); 454 return createFromNamedConstraints(context, mandatory, optional, errorState);
460 } 455 }
461 456
462 void copyLongConstraint(const ConstrainLongRange& blinkForm, LongConstraint& web Form) 457 void copyLongConstraint(const ConstrainLongRange& blinkForm, LongConstraint& web Form)
463 { 458 {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 advancedBuffer.append(advancedElement); 562 advancedBuffer.append(advancedElement);
568 } 563 }
569 } 564 }
570 // TODO(hta): Add initialization of advanced constraints once present. 565 // TODO(hta): Add initialization of advanced constraints once present.
571 // https://crbug.com/253412 566 // https://crbug.com/253412
572 if (constraintsIn.hasOptional() || constraintsIn.hasMandatory()) { 567 if (constraintsIn.hasOptional() || constraintsIn.hasMandatory()) {
573 if (!constraintBuffer.isEmpty() || constraintsIn.hasAdvanced()) { 568 if (!constraintBuffer.isEmpty() || constraintsIn.hasAdvanced()) {
574 errorState.throwTypeError("Malformed constraint: Cannot use both opt ional/mandatory and specific or advanced constraints."); 569 errorState.throwTypeError("Malformed constraint: Cannot use both opt ional/mandatory and specific or advanced constraints.");
575 return WebMediaConstraints(); 570 return WebMediaConstraints();
576 } 571 }
577 WebVector<WebMediaConstraint> optional; 572 Vector<NameValueStringConstraint> optional;
578 WebVector<WebMediaConstraint> mandatory; 573 Vector<NameValueStringConstraint> mandatory;
579 if (!parse(constraintsIn, optional, mandatory)) { 574 if (!parse(constraintsIn, optional, mandatory)) {
580 errorState.throwTypeError("Malformed constraints object."); 575 errorState.throwTypeError("Malformed constraints object.");
581 return WebMediaConstraints(); 576 return WebMediaConstraints();
582 } 577 }
583 UseCounter::count(context, UseCounter::MediaStreamConstraintsNameValue); 578 UseCounter::count(context, UseCounter::MediaStreamConstraintsNameValue);
584 return createFromNamedConstraints(context, mandatory, optional, errorSta te); 579 return createFromNamedConstraints(context, mandatory, optional, errorSta te);
585 } 580 }
586 UseCounter::count(context, UseCounter::MediaStreamConstraintsConformant); 581 UseCounter::count(context, UseCounter::MediaStreamConstraintsConformant);
587 constraints.initialize(constraintBuffer, advancedBuffer); 582 constraints.initialize(constraintBuffer, advancedBuffer);
588 return constraints; 583 return constraints;
589 } 584 }
590 585
591 WebMediaConstraints create() 586 WebMediaConstraints create()
592 { 587 {
593 WebMediaConstraints constraints; 588 WebMediaConstraints constraints;
594 constraints.initialize(); 589 constraints.initialize();
595 return constraints; 590 return constraints;
596 } 591 }
597 592
593 ConstrainLongRange convertLong(const LongConstraint& input)
594 {
595
596 ConstrainLongRange output;
597 if (input.hasExact())
598 output.setExact(input.exact());
599 if (input.hasIdeal())
600 output.setIdeal(input.ideal());
601 if (input.hasMin())
602 output.setMin(input.min());
603 if (input.hasMax())
604 output.setMax(input.max());
605 return output;
606 }
607
608 ConstrainDoubleRange convertDouble(const DoubleConstraint& input)
609 {
610
611 ConstrainDoubleRange output;
612 if (input.hasExact())
613 output.setExact(input.exact());
614 if (input.hasIdeal())
615 output.setIdeal(input.ideal());
616 if (input.hasMin())
617 output.setMin(input.min());
618 if (input.hasMax())
619 output.setMax(input.max());
620 return output;
621 }
622
623 ConstrainDOMStringParameters convertString(const StringConstraint& input)
624 {
625 ConstrainDOMStringParameters output;
626 if (input.hasIdeal()) {
627 Vector<String> buffer;
628 for (const auto& scanner : input.ideal())
629 buffer.append(scanner);
630 output.setIdeal(buffer);
631 }
632 if (input.hasExact()) {
633 Vector<String> buffer;
634 for (const auto& scanner : input.exact())
635 buffer.append(scanner);
636 output.setExact(buffer);
637 }
638 return output;
639 }
640
641 ConstrainBooleanParameters convertBoolean(const BooleanConstraint& input)
642 {
643
644 ConstrainBooleanParameters output;
645 if (input.hasExact())
646 output.setExact(input.exact());
647 if (input.hasIdeal())
648 output.setIdeal(input.ideal());
649 return output;
650 }
651
652 void convertConstraintSet(const WebMediaTrackConstraintSet& input, MediaTrackCon straintSet& output)
653 {
654 if (!input.width.isEmpty())
655 output.setWidth(convertLong(input.width));
656 if (!input.height.isEmpty())
657 output.setHeight(convertLong(input.height));
658 if (!input.aspectRatio.isEmpty())
659 output.setAspectRatio(convertDouble(input.aspectRatio));
660 if (!input.frameRate.isEmpty())
661 output.setFrameRate(convertDouble(input.frameRate));
662 if (!input.facingMode.isEmpty())
663 output.setFacingMode(convertString(input.facingMode));
664 if (!input.volume.isEmpty())
665 output.setVolume(convertDouble(input.volume));
666 if (!input.sampleRate.isEmpty())
667 output.setSampleRate(convertLong(input.sampleRate));
668 if (!input.sampleSize.isEmpty())
669 output.setSampleSize(convertLong(input.sampleSize));
670 if (!input.echoCancellation.isEmpty())
671 output.setEchoCancellation(convertBoolean(input.echoCancellation));
672 if (!input.latency.isEmpty())
673 output.setLatency(convertDouble(input.latency));
674 if (!input.channelCount.isEmpty())
675 output.setChannelCount(convertLong(input.channelCount));
676 if (!input.deviceId.isEmpty())
677 output.setDeviceId(convertString(input.deviceId));
678 if (!input.groupId.isEmpty())
679 output.setGroupId(convertString(input.groupId));
680 // TODO(hta): Decide the future of the nonstandard constraints.
681 // If they go forward, they need to be added here.
682 // https://crbug.com/605673
683 }
684
685 void convertConstraints(const WebMediaConstraints& input, MediaTrackConstraints& output)
686 {
687 if (input.isNull())
688 return;
689 convertConstraintSet(input.basic(), output);
690 HeapVector<MediaTrackConstraintSet> advancedVector;
691 for (const auto& it : input.advanced()) {
692 MediaTrackConstraintSet element;
693 convertConstraintSet(it, element);
694 advancedVector.append(element);
695 }
696 if (!advancedVector.isEmpty())
697 output.setAdvanced(advancedVector);
698 }
699
598 } // namespace MediaConstraintsImpl 700 } // namespace MediaConstraintsImpl
599 } // namespace blink 701 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698