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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // From webrtc_audio_capturer | 142 // From webrtc_audio_capturer |
143 const char kAudioLatency[] = "latencyMs"; | 143 const char kAudioLatency[] = "latencyMs"; |
144 // From media_stream_video_capturer_source | 144 // From media_stream_video_capturer_source |
145 | 145 |
146 // End of names from libjingle | 146 // End of names from libjingle |
147 // Names that have been used in the past, but should now be ignored. | 147 // Names that have been used in the past, but should now be ignored. |
148 // Kept around for backwards compatibility. | 148 // Kept around for backwards compatibility. |
149 // https://crbug.com/579729 | 149 // https://crbug.com/579729 |
150 const char kGoogLeakyBucket[] = "googLeakyBucket"; | 150 const char kGoogLeakyBucket[] = "googLeakyBucket"; |
151 const char kPowerLineFrequency[] = "googPowerLineFrequency"; | 151 const char kPowerLineFrequency[] = "googPowerLineFrequency"; |
| 152 // mediacapture-depth: videoKind key and VideoKindEnum values. |
| 153 const char kVideoKind[] = "videoKind"; |
| 154 const char kVideoKindColor[] = "color"; |
| 155 const char kVideoKindDepth[] = "depth"; |
152 // Names used for testing. | 156 // Names used for testing. |
153 const char kTestConstraint1[] = "valid_and_supported_1"; | 157 const char kTestConstraint1[] = "valid_and_supported_1"; |
154 const char kTestConstraint2[] = "valid_and_supported_2"; | 158 const char kTestConstraint2[] = "valid_and_supported_2"; |
155 | 159 |
156 static bool parseMandatoryConstraintsDictionary( | 160 static bool parseMandatoryConstraintsDictionary( |
157 const Dictionary& mandatoryConstraintsDictionary, | 161 const Dictionary& mandatoryConstraintsDictionary, |
158 Vector<NameValueStringConstraint>& mandatory) { | 162 Vector<NameValueStringConstraint>& mandatory) { |
159 DummyExceptionStateForTesting exceptionState; | 163 DummyExceptionStateForTesting exceptionState; |
160 const HashMap<String, String>& mandatoryConstraintsHashMap = | 164 const HashMap<String, String>& mandatoryConstraintsHashMap = |
161 mandatoryConstraintsDictionary.getOwnPropertiesAsStringHashMap( | 165 mandatoryConstraintsDictionary.getOwnPropertiesAsStringHashMap( |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 } else if (constraint.m_name.equals(kAudioLatency)) { | 423 } else if (constraint.m_name.equals(kAudioLatency)) { |
420 result.googLatencyMs.setExact(atoi(constraint.m_value.utf8().c_str())); | 424 result.googLatencyMs.setExact(atoi(constraint.m_value.utf8().c_str())); |
421 } else if (constraint.m_name.equals(kPowerLineFrequency)) { | 425 } else if (constraint.m_name.equals(kPowerLineFrequency)) { |
422 result.googPowerLineFrequency.setExact( | 426 result.googPowerLineFrequency.setExact( |
423 atoi(constraint.m_value.utf8().c_str())); | 427 atoi(constraint.m_value.utf8().c_str())); |
424 } else if (constraint.m_name.equals(kGoogLeakyBucket)) { | 428 } else if (constraint.m_name.equals(kGoogLeakyBucket)) { |
425 context->addConsoleMessage(ConsoleMessage::create( | 429 context->addConsoleMessage(ConsoleMessage::create( |
426 DeprecationMessageSource, WarningMessageLevel, | 430 DeprecationMessageSource, WarningMessageLevel, |
427 "Obsolete constraint named " + String(constraint.m_name) + | 431 "Obsolete constraint named " + String(constraint.m_name) + |
428 " is ignored. Please stop using it.")); | 432 " is ignored. Please stop using it.")); |
| 433 } else if (constraint.m_name.equals(kVideoKind)) { |
| 434 if (!constraint.m_value.equals(kVideoKindColor) && |
| 435 !constraint.m_value.equals(kVideoKindDepth)) { |
| 436 errorState.throwConstraintError("Illegal value for constraint", |
| 437 constraint.m_name); |
| 438 } else { |
| 439 result.videoKind.setExact(constraint.m_value); |
| 440 } |
429 } else if (constraint.m_name.equals(kTestConstraint1) || | 441 } else if (constraint.m_name.equals(kTestConstraint1) || |
430 constraint.m_name.equals(kTestConstraint2)) { | 442 constraint.m_name.equals(kTestConstraint2)) { |
431 // These constraints are only for testing parsing. | 443 // These constraints are only for testing parsing. |
432 // Values 0 and 1 are legal, all others are a ConstraintError. | 444 // Values 0 and 1 are legal, all others are a ConstraintError. |
433 if (!constraint.m_value.equals("0") && !constraint.m_value.equals("1")) { | 445 if (!constraint.m_value.equals("0") && !constraint.m_value.equals("1")) { |
434 errorState.throwConstraintError("Illegal value for constraint", | 446 errorState.throwConstraintError("Illegal value for constraint", |
435 constraint.m_name); | 447 constraint.m_name); |
436 } | 448 } |
437 } else { | 449 } else { |
438 if (reportUnknownNames) { | 450 if (reportUnknownNames) { |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 constraintBuffer.channelCount); | 675 constraintBuffer.channelCount); |
664 } | 676 } |
665 if (constraintsIn.hasDeviceId()) { | 677 if (constraintsIn.hasDeviceId()) { |
666 copyStringConstraint(constraintsIn.deviceId(), nakedTreatment, | 678 copyStringConstraint(constraintsIn.deviceId(), nakedTreatment, |
667 constraintBuffer.deviceId); | 679 constraintBuffer.deviceId); |
668 } | 680 } |
669 if (constraintsIn.hasGroupId()) { | 681 if (constraintsIn.hasGroupId()) { |
670 copyStringConstraint(constraintsIn.groupId(), nakedTreatment, | 682 copyStringConstraint(constraintsIn.groupId(), nakedTreatment, |
671 constraintBuffer.groupId); | 683 constraintBuffer.groupId); |
672 } | 684 } |
| 685 if (constraintsIn.hasVideoKind()) { |
| 686 copyStringConstraint(constraintsIn.videoKind(), nakedTreatment, |
| 687 constraintBuffer.videoKind); |
| 688 } |
673 if (constraintsIn.hasDepthNear()) { | 689 if (constraintsIn.hasDepthNear()) { |
674 copyDoubleConstraint(constraintsIn.depthNear(), nakedTreatment, | 690 copyDoubleConstraint(constraintsIn.depthNear(), nakedTreatment, |
675 constraintBuffer.depthNear); | 691 constraintBuffer.depthNear); |
676 } | 692 } |
677 if (constraintsIn.hasDepthFar()) { | 693 if (constraintsIn.hasDepthFar()) { |
678 copyDoubleConstraint(constraintsIn.depthFar(), nakedTreatment, | 694 copyDoubleConstraint(constraintsIn.depthFar(), nakedTreatment, |
679 constraintBuffer.depthFar); | 695 constraintBuffer.depthFar); |
680 } | 696 } |
681 if (constraintsIn.hasFocalLengthX()) { | 697 if (constraintsIn.hasFocalLengthX()) { |
682 copyDoubleConstraint(constraintsIn.focalLengthX(), nakedTreatment, | 698 copyDoubleConstraint(constraintsIn.focalLengthX(), nakedTreatment, |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 convertBoolean(input.echoCancellation, nakedTreatment)); | 920 convertBoolean(input.echoCancellation, nakedTreatment)); |
905 } | 921 } |
906 if (!input.latency.isEmpty()) | 922 if (!input.latency.isEmpty()) |
907 output.setLatency(convertDouble(input.latency, nakedTreatment)); | 923 output.setLatency(convertDouble(input.latency, nakedTreatment)); |
908 if (!input.channelCount.isEmpty()) | 924 if (!input.channelCount.isEmpty()) |
909 output.setChannelCount(convertLong(input.channelCount, nakedTreatment)); | 925 output.setChannelCount(convertLong(input.channelCount, nakedTreatment)); |
910 if (!input.deviceId.isEmpty()) | 926 if (!input.deviceId.isEmpty()) |
911 output.setDeviceId(convertString(input.deviceId, nakedTreatment)); | 927 output.setDeviceId(convertString(input.deviceId, nakedTreatment)); |
912 if (!input.groupId.isEmpty()) | 928 if (!input.groupId.isEmpty()) |
913 output.setGroupId(convertString(input.groupId, nakedTreatment)); | 929 output.setGroupId(convertString(input.groupId, nakedTreatment)); |
| 930 if (!input.videoKind.isEmpty()) |
| 931 output.setVideoKind(convertString(input.videoKind, nakedTreatment)); |
914 // TODO(hta): Decide the future of the nonstandard constraints. | 932 // TODO(hta): Decide the future of the nonstandard constraints. |
915 // If they go forward, they need to be added here. | 933 // If they go forward, they need to be added here. |
916 // https://crbug.com/605673 | 934 // https://crbug.com/605673 |
917 } | 935 } |
918 | 936 |
919 void convertConstraints(const WebMediaConstraints& input, | 937 void convertConstraints(const WebMediaConstraints& input, |
920 MediaTrackConstraints& output) { | 938 MediaTrackConstraints& output) { |
921 if (input.isNull()) | 939 if (input.isNull()) |
922 return; | 940 return; |
923 convertConstraintSet(input.basic(), NakedValueDisposition::kTreatAsIdeal, | 941 convertConstraintSet(input.basic(), NakedValueDisposition::kTreatAsIdeal, |
924 output); | 942 output); |
925 HeapVector<MediaTrackConstraintSet> advancedVector; | 943 HeapVector<MediaTrackConstraintSet> advancedVector; |
926 for (const auto& it : input.advanced()) { | 944 for (const auto& it : input.advanced()) { |
927 MediaTrackConstraintSet element; | 945 MediaTrackConstraintSet element; |
928 convertConstraintSet(it, NakedValueDisposition::kTreatAsExact, element); | 946 convertConstraintSet(it, NakedValueDisposition::kTreatAsExact, element); |
929 advancedVector.push_back(element); | 947 advancedVector.push_back(element); |
930 } | 948 } |
931 if (!advancedVector.isEmpty()) | 949 if (!advancedVector.isEmpty()) |
932 output.setAdvanced(advancedVector); | 950 output.setAdvanced(advancedVector); |
933 } | 951 } |
934 | 952 |
935 } // namespace MediaConstraintsImpl | 953 } // namespace MediaConstraintsImpl |
936 } // namespace blink | 954 } // namespace blink |
OLD | NEW |