OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 Loading... | |
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 Loading... | |
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 Loading... | |
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 Loading... | |
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 Loading... | |
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::CritScope cs_render(&crit_render_); | |
1610 rtc::CritScope cs_capture(&crit_capture_); | |
1611 RTC_DCHECK(aec_dump); | |
the sun
2017/05/23 12:00:22
super nit: DCHECK before the locks
aleloi
2017/05/23 12:24:09
Done.
| |
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 apm_config_for_aec_dump_ = InternalAPMConfig(); | |
the sun
2017/05/23 12:00:22
Why? This variable is force-updated in AttachAecDu
aleloi
2017/05/23 12:24:09
Done.
| |
1630 } | |
1631 } | |
1632 | |
1565 int AudioProcessingImpl::StartDebugRecording( | 1633 int AudioProcessingImpl::StartDebugRecording( |
1566 const char filename[AudioProcessing::kMaxFilenameSize], | 1634 const char filename[AudioProcessing::kMaxFilenameSize], |
1567 int64_t max_log_size_bytes) { | 1635 int64_t max_log_size_bytes) { |
1568 // Run in a single-threaded manner. | 1636 // Run in a single-threaded manner. |
1569 rtc::CritScope cs_render(&crit_render_); | 1637 rtc::CritScope cs_render(&crit_render_); |
1570 rtc::CritScope cs_capture(&crit_capture_); | 1638 rtc::CritScope cs_capture(&crit_capture_); |
1571 static_assert(kMaxFilenameSize == FileWrapper::kMaxFileNameSize, ""); | 1639 static_assert(kMaxFilenameSize == FileWrapper::kMaxFileNameSize, ""); |
1572 | 1640 |
1573 if (filename == nullptr) { | 1641 if (filename == nullptr) { |
1574 return kNullPointerError; | 1642 return kNullPointerError; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1626 int AudioProcessingImpl::StartDebugRecordingForPlatformFile( | 1694 int AudioProcessingImpl::StartDebugRecordingForPlatformFile( |
1627 rtc::PlatformFile handle) { | 1695 rtc::PlatformFile handle) { |
1628 // Run in a single-threaded manner. | 1696 // Run in a single-threaded manner. |
1629 rtc::CritScope cs_render(&crit_render_); | 1697 rtc::CritScope cs_render(&crit_render_); |
1630 rtc::CritScope cs_capture(&crit_capture_); | 1698 rtc::CritScope cs_capture(&crit_capture_); |
1631 FILE* stream = rtc::FdopenPlatformFileForWriting(handle); | 1699 FILE* stream = rtc::FdopenPlatformFileForWriting(handle); |
1632 return StartDebugRecording(stream, -1); | 1700 return StartDebugRecording(stream, -1); |
1633 } | 1701 } |
1634 | 1702 |
1635 int AudioProcessingImpl::StopDebugRecording() { | 1703 int AudioProcessingImpl::StopDebugRecording() { |
1704 DetachAecDump(); | |
1705 | |
1706 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | |
1636 // Run in a single-threaded manner. | 1707 // Run in a single-threaded manner. |
1637 rtc::CritScope cs_render(&crit_render_); | 1708 rtc::CritScope cs_render(&crit_render_); |
1638 rtc::CritScope cs_capture(&crit_capture_); | 1709 rtc::CritScope cs_capture(&crit_capture_); |
1639 | |
1640 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | |
1641 // We just return if recording hasn't started. | 1710 // We just return if recording hasn't started. |
1642 debug_dump_.debug_file->CloseFile(); | 1711 debug_dump_.debug_file->CloseFile(); |
1643 return kNoError; | 1712 return kNoError; |
1644 #else | 1713 #else |
1645 return kUnsupportedFunctionError; | 1714 return kUnsupportedFunctionError; |
1646 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | 1715 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
1647 } | 1716 } |
1648 | 1717 |
1649 AudioProcessing::AudioProcessingStatistics::AudioProcessingStatistics() { | 1718 AudioProcessing::AudioProcessingStatistics::AudioProcessingStatistics() { |
1650 residual_echo_return_loss.Set(-100.0f, -100.0f, -100.0f, -100.0f); | 1719 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 Loading... | |
1891 capture_.last_stream_delay_ms = 0; | 1960 capture_.last_stream_delay_ms = 0; |
1892 | 1961 |
1893 if (capture_.aec_system_delay_jumps > -1) { | 1962 if (capture_.aec_system_delay_jumps > -1) { |
1894 RTC_HISTOGRAM_ENUMERATION("WebRTC.Audio.NumOfAecSystemDelayJumps", | 1963 RTC_HISTOGRAM_ENUMERATION("WebRTC.Audio.NumOfAecSystemDelayJumps", |
1895 capture_.aec_system_delay_jumps, 51); | 1964 capture_.aec_system_delay_jumps, 51); |
1896 } | 1965 } |
1897 capture_.aec_system_delay_jumps = -1; | 1966 capture_.aec_system_delay_jumps = -1; |
1898 capture_.last_aec_system_delay_ms = 0; | 1967 capture_.last_aec_system_delay_ms = 0; |
1899 } | 1968 } |
1900 | 1969 |
1970 void AudioProcessingImpl::WriteAecDumpConfigMessage(bool forced) { | |
1971 if (!aec_dump_) { | |
1972 return; | |
1973 } | |
1974 std::string experiments_description = | |
1975 public_submodules_->echo_cancellation->GetExperimentsDescription(); | |
1976 // TODO(peah): Add semicolon-separated concatenations of experiment | |
1977 // descriptions for other submodules. | |
1978 if (capture_nonlocked_.level_controller_enabled) { | |
1979 experiments_description += "LevelController;"; | |
1980 } | |
1981 if (constants_.agc_clipped_level_min != kClippedLevelMin) { | |
1982 experiments_description += "AgcClippingLevelExperiment;"; | |
1983 } | |
1984 if (capture_nonlocked_.echo_canceller3_enabled) { | |
1985 experiments_description += "EchoCanceller3;"; | |
1986 } | |
1987 | |
1988 InternalAPMConfig apm_config; | |
1989 | |
1990 apm_config.aec_enabled = public_submodules_->echo_cancellation->is_enabled(); | |
1991 apm_config.aec_delay_agnostic_enabled = | |
1992 public_submodules_->echo_cancellation->is_delay_agnostic_enabled(); | |
1993 apm_config.aec_drift_compensation_enabled = | |
1994 public_submodules_->echo_cancellation->is_drift_compensation_enabled(); | |
1995 apm_config.aec_extended_filter_enabled = | |
1996 public_submodules_->echo_cancellation->is_extended_filter_enabled(); | |
1997 apm_config.aec_suppression_level = static_cast<int>( | |
1998 public_submodules_->echo_cancellation->suppression_level()); | |
1999 | |
2000 apm_config.aecm_enabled = | |
2001 public_submodules_->echo_control_mobile->is_enabled(); | |
2002 apm_config.aecm_comfort_noise_enabled = | |
2003 public_submodules_->echo_control_mobile->is_comfort_noise_enabled(); | |
2004 apm_config.aecm_routing_mode = | |
2005 static_cast<int>(public_submodules_->echo_control_mobile->routing_mode()); | |
2006 | |
2007 apm_config.agc_enabled = public_submodules_->gain_control->is_enabled(); | |
2008 apm_config.agc_mode = | |
2009 static_cast<int>(public_submodules_->gain_control->mode()); | |
2010 apm_config.agc_limiter_enabled = | |
2011 public_submodules_->gain_control->is_limiter_enabled(); | |
2012 apm_config.noise_robust_agc_enabled = constants_.use_experimental_agc; | |
2013 | |
2014 apm_config.hpf_enabled = config_.high_pass_filter.enabled; | |
2015 | |
2016 apm_config.ns_enabled = public_submodules_->noise_suppression->is_enabled(); | |
2017 apm_config.ns_level = | |
2018 static_cast<int>(public_submodules_->noise_suppression->level()); | |
2019 | |
2020 apm_config.transient_suppression_enabled = | |
2021 capture_.transient_suppressor_enabled; | |
2022 apm_config.intelligibility_enhancer_enabled = | |
2023 capture_nonlocked_.intelligibility_enabled; | |
2024 apm_config.experiments_description = experiments_description; | |
2025 | |
2026 if (!forced && apm_config.Equals(apm_config_for_aec_dump_)) { | |
2027 return; | |
2028 } | |
2029 aec_dump_->WriteConfig(apm_config); | |
2030 apm_config_for_aec_dump_ = apm_config; | |
2031 } | |
2032 | |
2033 void AudioProcessingImpl::RecordUnprocessedCaptureStream( | |
2034 const float* const* src) { | |
2035 RTC_DCHECK(aec_dump_); | |
2036 WriteAecDumpConfigMessage(false); | |
2037 | |
2038 const size_t channel_size = formats_.api_format.input_stream().num_frames(); | |
2039 const size_t num_channels = formats_.api_format.input_stream().num_channels(); | |
2040 aec_dump_->AddCaptureStreamInput( | |
2041 FloatAudioFrame(src, num_channels, channel_size)); | |
2042 RecordAudioProcessingState(); | |
2043 } | |
2044 | |
2045 void AudioProcessingImpl::RecordUnprocessedCaptureStream( | |
2046 const AudioFrame& capture_frame) { | |
2047 RTC_DCHECK(aec_dump_); | |
2048 WriteAecDumpConfigMessage(false); | |
2049 | |
2050 aec_dump_->AddCaptureStreamInput(capture_frame); | |
2051 RecordAudioProcessingState(); | |
2052 } | |
2053 | |
2054 void AudioProcessingImpl::RecordProcessedCaptureStream( | |
2055 const float* const* processed_capture_stream) { | |
2056 RTC_DCHECK(aec_dump_); | |
2057 | |
2058 const size_t channel_size = formats_.api_format.output_stream().num_frames(); | |
2059 const size_t num_channels = | |
2060 formats_.api_format.output_stream().num_channels(); | |
2061 aec_dump_->AddCaptureStreamOutput( | |
2062 FloatAudioFrame(processed_capture_stream, num_channels, channel_size)); | |
2063 aec_dump_->WriteCaptureStreamMessage(); | |
2064 } | |
2065 | |
2066 void AudioProcessingImpl::RecordProcessedCaptureStream( | |
2067 const AudioFrame& processed_capture_frame) { | |
2068 RTC_DCHECK(aec_dump_); | |
2069 | |
2070 aec_dump_->AddCaptureStreamOutput(processed_capture_frame); | |
2071 aec_dump_->WriteCaptureStreamMessage(); | |
2072 } | |
2073 | |
2074 void AudioProcessingImpl::RecordAudioProcessingState() { | |
2075 RTC_DCHECK(aec_dump_); | |
2076 AecDump::AudioProcessingState audio_proc_state; | |
2077 audio_proc_state.delay = capture_nonlocked_.stream_delay_ms; | |
2078 audio_proc_state.drift = | |
2079 public_submodules_->echo_cancellation->stream_drift_samples(); | |
2080 audio_proc_state.level = gain_control()->stream_analog_level(); | |
2081 audio_proc_state.keypress = capture_.key_pressed; | |
2082 aec_dump_->AddAudioProcessingState(audio_proc_state); | |
2083 } | |
2084 | |
1901 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 2085 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
1902 int AudioProcessingImpl::WriteMessageToDebugFile( | 2086 int AudioProcessingImpl::WriteMessageToDebugFile( |
1903 FileWrapper* debug_file, | 2087 FileWrapper* debug_file, |
1904 int64_t* filesize_limit_bytes, | 2088 int64_t* filesize_limit_bytes, |
1905 rtc::CriticalSection* crit_debug, | 2089 rtc::CriticalSection* crit_debug, |
1906 ApmDebugDumpThreadState* debug_state) { | 2090 ApmDebugDumpThreadState* debug_state) { |
1907 int32_t size = debug_state->event_msg->ByteSize(); | 2091 int32_t size = debug_state->event_msg->ByteSize(); |
1908 if (size <= 0) { | 2092 if (size <= 0) { |
1909 return kUnspecifiedError; | 2093 return kUnspecifiedError; |
1910 } | 2094 } |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2064 previous_agc_level(0), | 2248 previous_agc_level(0), |
2065 echo_path_gain_change(false) {} | 2249 echo_path_gain_change(false) {} |
2066 | 2250 |
2067 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; | 2251 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; |
2068 | 2252 |
2069 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; | 2253 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; |
2070 | 2254 |
2071 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; | 2255 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; |
2072 | 2256 |
2073 } // namespace webrtc | 2257 } // namespace webrtc |
OLD | NEW |