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

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

Issue 1641653002: Adding counters for the types of Media Constraints. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 10 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 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "modules/mediastream/MediaConstraintsImpl.h" 31 #include "modules/mediastream/MediaConstraintsImpl.h"
32 32
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/frame/UseCounter.h"
37 #include "modules/mediastream/MediaTrackConstraintSet.h" 38 #include "modules/mediastream/MediaTrackConstraintSet.h"
38 #include "platform/Logging.h" 39 #include "platform/Logging.h"
39 #include "platform/RuntimeEnabledFeatures.h" 40 #include "platform/RuntimeEnabledFeatures.h"
40 #include "wtf/HashMap.h" 41 #include "wtf/HashMap.h"
41 #include "wtf/Vector.h" 42 #include "wtf/Vector.h"
42 #include "wtf/text/StringHash.h" 43 #include "wtf/text/StringHash.h"
43 44
44 namespace blink { 45 namespace blink {
45 46
46 namespace MediaConstraintsImpl { 47 namespace MediaConstraintsImpl {
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 // We ignore errors in optional constraints. 379 // We ignore errors in optional constraints.
379 MediaErrorState ignoredErrorState; 380 MediaErrorState ignoredErrorState;
380 parseOldStyleNames(optional, advanced, ignoredErrorState); 381 parseOldStyleNames(optional, advanced, ignoredErrorState);
381 WebVector<WebMediaTrackConstraintSet> advancedVector(&advanced, 1); 382 WebVector<WebMediaTrackConstraintSet> advancedVector(&advanced, 1);
382 // Use the 4-argument initializer until Chrome has been converted. 383 // Use the 4-argument initializer until Chrome has been converted.
383 constraints.initialize(optional, mandatory, basic, advancedVector); 384 constraints.initialize(optional, mandatory, basic, advancedVector);
384 return constraints; 385 return constraints;
385 } 386 }
386 387
387 // Deprecated. 388 // Deprecated.
388 WebMediaConstraints create(const Dictionary& constraintsDictionary, MediaErrorSt ate& errorState) 389 WebMediaConstraints create(const ExecutionContext* context, const Dictionary& co nstraintsDictionary, MediaErrorState& errorState)
389 { 390 {
390 WebVector<WebMediaConstraint> optional; 391 WebVector<WebMediaConstraint> optional;
391 WebVector<WebMediaConstraint> mandatory; 392 WebVector<WebMediaConstraint> mandatory;
392 if (!parse(constraintsDictionary, optional, mandatory)) { 393 if (!parse(constraintsDictionary, optional, mandatory)) {
393 errorState.throwTypeError("Malformed constraints object."); 394 errorState.throwTypeError("Malformed constraints object.");
394 return WebMediaConstraints(); 395 return WebMediaConstraints();
395 } 396 }
397 UseCounter::count(context, UseCounter::MediaStreamConstraintsFromDictionary) ;
396 return createFromNamedConstraints(mandatory, optional, errorState); 398 return createFromNamedConstraints(mandatory, optional, errorState);
397 } 399 }
398 400
399 void copyLongConstraint(const ConstrainLongRange& blinkForm, LongConstraint& web Form) 401 void copyLongConstraint(const ConstrainLongRange& blinkForm, LongConstraint& web Form)
400 { 402 {
401 if (blinkForm.hasMin()) { 403 if (blinkForm.hasMin()) {
402 webForm.setMin(blinkForm.min()); 404 webForm.setMin(blinkForm.min());
403 } 405 }
404 if (blinkForm.hasMax()) { 406 if (blinkForm.hasMax()) {
405 webForm.setMax(blinkForm.max()); 407 webForm.setMax(blinkForm.max());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 copyLongConstraint(constraintsIn.channelCount(), constraintBuffer.channe lCount); 486 copyLongConstraint(constraintsIn.channelCount(), constraintBuffer.channe lCount);
485 } 487 }
486 if (constraintsIn.hasDeviceId()) { 488 if (constraintsIn.hasDeviceId()) {
487 copyStringConstraint(constraintsIn.deviceId(), constraintBuffer.deviceId ); 489 copyStringConstraint(constraintsIn.deviceId(), constraintBuffer.deviceId );
488 } 490 }
489 if (constraintsIn.hasGroupId()) { 491 if (constraintsIn.hasGroupId()) {
490 copyStringConstraint(constraintsIn.groupId(), constraintBuffer.groupId); 492 copyStringConstraint(constraintsIn.groupId(), constraintBuffer.groupId);
491 } 493 }
492 } 494 }
493 495
494 WebMediaConstraints create(const MediaTrackConstraintSet& constraintsIn, MediaEr rorState& errorState) 496 WebMediaConstraints create(const ExecutionContext* context, const MediaTrackCons traintSet& constraintsIn, MediaErrorState& errorState)
495 { 497 {
496 WebMediaConstraints constraints; 498 WebMediaConstraints constraints;
497 WebMediaTrackConstraintSet constraintBuffer; 499 WebMediaTrackConstraintSet constraintBuffer;
498 WebVector<WebMediaTrackConstraintSet> advancedBuffer; 500 WebVector<WebMediaTrackConstraintSet> advancedBuffer;
499 copyConstraints(constraintsIn, constraintBuffer); 501 copyConstraints(constraintsIn, constraintBuffer);
500 // TODO(hta): Add initialization of advanced constraints once present. 502 // TODO(hta): Add initialization of advanced constraints once present.
501 // https://crbug.com/253412 503 // https://crbug.com/253412
502 if (constraintsIn.hasOptional() || constraintsIn.hasMandatory()) { 504 if (constraintsIn.hasOptional() || constraintsIn.hasMandatory()) {
503 if (!constraintBuffer.isEmpty()) { 505 if (!constraintBuffer.isEmpty()) {
504 errorState.throwTypeError("Malformed constraint: Cannot use both opt ional/mandatory and specific constraints."); 506 errorState.throwTypeError("Malformed constraint: Cannot use both opt ional/mandatory and specific constraints.");
505 return WebMediaConstraints(); 507 return WebMediaConstraints();
506 } 508 }
507 WebVector<WebMediaConstraint> optional; 509 WebVector<WebMediaConstraint> optional;
508 WebVector<WebMediaConstraint> mandatory; 510 WebVector<WebMediaConstraint> mandatory;
509 if (!parse(constraintsIn, optional, mandatory)) { 511 if (!parse(constraintsIn, optional, mandatory)) {
510 errorState.throwTypeError("Malformed constraints object."); 512 errorState.throwTypeError("Malformed constraints object.");
511 return WebMediaConstraints(); 513 return WebMediaConstraints();
512 } 514 }
515 UseCounter::count(context, UseCounter::MediaStreamConstraintsNameValue);
513 return createFromNamedConstraints(mandatory, optional, errorState); 516 return createFromNamedConstraints(mandatory, optional, errorState);
514 } 517 }
518 UseCounter::count(context, UseCounter::MediaStreamConstraintsConformant);
515 constraints.initialize(constraintBuffer, advancedBuffer); 519 constraints.initialize(constraintBuffer, advancedBuffer);
516 return constraints; 520 return constraints;
517 } 521 }
518 522
519 WebMediaConstraints create() 523 WebMediaConstraints create()
520 { 524 {
521 WebMediaConstraints constraints; 525 WebMediaConstraints constraints;
522 constraints.initialize(); 526 constraints.initialize();
523 return constraints; 527 return constraints;
524 } 528 }
525 529
526 } // namespace MediaConstraintsImpl 530 } // namespace MediaConstraintsImpl
527 } // namespace blink 531 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698