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

Side by Side Diff: webrtc/api/mediaconstraintsinterface.cc

Issue 1717583002: Non-constraint interfaces for all constrainable interfaces (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Removing a TODO Created 4 years, 9 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 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 if (mandatory_constraints) 121 if (mandatory_constraints)
122 ++*mandatory_constraints; 122 ++*mandatory_constraints;
123 return rtc::FromString(string_value, value); 123 return rtc::FromString(string_value, value);
124 } 124 }
125 if (constraints->GetOptional().FindFirst(key, &string_value)) { 125 if (constraints->GetOptional().FindFirst(key, &string_value)) {
126 return rtc::FromString(string_value, value); 126 return rtc::FromString(string_value, value);
127 } 127 }
128 return false; 128 return false;
129 } 129 }
130 130
131 // As above, but for integers.
132 bool FindConstraint(const MediaConstraintsInterface* constraints,
133 const std::string& key,
134 int* value,
135 size_t* mandatory_constraints) {
136 std::string string_value;
137 if (!constraints) {
138 return false;
139 }
140 if (constraints->GetMandatory().FindFirst(key, &string_value)) {
141 if (mandatory_constraints)
perkj_webrtc 2016/03/01 08:41:26 nit : {}
hta-webrtc 2016/03/02 09:33:40 Done (here and in existing code above).
142 ++*mandatory_constraints;
143 return rtc::FromString(string_value, value);
144 }
145 if (constraints->GetOptional().FindFirst(key, &string_value)) {
146 return rtc::FromString(string_value, value);
147 }
148 return false;
149 }
150
151 rtc::Optional<bool> ConstraintToOptionalBool(
152 const MediaConstraintsInterface* constraints,
153 const std::string& key) {
154 bool value;
155 bool present = FindConstraint(constraints, key, &value, nullptr);
156 if (present) {
157 return rtc::Optional<bool>(value);
158 }
159 return rtc::Optional<bool>();
160 }
161
162 rtc::Optional<int> ConstraintToOptionalInt(
163 const MediaConstraintsInterface* constraints,
164 const std::string& key) {
165 int value;
166 bool present = FindConstraint(constraints, key, &value, nullptr);
167 if (present) {
168 return rtc::Optional<int>(value);
169 }
170 return rtc::Optional<int>();
171 }
172
131 } // namespace webrtc 173 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698