| Index: webrtc/api/mediaconstraintsinterface.cc
 | 
| diff --git a/webrtc/api/mediaconstraintsinterface.cc b/webrtc/api/mediaconstraintsinterface.cc
 | 
| index b0a68b15b0b31b75ea754e62647d5510413dbe21..4e968aca93274f1c4bd85df2bcbd3c9c7a1d97ed 100644
 | 
| --- a/webrtc/api/mediaconstraintsinterface.cc
 | 
| +++ b/webrtc/api/mediaconstraintsinterface.cc
 | 
| @@ -10,6 +10,7 @@
 | 
|  
 | 
|  #include "webrtc/api/mediaconstraintsinterface.h"
 | 
|  
 | 
| +#include "webrtc/api/peerconnectioninterface.h"
 | 
|  #include "webrtc/base/stringencode.h"
 | 
|  
 | 
|  namespace webrtc {
 | 
| @@ -118,8 +119,30 @@ bool FindConstraint(const MediaConstraintsInterface* constraints,
 | 
|      return false;
 | 
|    }
 | 
|    if (constraints->GetMandatory().FindFirst(key, &string_value)) {
 | 
| -    if (mandatory_constraints)
 | 
| +    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;
 | 
| +}
 | 
| +
 | 
| +// 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)) {
 | 
| @@ -128,4 +151,63 @@ bool FindConstraint(const MediaConstraintsInterface* constraints,
 | 
|    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>();
 | 
| +}
 | 
| +
 | 
| +void CopyConstraintsIntoRtcConfiguration(
 | 
| +    const MediaConstraintsInterface* constraints,
 | 
| +    PeerConnectionInterface::RTCConfiguration* configuration) {
 | 
| +  // Copy info from constraints into configuration, if present.
 | 
| +  if (!constraints) {
 | 
| +    return;
 | 
| +  }
 | 
| +
 | 
| +  bool value;
 | 
| +  if (FindConstraint(constraints, MediaConstraintsInterface::kEnableIPv6,
 | 
| +                     &value, nullptr)) {
 | 
| +    if (!value) {
 | 
| +      configuration->disable_ipv6 = true;
 | 
| +    }
 | 
| +  }
 | 
| +  configuration->enable_dscp = ConstraintToOptionalBool(
 | 
| +      constraints, MediaConstraintsInterface::kEnableDscp);
 | 
| +  configuration->cpu_overuse_detection = ConstraintToOptionalBool(
 | 
| +      constraints, MediaConstraintsInterface::kCpuOveruseDetection);
 | 
| +  if (FindConstraint(constraints,
 | 
| +                     MediaConstraintsInterface::kEnableRtpDataChannels, &value,
 | 
| +                     NULL) &&
 | 
| +      value) {
 | 
| +    configuration->enable_rtp_data_channel = true;
 | 
| +  }
 | 
| +  // Find Suspend Below Min Bitrate constraint.
 | 
| +  configuration->suspend_below_min_bitrate = ConstraintToOptionalBool(
 | 
| +      constraints,
 | 
| +      MediaConstraintsInterface::kEnableVideoSuspendBelowMinBitrate);
 | 
| +  configuration->screencast_min_bitrate = ConstraintToOptionalInt(
 | 
| +      constraints, MediaConstraintsInterface::kScreencastMinBitrate);
 | 
| +  configuration->combined_audio_video_bwe = ConstraintToOptionalBool(
 | 
| +      constraints, MediaConstraintsInterface::kCombinedAudioVideoBwe);
 | 
| +  configuration->enable_dtls_srtp = ConstraintToOptionalBool(
 | 
| +      constraints, MediaConstraintsInterface::kEnableDtlsSrtp);
 | 
| +}
 | 
| +
 | 
|  }  // namespace webrtc
 | 
| 
 |