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

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

Issue 2778783002: AecDump interface (Closed)
Patch Set: New FloatAudioFrame class for passing float** audio. 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 bool is_enabled() const override { 146 bool is_enabled() const override {
147 return apm_->GetConfig().high_pass_filter.enabled; 147 return apm_->GetConfig().high_pass_filter.enabled;
148 } 148 }
149 149
150 private: 150 private:
151 AudioProcessingImpl* apm_; 151 AudioProcessingImpl* apm_;
152 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(HighPassFilterImpl); 152 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(HighPassFilterImpl);
153 }; 153 };
154 154
155 webrtc::InternalAPMStreamsConfig ToStreamsConfig(
156 const ProcessingConfig& api_format) {
157 webrtc::InternalAPMStreamsConfig result;
158 result.input_sample_rate = api_format.input_stream().sample_rate_hz();
159 result.input_num_channels = api_format.input_stream().num_channels();
160 result.output_num_channels = api_format.output_stream().num_channels();
161 result.render_input_num_channels =
162 api_format.reverse_input_stream().num_channels();
163 result.render_input_sample_rate =
164 api_format.reverse_input_stream().sample_rate_hz();
165 result.output_sample_rate = api_format.output_stream().sample_rate_hz();
166 result.render_output_sample_rate =
167 api_format.reverse_output_stream().sample_rate_hz();
168 result.render_output_num_channels =
169 api_format.reverse_output_stream().num_channels();
170 return result;
171 }
155 } // namespace 172 } // namespace
156 173
157 // Throughout webrtc, it's assumed that success is represented by zero. 174 // Throughout webrtc, it's assumed that success is represented by zero.
158 static_assert(AudioProcessing::kNoError == 0, "kNoError must be zero"); 175 static_assert(AudioProcessing::kNoError == 0, "kNoError must be zero");
159 176
160 AudioProcessingImpl::ApmSubmoduleStates::ApmSubmoduleStates() {} 177 AudioProcessingImpl::ApmSubmoduleStates::ApmSubmoduleStates() {}
161 178
162 bool AudioProcessingImpl::ApmSubmoduleStates::Update( 179 bool AudioProcessingImpl::ApmSubmoduleStates::Update(
163 bool low_cut_filter_enabled, 180 bool low_cut_filter_enabled,
164 bool echo_canceller_enabled, 181 bool echo_canceller_enabled,
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 InitializeEchoCanceller3(); 536 InitializeEchoCanceller3();
520 537
521 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 538 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
522 if (debug_dump_.debug_file->is_open()) { 539 if (debug_dump_.debug_file->is_open()) {
523 int err = WriteInitMessage(); 540 int err = WriteInitMessage();
524 if (err != kNoError) { 541 if (err != kNoError) {
525 return err; 542 return err;
526 } 543 }
527 } 544 }
528 #endif 545 #endif
529 546 if (aec_dump_) {
547 aec_dump_->WriteInitMessage(ToStreamsConfig(formats_.api_format));
548 }
530 return kNoError; 549 return kNoError;
531 } 550 }
532 551
533 int AudioProcessingImpl::InitializeLocked(const ProcessingConfig& config) { 552 int AudioProcessingImpl::InitializeLocked(const ProcessingConfig& config) {
534 for (const auto& stream : config.streams) { 553 for (const auto& stream : config.streams) {
535 if (stream.num_channels() > 0 && stream.sample_rate_hz() <= 0) { 554 if (stream.num_channels() > 0 && stream.sample_rate_hz() <= 0) {
536 return kBadSampleRateError; 555 return kBadSampleRateError;
537 } 556 }
538 } 557 }
539 558
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 debug_dump_.capture.event_msg->set_type(audioproc::Event::STREAM); 836 debug_dump_.capture.event_msg->set_type(audioproc::Event::STREAM);
818 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream(); 837 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream();
819 const size_t channel_size = 838 const size_t channel_size =
820 sizeof(float) * formats_.api_format.input_stream().num_frames(); 839 sizeof(float) * formats_.api_format.input_stream().num_frames();
821 for (size_t i = 0; i < formats_.api_format.input_stream().num_channels(); 840 for (size_t i = 0; i < formats_.api_format.input_stream().num_channels();
822 ++i) 841 ++i)
823 msg->add_input_channel(src[i], channel_size); 842 msg->add_input_channel(src[i], channel_size);
824 } 843 }
825 #endif 844 #endif
826 845
846 std::unique_ptr<AecDump::CaptureStreamInfo> stream_info;
847 if (aec_dump_) {
848 stream_info = RecordUnprocessedCaptureStream(src);
849 }
850
827 capture_.capture_audio->CopyFrom(src, formats_.api_format.input_stream()); 851 capture_.capture_audio->CopyFrom(src, formats_.api_format.input_stream());
828 RETURN_ON_ERR(ProcessCaptureStreamLocked()); 852 RETURN_ON_ERR(ProcessCaptureStreamLocked());
829 capture_.capture_audio->CopyTo(formats_.api_format.output_stream(), dest); 853 capture_.capture_audio->CopyTo(formats_.api_format.output_stream(), dest);
830 854
831 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 855 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
832 if (debug_dump_.debug_file->is_open()) { 856 if (debug_dump_.debug_file->is_open()) {
833 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream(); 857 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream();
834 const size_t channel_size = 858 const size_t channel_size =
835 sizeof(float) * formats_.api_format.output_stream().num_frames(); 859 sizeof(float) * formats_.api_format.output_stream().num_frames();
836 for (size_t i = 0; i < formats_.api_format.output_stream().num_channels(); 860 for (size_t i = 0; i < formats_.api_format.output_stream().num_channels();
837 ++i) 861 ++i)
838 msg->add_output_channel(dest[i], channel_size); 862 msg->add_output_channel(dest[i], channel_size);
839 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 863 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
840 &debug_dump_.num_bytes_left_for_log_, 864 &debug_dump_.num_bytes_left_for_log_,
841 &crit_debug_, &debug_dump_.capture)); 865 &crit_debug_, &debug_dump_.capture));
842 } 866 }
843 #endif 867 #endif
844 868 if (aec_dump_) {
869 RecordProcessedCaptureStream(dest, std::move(stream_info));
870 }
845 return kNoError; 871 return kNoError;
846 } 872 }
847 873
848 void AudioProcessingImpl::QueueRenderAudio(AudioBuffer* audio) { 874 void AudioProcessingImpl::QueueRenderAudio(AudioBuffer* audio) {
849 EchoCancellationImpl::PackRenderAudioBuffer(audio, num_output_channels(), 875 EchoCancellationImpl::PackRenderAudioBuffer(audio, num_output_channels(),
850 num_reverse_channels(), 876 num_reverse_channels(),
851 &aec_render_queue_buffer_); 877 &aec_render_queue_buffer_);
852 878
853 RTC_DCHECK_GE(160, audio->num_frames_per_band()); 879 RTC_DCHECK_GE(160, audio->num_frames_per_band());
854 880
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 rtc::CritScope cs_render(&crit_render_); 1097 rtc::CritScope cs_render(&crit_render_);
1072 RETURN_ON_ERR( 1098 RETURN_ON_ERR(
1073 MaybeInitializeCapture(processing_config, reinitialization_required)); 1099 MaybeInitializeCapture(processing_config, reinitialization_required));
1074 } 1100 }
1075 rtc::CritScope cs_capture(&crit_capture_); 1101 rtc::CritScope cs_capture(&crit_capture_);
1076 if (frame->samples_per_channel_ != 1102 if (frame->samples_per_channel_ !=
1077 formats_.api_format.input_stream().num_frames()) { 1103 formats_.api_format.input_stream().num_frames()) {
1078 return kBadDataLengthError; 1104 return kBadDataLengthError;
1079 } 1105 }
1080 1106
1107 std::unique_ptr<AecDump::CaptureStreamInfo> stream_info;
1108 if (aec_dump_) {
1109 stream_info = RecordUnprocessedCaptureStream(*frame);
1110 }
1111
1081 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 1112 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1082 if (debug_dump_.debug_file->is_open()) { 1113 if (debug_dump_.debug_file->is_open()) {
1083 RETURN_ON_ERR(WriteConfigMessage(false)); 1114 RETURN_ON_ERR(WriteConfigMessage(false));
1084 1115
1085 debug_dump_.capture.event_msg->set_type(audioproc::Event::STREAM); 1116 debug_dump_.capture.event_msg->set_type(audioproc::Event::STREAM);
1086 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream(); 1117 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream();
1087 const size_t data_size = 1118 const size_t data_size =
1088 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_; 1119 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_;
1089 msg->set_input_data(frame->data_, data_size); 1120 msg->set_input_data(frame->data_, data_size);
1090 } 1121 }
1091 #endif 1122 #endif
1092 1123
1093 capture_.capture_audio->DeinterleaveFrom(frame); 1124 capture_.capture_audio->DeinterleaveFrom(frame);
1094 RETURN_ON_ERR(ProcessCaptureStreamLocked()); 1125 RETURN_ON_ERR(ProcessCaptureStreamLocked());
1095 capture_.capture_audio->InterleaveTo( 1126 capture_.capture_audio->InterleaveTo(
1096 frame, submodule_states_.CaptureMultiBandProcessingActive()); 1127 frame, submodule_states_.CaptureMultiBandProcessingActive());
1097 1128
1129 if (aec_dump_) {
1130 RecordProcessedCaptureStream(*frame, std::move(stream_info));
1131 }
1098 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 1132 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1099 if (debug_dump_.debug_file->is_open()) { 1133 if (debug_dump_.debug_file->is_open()) {
1100 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream(); 1134 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream();
1101 const size_t data_size = 1135 const size_t data_size =
1102 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_; 1136 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_;
1103 msg->set_output_data(frame->data_, data_size); 1137 msg->set_output_data(frame->data_, data_size);
1104 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1138 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1105 &debug_dump_.num_bytes_left_for_log_, 1139 &debug_dump_.num_bytes_left_for_log_,
1106 &crit_debug_, &debug_dump_.capture)); 1140 &crit_debug_, &debug_dump_.capture));
1107 } 1141 }
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 const size_t channel_size = 1403 const size_t channel_size =
1370 sizeof(float) * formats_.api_format.reverse_input_stream().num_frames(); 1404 sizeof(float) * formats_.api_format.reverse_input_stream().num_frames();
1371 for (size_t i = 0; 1405 for (size_t i = 0;
1372 i < formats_.api_format.reverse_input_stream().num_channels(); ++i) 1406 i < formats_.api_format.reverse_input_stream().num_channels(); ++i)
1373 msg->add_channel(src[i], channel_size); 1407 msg->add_channel(src[i], channel_size);
1374 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1408 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1375 &debug_dump_.num_bytes_left_for_log_, 1409 &debug_dump_.num_bytes_left_for_log_,
1376 &crit_debug_, &debug_dump_.render)); 1410 &crit_debug_, &debug_dump_.render));
1377 } 1411 }
1378 #endif 1412 #endif
1379 1413 if (aec_dump_) {
1414 const size_t channel_size =
1415 formats_.api_format.reverse_input_stream().num_frames();
1416 const size_t num_channels =
1417 formats_.api_format.reverse_input_stream().num_channels();
1418 aec_dump_->WriteRenderStreamMessage(
1419 FloatAudioFrame(src, num_channels, channel_size));
1420 }
1380 render_.render_audio->CopyFrom(src, 1421 render_.render_audio->CopyFrom(src,
1381 formats_.api_format.reverse_input_stream()); 1422 formats_.api_format.reverse_input_stream());
1382 return ProcessRenderStreamLocked(); 1423 return ProcessRenderStreamLocked();
1383 } 1424 }
1384 1425
1385 int AudioProcessingImpl::ProcessReverseStream(AudioFrame* frame) { 1426 int AudioProcessingImpl::ProcessReverseStream(AudioFrame* frame) {
1386 TRACE_EVENT0("webrtc", "AudioProcessing::ProcessReverseStream_AudioFrame"); 1427 TRACE_EVENT0("webrtc", "AudioProcessing::ProcessReverseStream_AudioFrame");
1387 rtc::CritScope cs(&crit_render_); 1428 rtc::CritScope cs(&crit_render_);
1388 if (frame == nullptr) { 1429 if (frame == nullptr) {
1389 return kNullPointerError; 1430 return kNullPointerError;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 audioproc::ReverseStream* msg = 1463 audioproc::ReverseStream* msg =
1423 debug_dump_.render.event_msg->mutable_reverse_stream(); 1464 debug_dump_.render.event_msg->mutable_reverse_stream();
1424 const size_t data_size = 1465 const size_t data_size =
1425 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_; 1466 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_;
1426 msg->set_data(frame->data_, data_size); 1467 msg->set_data(frame->data_, data_size);
1427 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1468 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1428 &debug_dump_.num_bytes_left_for_log_, 1469 &debug_dump_.num_bytes_left_for_log_,
1429 &crit_debug_, &debug_dump_.render)); 1470 &crit_debug_, &debug_dump_.render));
1430 } 1471 }
1431 #endif 1472 #endif
1473 if (aec_dump_) {
1474 aec_dump_->WriteRenderStreamMessage(*frame);
1475 }
1476
1432 render_.render_audio->DeinterleaveFrom(frame); 1477 render_.render_audio->DeinterleaveFrom(frame);
1433 RETURN_ON_ERR(ProcessRenderStreamLocked()); 1478 RETURN_ON_ERR(ProcessRenderStreamLocked());
1434 render_.render_audio->InterleaveTo( 1479 render_.render_audio->InterleaveTo(
1435 frame, submodule_states_.RenderMultiBandProcessingActive()); 1480 frame, submodule_states_.RenderMultiBandProcessingActive());
1436 return kNoError; 1481 return kNoError;
1437 } 1482 }
1438 1483
1439 int AudioProcessingImpl::ProcessRenderStreamLocked() { 1484 int AudioProcessingImpl::ProcessRenderStreamLocked() {
1440 AudioBuffer* render_buffer = render_.render_audio.get(); // For brevity. 1485 AudioBuffer* render_buffer = render_.render_audio.get(); // For brevity.
1441 if (submodule_states_.RenderMultiBandSubModulesActive() && 1486 if (submodule_states_.RenderMultiBandSubModulesActive() &&
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 void AudioProcessingImpl::set_delay_offset_ms(int offset) { 1550 void AudioProcessingImpl::set_delay_offset_ms(int offset) {
1506 rtc::CritScope cs(&crit_capture_); 1551 rtc::CritScope cs(&crit_capture_);
1507 capture_.delay_offset_ms = offset; 1552 capture_.delay_offset_ms = offset;
1508 } 1553 }
1509 1554
1510 int AudioProcessingImpl::delay_offset_ms() const { 1555 int AudioProcessingImpl::delay_offset_ms() const {
1511 rtc::CritScope cs(&crit_capture_); 1556 rtc::CritScope cs(&crit_capture_);
1512 return capture_.delay_offset_ms; 1557 return capture_.delay_offset_ms;
1513 } 1558 }
1514 1559
1560 void AudioProcessingImpl::StartDebugRecording(
1561 std::unique_ptr<AecDump> aec_dump) {
1562 rtc::CritScope cs_render(&crit_render_);
1563 rtc::CritScope cs_capture(&crit_capture_);
1564 RTC_DCHECK(aec_dump);
1565 aec_dump_ = std::move(aec_dump);
1566
1567 aec_dump_->WriteConfig(CollectApmConfig(), true);
1568 aec_dump_->WriteInitMessage(ToStreamsConfig(formats_.api_format));
1569 }
1570
1515 int AudioProcessingImpl::StartDebugRecording( 1571 int AudioProcessingImpl::StartDebugRecording(
1516 const char filename[AudioProcessing::kMaxFilenameSize], 1572 const char filename[AudioProcessing::kMaxFilenameSize],
1517 int64_t max_log_size_bytes) { 1573 int64_t max_log_size_bytes) {
1518 // Run in a single-threaded manner. 1574 // Run in a single-threaded manner.
1519 rtc::CritScope cs_render(&crit_render_); 1575 rtc::CritScope cs_render(&crit_render_);
1520 rtc::CritScope cs_capture(&crit_capture_); 1576 rtc::CritScope cs_capture(&crit_capture_);
1521 static_assert(kMaxFilenameSize == FileWrapper::kMaxFileNameSize, ""); 1577 static_assert(kMaxFilenameSize == FileWrapper::kMaxFileNameSize, "");
1522 1578
1523 if (filename == nullptr) { 1579 if (filename == nullptr) {
1524 return kNullPointerError; 1580 return kNullPointerError;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 rtc::CritScope cs_render(&crit_render_); 1635 rtc::CritScope cs_render(&crit_render_);
1580 rtc::CritScope cs_capture(&crit_capture_); 1636 rtc::CritScope cs_capture(&crit_capture_);
1581 FILE* stream = rtc::FdopenPlatformFileForWriting(handle); 1637 FILE* stream = rtc::FdopenPlatformFileForWriting(handle);
1582 return StartDebugRecording(stream, -1); 1638 return StartDebugRecording(stream, -1);
1583 } 1639 }
1584 1640
1585 int AudioProcessingImpl::StopDebugRecording() { 1641 int AudioProcessingImpl::StopDebugRecording() {
1586 // Run in a single-threaded manner. 1642 // Run in a single-threaded manner.
1587 rtc::CritScope cs_render(&crit_render_); 1643 rtc::CritScope cs_render(&crit_render_);
1588 rtc::CritScope cs_capture(&crit_capture_); 1644 rtc::CritScope cs_capture(&crit_capture_);
1645 aec_dump_.reset();
1589 1646
1590 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 1647 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1591 // We just return if recording hasn't started. 1648 // We just return if recording hasn't started.
1592 debug_dump_.debug_file->CloseFile(); 1649 debug_dump_.debug_file->CloseFile();
1593 return kNoError; 1650 return kNoError;
1594 #else 1651 #else
1595 return kUnsupportedFunctionError; 1652 return kUnsupportedFunctionError;
1596 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1653 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1597 } 1654 }
1598 1655
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1830 capture_.last_stream_delay_ms = 0; 1887 capture_.last_stream_delay_ms = 0;
1831 1888
1832 if (capture_.aec_system_delay_jumps > -1) { 1889 if (capture_.aec_system_delay_jumps > -1) {
1833 RTC_HISTOGRAM_ENUMERATION("WebRTC.Audio.NumOfAecSystemDelayJumps", 1890 RTC_HISTOGRAM_ENUMERATION("WebRTC.Audio.NumOfAecSystemDelayJumps",
1834 capture_.aec_system_delay_jumps, 51); 1891 capture_.aec_system_delay_jumps, 51);
1835 } 1892 }
1836 capture_.aec_system_delay_jumps = -1; 1893 capture_.aec_system_delay_jumps = -1;
1837 capture_.last_aec_system_delay_ms = 0; 1894 capture_.last_aec_system_delay_ms = 0;
1838 } 1895 }
1839 1896
1897 InternalAPMConfig AudioProcessingImpl::CollectApmConfig() const {
1898 std::string experiments_description =
1899 public_submodules_->echo_cancellation->GetExperimentsDescription();
1900 // TODO(peah): Add semicolon-separated concatenations of experiment
1901 // descriptions for other submodules.
1902 if (capture_nonlocked_.level_controller_enabled) {
1903 experiments_description += "LevelController;";
1904 }
1905 if (constants_.agc_clipped_level_min != kClippedLevelMin) {
1906 experiments_description += "AgcClippingLevelExperiment;";
1907 }
1908 if (capture_nonlocked_.echo_canceller3_enabled) {
1909 experiments_description += "EchoCanceller3;";
1910 }
1911
1912 InternalAPMConfig apm_config;
1913
1914 apm_config.aec_enabled = public_submodules_->echo_cancellation->is_enabled();
1915 apm_config.aec_delay_agnostic_enabled =
1916 public_submodules_->echo_cancellation->is_delay_agnostic_enabled();
1917 apm_config.aec_drift_compensation_enabled =
1918 public_submodules_->echo_cancellation->is_drift_compensation_enabled();
1919 apm_config.aec_extended_filter_enabled =
1920 public_submodules_->echo_cancellation->is_extended_filter_enabled();
1921 apm_config.aec_suppression_level = static_cast<int>(
1922 public_submodules_->echo_cancellation->suppression_level());
1923
1924 apm_config.aecm_enabled =
1925 public_submodules_->echo_control_mobile->is_enabled();
1926 apm_config.aecm_comfort_noise_enabled =
1927 public_submodules_->echo_control_mobile->is_comfort_noise_enabled();
1928 apm_config.aecm_routing_mode =
1929 static_cast<int>(public_submodules_->echo_control_mobile->routing_mode());
1930
1931 apm_config.agc_enabled = public_submodules_->gain_control->is_enabled();
1932 apm_config.agc_mode =
1933 static_cast<int>(public_submodules_->gain_control->mode());
1934 apm_config.agc_limiter_enabled =
1935 public_submodules_->gain_control->is_limiter_enabled();
1936 apm_config.noise_robust_agc_enabled = constants_.use_experimental_agc;
1937
1938 apm_config.hpf_enabled = config_.high_pass_filter.enabled;
1939
1940 apm_config.ns_enabled = public_submodules_->noise_suppression->is_enabled();
1941 apm_config.ns_level =
1942 static_cast<int>(public_submodules_->noise_suppression->level());
1943
1944 apm_config.transient_suppression_enabled =
1945 capture_.transient_suppressor_enabled;
1946 apm_config.intelligibility_enhancer_enabled =
1947 capture_nonlocked_.intelligibility_enabled;
1948 apm_config.experiments_description = experiments_description;
1949 return apm_config;
1950 }
1951
1952 std::unique_ptr<AecDump::CaptureStreamInfo>
1953 AudioProcessingImpl::RecordUnprocessedCaptureStream(
1954 const float* const* src) const {
1955 RTC_DCHECK(aec_dump_);
1956 aec_dump_->WriteConfig(CollectApmConfig(), false);
1957 auto stream_info = aec_dump_->GetCaptureStreamInfo();
1958 RTC_DCHECK(stream_info);
1959
1960 const size_t channel_size = formats_.api_format.input_stream().num_frames();
1961 const size_t num_channels = formats_.api_format.input_stream().num_channels();
1962 stream_info->AddInput(FloatAudioFrame(src, num_channels, channel_size));
1963 PopulateStreamInfoWithConfig(stream_info.get());
1964 return stream_info;
1965 }
1966
1967 std::unique_ptr<AecDump::CaptureStreamInfo>
1968 AudioProcessingImpl::RecordUnprocessedCaptureStream(
1969 const AudioFrame& capture_frame) const {
1970 RTC_DCHECK(aec_dump_);
1971 auto stream_info = aec_dump_->GetCaptureStreamInfo();
1972 RTC_DCHECK(stream_info);
1973
1974 stream_info->AddInput(capture_frame);
1975 PopulateStreamInfoWithConfig(stream_info.get());
1976 aec_dump_->WriteConfig(CollectApmConfig(), false);
1977 return stream_info;
1978 }
1979
1980 void AudioProcessingImpl::RecordProcessedCaptureStream(
1981 const float* const* processed_capture_stream,
1982 std::unique_ptr<AecDump::CaptureStreamInfo> stream_info) const {
1983 RTC_DCHECK(stream_info);
1984 RTC_DCHECK(aec_dump_);
1985
1986 const size_t channel_size = formats_.api_format.output_stream().num_frames();
1987 const size_t num_channels =
1988 formats_.api_format.output_stream().num_channels();
1989 stream_info->AddOutput(
1990 FloatAudioFrame(processed_capture_stream, num_channels, channel_size));
1991 aec_dump_->WriteCaptureStreamMessage(std::move(stream_info));
1992 }
1993
1994 void AudioProcessingImpl::RecordProcessedCaptureStream(
1995 const AudioFrame& processed_capture_frame,
1996 std::unique_ptr<AecDump::CaptureStreamInfo> stream_info) const {
1997 RTC_DCHECK(stream_info);
1998 RTC_DCHECK(aec_dump_);
1999
2000 stream_info->AddOutput(processed_capture_frame);
2001 aec_dump_->WriteCaptureStreamMessage(std::move(stream_info));
2002 }
2003
2004 void AudioProcessingImpl::PopulateStreamInfoWithConfig(
peah-webrtc 2017/05/04 06:19:08 This naming is a big ambiguous as we have WriteCon
aleloi 2017/05/04 08:56:40 I like PopulateStreamInfoWithState the most. Done.
2005 AecDump::CaptureStreamInfo* stream_info) const {
2006 RTC_DCHECK(stream_info);
2007
2008 stream_info->set_delay(capture_nonlocked_.stream_delay_ms);
peah-webrtc 2017/05/04 06:19:08 Would it be possible to instead bundle these 4 set
aleloi 2017/05/04 08:56:40 I'd rather not. The setter names serve as document
peah-webrtc 2017/05/04 10:57:51 I definitely like the documentation part. But this
2009 stream_info->set_drift(
2010 public_submodules_->echo_cancellation->stream_drift_samples());
2011 stream_info->set_level(gain_control()->stream_analog_level());
2012 stream_info->set_keypress(capture_.key_pressed);
2013 }
2014
1840 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 2015 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1841 int AudioProcessingImpl::WriteMessageToDebugFile( 2016 int AudioProcessingImpl::WriteMessageToDebugFile(
1842 FileWrapper* debug_file, 2017 FileWrapper* debug_file,
1843 int64_t* filesize_limit_bytes, 2018 int64_t* filesize_limit_bytes,
1844 rtc::CriticalSection* crit_debug, 2019 rtc::CriticalSection* crit_debug,
1845 ApmDebugDumpThreadState* debug_state) { 2020 ApmDebugDumpThreadState* debug_state) {
1846 int32_t size = debug_state->event_msg->ByteSize(); 2021 int32_t size = debug_state->event_msg->ByteSize();
1847 if (size <= 0) { 2022 if (size <= 0) {
1848 return kUnspecifiedError; 2023 return kUnspecifiedError;
1849 } 2024 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2003 previous_agc_level(0), 2178 previous_agc_level(0),
2004 echo_path_gain_change(false) {} 2179 echo_path_gain_change(false) {}
2005 2180
2006 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; 2181 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default;
2007 2182
2008 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; 2183 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default;
2009 2184
2010 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; 2185 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default;
2011 2186
2012 } // namespace webrtc 2187 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698