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

Side by Side Diff: webrtc/modules/audio_processing/audio_processing_impl.cc

Issue 1348903004: Adding APM configuration in AEC dump. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: update Created 5 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 232
233 noise_suppression_ = new NoiseSuppressionImpl(this, crit_); 233 noise_suppression_ = new NoiseSuppressionImpl(this, crit_);
234 component_list_.push_back(noise_suppression_); 234 component_list_.push_back(noise_suppression_);
235 235
236 voice_detection_ = new VoiceDetectionImpl(this, crit_); 236 voice_detection_ = new VoiceDetectionImpl(this, crit_);
237 component_list_.push_back(voice_detection_); 237 component_list_.push_back(voice_detection_);
238 238
239 gain_control_for_new_agc_.reset(new GainControlForNewAgc(gain_control_)); 239 gain_control_for_new_agc_.reset(new GainControlForNewAgc(gain_control_));
240 240
241 SetExtraOptions(config); 241 SetExtraOptions(config);
242
243 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
244 config_ = GetCurrentConfig();
245 #endif
242 } 246 }
243 247
244 AudioProcessingImpl::~AudioProcessingImpl() { 248 AudioProcessingImpl::~AudioProcessingImpl() {
245 { 249 {
246 CriticalSectionScoped crit_scoped(crit_); 250 CriticalSectionScoped crit_scoped(crit_);
247 // Depends on gain_control_ and gain_control_for_new_agc_. 251 // Depends on gain_control_ and gain_control_for_new_agc_.
248 agc_manager_.reset(); 252 agc_manager_.reset();
249 // Depends on gain_control_. 253 // Depends on gain_control_.
250 gain_control_for_new_agc_.reset(); 254 gain_control_for_new_agc_.reset();
251 while (!component_list_.empty()) { 255 while (!component_list_.empty()) {
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 ProcessingConfig processing_config = api_format_; 549 ProcessingConfig processing_config = api_format_;
546 processing_config.input_stream() = input_config; 550 processing_config.input_stream() = input_config;
547 processing_config.output_stream() = output_config; 551 processing_config.output_stream() = output_config;
548 552
549 RETURN_ON_ERR(MaybeInitializeLocked(processing_config)); 553 RETURN_ON_ERR(MaybeInitializeLocked(processing_config));
550 assert(processing_config.input_stream().num_frames() == 554 assert(processing_config.input_stream().num_frames() ==
551 api_format_.input_stream().num_frames()); 555 api_format_.input_stream().num_frames());
552 556
553 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 557 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
554 if (debug_file_->Open()) { 558 if (debug_file_->Open()) {
559 ApmConfig current_config = GetCurrentConfig();
560 if (current_config != config_) {
minyue-webrtc 2015/09/24 17:26:23 I changed the way of detecting changes in the conf
561 config_ = current_config;
562 RETURN_ON_ERR(WriteConfigMessage());
563 }
564 }
565 #endif
566
567 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
568 if (debug_file_->Open()) {
555 event_msg_->set_type(audioproc::Event::STREAM); 569 event_msg_->set_type(audioproc::Event::STREAM);
556 audioproc::Stream* msg = event_msg_->mutable_stream(); 570 audioproc::Stream* msg = event_msg_->mutable_stream();
557 const size_t channel_size = 571 const size_t channel_size =
558 sizeof(float) * api_format_.input_stream().num_frames(); 572 sizeof(float) * api_format_.input_stream().num_frames();
559 for (int i = 0; i < api_format_.input_stream().num_channels(); ++i) 573 for (int i = 0; i < api_format_.input_stream().num_channels(); ++i)
560 msg->add_input_channel(src[i], channel_size); 574 msg->add_input_channel(src[i], channel_size);
561 } 575 }
562 #endif 576 #endif
563 577
564 capture_audio_->CopyFrom(src, api_format_.input_stream()); 578 capture_audio_->CopyFrom(src, api_format_.input_stream());
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 if (debug_file_->CloseFile() == -1) { 944 if (debug_file_->CloseFile() == -1) {
931 return kFileError; 945 return kFileError;
932 } 946 }
933 } 947 }
934 948
935 if (debug_file_->OpenFile(filename, false) == -1) { 949 if (debug_file_->OpenFile(filename, false) == -1) {
936 debug_file_->CloseFile(); 950 debug_file_->CloseFile();
937 return kFileError; 951 return kFileError;
938 } 952 }
939 953
940 int err = WriteInitMessage(); 954 int err = WriteConfigMessage();
941 if (err != kNoError) { 955 if (err != kNoError) {
942 return err; 956 return err;
943 } 957 }
958
959 err = WriteInitMessage();
960 if (err != kNoError) {
961 return err;
962 }
944 return kNoError; 963 return kNoError;
945 #else 964 #else
946 return kUnsupportedFunctionError; 965 return kUnsupportedFunctionError;
947 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 966 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
948 } 967 }
949 968
950 int AudioProcessingImpl::StartDebugRecording(FILE* handle) { 969 int AudioProcessingImpl::StartDebugRecording(FILE* handle) {
951 CriticalSectionScoped crit_scoped(crit_); 970 CriticalSectionScoped crit_scoped(crit_);
952 971
953 if (handle == NULL) { 972 if (handle == NULL) {
954 return kNullPointerError; 973 return kNullPointerError;
955 } 974 }
956 975
957 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 976 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
958 // Stop any ongoing recording. 977 // Stop any ongoing recording.
959 if (debug_file_->Open()) { 978 if (debug_file_->Open()) {
960 if (debug_file_->CloseFile() == -1) { 979 if (debug_file_->CloseFile() == -1) {
961 return kFileError; 980 return kFileError;
962 } 981 }
963 } 982 }
964 983
965 if (debug_file_->OpenFromFileHandle(handle, true, false) == -1) { 984 if (debug_file_->OpenFromFileHandle(handle, true, false) == -1) {
966 return kFileError; 985 return kFileError;
967 } 986 }
968 987
969 int err = WriteInitMessage(); 988 int err = WriteConfigMessage();
970 if (err != kNoError) { 989 if (err != kNoError) {
971 return err; 990 return err;
972 } 991 }
992
993 err = WriteInitMessage();
994 if (err != kNoError) {
995 return err;
996 }
973 return kNoError; 997 return kNoError;
974 #else 998 #else
975 return kUnsupportedFunctionError; 999 return kUnsupportedFunctionError;
976 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1000 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
977 } 1001 }
978 1002
979 int AudioProcessingImpl::StartDebugRecordingForPlatformFile( 1003 int AudioProcessingImpl::StartDebugRecordingForPlatformFile(
980 rtc::PlatformFile handle) { 1004 rtc::PlatformFile handle) {
981 FILE* stream = rtc::FdopenPlatformFileForWriting(handle); 1005 FILE* stream = rtc::FdopenPlatformFileForWriting(handle);
982 return StartDebugRecording(stream); 1006 return StartDebugRecording(stream);
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 msg->set_output_sample_rate(api_format_.output_stream().sample_rate_hz()); 1263 msg->set_output_sample_rate(api_format_.output_stream().sample_rate_hz());
1240 // TODO(ekmeyerson): Add reverse output fields to event_msg_. 1264 // TODO(ekmeyerson): Add reverse output fields to event_msg_.
1241 1265
1242 int err = WriteMessageToDebugFile(); 1266 int err = WriteMessageToDebugFile();
1243 if (err != kNoError) { 1267 if (err != kNoError) {
1244 return err; 1268 return err;
1245 } 1269 }
1246 1270
1247 return kNoError; 1271 return kNoError;
1248 } 1272 }
1273
1274 AudioProcessingImpl::ApmConfig AudioProcessingImpl::GetCurrentConfig() const {
1275 ApmConfig config;
1276 // Acoustic echo canceler
1277 config.aec_enabled = echo_cancellation_->is_enabled();
1278 config.aec_delay_agnostic = echo_cancellation_->is_delay_agnostic_enabled();
1279 config.aec_drift_compensation =
1280 echo_cancellation_->is_drift_compensation_enabled();
1281 config.aec_extended_filter =
1282 echo_cancellation_->is_extended_filter_enabled();
1283 config.aec_suppression_level = echo_cancellation_->suppression_level();
1284
1285 // Mobile AEC
1286 config.aecm_enabled = echo_control_mobile_->is_enabled();
1287 config.aecm_comfort_noise =
1288 echo_control_mobile_->is_comfort_noise_enabled();
1289 config.aecm_routing_mode = echo_control_mobile_->routing_mode();
1290
1291 // Automatic gain controller
1292 config.agc_enabled = gain_control_->is_enabled();
1293 config.agc_experiment = use_new_agc_;
1294 config.agc_mode = gain_control_->mode();
1295 config.agc_limiter = gain_control_->is_limiter_enabled();
1296
1297 // High pass filter
1298 config.hpf_enabled = high_pass_filter_->is_enabled();
1299
1300 // Noise suppression
1301 config.ns_enabled = noise_suppression_->is_enabled();
1302 config.ns_experiment = transient_suppressor_enabled_;
1303 config.ns_level = noise_suppression_->level();
1304
1305 return config;
1306 }
1307
1308 int AudioProcessingImpl::WriteConfigMessage() {
1309 event_msg_->set_type(audioproc::Event::CONFIG);
1310 audioproc::Config* msg = event_msg_->mutable_config();
1311
1312 // Acoustic echo canceler
1313 msg->set_aec_enabled(config_.aec_enabled);
1314 msg->set_aec_delay_agnostic(config_.aec_delay_agnostic);
1315
1316 msg->set_aec_drift_compensation(config_.aec_drift_compensation);
1317 msg->set_aec_extended_filter(config_.aec_extended_filter);
1318 msg->set_aec_suppression_level(config_.aec_suppression_level);
1319
1320 // Mobile AEC
1321 msg->set_aecm_enabled(config_.aecm_enabled);
1322 msg->set_aecm_comfort_noise(config_.aecm_comfort_noise);
1323 msg->set_aecm_routing_mode(config_.aecm_routing_mode);
1324
1325 // Automatic gain controller
1326 msg->set_agc_enabled(config_.agc_enabled);
1327 msg->set_agc_experiment(config_.agc_experiment);
1328 msg->set_agc_mode(config_.agc_mode);
1329 msg->set_agc_limiter(config_.agc_limiter);
1330
1331 // High pass filter
1332 msg->set_hpf_enabled(config_.hpf_enabled);
1333
1334 // Noise suppression
1335 msg->set_ns_enabled(config_.ns_enabled);
1336 msg->set_ns_experiment(config_.ns_experiment);
1337 msg->set_ns_level(config_.ns_level);
1338
1339 int err = WriteMessageToDebugFile();
1340 if (err != kNoError) {
1341 return err;
1342 }
1343
1344 return kNoError;
1345 }
1249 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1346 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1250 1347
1251 } // namespace webrtc 1348 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698