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

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

Issue 2664673002: Media Capture Depth Stream Extensions API: videoKind settings and constraint. (Closed)
Patch Set: Created 3 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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 } 689 }
674 690
675 WebMediaConstraints convertConstraintsToWeb( 691 WebMediaConstraints convertConstraintsToWeb(
676 const MediaTrackConstraints& constraintsIn) { 692 const MediaTrackConstraints& constraintsIn) {
677 WebMediaConstraints constraints; 693 WebMediaConstraints constraints;
678 WebMediaTrackConstraintSet constraintBuffer; 694 WebMediaTrackConstraintSet constraintBuffer;
679 Vector<WebMediaTrackConstraintSet> advancedBuffer; 695 Vector<WebMediaTrackConstraintSet> advancedBuffer;
680 copyConstraintSet(constraintsIn, NakedValueDisposition::kTreatAsIdeal, 696 copyConstraintSet(constraintsIn, NakedValueDisposition::kTreatAsIdeal,
681 constraintBuffer); 697 constraintBuffer);
682 if (constraintsIn.hasAdvanced()) { 698 if (constraintsIn.hasAdvanced()) {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 convertBoolean(input.echoCancellation, nakedTreatment)); 904 convertBoolean(input.echoCancellation, nakedTreatment));
889 } 905 }
890 if (!input.latency.isEmpty()) 906 if (!input.latency.isEmpty())
891 output.setLatency(convertDouble(input.latency, nakedTreatment)); 907 output.setLatency(convertDouble(input.latency, nakedTreatment));
892 if (!input.channelCount.isEmpty()) 908 if (!input.channelCount.isEmpty())
893 output.setChannelCount(convertLong(input.channelCount, nakedTreatment)); 909 output.setChannelCount(convertLong(input.channelCount, nakedTreatment));
894 if (!input.deviceId.isEmpty()) 910 if (!input.deviceId.isEmpty())
895 output.setDeviceId(convertString(input.deviceId, nakedTreatment)); 911 output.setDeviceId(convertString(input.deviceId, nakedTreatment));
896 if (!input.groupId.isEmpty()) 912 if (!input.groupId.isEmpty())
897 output.setGroupId(convertString(input.groupId, nakedTreatment)); 913 output.setGroupId(convertString(input.groupId, nakedTreatment));
914 if (!input.videoKind.isEmpty())
915 output.setVideoKind(convertString(input.videoKind, nakedTreatment));
898 // TODO(hta): Decide the future of the nonstandard constraints. 916 // TODO(hta): Decide the future of the nonstandard constraints.
899 // If they go forward, they need to be added here. 917 // If they go forward, they need to be added here.
900 // https://crbug.com/605673 918 // https://crbug.com/605673
901 } 919 }
902 920
903 void convertConstraints(const WebMediaConstraints& input, 921 void convertConstraints(const WebMediaConstraints& input,
904 MediaTrackConstraints& output) { 922 MediaTrackConstraints& output) {
905 if (input.isNull()) 923 if (input.isNull())
906 return; 924 return;
907 convertConstraintSet(input.basic(), NakedValueDisposition::kTreatAsIdeal, 925 convertConstraintSet(input.basic(), NakedValueDisposition::kTreatAsIdeal,
908 output); 926 output);
909 HeapVector<MediaTrackConstraintSet> advancedVector; 927 HeapVector<MediaTrackConstraintSet> advancedVector;
910 for (const auto& it : input.advanced()) { 928 for (const auto& it : input.advanced()) {
911 MediaTrackConstraintSet element; 929 MediaTrackConstraintSet element;
912 convertConstraintSet(it, NakedValueDisposition::kTreatAsExact, element); 930 convertConstraintSet(it, NakedValueDisposition::kTreatAsExact, element);
913 advancedVector.push_back(element); 931 advancedVector.push_back(element);
914 } 932 }
915 if (!advancedVector.isEmpty()) 933 if (!advancedVector.isEmpty())
916 output.setAdvanced(advancedVector); 934 output.setAdvanced(advancedVector);
917 } 935 }
918 936
919 } // namespace MediaConstraintsImpl 937 } // namespace MediaConstraintsImpl
920 } // namespace blink 938 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698