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

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

Issue 2778783002: AecDump interface (Closed)
Patch Set: Next version; large changes to interface. Created 3 years, 8 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 298
299 return apm; 299 return apm;
300 } 300 }
301 301
302 AudioProcessingImpl::AudioProcessingImpl(const webrtc::Config& config) 302 AudioProcessingImpl::AudioProcessingImpl(const webrtc::Config& config)
303 : AudioProcessingImpl(config, nullptr) {} 303 : AudioProcessingImpl(config, nullptr) {}
304 304
305 AudioProcessingImpl::AudioProcessingImpl(const webrtc::Config& config, 305 AudioProcessingImpl::AudioProcessingImpl(const webrtc::Config& config,
306 NonlinearBeamformer* beamformer) 306 NonlinearBeamformer* beamformer)
307 : high_pass_filter_impl_(new HighPassFilterImpl(this)), 307 : high_pass_filter_impl_(new HighPassFilterImpl(this)),
308 aec_dump_(AecDump::CreateNullDump()),
308 public_submodules_(new ApmPublicSubmodules()), 309 public_submodules_(new ApmPublicSubmodules()),
309 private_submodules_(new ApmPrivateSubmodules(beamformer)), 310 private_submodules_(new ApmPrivateSubmodules(beamformer)),
310 constants_(config.Get<ExperimentalAgc>().startup_min_volume, 311 constants_(config.Get<ExperimentalAgc>().startup_min_volume,
311 config.Get<ExperimentalAgc>().clipped_level_min, 312 config.Get<ExperimentalAgc>().clipped_level_min,
312 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) 313 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
313 false), 314 false),
314 #else 315 #else
315 config.Get<ExperimentalAgc>().enabled), 316 config.Get<ExperimentalAgc>().enabled),
316 #endif 317 #endif
317 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) 318 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 InitializeEchoCanceller3(); 519 InitializeEchoCanceller3();
519 520
520 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 521 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
521 if (debug_dump_.debug_file->is_open()) { 522 if (debug_dump_.debug_file->is_open()) {
522 int err = WriteInitMessage(); 523 int err = WriteInitMessage();
523 if (err != kNoError) { 524 if (err != kNoError) {
524 return err; 525 return err;
525 } 526 }
526 } 527 }
527 #endif 528 #endif
528 529 aec_dump_->WriteInitMessage(formats_.api_format);
529 return kNoError; 530 return kNoError;
530 } 531 }
531 532
532 int AudioProcessingImpl::InitializeLocked(const ProcessingConfig& config) { 533 int AudioProcessingImpl::InitializeLocked(const ProcessingConfig& config) {
533 for (const auto& stream : config.streams) { 534 for (const auto& stream : config.streams) {
534 if (stream.num_channels() > 0 && stream.sample_rate_hz() <= 0) { 535 if (stream.num_channels() > 0 && stream.sample_rate_hz() <= 0) {
535 return kBadSampleRateError; 536 return kBadSampleRateError;
536 } 537 }
537 } 538 }
538 539
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 debug_dump_.capture.event_msg->set_type(audioproc::Event::STREAM); 810 debug_dump_.capture.event_msg->set_type(audioproc::Event::STREAM);
810 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream(); 811 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream();
811 const size_t channel_size = 812 const size_t channel_size =
812 sizeof(float) * formats_.api_format.input_stream().num_frames(); 813 sizeof(float) * formats_.api_format.input_stream().num_frames();
813 for (size_t i = 0; i < formats_.api_format.input_stream().num_channels(); 814 for (size_t i = 0; i < formats_.api_format.input_stream().num_channels();
814 ++i) 815 ++i)
815 msg->add_input_channel(src[i], channel_size); 816 msg->add_input_channel(src[i], channel_size);
816 } 817 }
817 #endif 818 #endif
818 819
820 std::unique_ptr<AecDump::CaptureStreamInfo> stream_info =
peah-webrtc 2017/04/07 12:57:15 I definitely like the aspect of the NullImplementa
aleloi 2017/04/12 11:05:29 I agree. Now everything is wrapped with if (aec_du
821 aec_dump_->GetCaptureStreamInfo();
822 const size_t channel_size =
823 sizeof(float) * formats_.api_format.input_stream().num_frames();
824
825 {
826 std::vector<rtc::ArrayView<const float>> src_view;
827 for (size_t i = 0; i < formats_.api_format.input_stream().num_channels();
828 ++i) {
829 src_view.emplace_back(src[i], channel_size);
830 }
831 stream_info->AddInput(src_view);
832 }
819 capture_.capture_audio->CopyFrom(src, formats_.api_format.input_stream()); 833 capture_.capture_audio->CopyFrom(src, formats_.api_format.input_stream());
834
835 RTC_DCHECK(!(public_submodules_->echo_cancellation->is_enabled() &&
836 public_submodules_->echo_control_mobile->is_enabled()));
837
838 stream_info->set_delay(capture_nonlocked_.stream_delay_ms);
839 stream_info->set_drift(
840 public_submodules_->echo_cancellation->stream_drift_samples());
841 stream_info->set_level(gain_control()->stream_analog_level());
842 stream_info->set_keypress(capture_.key_pressed);
843
820 RETURN_ON_ERR(ProcessCaptureStreamLocked()); 844 RETURN_ON_ERR(ProcessCaptureStreamLocked());
821 capture_.capture_audio->CopyTo(formats_.api_format.output_stream(), dest); 845 capture_.capture_audio->CopyTo(formats_.api_format.output_stream(), dest);
822 846
823 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 847 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
824 if (debug_dump_.debug_file->is_open()) { 848 if (debug_dump_.debug_file->is_open()) {
825 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream(); 849 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream();
826 const size_t channel_size = 850 const size_t channel_size =
827 sizeof(float) * formats_.api_format.output_stream().num_frames(); 851 sizeof(float) * formats_.api_format.output_stream().num_frames();
828 for (size_t i = 0; i < formats_.api_format.output_stream().num_channels(); 852 for (size_t i = 0; i < formats_.api_format.output_stream().num_channels();
829 ++i) 853 ++i)
830 msg->add_output_channel(dest[i], channel_size); 854 msg->add_output_channel(dest[i], channel_size);
831 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 855 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
832 &debug_dump_.num_bytes_left_for_log_, 856 &debug_dump_.num_bytes_left_for_log_,
833 &crit_debug_, &debug_dump_.capture)); 857 &crit_debug_, &debug_dump_.capture));
834 } 858 }
835 #endif 859 #endif
860 {
861 const size_t channel_size =
862 sizeof(float) * formats_.api_format.output_stream().num_frames();
863 std::vector<rtc::ArrayView<const float>> dest_view;
864 for (size_t i = 0; i < formats_.api_format.output_stream().num_channels();
865 ++i) {
866 dest_view.emplace_back(dest[i], channel_size);
867 }
868 stream_info->AddOutput(dest_view);
869 }
870 aec_dump_->WriteCaptureStreamMessage(std::move(stream_info));
836 871
837 return kNoError; 872 return kNoError;
838 } 873 }
839 874
840 void AudioProcessingImpl::QueueRenderAudio(AudioBuffer* audio) { 875 void AudioProcessingImpl::QueueRenderAudio(AudioBuffer* audio) {
841 EchoCancellationImpl::PackRenderAudioBuffer(audio, num_output_channels(), 876 EchoCancellationImpl::PackRenderAudioBuffer(audio, num_output_channels(),
842 num_reverse_channels(), 877 num_reverse_channels(),
843 &aec_render_queue_buffer_); 878 &aec_render_queue_buffer_);
844 879
845 RTC_DCHECK_GE(160, audio->num_frames_per_band()); 880 RTC_DCHECK_GE(160, audio->num_frames_per_band());
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 rtc::CritScope cs_render(&crit_render_); 1098 rtc::CritScope cs_render(&crit_render_);
1064 RETURN_ON_ERR( 1099 RETURN_ON_ERR(
1065 MaybeInitializeCapture(processing_config, reinitialization_required)); 1100 MaybeInitializeCapture(processing_config, reinitialization_required));
1066 } 1101 }
1067 rtc::CritScope cs_capture(&crit_capture_); 1102 rtc::CritScope cs_capture(&crit_capture_);
1068 if (frame->samples_per_channel_ != 1103 if (frame->samples_per_channel_ !=
1069 formats_.api_format.input_stream().num_frames()) { 1104 formats_.api_format.input_stream().num_frames()) {
1070 return kBadDataLengthError; 1105 return kBadDataLengthError;
1071 } 1106 }
1072 1107
1108 std::unique_ptr<AecDump::CaptureStreamInfo> stream_info =
1109 aec_dump_->GetCaptureStreamInfo();
peah-webrtc 2017/04/07 12:57:15 Same as above.
aleloi 2017/04/12 11:05:29 Acknowledged.
1110 stream_info->AddInput(*frame);
1073 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 1111 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1074 if (debug_dump_.debug_file->is_open()) { 1112 if (debug_dump_.debug_file->is_open()) {
1075 RETURN_ON_ERR(WriteConfigMessage(false)); 1113 RETURN_ON_ERR(WriteConfigMessage(false));
1076 1114
1077 debug_dump_.capture.event_msg->set_type(audioproc::Event::STREAM); 1115 debug_dump_.capture.event_msg->set_type(audioproc::Event::STREAM);
1078 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream(); 1116 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream();
1079 const size_t data_size = 1117 const size_t data_size =
1080 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_; 1118 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_;
1081 msg->set_input_data(frame->data_, data_size); 1119 msg->set_input_data(frame->data_, data_size);
1082 } 1120 }
1083 #endif 1121 #endif
1084 1122
1085 capture_.capture_audio->DeinterleaveFrom(frame); 1123 capture_.capture_audio->DeinterleaveFrom(frame);
1124
1125 RTC_DCHECK(!(public_submodules_->echo_cancellation->is_enabled() &&
1126 public_submodules_->echo_control_mobile->is_enabled()));
1127
1128 stream_info->set_delay(capture_nonlocked_.stream_delay_ms);
1129 stream_info->set_drift(
1130 public_submodules_->echo_cancellation->stream_drift_samples());
1131 stream_info->set_level(gain_control()->stream_analog_level());
1132 stream_info->set_keypress(capture_.key_pressed);
1133
1086 RETURN_ON_ERR(ProcessCaptureStreamLocked()); 1134 RETURN_ON_ERR(ProcessCaptureStreamLocked());
1087 capture_.capture_audio->InterleaveTo( 1135 capture_.capture_audio->InterleaveTo(
1088 frame, submodule_states_.CaptureMultiBandProcessingActive()); 1136 frame, submodule_states_.CaptureMultiBandProcessingActive());
1089 1137
1138 stream_info->AddOutput(*frame);
1139 aec_dump_->WriteCaptureStreamMessage(std::move(stream_info));
1090 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 1140 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1091 if (debug_dump_.debug_file->is_open()) { 1141 if (debug_dump_.debug_file->is_open()) {
1092 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream(); 1142 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream();
1093 const size_t data_size = 1143 const size_t data_size =
1094 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_; 1144 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_;
1095 msg->set_output_data(frame->data_, data_size); 1145 msg->set_output_data(frame->data_, data_size);
1096 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1146 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1097 &debug_dump_.num_bytes_left_for_log_, 1147 &debug_dump_.num_bytes_left_for_log_,
1098 &crit_debug_, &debug_dump_.capture)); 1148 &crit_debug_, &debug_dump_.capture));
1099 } 1149 }
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 const size_t channel_size = 1406 const size_t channel_size =
1357 sizeof(float) * formats_.api_format.reverse_input_stream().num_frames(); 1407 sizeof(float) * formats_.api_format.reverse_input_stream().num_frames();
1358 for (size_t i = 0; 1408 for (size_t i = 0;
1359 i < formats_.api_format.reverse_input_stream().num_channels(); ++i) 1409 i < formats_.api_format.reverse_input_stream().num_channels(); ++i)
1360 msg->add_channel(src[i], channel_size); 1410 msg->add_channel(src[i], channel_size);
1361 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1411 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1362 &debug_dump_.num_bytes_left_for_log_, 1412 &debug_dump_.num_bytes_left_for_log_,
1363 &crit_debug_, &debug_dump_.render)); 1413 &crit_debug_, &debug_dump_.render));
1364 } 1414 }
1365 #endif 1415 #endif
1416 std::vector<rtc::ArrayView<const float>> src_view;
1417 const size_t channel_size =
peah-webrtc 2017/04/07 12:57:15 Same as above.
aleloi 2017/04/12 11:05:29 Acknowledged.
1418 sizeof(float) * formats_.api_format.reverse_input_stream().num_frames();
1419
1420 for (size_t i = 0;
1421 i < formats_.api_format.reverse_input_stream().num_channels(); ++i) {
1422 src_view.emplace_back(src[i], channel_size);
1423 }
1424 aec_dump_->WriteRenderStreamMessage(src_view);
1366 1425
1367 render_.render_audio->CopyFrom(src, 1426 render_.render_audio->CopyFrom(src,
1368 formats_.api_format.reverse_input_stream()); 1427 formats_.api_format.reverse_input_stream());
1369 return ProcessRenderStreamLocked(); 1428 return ProcessRenderStreamLocked();
1370 } 1429 }
1371 1430
1372 int AudioProcessingImpl::ProcessReverseStream(AudioFrame* frame) { 1431 int AudioProcessingImpl::ProcessReverseStream(AudioFrame* frame) {
1373 TRACE_EVENT0("webrtc", "AudioProcessing::ProcessReverseStream_AudioFrame"); 1432 TRACE_EVENT0("webrtc", "AudioProcessing::ProcessReverseStream_AudioFrame");
1374 rtc::CritScope cs(&crit_render_); 1433 rtc::CritScope cs(&crit_render_);
1375 if (frame == nullptr) { 1434 if (frame == nullptr) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 audioproc::ReverseStream* msg = 1468 audioproc::ReverseStream* msg =
1410 debug_dump_.render.event_msg->mutable_reverse_stream(); 1469 debug_dump_.render.event_msg->mutable_reverse_stream();
1411 const size_t data_size = 1470 const size_t data_size =
1412 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_; 1471 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_;
1413 msg->set_data(frame->data_, data_size); 1472 msg->set_data(frame->data_, data_size);
1414 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1473 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1415 &debug_dump_.num_bytes_left_for_log_, 1474 &debug_dump_.num_bytes_left_for_log_,
1416 &crit_debug_, &debug_dump_.render)); 1475 &crit_debug_, &debug_dump_.render));
1417 } 1476 }
1418 #endif 1477 #endif
1478 aec_dump_->WriteRenderStreamMessage(*frame);
1479
1419 render_.render_audio->DeinterleaveFrom(frame); 1480 render_.render_audio->DeinterleaveFrom(frame);
1420 RETURN_ON_ERR(ProcessRenderStreamLocked()); 1481 RETURN_ON_ERR(ProcessRenderStreamLocked());
1421 render_.render_audio->InterleaveTo( 1482 render_.render_audio->InterleaveTo(
1422 frame, submodule_states_.RenderMultiBandProcessingActive()); 1483 frame, submodule_states_.RenderMultiBandProcessingActive());
1423 return kNoError; 1484 return kNoError;
1424 } 1485 }
1425 1486
1426 int AudioProcessingImpl::ProcessRenderStreamLocked() { 1487 int AudioProcessingImpl::ProcessRenderStreamLocked() {
1427 AudioBuffer* render_buffer = render_.render_audio.get(); // For brevity. 1488 AudioBuffer* render_buffer = render_.render_audio.get(); // For brevity.
1428 if (submodule_states_.RenderMultiBandSubModulesActive() && 1489 if (submodule_states_.RenderMultiBandSubModulesActive() &&
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 void AudioProcessingImpl::set_delay_offset_ms(int offset) { 1553 void AudioProcessingImpl::set_delay_offset_ms(int offset) {
1493 rtc::CritScope cs(&crit_capture_); 1554 rtc::CritScope cs(&crit_capture_);
1494 capture_.delay_offset_ms = offset; 1555 capture_.delay_offset_ms = offset;
1495 } 1556 }
1496 1557
1497 int AudioProcessingImpl::delay_offset_ms() const { 1558 int AudioProcessingImpl::delay_offset_ms() const {
1498 rtc::CritScope cs(&crit_capture_); 1559 rtc::CritScope cs(&crit_capture_);
1499 return capture_.delay_offset_ms; 1560 return capture_.delay_offset_ms;
1500 } 1561 }
1501 1562
1563 void AudioProcessingImpl::StartDebugRecording(
1564 std::unique_ptr<AecDump> aec_dump) {
1565 rtc::CritScope cs_render(&crit_render_);
1566 rtc::CritScope cs_capture(&crit_capture_);
1567 aec_dump_ = std::move(aec_dump);
1568
1569 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1570 const int error = WriteConfigMessage(true);
1571 RTC_DCHECK(error);
1572 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1573
1574 aec_dump_->WriteInitMessage(formats_.api_format);
1575 }
1576
1502 int AudioProcessingImpl::StartDebugRecording( 1577 int AudioProcessingImpl::StartDebugRecording(
1503 const char filename[AudioProcessing::kMaxFilenameSize], 1578 const char filename[AudioProcessing::kMaxFilenameSize],
1504 int64_t max_log_size_bytes) { 1579 int64_t max_log_size_bytes) {
1505 // Run in a single-threaded manner. 1580 // Run in a single-threaded manner.
1506 rtc::CritScope cs_render(&crit_render_); 1581 rtc::CritScope cs_render(&crit_render_);
1507 rtc::CritScope cs_capture(&crit_capture_); 1582 rtc::CritScope cs_capture(&crit_capture_);
1508 static_assert(kMaxFilenameSize == FileWrapper::kMaxFileNameSize, ""); 1583 static_assert(kMaxFilenameSize == FileWrapper::kMaxFileNameSize, "");
1509 1584
1510 if (filename == nullptr) { 1585 if (filename == nullptr) {
1511 return kNullPointerError; 1586 return kNullPointerError;
1512 } 1587 }
1513 1588
1589 aec_dump_->WriteInitMessage(formats_.api_format);
peah-webrtc 2017/04/07 12:57:15 Is this needed? Nothing is anyway written until th
aleloi 2017/04/12 11:05:29 Good point. Removed.
1514 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 1590 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1515 debug_dump_.num_bytes_left_for_log_ = max_log_size_bytes; 1591 debug_dump_.num_bytes_left_for_log_ = max_log_size_bytes;
1516 // Stop any ongoing recording. 1592 // Stop any ongoing recording.
1517 debug_dump_.debug_file->CloseFile(); 1593 debug_dump_.debug_file->CloseFile();
1518 1594
1519 if (!debug_dump_.debug_file->OpenFile(filename, false)) { 1595 if (!debug_dump_.debug_file->OpenFile(filename, false)) {
1520 return kFileError; 1596 return kFileError;
1521 } 1597 }
1522 1598
1523 RETURN_ON_ERR(WriteConfigMessage(true)); 1599 RETURN_ON_ERR(WriteConfigMessage(true));
1524 RETURN_ON_ERR(WriteInitMessage()); 1600 RETURN_ON_ERR(WriteInitMessage());
1525 return kNoError; 1601 return kNoError;
1526 #else 1602 #else
1527 return kUnsupportedFunctionError; 1603 return kUnsupportedFunctionError;
1528 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1604 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1529 } 1605 }
1530 1606
1531 int AudioProcessingImpl::StartDebugRecording(FILE* handle, 1607 int AudioProcessingImpl::StartDebugRecording(FILE* handle,
1532 int64_t max_log_size_bytes) { 1608 int64_t max_log_size_bytes) {
1533 // Run in a single-threaded manner. 1609 // Run in a single-threaded manner.
1534 rtc::CritScope cs_render(&crit_render_); 1610 rtc::CritScope cs_render(&crit_render_);
1535 rtc::CritScope cs_capture(&crit_capture_); 1611 rtc::CritScope cs_capture(&crit_capture_);
1536 1612
1537 if (handle == nullptr) { 1613 if (handle == nullptr) {
1538 return kNullPointerError; 1614 return kNullPointerError;
1539 } 1615 }
1540 1616
1617 aec_dump_->WriteInitMessage(formats_.api_format);
peah-webrtc 2017/04/07 12:57:15 Same as above.
aleloi 2017/04/12 11:05:29 Acknowledged.
1541 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 1618 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1542 debug_dump_.num_bytes_left_for_log_ = max_log_size_bytes; 1619 debug_dump_.num_bytes_left_for_log_ = max_log_size_bytes;
1543 1620
1544 // Stop any ongoing recording. 1621 // Stop any ongoing recording.
1545 debug_dump_.debug_file->CloseFile(); 1622 debug_dump_.debug_file->CloseFile();
1546 1623
1547 if (!debug_dump_.debug_file->OpenFromFileHandle(handle)) { 1624 if (!debug_dump_.debug_file->OpenFromFileHandle(handle)) {
1548 return kFileError; 1625 return kFileError;
1549 } 1626 }
1550 1627
(...skipping 15 matching lines...) Expand all
1566 rtc::CritScope cs_render(&crit_render_); 1643 rtc::CritScope cs_render(&crit_render_);
1567 rtc::CritScope cs_capture(&crit_capture_); 1644 rtc::CritScope cs_capture(&crit_capture_);
1568 FILE* stream = rtc::FdopenPlatformFileForWriting(handle); 1645 FILE* stream = rtc::FdopenPlatformFileForWriting(handle);
1569 return StartDebugRecording(stream, -1); 1646 return StartDebugRecording(stream, -1);
1570 } 1647 }
1571 1648
1572 int AudioProcessingImpl::StopDebugRecording() { 1649 int AudioProcessingImpl::StopDebugRecording() {
1573 // Run in a single-threaded manner. 1650 // Run in a single-threaded manner.
1574 rtc::CritScope cs_render(&crit_render_); 1651 rtc::CritScope cs_render(&crit_render_);
1575 rtc::CritScope cs_capture(&crit_capture_); 1652 rtc::CritScope cs_capture(&crit_capture_);
1653 aec_dump_ = AecDump::CreateNullDump();
1576 1654
1577 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 1655 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1578 // We just return if recording hasn't started. 1656 // We just return if recording hasn't started.
1579 debug_dump_.debug_file->CloseFile(); 1657 debug_dump_.debug_file->CloseFile();
1580 return kNoError; 1658 return kNoError;
1581 #else 1659 #else
1582 return kUnsupportedFunctionError; 1660 return kUnsupportedFunctionError;
1583 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1661 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1584 } 1662 }
1585 1663
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1930 2008
1931 config.set_ns_enabled(public_submodules_->noise_suppression->is_enabled()); 2009 config.set_ns_enabled(public_submodules_->noise_suppression->is_enabled());
1932 config.set_ns_level( 2010 config.set_ns_level(
1933 static_cast<int>(public_submodules_->noise_suppression->level())); 2011 static_cast<int>(public_submodules_->noise_suppression->level()));
1934 2012
1935 config.set_transient_suppression_enabled( 2013 config.set_transient_suppression_enabled(
1936 capture_.transient_suppressor_enabled); 2014 capture_.transient_suppressor_enabled);
1937 config.set_intelligibility_enhancer_enabled( 2015 config.set_intelligibility_enhancer_enabled(
1938 capture_nonlocked_.intelligibility_enabled); 2016 capture_nonlocked_.intelligibility_enabled);
1939 2017
2018 InternalAPMConfig apm_config;
2019
2020 apm_config.aec_enabled = public_submodules_->echo_cancellation->is_enabled();
2021 apm_config.aec_delay_agnostic_enabled =
2022 public_submodules_->echo_cancellation->is_delay_agnostic_enabled();
2023 apm_config.aec_drift_compensation_enabled =
2024 public_submodules_->echo_cancellation->is_drift_compensation_enabled();
2025 apm_config.aec_extended_filter_enabled =
2026 public_submodules_->echo_cancellation->is_extended_filter_enabled();
2027 apm_config.aec_suppression_level = static_cast<int>(
2028 public_submodules_->echo_cancellation->suppression_level());
2029
2030 apm_config.aecm_enabled =
2031 public_submodules_->echo_control_mobile->is_enabled();
2032 apm_config.aecm_comfort_noise_enabled =
2033 public_submodules_->echo_control_mobile->is_comfort_noise_enabled();
2034 apm_config.aecm_routing_mode =
2035 static_cast<int>(public_submodules_->echo_control_mobile->routing_mode());
2036
2037 apm_config.agc_enabled = public_submodules_->gain_control->is_enabled();
2038 apm_config.agc_mode =
2039 static_cast<int>(public_submodules_->gain_control->mode());
2040 apm_config.agc_limiter_enabled =
2041 public_submodules_->gain_control->is_limiter_enabled();
2042 apm_config.noise_robust_agc_enabled = constants_.use_experimental_agc;
2043
2044 apm_config.hpf_enabled = config_.high_pass_filter.enabled;
2045
2046 apm_config.ns_enabled = public_submodules_->noise_suppression->is_enabled();
2047 apm_config.ns_level =
2048 static_cast<int>(public_submodules_->noise_suppression->level());
2049
2050 apm_config.transient_suppression_enabled =
2051 capture_.transient_suppressor_enabled;
2052 apm_config.intelligibility_enhancer_enabled =
2053 capture_nonlocked_.intelligibility_enabled;
2054
1940 std::string experiments_description = 2055 std::string experiments_description =
1941 public_submodules_->echo_cancellation->GetExperimentsDescription(); 2056 public_submodules_->echo_cancellation->GetExperimentsDescription();
1942 // TODO(peah): Add semicolon-separated concatenations of experiment 2057 // TODO(peah): Add semicolon-separated concatenations of experiment
1943 // descriptions for other submodules. 2058 // descriptions for other submodules.
1944 if (capture_nonlocked_.level_controller_enabled) { 2059 if (capture_nonlocked_.level_controller_enabled) {
1945 experiments_description += "LevelController;"; 2060 experiments_description += "LevelController;";
1946 } 2061 }
1947 if (constants_.agc_clipped_level_min != kClippedLevelMin) { 2062 if (constants_.agc_clipped_level_min != kClippedLevelMin) {
1948 experiments_description += "AgcClippingLevelExperiment;"; 2063 experiments_description += "AgcClippingLevelExperiment;";
1949 } 2064 }
1950 if (capture_nonlocked_.echo_canceller3_enabled) { 2065 if (capture_nonlocked_.echo_canceller3_enabled) {
1951 experiments_description += "EchoCanceller3;"; 2066 experiments_description += "EchoCanceller3;";
1952 } 2067 }
1953 config.set_experiments_description(experiments_description); 2068 config.set_experiments_description(experiments_description);
1954 2069
2070 apm_config.experiments_description = experiments_description;
2071 aec_dump_->WriteConfig(apm_config, forced);
2072
1955 std::string serialized_config = config.SerializeAsString(); 2073 std::string serialized_config = config.SerializeAsString();
1956 if (!forced && 2074 if (!forced &&
1957 debug_dump_.capture.last_serialized_config == serialized_config) { 2075 debug_dump_.capture.last_serialized_config == serialized_config) {
1958 return kNoError; 2076 return kNoError;
1959 } 2077 }
1960 2078
1961 debug_dump_.capture.last_serialized_config = serialized_config; 2079 debug_dump_.capture.last_serialized_config = serialized_config;
1962 2080
1963 debug_dump_.capture.event_msg->set_type(audioproc::Event::CONFIG); 2081 debug_dump_.capture.event_msg->set_type(audioproc::Event::CONFIG);
1964 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); 2082 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config);
(...skipping 23 matching lines...) Expand all
1988 capture_processing_format(kSampleRate16kHz), 2106 capture_processing_format(kSampleRate16kHz),
1989 split_rate(kSampleRate16kHz) {} 2107 split_rate(kSampleRate16kHz) {}
1990 2108
1991 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; 2109 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default;
1992 2110
1993 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; 2111 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default;
1994 2112
1995 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; 2113 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default;
1996 2114
1997 } // namespace webrtc 2115 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698