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

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

Issue 1384653002: Compare serialized Configs. Base URL: https://chromium.googlesource.com/external/webrtc.git@apmconfig
Patch Set: 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
« no previous file with comments | « webrtc/modules/audio_processing/audio_processing_impl.h ('k') | no next file » | 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 * 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 235
236 noise_suppression_ = new NoiseSuppressionImpl(this, crit_); 236 noise_suppression_ = new NoiseSuppressionImpl(this, crit_);
237 component_list_.push_back(noise_suppression_); 237 component_list_.push_back(noise_suppression_);
238 238
239 voice_detection_ = new VoiceDetectionImpl(this, crit_); 239 voice_detection_ = new VoiceDetectionImpl(this, crit_);
240 component_list_.push_back(voice_detection_); 240 component_list_.push_back(voice_detection_);
241 241
242 gain_control_for_new_agc_.reset(new GainControlForNewAgc(gain_control_)); 242 gain_control_for_new_agc_.reset(new GainControlForNewAgc(gain_control_));
243 243
244 SetExtraOptions(config); 244 SetExtraOptions(config);
245
246 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
247 UpdateCurrentConfig();
248 #endif
249 } 245 }
250 246
251 AudioProcessingImpl::~AudioProcessingImpl() { 247 AudioProcessingImpl::~AudioProcessingImpl() {
252 { 248 {
253 CriticalSectionScoped crit_scoped(crit_); 249 CriticalSectionScoped crit_scoped(crit_);
254 // Depends on gain_control_ and gain_control_for_new_agc_. 250 // Depends on gain_control_ and gain_control_for_new_agc_.
255 agc_manager_.reset(); 251 agc_manager_.reset();
256 // Depends on gain_control_. 252 // Depends on gain_control_.
257 gain_control_for_new_agc_.reset(); 253 gain_control_for_new_agc_.reset();
258 while (!component_list_.empty()) { 254 while (!component_list_.empty()) {
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 545
550 ProcessingConfig processing_config = api_format_; 546 ProcessingConfig processing_config = api_format_;
551 processing_config.input_stream() = input_config; 547 processing_config.input_stream() = input_config;
552 processing_config.output_stream() = output_config; 548 processing_config.output_stream() = output_config;
553 549
554 RETURN_ON_ERR(MaybeInitializeLocked(processing_config)); 550 RETURN_ON_ERR(MaybeInitializeLocked(processing_config));
555 assert(processing_config.input_stream().num_frames() == 551 assert(processing_config.input_stream().num_frames() ==
556 api_format_.input_stream().num_frames()); 552 api_format_.input_stream().num_frames());
557 553
558 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 554 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
559 if (debug_file_->Open() && UpdateCurrentConfig()) { 555 if (debug_file_->Open()) {
560 RETURN_ON_ERR(WriteConfigMessage()); 556 RETURN_ON_ERR(WriteConfigMessageIfChanged());
561 }
562 557
563 if (debug_file_->Open()) {
564 event_msg_->set_type(audioproc::Event::STREAM); 558 event_msg_->set_type(audioproc::Event::STREAM);
565 audioproc::Stream* msg = event_msg_->mutable_stream(); 559 audioproc::Stream* msg = event_msg_->mutable_stream();
566 const size_t channel_size = 560 const size_t channel_size =
567 sizeof(float) * api_format_.input_stream().num_frames(); 561 sizeof(float) * api_format_.input_stream().num_frames();
568 for (int i = 0; i < api_format_.input_stream().num_channels(); ++i) 562 for (int i = 0; i < api_format_.input_stream().num_channels(); ++i)
569 msg->add_input_channel(src[i], channel_size); 563 msg->add_input_channel(src[i], channel_size);
570 } 564 }
571 #endif 565 #endif
572 566
573 capture_audio_->CopyFrom(src, api_format_.input_stream()); 567 capture_audio_->CopyFrom(src, api_format_.input_stream());
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 if (debug_file_->CloseFile() == -1) { 933 if (debug_file_->CloseFile() == -1) {
940 return kFileError; 934 return kFileError;
941 } 935 }
942 } 936 }
943 937
944 if (debug_file_->OpenFile(filename, false) == -1) { 938 if (debug_file_->OpenFile(filename, false) == -1) {
945 debug_file_->CloseFile(); 939 debug_file_->CloseFile();
946 return kFileError; 940 return kFileError;
947 } 941 }
948 942
949 UpdateCurrentConfig(); 943 RETURN_ON_ERR(WriteConfigMessageIfChanged());
950 int err = WriteConfigMessage(); 944 RETURN_ON_ERR(WriteInitMessage());
951 if (err != kNoError) {
952 return err;
953 }
954
955 err = WriteInitMessage();
956 if (err != kNoError) {
957 return err;
958 }
959 return kNoError; 945 return kNoError;
960 #else 946 #else
961 return kUnsupportedFunctionError; 947 return kUnsupportedFunctionError;
962 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 948 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
963 } 949 }
964 950
965 int AudioProcessingImpl::StartDebugRecording(FILE* handle) { 951 int AudioProcessingImpl::StartDebugRecording(FILE* handle) {
966 CriticalSectionScoped crit_scoped(crit_); 952 CriticalSectionScoped crit_scoped(crit_);
967 953
968 if (handle == NULL) { 954 if (handle == NULL) {
969 return kNullPointerError; 955 return kNullPointerError;
970 } 956 }
971 957
972 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 958 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
973 // Stop any ongoing recording. 959 // Stop any ongoing recording.
974 if (debug_file_->Open()) { 960 if (debug_file_->Open()) {
975 if (debug_file_->CloseFile() == -1) { 961 if (debug_file_->CloseFile() == -1) {
976 return kFileError; 962 return kFileError;
977 } 963 }
978 } 964 }
979 965
980 if (debug_file_->OpenFromFileHandle(handle, true, false) == -1) { 966 if (debug_file_->OpenFromFileHandle(handle, true, false) == -1) {
981 return kFileError; 967 return kFileError;
982 } 968 }
983 969
984 UpdateCurrentConfig(); 970 RETURN_ON_ERR(WriteConfigMessageIfChanged());
985 int err = WriteConfigMessage(); 971 RETURN_ON_ERR(WriteInitMessage());
986 if (err != kNoError) {
987 return err;
988 }
989
990 err = WriteInitMessage();
991 if (err != kNoError) {
992 return err;
993 }
994 return kNoError; 972 return kNoError;
995 #else 973 #else
996 return kUnsupportedFunctionError; 974 return kUnsupportedFunctionError;
997 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 975 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
998 } 976 }
999 977
1000 int AudioProcessingImpl::StartDebugRecordingForPlatformFile( 978 int AudioProcessingImpl::StartDebugRecordingForPlatformFile(
1001 rtc::PlatformFile handle) { 979 rtc::PlatformFile handle) {
1002 FILE* stream = rtc::FdopenPlatformFileForWriting(handle); 980 FILE* stream = rtc::FdopenPlatformFileForWriting(handle);
1003 return StartDebugRecording(stream); 981 return StartDebugRecording(stream);
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 // TODO(ekmeyerson): Add reverse output fields to event_msg_. 1239 // TODO(ekmeyerson): Add reverse output fields to event_msg_.
1262 1240
1263 int err = WriteMessageToDebugFile(); 1241 int err = WriteMessageToDebugFile();
1264 if (err != kNoError) { 1242 if (err != kNoError) {
1265 return err; 1243 return err;
1266 } 1244 }
1267 1245
1268 return kNoError; 1246 return kNoError;
1269 } 1247 }
1270 1248
1271 bool AudioProcessingImpl::UpdateCurrentConfig() { 1249 int AudioProcessingImpl::WriteConfigMessageIfChanged() {
1272 bool changed = false; 1250 audioproc::Config config;
1251 config.set_aec_enabled(echo_cancellation_->is_enabled());
1252 config.set_aec_delay_agnostic(
1253 echo_cancellation_->is_delay_agnostic_enabled());
1254 config.set_agc_enabled(gain_control_->is_enabled());
1255 // More fields...
1273 1256
1274 // Acoustic echo canceler. 1257 std::string serialized_config = config.SerializeAsString();
1275 { 1258 if (serialized_config != last_serialized_config_) {
1276 const bool value = echo_cancellation_->is_enabled(); 1259 last_serialized_config_ = serialized_config;
1277 if (!config_->has_aec_enabled() || value != config_->aec_enabled()) {
1278 config_->set_aec_enabled(value);
1279 changed = true;
1280 }
1281 }
1282 {
1283 const bool value = echo_cancellation_->is_delay_agnostic_enabled();
1284 if (!config_->has_aec_delay_agnostic() ||
1285 value != config_->aec_delay_agnostic()) {
1286 config_->set_aec_delay_agnostic(value);
1287 changed = true;
1288 }
1289 }
1290 {
1291 const bool value = echo_cancellation_->is_drift_compensation_enabled();
1292 if (!config_->has_aec_drift_compensation() ||
1293 value != config_->aec_drift_compensation()) {
1294 config_->set_aec_drift_compensation(value);
1295 changed = true;
1296 }
1297 }
1298 {
1299 const bool value = echo_cancellation_->is_extended_filter_enabled();
1300 if (!config_->has_aec_extended_filter() ||
1301 value != config_->aec_extended_filter()) {
1302 config_->set_aec_extended_filter(value);
1303 changed = true;
1304 }
1305 }
1306 {
1307 const int value = static_cast<int>(echo_cancellation_->suppression_level());
1308 if (!config_->has_aec_suppression_level() ||
1309 value != config_->aec_suppression_level()) {
1310 config_->set_aec_suppression_level(value);
1311 changed = true;
1312 }
1313 }
1314 1260
1315 // Mobile AEC. 1261 event_msg_->set_type(audioproc::Event::CONFIG);
1316 { 1262 event_msg_->mutable_config()->CopyFrom(config);
1317 const bool value = echo_control_mobile_->is_enabled();
1318 if (!config_->has_aecm_enabled() || value != config_->aecm_enabled()) {
1319 config_->set_aecm_enabled(value);
1320 changed = true;
1321 }
1322 }
1323 {
1324 const bool value = echo_control_mobile_->is_comfort_noise_enabled();
1325 if (!config_->has_aecm_comfort_noise() ||
1326 value != config_->aecm_comfort_noise()) {
1327 config_->set_aecm_comfort_noise(value);
1328 changed = true;
1329 }
1330 }
1331 {
1332 const int value = static_cast<int>(echo_control_mobile_->routing_mode());
1333 if (!config_->has_aecm_routing_mode() ||
1334 value != config_->aecm_routing_mode()) {
1335 config_->set_aecm_routing_mode(value);
1336 changed = true;
1337 }
1338 }
1339 1263
1340 // Automatic gain controller. 1264 RETURN_ON_ERR(WriteMessageToDebugFile());
1341 {
1342 const bool value = gain_control_->is_enabled();
1343 if (!config_->has_agc_enabled() || value != config_->agc_enabled()) {
1344 config_->set_agc_enabled(value);
1345 changed = true;
1346 }
1347 }
1348 {
1349 const bool value = use_new_agc_;
1350 if (!config_->has_agc_experiment() || value != config_->agc_experiment()) {
1351 config_->set_agc_experiment(value);
1352 changed = true;
1353 }
1354 }
1355 {
1356 const int value = static_cast<int>(gain_control_->mode());
1357 if (!config_->has_agc_mode() || value != config_->agc_mode()) {
1358 config_->set_agc_mode(value);
1359 changed = true;
1360 }
1361 }
1362 {
1363 const bool value = gain_control_->is_limiter_enabled();
1364 if (!config_->has_agc_limiter() || value != config_->agc_limiter()) {
1365 config_->set_agc_limiter(value);
1366 changed = true;
1367 }
1368 }
1369
1370 // High pass filter.
1371 {
1372 const bool value = high_pass_filter_->is_enabled();
1373 if (!config_->has_hpf_enabled() || value != config_->hpf_enabled()) {
1374 config_->set_hpf_enabled(value);
1375 changed = true;
1376 }
1377 }
1378
1379 // Noise suppression.
1380 {
1381 const bool value = noise_suppression_->is_enabled();
1382 if (!config_->has_ns_enabled() || value != config_->ns_enabled()) {
1383 config_->set_ns_enabled(value);
1384 changed = true;
1385 }
1386 }
1387 {
1388 const bool value = transient_suppressor_enabled_;
1389 if (!config_->has_ns_experiment() || value != config_->ns_experiment()) {
1390 config_->set_ns_experiment(value);
1391 changed = true;
1392 }
1393 }
1394 {
1395 const int value = static_cast<int>(noise_suppression_->level());
1396 if (!config_->has_ns_level() || value != config_->ns_level()) {
1397 config_->set_ns_level(value);
1398 changed = true;
1399 }
1400 }
1401
1402 return changed;
1403 }
1404
1405 int AudioProcessingImpl::WriteConfigMessage() {
1406 event_msg_->set_type(audioproc::Event::CONFIG);
1407 event_msg_->mutable_config()->CopyFrom(*config_);
1408
1409 int err = WriteMessageToDebugFile();
1410 if (err != kNoError) {
1411 return err;
1412 } 1265 }
1413 1266
1414 return kNoError; 1267 return kNoError;
1415 } 1268 }
1416 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1269 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1417 1270
1418 } // namespace webrtc 1271 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/audio_processing_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698