Chromium Code Reviews| Index: talk/app/webrtc/localaudiosource.cc |
| diff --git a/talk/app/webrtc/localaudiosource.cc b/talk/app/webrtc/localaudiosource.cc |
| index b37d1e3e41f8a704309465f25577adcc225ca578..2c9cbc70187cb059cfe2f5763e6180bad597e243 100644 |
| --- a/talk/app/webrtc/localaudiosource.cc |
| +++ b/talk/app/webrtc/localaudiosource.cc |
| @@ -43,43 +43,52 @@ namespace { |
| // invalid. |
| void FromConstraints(const MediaConstraintsInterface::Constraints& constraints, |
| cricket::AudioOptions* options) { |
| - MediaConstraintsInterface::Constraints::const_iterator iter; |
| - |
| // This design relies on the fact that all the audio constraints are actually |
| // "options", i.e. boolean-valued and always satisfiable. If the constraints |
| // are extended to include non-boolean values or actual format constraints, |
| // a different algorithm will be required. |
| - for (iter = constraints.begin(); iter != constraints.end(); ++iter) { |
| + for (const auto& constraint : constraints) { |
| bool value = false; |
| - if (!rtc::FromString(iter->value, &value)) |
| + if (!rtc::FromString(constraint.value, &value)) |
| continue; |
| - if (iter->key == MediaConstraintsInterface::kEchoCancellation) |
| - options->echo_cancellation.Set(value); |
| - else if (iter->key == |
| - MediaConstraintsInterface::kExperimentalEchoCancellation) |
| - options->experimental_aec.Set(value); |
| - else if (iter->key == MediaConstraintsInterface::kDAEchoCancellation) |
| - options->delay_agnostic_aec.Set(value); |
| - else if (iter->key == MediaConstraintsInterface::kAutoGainControl) |
| - options->auto_gain_control.Set(value); |
| - else if (iter->key == |
| - MediaConstraintsInterface::kExperimentalAutoGainControl) |
| - options->experimental_agc.Set(value); |
| - else if (iter->key == MediaConstraintsInterface::kNoiseSuppression) |
| - options->noise_suppression.Set(value); |
| - else if (iter->key == |
| - MediaConstraintsInterface::kExperimentalNoiseSuppression) |
| - options->experimental_ns.Set(value); |
| - else if (iter->key == MediaConstraintsInterface::kHighpassFilter) |
| - options->highpass_filter.Set(value); |
| - else if (iter->key == MediaConstraintsInterface::kTypingNoiseDetection) |
| - options->typing_detection.Set(value); |
| - else if (iter->key == MediaConstraintsInterface::kAudioMirroring) |
| - options->stereo_swapping.Set(value); |
| - else if (iter->key == MediaConstraintsInterface::kAecDump) |
| - options->aec_dump.Set(value); |
| + struct { |
| + const char* name; |
| + cricket::Settable<bool>& value; |
| + } key_to_value[] = { |
|
tommi
2015/06/09 08:50:11
You could move this outside the loop (e.g. top of
hlundin-webrtc
2015/06/09 09:02:09
Done.
|
| + {MediaConstraintsInterface::kEchoCancellation, |
| + options->echo_cancellation}, |
| + // Both kExperimentalEchoCancellation (old) and |
| + // kExtendedFilterEchoCancellation (new) translate to |
| + // extended_filter_aec |
| + // option being set. This is to manage the transition from the old to |
| + // the |
| + // new without breaking dependent code. |
| + {MediaConstraintsInterface::kExperimentalEchoCancellation, |
| + options->extended_filter_aec}, |
| + {MediaConstraintsInterface::kExtendedFilterEchoCancellation, |
| + options->extended_filter_aec}, |
| + {MediaConstraintsInterface::kDAEchoCancellation, |
| + options->delay_agnostic_aec}, |
| + {MediaConstraintsInterface::kAutoGainControl, |
| + options->auto_gain_control}, |
| + {MediaConstraintsInterface::kExperimentalAutoGainControl, |
| + options->experimental_agc}, |
| + {MediaConstraintsInterface::kNoiseSuppression, |
| + options->noise_suppression}, |
| + {MediaConstraintsInterface::kExperimentalNoiseSuppression, |
| + options->experimental_ns}, |
| + {MediaConstraintsInterface::kHighpassFilter, options->highpass_filter}, |
| + {MediaConstraintsInterface::kTypingNoiseDetection, |
| + options->typing_detection}, |
| + {MediaConstraintsInterface::kAudioMirroring, options->stereo_swapping}, |
| + {MediaConstraintsInterface::kAecDump, options->aec_dump}}; |
|
tommi
2015/06/09 08:50:11
nit: Move }; to the next line
hlundin-webrtc
2015/06/09 09:02:09
Nope. This is clang format. I'm not fighting that
hlundin-webrtc
2015/06/09 14:00:18
Ok, ok. I picked a fight with the windmill anyway.
kwiberg-webrtc
2015/06/09 14:16:37
Don't worry---I'm sure it'll be a breeze!
|
| + |
| + for (auto& entry : key_to_value) { |
| + if (constraint.key.compare(entry.name) == 0) |
| + entry.value.Set(value); |
| + } |
| } |
| } |