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

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

Issue 2778783002: AecDump interface (Closed)
Patch Set: Comment formatting. Created 3 years, 7 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 bool is_enabled() const override { 151 bool is_enabled() const override {
152 return apm_->GetConfig().high_pass_filter.enabled; 152 return apm_->GetConfig().high_pass_filter.enabled;
153 } 153 }
154 154
155 private: 155 private:
156 AudioProcessingImpl* apm_; 156 AudioProcessingImpl* apm_;
157 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(HighPassFilterImpl); 157 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(HighPassFilterImpl);
158 }; 158 };
159 159
160 webrtc::InternalAPMStreamsConfig ToStreamsConfig(
161 const ProcessingConfig& api_format) {
162 webrtc::InternalAPMStreamsConfig result;
163 result.input_sample_rate = api_format.input_stream().sample_rate_hz();
164 result.input_num_channels = api_format.input_stream().num_channels();
165 result.output_num_channels = api_format.output_stream().num_channels();
166 result.render_input_num_channels =
167 api_format.reverse_input_stream().num_channels();
168 result.render_input_sample_rate =
169 api_format.reverse_input_stream().sample_rate_hz();
170 result.output_sample_rate = api_format.output_stream().sample_rate_hz();
171 result.render_output_sample_rate =
172 api_format.reverse_output_stream().sample_rate_hz();
173 result.render_output_num_channels =
174 api_format.reverse_output_stream().num_channels();
175 return result;
176 }
160 } // namespace 177 } // namespace
161 178
162 // Throughout webrtc, it's assumed that success is represented by zero. 179 // Throughout webrtc, it's assumed that success is represented by zero.
163 static_assert(AudioProcessing::kNoError == 0, "kNoError must be zero"); 180 static_assert(AudioProcessing::kNoError == 0, "kNoError must be zero");
164 181
165 AudioProcessingImpl::ApmSubmoduleStates::ApmSubmoduleStates() {} 182 AudioProcessingImpl::ApmSubmoduleStates::ApmSubmoduleStates() {}
166 183
167 bool AudioProcessingImpl::ApmSubmoduleStates::Update( 184 bool AudioProcessingImpl::ApmSubmoduleStates::Update(
168 bool low_cut_filter_enabled, 185 bool low_cut_filter_enabled,
169 bool echo_canceller_enabled, 186 bool echo_canceller_enabled,
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 InitializeGainController2(); 546 InitializeGainController2();
530 547
531 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 548 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
532 if (debug_dump_.debug_file->is_open()) { 549 if (debug_dump_.debug_file->is_open()) {
533 int err = WriteInitMessage(); 550 int err = WriteInitMessage();
534 if (err != kNoError) { 551 if (err != kNoError) {
535 return err; 552 return err;
536 } 553 }
537 } 554 }
538 #endif 555 #endif
539 556 if (aec_dump_) {
557 aec_dump_->WriteInitMessage(ToStreamsConfig(formats_.api_format));
558 }
540 return kNoError; 559 return kNoError;
541 } 560 }
542 561
543 int AudioProcessingImpl::InitializeLocked(const ProcessingConfig& config) { 562 int AudioProcessingImpl::InitializeLocked(const ProcessingConfig& config) {
544 for (const auto& stream : config.streams) { 563 for (const auto& stream : config.streams) {
545 if (stream.num_channels() > 0 && stream.sample_rate_hz() <= 0) { 564 if (stream.num_channels() > 0 && stream.sample_rate_hz() <= 0) {
546 return kBadSampleRateError; 565 return kBadSampleRateError;
547 } 566 }
548 } 567 }
549 568
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 debug_dump_.capture.event_msg->set_type(audioproc::Event::STREAM); 874 debug_dump_.capture.event_msg->set_type(audioproc::Event::STREAM);
856 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream(); 875 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream();
857 const size_t channel_size = 876 const size_t channel_size =
858 sizeof(float) * formats_.api_format.input_stream().num_frames(); 877 sizeof(float) * formats_.api_format.input_stream().num_frames();
859 for (size_t i = 0; i < formats_.api_format.input_stream().num_channels(); 878 for (size_t i = 0; i < formats_.api_format.input_stream().num_channels();
860 ++i) 879 ++i)
861 msg->add_input_channel(src[i], channel_size); 880 msg->add_input_channel(src[i], channel_size);
862 } 881 }
863 #endif 882 #endif
864 883
884 if (aec_dump_) {
885 RecordUnprocessedCaptureStream(src);
886 }
887
865 capture_.capture_audio->CopyFrom(src, formats_.api_format.input_stream()); 888 capture_.capture_audio->CopyFrom(src, formats_.api_format.input_stream());
866 RETURN_ON_ERR(ProcessCaptureStreamLocked()); 889 RETURN_ON_ERR(ProcessCaptureStreamLocked());
867 capture_.capture_audio->CopyTo(formats_.api_format.output_stream(), dest); 890 capture_.capture_audio->CopyTo(formats_.api_format.output_stream(), dest);
868 891
869 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 892 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
870 if (debug_dump_.debug_file->is_open()) { 893 if (debug_dump_.debug_file->is_open()) {
871 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream(); 894 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream();
872 const size_t channel_size = 895 const size_t channel_size =
873 sizeof(float) * formats_.api_format.output_stream().num_frames(); 896 sizeof(float) * formats_.api_format.output_stream().num_frames();
874 for (size_t i = 0; i < formats_.api_format.output_stream().num_channels(); 897 for (size_t i = 0; i < formats_.api_format.output_stream().num_channels();
875 ++i) 898 ++i)
876 msg->add_output_channel(dest[i], channel_size); 899 msg->add_output_channel(dest[i], channel_size);
877 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 900 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
878 &debug_dump_.num_bytes_left_for_log_, 901 &debug_dump_.num_bytes_left_for_log_,
879 &crit_debug_, &debug_dump_.capture)); 902 &crit_debug_, &debug_dump_.capture));
880 } 903 }
881 #endif 904 #endif
882 905 if (aec_dump_) {
906 RecordProcessedCaptureStream(dest);
907 }
883 return kNoError; 908 return kNoError;
884 } 909 }
885 910
886 void AudioProcessingImpl::QueueBandedRenderAudio(AudioBuffer* audio) { 911 void AudioProcessingImpl::QueueBandedRenderAudio(AudioBuffer* audio) {
887 EchoCancellationImpl::PackRenderAudioBuffer(audio, num_output_channels(), 912 EchoCancellationImpl::PackRenderAudioBuffer(audio, num_output_channels(),
888 num_reverse_channels(), 913 num_reverse_channels(),
889 &aec_render_queue_buffer_); 914 &aec_render_queue_buffer_);
890 915
891 RTC_DCHECK_GE(160, audio->num_frames_per_band()); 916 RTC_DCHECK_GE(160, audio->num_frames_per_band());
892 917
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 rtc::CritScope cs_render(&crit_render_); 1136 rtc::CritScope cs_render(&crit_render_);
1112 RETURN_ON_ERR( 1137 RETURN_ON_ERR(
1113 MaybeInitializeCapture(processing_config, reinitialization_required)); 1138 MaybeInitializeCapture(processing_config, reinitialization_required));
1114 } 1139 }
1115 rtc::CritScope cs_capture(&crit_capture_); 1140 rtc::CritScope cs_capture(&crit_capture_);
1116 if (frame->samples_per_channel_ != 1141 if (frame->samples_per_channel_ !=
1117 formats_.api_format.input_stream().num_frames()) { 1142 formats_.api_format.input_stream().num_frames()) {
1118 return kBadDataLengthError; 1143 return kBadDataLengthError;
1119 } 1144 }
1120 1145
1146 if (aec_dump_) {
1147 RecordUnprocessedCaptureStream(*frame);
1148 }
1149
1121 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 1150 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1122 if (debug_dump_.debug_file->is_open()) { 1151 if (debug_dump_.debug_file->is_open()) {
1123 RETURN_ON_ERR(WriteConfigMessage(false)); 1152 RETURN_ON_ERR(WriteConfigMessage(false));
1124 1153
1125 debug_dump_.capture.event_msg->set_type(audioproc::Event::STREAM); 1154 debug_dump_.capture.event_msg->set_type(audioproc::Event::STREAM);
1126 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream(); 1155 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream();
1127 const size_t data_size = 1156 const size_t data_size =
1128 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_; 1157 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_;
1129 msg->set_input_data(frame->data_, data_size); 1158 msg->set_input_data(frame->data_, data_size);
1130 } 1159 }
1131 #endif 1160 #endif
1132 1161
1133 capture_.capture_audio->DeinterleaveFrom(frame); 1162 capture_.capture_audio->DeinterleaveFrom(frame);
1134 RETURN_ON_ERR(ProcessCaptureStreamLocked()); 1163 RETURN_ON_ERR(ProcessCaptureStreamLocked());
1135 capture_.capture_audio->InterleaveTo( 1164 capture_.capture_audio->InterleaveTo(
1136 frame, submodule_states_.CaptureMultiBandProcessingActive()); 1165 frame, submodule_states_.CaptureMultiBandProcessingActive());
1137 1166
1167 if (aec_dump_) {
1168 RecordProcessedCaptureStream(*frame);
1169 }
1138 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 1170 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1139 if (debug_dump_.debug_file->is_open()) { 1171 if (debug_dump_.debug_file->is_open()) {
1140 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream(); 1172 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream();
1141 const size_t data_size = 1173 const size_t data_size =
1142 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_; 1174 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_;
1143 msg->set_output_data(frame->data_, data_size); 1175 msg->set_output_data(frame->data_, data_size);
1144 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1176 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1145 &debug_dump_.num_bytes_left_for_log_, 1177 &debug_dump_.num_bytes_left_for_log_,
1146 &crit_debug_, &debug_dump_.capture)); 1178 &crit_debug_, &debug_dump_.capture));
1147 } 1179 }
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 const size_t channel_size = 1445 const size_t channel_size =
1414 sizeof(float) * formats_.api_format.reverse_input_stream().num_frames(); 1446 sizeof(float) * formats_.api_format.reverse_input_stream().num_frames();
1415 for (size_t i = 0; 1447 for (size_t i = 0;
1416 i < formats_.api_format.reverse_input_stream().num_channels(); ++i) 1448 i < formats_.api_format.reverse_input_stream().num_channels(); ++i)
1417 msg->add_channel(src[i], channel_size); 1449 msg->add_channel(src[i], channel_size);
1418 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1450 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1419 &debug_dump_.num_bytes_left_for_log_, 1451 &debug_dump_.num_bytes_left_for_log_,
1420 &crit_debug_, &debug_dump_.render)); 1452 &crit_debug_, &debug_dump_.render));
1421 } 1453 }
1422 #endif 1454 #endif
1423 1455 if (aec_dump_) {
1456 const size_t channel_size =
1457 formats_.api_format.reverse_input_stream().num_frames();
1458 const size_t num_channels =
1459 formats_.api_format.reverse_input_stream().num_channels();
1460 aec_dump_->WriteRenderStreamMessage(
1461 FloatAudioFrame(src, num_channels, channel_size));
1462 }
1424 render_.render_audio->CopyFrom(src, 1463 render_.render_audio->CopyFrom(src,
1425 formats_.api_format.reverse_input_stream()); 1464 formats_.api_format.reverse_input_stream());
1426 return ProcessRenderStreamLocked(); 1465 return ProcessRenderStreamLocked();
1427 } 1466 }
1428 1467
1429 int AudioProcessingImpl::ProcessReverseStream(AudioFrame* frame) { 1468 int AudioProcessingImpl::ProcessReverseStream(AudioFrame* frame) {
1430 TRACE_EVENT0("webrtc", "AudioProcessing::ProcessReverseStream_AudioFrame"); 1469 TRACE_EVENT0("webrtc", "AudioProcessing::ProcessReverseStream_AudioFrame");
1431 rtc::CritScope cs(&crit_render_); 1470 rtc::CritScope cs(&crit_render_);
1432 if (frame == nullptr) { 1471 if (frame == nullptr) {
1433 return kNullPointerError; 1472 return kNullPointerError;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 audioproc::ReverseStream* msg = 1505 audioproc::ReverseStream* msg =
1467 debug_dump_.render.event_msg->mutable_reverse_stream(); 1506 debug_dump_.render.event_msg->mutable_reverse_stream();
1468 const size_t data_size = 1507 const size_t data_size =
1469 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_; 1508 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_;
1470 msg->set_data(frame->data_, data_size); 1509 msg->set_data(frame->data_, data_size);
1471 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1510 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1472 &debug_dump_.num_bytes_left_for_log_, 1511 &debug_dump_.num_bytes_left_for_log_,
1473 &crit_debug_, &debug_dump_.render)); 1512 &crit_debug_, &debug_dump_.render));
1474 } 1513 }
1475 #endif 1514 #endif
1515 if (aec_dump_) {
1516 aec_dump_->WriteRenderStreamMessage(*frame);
1517 }
1518
1476 render_.render_audio->DeinterleaveFrom(frame); 1519 render_.render_audio->DeinterleaveFrom(frame);
1477 RETURN_ON_ERR(ProcessRenderStreamLocked()); 1520 RETURN_ON_ERR(ProcessRenderStreamLocked());
1478 render_.render_audio->InterleaveTo( 1521 render_.render_audio->InterleaveTo(
1479 frame, submodule_states_.RenderMultiBandProcessingActive()); 1522 frame, submodule_states_.RenderMultiBandProcessingActive());
1480 return kNoError; 1523 return kNoError;
1481 } 1524 }
1482 1525
1483 int AudioProcessingImpl::ProcessRenderStreamLocked() { 1526 int AudioProcessingImpl::ProcessRenderStreamLocked() {
1484 AudioBuffer* render_buffer = render_.render_audio.get(); // For brevity. 1527 AudioBuffer* render_buffer = render_.render_audio.get(); // For brevity.
1485 1528
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 void AudioProcessingImpl::set_delay_offset_ms(int offset) { 1598 void AudioProcessingImpl::set_delay_offset_ms(int offset) {
1556 rtc::CritScope cs(&crit_capture_); 1599 rtc::CritScope cs(&crit_capture_);
1557 capture_.delay_offset_ms = offset; 1600 capture_.delay_offset_ms = offset;
1558 } 1601 }
1559 1602
1560 int AudioProcessingImpl::delay_offset_ms() const { 1603 int AudioProcessingImpl::delay_offset_ms() const {
1561 rtc::CritScope cs(&crit_capture_); 1604 rtc::CritScope cs(&crit_capture_);
1562 return capture_.delay_offset_ms; 1605 return capture_.delay_offset_ms;
1563 } 1606 }
1564 1607
1608 void AudioProcessingImpl::AttachAecDump(std::unique_ptr<AecDump> aec_dump) {
1609 RTC_DCHECK(aec_dump);
1610 rtc::CritScope cs_render(&crit_render_);
1611 rtc::CritScope cs_capture(&crit_capture_);
1612
1613 // The previously attached AecDump will be destroyed with the
1614 // 'aec_dump' parameter, which is after locks are released.
1615 aec_dump_.swap(aec_dump);
1616 WriteAecDumpConfigMessage(true);
1617 aec_dump_->WriteInitMessage(ToStreamsConfig(formats_.api_format));
1618 }
1619
1620 void AudioProcessingImpl::DetachAecDump() {
1621 // The d-tor of a task-queue based AecDump blocks until all pending
1622 // tasks are done. This construction avoids blocking while holding
1623 // the render and capture locks.
1624 std::unique_ptr<AecDump> aec_dump = nullptr;
1625 {
1626 rtc::CritScope cs_render(&crit_render_);
1627 rtc::CritScope cs_capture(&crit_capture_);
1628 aec_dump = std::move(aec_dump_);
1629 }
1630 }
1631
1565 int AudioProcessingImpl::StartDebugRecording( 1632 int AudioProcessingImpl::StartDebugRecording(
1566 const char filename[AudioProcessing::kMaxFilenameSize], 1633 const char filename[AudioProcessing::kMaxFilenameSize],
1567 int64_t max_log_size_bytes) { 1634 int64_t max_log_size_bytes) {
1568 // Run in a single-threaded manner. 1635 // Run in a single-threaded manner.
1569 rtc::CritScope cs_render(&crit_render_); 1636 rtc::CritScope cs_render(&crit_render_);
1570 rtc::CritScope cs_capture(&crit_capture_); 1637 rtc::CritScope cs_capture(&crit_capture_);
1571 static_assert(kMaxFilenameSize == FileWrapper::kMaxFileNameSize, ""); 1638 static_assert(kMaxFilenameSize == FileWrapper::kMaxFileNameSize, "");
1572 1639
1573 if (filename == nullptr) { 1640 if (filename == nullptr) {
1574 return kNullPointerError; 1641 return kNullPointerError;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 int AudioProcessingImpl::StartDebugRecordingForPlatformFile( 1693 int AudioProcessingImpl::StartDebugRecordingForPlatformFile(
1627 rtc::PlatformFile handle) { 1694 rtc::PlatformFile handle) {
1628 // Run in a single-threaded manner. 1695 // Run in a single-threaded manner.
1629 rtc::CritScope cs_render(&crit_render_); 1696 rtc::CritScope cs_render(&crit_render_);
1630 rtc::CritScope cs_capture(&crit_capture_); 1697 rtc::CritScope cs_capture(&crit_capture_);
1631 FILE* stream = rtc::FdopenPlatformFileForWriting(handle); 1698 FILE* stream = rtc::FdopenPlatformFileForWriting(handle);
1632 return StartDebugRecording(stream, -1); 1699 return StartDebugRecording(stream, -1);
1633 } 1700 }
1634 1701
1635 int AudioProcessingImpl::StopDebugRecording() { 1702 int AudioProcessingImpl::StopDebugRecording() {
1703 DetachAecDump();
1704
1705 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1636 // Run in a single-threaded manner. 1706 // Run in a single-threaded manner.
1637 rtc::CritScope cs_render(&crit_render_); 1707 rtc::CritScope cs_render(&crit_render_);
1638 rtc::CritScope cs_capture(&crit_capture_); 1708 rtc::CritScope cs_capture(&crit_capture_);
1639
1640 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1641 // We just return if recording hasn't started. 1709 // We just return if recording hasn't started.
1642 debug_dump_.debug_file->CloseFile(); 1710 debug_dump_.debug_file->CloseFile();
1643 return kNoError; 1711 return kNoError;
1644 #else 1712 #else
1645 return kUnsupportedFunctionError; 1713 return kUnsupportedFunctionError;
1646 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1714 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1647 } 1715 }
1648 1716
1649 AudioProcessing::AudioProcessingStatistics::AudioProcessingStatistics() { 1717 AudioProcessing::AudioProcessingStatistics::AudioProcessingStatistics() {
1650 residual_echo_return_loss.Set(-100.0f, -100.0f, -100.0f, -100.0f); 1718 residual_echo_return_loss.Set(-100.0f, -100.0f, -100.0f, -100.0f);
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 capture_.last_stream_delay_ms = 0; 1959 capture_.last_stream_delay_ms = 0;
1892 1960
1893 if (capture_.aec_system_delay_jumps > -1) { 1961 if (capture_.aec_system_delay_jumps > -1) {
1894 RTC_HISTOGRAM_ENUMERATION("WebRTC.Audio.NumOfAecSystemDelayJumps", 1962 RTC_HISTOGRAM_ENUMERATION("WebRTC.Audio.NumOfAecSystemDelayJumps",
1895 capture_.aec_system_delay_jumps, 51); 1963 capture_.aec_system_delay_jumps, 51);
1896 } 1964 }
1897 capture_.aec_system_delay_jumps = -1; 1965 capture_.aec_system_delay_jumps = -1;
1898 capture_.last_aec_system_delay_ms = 0; 1966 capture_.last_aec_system_delay_ms = 0;
1899 } 1967 }
1900 1968
1969 void AudioProcessingImpl::WriteAecDumpConfigMessage(bool forced) {
1970 if (!aec_dump_) {
1971 return;
1972 }
1973 std::string experiments_description =
1974 public_submodules_->echo_cancellation->GetExperimentsDescription();
1975 // TODO(peah): Add semicolon-separated concatenations of experiment
1976 // descriptions for other submodules.
1977 if (capture_nonlocked_.level_controller_enabled) {
1978 experiments_description += "LevelController;";
1979 }
1980 if (constants_.agc_clipped_level_min != kClippedLevelMin) {
1981 experiments_description += "AgcClippingLevelExperiment;";
1982 }
1983 if (capture_nonlocked_.echo_canceller3_enabled) {
1984 experiments_description += "EchoCanceller3;";
1985 }
1986
1987 InternalAPMConfig apm_config;
1988
1989 apm_config.aec_enabled = public_submodules_->echo_cancellation->is_enabled();
1990 apm_config.aec_delay_agnostic_enabled =
1991 public_submodules_->echo_cancellation->is_delay_agnostic_enabled();
1992 apm_config.aec_drift_compensation_enabled =
1993 public_submodules_->echo_cancellation->is_drift_compensation_enabled();
1994 apm_config.aec_extended_filter_enabled =
1995 public_submodules_->echo_cancellation->is_extended_filter_enabled();
1996 apm_config.aec_suppression_level = static_cast<int>(
1997 public_submodules_->echo_cancellation->suppression_level());
1998
1999 apm_config.aecm_enabled =
2000 public_submodules_->echo_control_mobile->is_enabled();
2001 apm_config.aecm_comfort_noise_enabled =
2002 public_submodules_->echo_control_mobile->is_comfort_noise_enabled();
2003 apm_config.aecm_routing_mode =
2004 static_cast<int>(public_submodules_->echo_control_mobile->routing_mode());
2005
2006 apm_config.agc_enabled = public_submodules_->gain_control->is_enabled();
2007 apm_config.agc_mode =
2008 static_cast<int>(public_submodules_->gain_control->mode());
2009 apm_config.agc_limiter_enabled =
2010 public_submodules_->gain_control->is_limiter_enabled();
2011 apm_config.noise_robust_agc_enabled = constants_.use_experimental_agc;
2012
2013 apm_config.hpf_enabled = config_.high_pass_filter.enabled;
2014
2015 apm_config.ns_enabled = public_submodules_->noise_suppression->is_enabled();
2016 apm_config.ns_level =
2017 static_cast<int>(public_submodules_->noise_suppression->level());
2018
2019 apm_config.transient_suppression_enabled =
2020 capture_.transient_suppressor_enabled;
2021 apm_config.intelligibility_enhancer_enabled =
2022 capture_nonlocked_.intelligibility_enabled;
2023 apm_config.experiments_description = experiments_description;
2024
2025 if (!forced && apm_config == apm_config_for_aec_dump_) {
2026 return;
2027 }
2028 aec_dump_->WriteConfig(apm_config);
2029 apm_config_for_aec_dump_ = apm_config;
2030 }
2031
2032 void AudioProcessingImpl::RecordUnprocessedCaptureStream(
2033 const float* const* src) {
2034 RTC_DCHECK(aec_dump_);
2035 WriteAecDumpConfigMessage(false);
2036
2037 const size_t channel_size = formats_.api_format.input_stream().num_frames();
2038 const size_t num_channels = formats_.api_format.input_stream().num_channels();
2039 aec_dump_->AddCaptureStreamInput(
2040 FloatAudioFrame(src, num_channels, channel_size));
2041 RecordAudioProcessingState();
2042 }
2043
2044 void AudioProcessingImpl::RecordUnprocessedCaptureStream(
2045 const AudioFrame& capture_frame) {
2046 RTC_DCHECK(aec_dump_);
2047 WriteAecDumpConfigMessage(false);
2048
2049 aec_dump_->AddCaptureStreamInput(capture_frame);
2050 RecordAudioProcessingState();
2051 }
2052
2053 void AudioProcessingImpl::RecordProcessedCaptureStream(
2054 const float* const* processed_capture_stream) {
2055 RTC_DCHECK(aec_dump_);
2056
2057 const size_t channel_size = formats_.api_format.output_stream().num_frames();
2058 const size_t num_channels =
2059 formats_.api_format.output_stream().num_channels();
2060 aec_dump_->AddCaptureStreamOutput(
2061 FloatAudioFrame(processed_capture_stream, num_channels, channel_size));
2062 aec_dump_->WriteCaptureStreamMessage();
2063 }
2064
2065 void AudioProcessingImpl::RecordProcessedCaptureStream(
2066 const AudioFrame& processed_capture_frame) {
2067 RTC_DCHECK(aec_dump_);
2068
2069 aec_dump_->AddCaptureStreamOutput(processed_capture_frame);
2070 aec_dump_->WriteCaptureStreamMessage();
2071 }
2072
2073 void AudioProcessingImpl::RecordAudioProcessingState() {
2074 RTC_DCHECK(aec_dump_);
2075 AecDump::AudioProcessingState audio_proc_state;
2076 audio_proc_state.delay = capture_nonlocked_.stream_delay_ms;
2077 audio_proc_state.drift =
2078 public_submodules_->echo_cancellation->stream_drift_samples();
2079 audio_proc_state.level = gain_control()->stream_analog_level();
2080 audio_proc_state.keypress = capture_.key_pressed;
2081 aec_dump_->AddAudioProcessingState(audio_proc_state);
2082 }
2083
1901 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 2084 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1902 int AudioProcessingImpl::WriteMessageToDebugFile( 2085 int AudioProcessingImpl::WriteMessageToDebugFile(
1903 FileWrapper* debug_file, 2086 FileWrapper* debug_file,
1904 int64_t* filesize_limit_bytes, 2087 int64_t* filesize_limit_bytes,
1905 rtc::CriticalSection* crit_debug, 2088 rtc::CriticalSection* crit_debug,
1906 ApmDebugDumpThreadState* debug_state) { 2089 ApmDebugDumpThreadState* debug_state) {
1907 int32_t size = debug_state->event_msg->ByteSize(); 2090 int32_t size = debug_state->event_msg->ByteSize();
1908 if (size <= 0) { 2091 if (size <= 0) {
1909 return kUnspecifiedError; 2092 return kUnspecifiedError;
1910 } 2093 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2064 previous_agc_level(0), 2247 previous_agc_level(0),
2065 echo_path_gain_change(false) {} 2248 echo_path_gain_change(false) {}
2066 2249
2067 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; 2250 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default;
2068 2251
2069 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; 2252 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default;
2070 2253
2071 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; 2254 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default;
2072 2255
2073 } // namespace webrtc 2256 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/audio_processing_impl.h ('k') | webrtc/modules/audio_processing/include/aec_dump.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698