// Find the highest-priority instance of the T-valued constraint named by // `key` and return its value as `value`. `constraints` can be null. // If `mandatory_constraints` is non-null, it is incremented if the key appears // among the mandatory constraints. // Returns true if the key was found and has a valid value for type T. // If the key appears multiple times as an optional constraint, appearances // after the first are ignored. // Note: Because this uses FindFirst, repeated optional constraints whose // first instance has an unrecognized value are not handled precisely in // accordance with the specification. template <typename T> bool FindConstraint(const MediaConstraints* constraints, const std::string& key,
T* value,
size_t* mandatory_constraints) {
std::string string_value;
if (!FindConstraint(constraints, key, &string_value, mandatory_constraints)) { return false;
} return FromString(string_value, value);
}
// Specialization for std::string, since a string doesn't need conversion. template <> bool FindConstraint(const MediaConstraints* constraints, const std::string& key,
std::string* value,
size_t* mandatory_constraints) {
if (!constraints) { return false;
}
if (constraints->GetMandatory().FindFirst(key, value)) {
if (mandatory_constraints) {
++*mandatory_constraints;
} returntrue;
}
if (constraints->GetOptional().FindFirst(key, value)) { returntrue;
} return false;
}
// Set `value` to the value associated with the first appearance of `key`, or // return false if `key` is not found. bool MediaConstraints::Constraints::FindFirst(const std::string& key,
std::string* value) const {
for (Constraints::const_iterator iter = begin(); iter != end(); ++iter) {
if (iter->key == key) {
*value = iter->value; returntrue;
}
} return false;
}
void CopyConstraintsIntoRtcConfiguration( const MediaConstraints* constraints,
PeerConnectionInterface::RTCConfiguration* configuration) { // Copy info from constraints into configuration, if present.
if (!constraints) { return;
}
ConstraintToOptional<bool>(constraints,
MediaConstraints::kGoogEchoCancellation,
&options->echo_cancellation);
ConstraintToOptional<bool>(constraints, MediaConstraints::kAutoGainControl,
&options->auto_gain_control);
ConstraintToOptional<bool>(constraints, MediaConstraints::kNoiseSuppression,
&options->noise_suppression);
ConstraintToOptional<bool>(constraints, MediaConstraints::kHighpassFilter,
&options->highpass_filter);
ConstraintToOptional<bool>(constraints, MediaConstraints::kAudioMirroring,
&options->stereo_swapping);
ConstraintToOptional<std::string>(
constraints, MediaConstraints::kAudioNetworkAdaptorConfig,
&options->audio_network_adaptor_config); // When `kAudioNetworkAdaptorConfig` is defined, it both means that audio // network adaptor is desired, and provides the config string.
if (options->audio_network_adaptor_config) {
options->audio_network_adaptor = true;
}
ConstraintToOptional<bool>(constraints,
MediaConstraints::kInitAudioRecordingOnSend,
&options->init_recording_on_send);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.