| Index: webrtc/api/mediaconstraintsinterface.cc
|
| diff --git a/webrtc/api/mediaconstraintsinterface.cc b/webrtc/api/mediaconstraintsinterface.cc
|
| index 51521946f6674ff5d0aa5647ab465fd7f758f973..6d54640472f4a748a230ff8cb72be236e45593b3 100644
|
| --- a/webrtc/api/mediaconstraintsinterface.cc
|
| +++ b/webrtc/api/mediaconstraintsinterface.cc
|
| @@ -129,4 +129,46 @@ bool FindConstraint(const MediaConstraintsInterface* constraints,
|
| return false;
|
| }
|
|
|
| +// As above, but for integers.
|
| +bool FindConstraint(const MediaConstraintsInterface* constraints,
|
| + const std::string& key,
|
| + int* value,
|
| + size_t* mandatory_constraints) {
|
| + std::string string_value;
|
| + if (!constraints) {
|
| + return false;
|
| + }
|
| + if (constraints->GetMandatory().FindFirst(key, &string_value)) {
|
| + if (mandatory_constraints)
|
| + ++*mandatory_constraints;
|
| + return rtc::FromString(string_value, value);
|
| + }
|
| + if (constraints->GetOptional().FindFirst(key, &string_value)) {
|
| + return rtc::FromString(string_value, value);
|
| + }
|
| + return false;
|
| +}
|
| +
|
| +rtc::Optional<bool> ConstraintToOptionalBool(
|
| + const MediaConstraintsInterface* constraints,
|
| + const std::string& key) {
|
| + bool value;
|
| + bool present = FindConstraint(constraints, key, &value, nullptr);
|
| + if (present) {
|
| + return rtc::Optional<bool>(value);
|
| + }
|
| + return rtc::Optional<bool>();
|
| +}
|
| +
|
| +rtc::Optional<int> ConstraintToOptionalInt(
|
| + const MediaConstraintsInterface* constraints,
|
| + const std::string& key) {
|
| + int value;
|
| + bool present = FindConstraint(constraints, key, &value, nullptr);
|
| + if (present) {
|
| + return rtc::Optional<int>(value);
|
| + }
|
| + return rtc::Optional<int>();
|
| +}
|
| +
|
| } // namespace webrtc
|
|
|