| OLD | NEW |
| 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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 static WebMediaConstraints createFromNamedConstraints(ExecutionContext* context,
WebVector<WebMediaConstraint>& mandatory, const WebVector<WebMediaConstraint>&
optional, MediaErrorState& errorState) | 427 static WebMediaConstraints createFromNamedConstraints(ExecutionContext* context,
WebVector<WebMediaConstraint>& mandatory, const WebVector<WebMediaConstraint>&
optional, MediaErrorState& errorState) |
| 428 { | 428 { |
| 429 WebMediaTrackConstraintSet basic; | 429 WebMediaTrackConstraintSet basic; |
| 430 WebMediaTrackConstraintSet advanced; | 430 WebMediaTrackConstraintSet advanced; |
| 431 WebMediaConstraints constraints; | 431 WebMediaConstraints constraints; |
| 432 parseOldStyleNames(context, mandatory, true, basic, errorState); | 432 parseOldStyleNames(context, mandatory, true, basic, errorState); |
| 433 if (errorState.hadException()) | 433 if (errorState.hadException()) |
| 434 return constraints; | 434 return constraints; |
| 435 // We ignore unknow names and syntax errors in optional constraints. | 435 // We ignore unknow names and syntax errors in optional constraints. |
| 436 MediaErrorState ignoredErrorState; | 436 MediaErrorState ignoredErrorState; |
| 437 parseOldStyleNames(context, optional, false, advanced, ignoredErrorState); | 437 Vector<WebMediaTrackConstraintSet> advancedVector; |
| 438 if (advanced.isEmpty()) { | 438 for (const auto& optionalConstraint : optional) { |
| 439 WebVector<WebMediaTrackConstraintSet> emptyVector; | 439 WebMediaTrackConstraintSet advancedElement; |
| 440 constraints.initialize(basic, emptyVector); | 440 WebVector<WebMediaConstraint> elementAsList(&optionalConstraint, 1); |
| 441 } else { | 441 parseOldStyleNames(context, elementAsList, false, advancedElement, ignor
edErrorState); |
| 442 WebVector<WebMediaTrackConstraintSet> advancedVector(&advanced, 1); | 442 if (!advancedElement.isEmpty()) |
| 443 constraints.initialize(basic, advancedVector); | 443 advancedVector.append(advancedElement); |
| 444 } | 444 } |
| 445 constraints.initialize(basic, advancedVector); |
| 445 return constraints; | 446 return constraints; |
| 446 } | 447 } |
| 447 | 448 |
| 448 // Deprecated. | 449 // Deprecated. |
| 449 WebMediaConstraints create(ExecutionContext* context, const Dictionary& constrai
ntsDictionary, MediaErrorState& errorState) | 450 WebMediaConstraints create(ExecutionContext* context, const Dictionary& constrai
ntsDictionary, MediaErrorState& errorState) |
| 450 { | 451 { |
| 451 WebVector<WebMediaConstraint> optional; | 452 WebVector<WebMediaConstraint> optional; |
| 452 WebVector<WebMediaConstraint> mandatory; | 453 WebVector<WebMediaConstraint> mandatory; |
| 453 if (!parse(constraintsDictionary, optional, mandatory)) { | 454 if (!parse(constraintsDictionary, optional, mandatory)) { |
| 454 errorState.throwTypeError("Malformed constraints object."); | 455 errorState.throwTypeError("Malformed constraints object."); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 | 583 |
| 583 WebMediaConstraints create() | 584 WebMediaConstraints create() |
| 584 { | 585 { |
| 585 WebMediaConstraints constraints; | 586 WebMediaConstraints constraints; |
| 586 constraints.initialize(); | 587 constraints.initialize(); |
| 587 return constraints; | 588 return constraints; |
| 588 } | 589 } |
| 589 | 590 |
| 590 } // namespace MediaConstraintsImpl | 591 } // namespace MediaConstraintsImpl |
| 591 } // namespace blink | 592 } // namespace blink |
| OLD | NEW |