Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: talk/app/webrtc/localaudiosource.cc

Issue 1151573021: Re-land r9378 "Rename APM Config DelayCorrection to ExtendedFilter" (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: New line Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | talk/app/webrtc/localaudiosource_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 25 matching lines...) Expand all
36 using webrtc::MediaSourceInterface; 36 using webrtc::MediaSourceInterface;
37 37
38 namespace webrtc { 38 namespace webrtc {
39 39
40 namespace { 40 namespace {
41 41
42 // Convert constraints to audio options. Return false if constraints are 42 // Convert constraints to audio options. Return false if constraints are
43 // invalid. 43 // invalid.
44 void FromConstraints(const MediaConstraintsInterface::Constraints& constraints, 44 void FromConstraints(const MediaConstraintsInterface::Constraints& constraints,
45 cricket::AudioOptions* options) { 45 cricket::AudioOptions* options) {
46 MediaConstraintsInterface::Constraints::const_iterator iter;
47
48 // This design relies on the fact that all the audio constraints are actually 46 // This design relies on the fact that all the audio constraints are actually
49 // "options", i.e. boolean-valued and always satisfiable. If the constraints 47 // "options", i.e. boolean-valued and always satisfiable. If the constraints
50 // are extended to include non-boolean values or actual format constraints, 48 // are extended to include non-boolean values or actual format constraints,
51 // a different algorithm will be required. 49 // a different algorithm will be required.
52 for (iter = constraints.begin(); iter != constraints.end(); ++iter) { 50 struct {
51 const char* name;
52 cricket::Settable<bool>& value;
53 } key_to_value[] = {
54 {MediaConstraintsInterface::kEchoCancellation,
55 options->echo_cancellation},
56 // Both kExperimentalEchoCancellation (old) and
57 // kExtendedFilterEchoCancellation (new) translate to
58 // extended_filter_aec
59 // option being set. This is to manage the transition from the old to
60 // the
61 // new without breaking dependent code.
62 {MediaConstraintsInterface::kExperimentalEchoCancellation,
63 options->extended_filter_aec},
64 {MediaConstraintsInterface::kExtendedFilterEchoCancellation,
65 options->extended_filter_aec},
66 {MediaConstraintsInterface::kDAEchoCancellation,
67 options->delay_agnostic_aec},
68 {MediaConstraintsInterface::kAutoGainControl, options->auto_gain_control},
69 {MediaConstraintsInterface::kExperimentalAutoGainControl,
70 options->experimental_agc},
71 {MediaConstraintsInterface::kNoiseSuppression,
72 options->noise_suppression},
73 {MediaConstraintsInterface::kExperimentalNoiseSuppression,
74 options->experimental_ns},
75 {MediaConstraintsInterface::kHighpassFilter, options->highpass_filter},
76 {MediaConstraintsInterface::kTypingNoiseDetection,
77 options->typing_detection},
78 {MediaConstraintsInterface::kAudioMirroring, options->stereo_swapping},
79 {MediaConstraintsInterface::kAecDump, options->aec_dump}
80 };
81
82 for (const auto& constraint : constraints) {
53 bool value = false; 83 bool value = false;
54 84 if (!rtc::FromString(constraint.value, &value))
55 if (!rtc::FromString(iter->value, &value))
56 continue; 85 continue;
57 86
58 if (iter->key == MediaConstraintsInterface::kEchoCancellation) 87 for (auto& entry : key_to_value) {
59 options->echo_cancellation.Set(value); 88 if (constraint.key.compare(entry.name) == 0)
60 else if (iter->key == 89 entry.value.Set(value);
61 MediaConstraintsInterface::kExperimentalEchoCancellation) 90 }
62 options->experimental_aec.Set(value);
63 else if (iter->key == MediaConstraintsInterface::kDAEchoCancellation)
64 options->delay_agnostic_aec.Set(value);
65 else if (iter->key == MediaConstraintsInterface::kAutoGainControl)
66 options->auto_gain_control.Set(value);
67 else if (iter->key ==
68 MediaConstraintsInterface::kExperimentalAutoGainControl)
69 options->experimental_agc.Set(value);
70 else if (iter->key == MediaConstraintsInterface::kNoiseSuppression)
71 options->noise_suppression.Set(value);
72 else if (iter->key ==
73 MediaConstraintsInterface::kExperimentalNoiseSuppression)
74 options->experimental_ns.Set(value);
75 else if (iter->key == MediaConstraintsInterface::kHighpassFilter)
76 options->highpass_filter.Set(value);
77 else if (iter->key == MediaConstraintsInterface::kTypingNoiseDetection)
78 options->typing_detection.Set(value);
79 else if (iter->key == MediaConstraintsInterface::kAudioMirroring)
80 options->stereo_swapping.Set(value);
81 else if (iter->key == MediaConstraintsInterface::kAecDump)
82 options->aec_dump.Set(value);
83 } 91 }
84 } 92 }
85 93
86 } // namespace 94 } // namespace
87 95
88 rtc::scoped_refptr<LocalAudioSource> LocalAudioSource::Create( 96 rtc::scoped_refptr<LocalAudioSource> LocalAudioSource::Create(
89 const PeerConnectionFactoryInterface::Options& options, 97 const PeerConnectionFactoryInterface::Options& options,
90 const MediaConstraintsInterface* constraints) { 98 const MediaConstraintsInterface* constraints) {
91 rtc::scoped_refptr<LocalAudioSource> source( 99 rtc::scoped_refptr<LocalAudioSource> source(
92 new rtc::RefCountedObject<LocalAudioSource>()); 100 new rtc::RefCountedObject<LocalAudioSource>());
(...skipping 11 matching lines...) Expand all
104 // constraints. 112 // constraints.
105 FromConstraints(constraints->GetOptional(), &options_); 113 FromConstraints(constraints->GetOptional(), &options_);
106 114
107 cricket::AudioOptions mandatory_options; 115 cricket::AudioOptions mandatory_options;
108 FromConstraints(constraints->GetMandatory(), &mandatory_options); 116 FromConstraints(constraints->GetMandatory(), &mandatory_options);
109 options_.SetAll(mandatory_options); 117 options_.SetAll(mandatory_options);
110 source_state_ = kLive; 118 source_state_ = kLive;
111 } 119 }
112 120
113 } // namespace webrtc 121 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | talk/app/webrtc/localaudiosource_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698