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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 if (blinkForm.hasIdeal()) { | 500 if (blinkForm.hasIdeal()) { |
501 webForm.setIdeal(blinkForm.ideal()); | 501 webForm.setIdeal(blinkForm.ideal()); |
502 } | 502 } |
503 if (blinkForm.hasExact()) { | 503 if (blinkForm.hasExact()) { |
504 webForm.setExact(blinkForm.exact()); | 504 webForm.setExact(blinkForm.exact()); |
505 } | 505 } |
506 } | 506 } |
507 | 507 |
508 void copyConstraints(const MediaTrackConstraintSet& constraintsIn, WebMediaTrack
ConstraintSet& constraintBuffer) | 508 void copyConstraints(const MediaTrackConstraintSet& constraintsIn, WebMediaTrack
ConstraintSet& constraintBuffer) |
509 { | 509 { |
510 if (constraintsIn.hasWidth()) { | 510 |
511 copyLongConstraint(constraintsIn.width(), constraintBuffer.width); | 511 #define CONSTRAINT_ITEM(lowercase, uppercase, datatype) \ |
| 512 if (constraintsIn.has##uppercase()) { \ |
| 513 copy##datatype##Constraint(constraintsIn.lowercase(), constraintBuffer.l
owercase); \ |
512 } | 514 } |
513 if (constraintsIn.hasHeight()) { | 515 |
514 copyLongConstraint(constraintsIn.height(), constraintBuffer.height); | 516 CONSTRAINT_LIST |
515 } | 517 |
516 if (constraintsIn.hasAspectRatio()) { | 518 #undef CONSTRAINT_ITEM |
517 copyDoubleConstraint(constraintsIn.aspectRatio(), constraintBuffer.aspec
tRatio); | |
518 } | |
519 if (constraintsIn.hasFrameRate()) { | |
520 copyDoubleConstraint(constraintsIn.frameRate(), constraintBuffer.frameRa
te); | |
521 } | |
522 if (constraintsIn.hasFacingMode()) { | |
523 copyStringConstraint(constraintsIn.facingMode(), constraintBuffer.facing
Mode); | |
524 } | |
525 if (constraintsIn.hasVolume()) { | |
526 copyDoubleConstraint(constraintsIn.volume(), constraintBuffer.volume); | |
527 } | |
528 if (constraintsIn.hasSampleRate()) { | |
529 copyLongConstraint(constraintsIn.sampleRate(), constraintBuffer.sampleRa
te); | |
530 } | |
531 if (constraintsIn.hasSampleSize()) { | |
532 copyLongConstraint(constraintsIn.sampleSize(), constraintBuffer.sampleSi
ze); | |
533 } | |
534 if (constraintsIn.hasEchoCancellation()) { | |
535 copyBooleanConstraint(constraintsIn.echoCancellation(), constraintBuffer
.echoCancellation); | |
536 } | |
537 if (constraintsIn.hasLatency()) { | |
538 copyDoubleConstraint(constraintsIn.latency(), constraintBuffer.latency); | |
539 } | |
540 if (constraintsIn.hasChannelCount()) { | |
541 copyLongConstraint(constraintsIn.channelCount(), constraintBuffer.channe
lCount); | |
542 } | |
543 if (constraintsIn.hasDeviceId()) { | |
544 copyStringConstraint(constraintsIn.deviceId(), constraintBuffer.deviceId
); | |
545 } | |
546 if (constraintsIn.hasGroupId()) { | |
547 copyStringConstraint(constraintsIn.groupId(), constraintBuffer.groupId); | |
548 } | |
549 } | 519 } |
550 | 520 |
551 WebMediaConstraints create(ExecutionContext* context, const MediaTrackConstraint
s& constraintsIn, MediaErrorState& errorState) | 521 WebMediaConstraints create(ExecutionContext* context, const MediaTrackConstraint
s& constraintsIn, MediaErrorState& errorState) |
552 { | 522 { |
553 WebMediaConstraints constraints; | 523 WebMediaConstraints constraints; |
554 WebMediaTrackConstraintSet constraintBuffer; | 524 WebMediaTrackConstraintSet constraintBuffer; |
555 Vector<WebMediaTrackConstraintSet> advancedBuffer; | 525 Vector<WebMediaTrackConstraintSet> advancedBuffer; |
556 copyConstraints(constraintsIn, constraintBuffer); | 526 copyConstraints(constraintsIn, constraintBuffer); |
557 if (constraintsIn.hasAdvanced()) { | 527 if (constraintsIn.hasAdvanced()) { |
558 for (const auto& element : constraintsIn.advanced()) { | 528 for (const auto& element : constraintsIn.advanced()) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 ConstrainBooleanParameters output; | 613 ConstrainBooleanParameters output; |
644 if (input.hasExact()) | 614 if (input.hasExact()) |
645 output.setExact(input.exact()); | 615 output.setExact(input.exact()); |
646 if (input.hasIdeal()) | 616 if (input.hasIdeal()) |
647 output.setIdeal(input.ideal()); | 617 output.setIdeal(input.ideal()); |
648 return output; | 618 return output; |
649 } | 619 } |
650 | 620 |
651 void convertConstraintSet(const WebMediaTrackConstraintSet& input, MediaTrackCon
straintSet& output) | 621 void convertConstraintSet(const WebMediaTrackConstraintSet& input, MediaTrackCon
straintSet& output) |
652 { | 622 { |
653 if (!input.width.isEmpty()) | 623 #define CONSTRAINT_ITEM(lowercase, uppercase, datatype) \ |
654 output.setWidth(convertLong(input.width)); | 624 if (!input.lowercase.isEmpty()) \ |
655 if (!input.height.isEmpty()) | 625 output.set##uppercase(convert##datatype(input.lowercase)); \ |
656 output.setHeight(convertLong(input.height)); | 626 |
657 if (!input.aspectRatio.isEmpty()) | 627 CONSTRAINT_LIST |
658 output.setAspectRatio(convertDouble(input.aspectRatio)); | 628 #undef CONSTRAINT_ITEM |
659 if (!input.frameRate.isEmpty()) | |
660 output.setFrameRate(convertDouble(input.frameRate)); | |
661 if (!input.facingMode.isEmpty()) | |
662 output.setFacingMode(convertString(input.facingMode)); | |
663 if (!input.volume.isEmpty()) | |
664 output.setVolume(convertDouble(input.volume)); | |
665 if (!input.sampleRate.isEmpty()) | |
666 output.setSampleRate(convertLong(input.sampleRate)); | |
667 if (!input.sampleSize.isEmpty()) | |
668 output.setSampleSize(convertLong(input.sampleSize)); | |
669 if (!input.echoCancellation.isEmpty()) | |
670 output.setEchoCancellation(convertBoolean(input.echoCancellation)); | |
671 if (!input.latency.isEmpty()) | |
672 output.setLatency(convertDouble(input.latency)); | |
673 if (!input.channelCount.isEmpty()) | |
674 output.setChannelCount(convertLong(input.channelCount)); | |
675 if (!input.deviceId.isEmpty()) | |
676 output.setDeviceId(convertString(input.deviceId)); | |
677 if (!input.groupId.isEmpty()) | |
678 output.setGroupId(convertString(input.groupId)); | |
679 // TODO(hta): Decide the future of the nonstandard constraints. | |
680 // If they go forward, they need to be added here. | |
681 // https://crbug.com/605673 | |
682 } | 629 } |
683 | 630 |
684 void convertConstraints(const WebMediaConstraints& input, MediaTrackConstraints&
output) | 631 void convertConstraints(const WebMediaConstraints& input, MediaTrackConstraints&
output) |
685 { | 632 { |
686 if (input.isNull()) | 633 if (input.isNull()) |
687 return; | 634 return; |
688 convertConstraintSet(input.basic(), output); | 635 convertConstraintSet(input.basic(), output); |
689 HeapVector<MediaTrackConstraintSet> advancedVector; | 636 HeapVector<MediaTrackConstraintSet> advancedVector; |
690 for (const auto& it : input.advanced()) { | 637 for (const auto& it : input.advanced()) { |
691 MediaTrackConstraintSet element; | 638 MediaTrackConstraintSet element; |
692 convertConstraintSet(it, element); | 639 convertConstraintSet(it, element); |
693 advancedVector.append(element); | 640 advancedVector.append(element); |
694 } | 641 } |
695 if (!advancedVector.isEmpty()) | 642 if (!advancedVector.isEmpty()) |
696 output.setAdvanced(advancedVector); | 643 output.setAdvanced(advancedVector); |
697 } | 644 } |
698 | 645 |
699 } // namespace MediaConstraintsImpl | 646 } // namespace MediaConstraintsImpl |
700 } // namespace blink | 647 } // namespace blink |
OLD | NEW |