Index: webrtc/api/localaudiosource.cc |
diff --git a/webrtc/api/localaudiosource.cc b/webrtc/api/localaudiosource.cc |
index 53c426e01119900d5eeb5fd4a5524f2f619e954a..7f9667854682c46d8bb8afae983e4f09490ba272 100644 |
--- a/webrtc/api/localaudiosource.cc |
+++ b/webrtc/api/localaudiosource.cc |
@@ -26,14 +26,11 @@ namespace { |
// invalid. |
void FromConstraints(const MediaConstraintsInterface::Constraints& constraints, |
cricket::AudioOptions* options) { |
- // 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. |
+ // Set boolean constarints first. |
tommi
2016/10/19 11:25:50
Fix typo
aleloi
2016/10/19 13:59:21
Done.
|
struct { |
const char* name; |
rtc::Optional<bool>& value; |
- } key_to_value[] = { |
+ } boolean_constraint_key_to_value[] = { |
tommi
2016/10/19 11:25:50
Are these changes relevant to the cl?
Maybe it's j
aleloi
2016/10/19 13:59:21
I agree, lets leave it as is.
|
{MediaConstraintsInterface::kGoogEchoCancellation, |
options->echo_cancellation}, |
{MediaConstraintsInterface::kExtendedFilterEchoCancellation, |
@@ -53,19 +50,30 @@ void FromConstraints(const MediaConstraintsInterface::Constraints& constraints, |
{MediaConstraintsInterface::kHighpassFilter, options->highpass_filter}, |
{MediaConstraintsInterface::kTypingNoiseDetection, |
options->typing_detection}, |
- {MediaConstraintsInterface::kAudioMirroring, options->stereo_swapping} |
- }; |
+ {MediaConstraintsInterface::kAudioMirroring, options->stereo_swapping}}; |
for (const auto& constraint : constraints) { |
bool value = false; |
if (!rtc::FromString(constraint.value, &value)) |
continue; |
- for (auto& entry : key_to_value) { |
+ for (auto& entry : boolean_constraint_key_to_value) { |
if (constraint.key.compare(entry.name) == 0) |
entry.value = rtc::Optional<bool>(value); |
} |
} |
+ |
+ // Set non-boolean constraints. |
+ std::string value; |
+ if (constraints.FindFirst( |
+ MediaConstraintsInterface::kLevelControlInitialPeakLevelDBFS, |
+ &value)) { |
+ float level_control_initial_peak_level_dbfs; |
+ if (rtc::FromString(value, &level_control_initial_peak_level_dbfs)) { |
+ options->level_control_initial_peak_level_dbfs = |
+ rtc::Optional<float>(level_control_initial_peak_level_dbfs); |
+ } |
+ } |
} |
} // namespace |