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

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

Issue 2838133003: Implementation of new AecDump interface. (Closed)
Patch Set: Changed CaptureStreamInfo behaviour. 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 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 debug_dump_.capture.event_msg->set_type(audioproc::Event::STREAM); 836 debug_dump_.capture.event_msg->set_type(audioproc::Event::STREAM);
837 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream(); 837 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream();
838 const size_t channel_size = 838 const size_t channel_size =
839 sizeof(float) * formats_.api_format.input_stream().num_frames(); 839 sizeof(float) * formats_.api_format.input_stream().num_frames();
840 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();
841 ++i) 841 ++i)
842 msg->add_input_channel(src[i], channel_size); 842 msg->add_input_channel(src[i], channel_size);
843 } 843 }
844 #endif 844 #endif
845 845
846 std::unique_ptr<AecDump::CaptureStreamInfo> stream_info; 846 AecDump::CaptureStreamInfo* stream_info;
847 if (aec_dump_) { 847 if (aec_dump_) {
848 stream_info = RecordUnprocessedCaptureStream(src); 848 stream_info = RecordUnprocessedCaptureStream(src);
849 } 849 }
850 850
851 capture_.capture_audio->CopyFrom(src, formats_.api_format.input_stream()); 851 capture_.capture_audio->CopyFrom(src, formats_.api_format.input_stream());
852 RETURN_ON_ERR(ProcessCaptureStreamLocked()); 852 RETURN_ON_ERR(ProcessCaptureStreamLocked());
853 capture_.capture_audio->CopyTo(formats_.api_format.output_stream(), dest); 853 capture_.capture_audio->CopyTo(formats_.api_format.output_stream(), dest);
854 854
855 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 855 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
856 if (debug_dump_.debug_file->is_open()) { 856 if (debug_dump_.debug_file->is_open()) {
857 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream(); 857 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream();
858 const size_t channel_size = 858 const size_t channel_size =
859 sizeof(float) * formats_.api_format.output_stream().num_frames(); 859 sizeof(float) * formats_.api_format.output_stream().num_frames();
860 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();
861 ++i) 861 ++i)
862 msg->add_output_channel(dest[i], channel_size); 862 msg->add_output_channel(dest[i], channel_size);
863 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 863 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
864 &debug_dump_.num_bytes_left_for_log_, 864 &debug_dump_.num_bytes_left_for_log_,
865 &crit_debug_, &debug_dump_.capture)); 865 &crit_debug_, &debug_dump_.capture));
866 } 866 }
867 #endif 867 #endif
868 if (aec_dump_) { 868 if (aec_dump_) {
869 RecordProcessedCaptureStream(dest, std::move(stream_info)); 869 RecordProcessedCaptureStream(dest, stream_info);
870 } 870 }
871 return kNoError; 871 return kNoError;
872 } 872 }
873 873
874 void AudioProcessingImpl::QueueRenderAudio(AudioBuffer* audio) { 874 void AudioProcessingImpl::QueueRenderAudio(AudioBuffer* audio) {
875 EchoCancellationImpl::PackRenderAudioBuffer(audio, num_output_channels(), 875 EchoCancellationImpl::PackRenderAudioBuffer(audio, num_output_channels(),
876 num_reverse_channels(), 876 num_reverse_channels(),
877 &aec_render_queue_buffer_); 877 &aec_render_queue_buffer_);
878 878
879 RTC_DCHECK_GE(160, audio->num_frames_per_band()); 879 RTC_DCHECK_GE(160, audio->num_frames_per_band());
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 rtc::CritScope cs_render(&crit_render_); 1097 rtc::CritScope cs_render(&crit_render_);
1098 RETURN_ON_ERR( 1098 RETURN_ON_ERR(
1099 MaybeInitializeCapture(processing_config, reinitialization_required)); 1099 MaybeInitializeCapture(processing_config, reinitialization_required));
1100 } 1100 }
1101 rtc::CritScope cs_capture(&crit_capture_); 1101 rtc::CritScope cs_capture(&crit_capture_);
1102 if (frame->samples_per_channel_ != 1102 if (frame->samples_per_channel_ !=
1103 formats_.api_format.input_stream().num_frames()) { 1103 formats_.api_format.input_stream().num_frames()) {
1104 return kBadDataLengthError; 1104 return kBadDataLengthError;
1105 } 1105 }
1106 1106
1107 std::unique_ptr<AecDump::CaptureStreamInfo> stream_info; 1107 AecDump::CaptureStreamInfo* stream_info;
1108 if (aec_dump_) { 1108 if (aec_dump_) {
1109 stream_info = RecordUnprocessedCaptureStream(*frame); 1109 stream_info = RecordUnprocessedCaptureStream(*frame);
1110 } 1110 }
1111 1111
1112 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 1112 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1113 if (debug_dump_.debug_file->is_open()) { 1113 if (debug_dump_.debug_file->is_open()) {
1114 RETURN_ON_ERR(WriteConfigMessage(false)); 1114 RETURN_ON_ERR(WriteConfigMessage(false));
1115 1115
1116 debug_dump_.capture.event_msg->set_type(audioproc::Event::STREAM); 1116 debug_dump_.capture.event_msg->set_type(audioproc::Event::STREAM);
1117 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream(); 1117 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream();
1118 const size_t data_size = 1118 const size_t data_size =
1119 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_; 1119 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_;
1120 msg->set_input_data(frame->data_, data_size); 1120 msg->set_input_data(frame->data_, data_size);
1121 } 1121 }
1122 #endif 1122 #endif
1123 1123
1124 capture_.capture_audio->DeinterleaveFrom(frame); 1124 capture_.capture_audio->DeinterleaveFrom(frame);
1125 RETURN_ON_ERR(ProcessCaptureStreamLocked()); 1125 RETURN_ON_ERR(ProcessCaptureStreamLocked());
1126 capture_.capture_audio->InterleaveTo( 1126 capture_.capture_audio->InterleaveTo(
1127 frame, submodule_states_.CaptureMultiBandProcessingActive()); 1127 frame, submodule_states_.CaptureMultiBandProcessingActive());
1128 1128
1129 if (aec_dump_) { 1129 if (aec_dump_) {
1130 RecordProcessedCaptureStream(*frame, std::move(stream_info)); 1130 RecordProcessedCaptureStream(*frame, stream_info);
1131 } 1131 }
1132 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 1132 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1133 if (debug_dump_.debug_file->is_open()) { 1133 if (debug_dump_.debug_file->is_open()) {
1134 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream(); 1134 audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream();
1135 const size_t data_size = 1135 const size_t data_size =
1136 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_; 1136 sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_;
1137 msg->set_output_data(frame->data_, data_size); 1137 msg->set_output_data(frame->data_, data_size);
1138 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1138 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1139 &debug_dump_.num_bytes_left_for_log_, 1139 &debug_dump_.num_bytes_left_for_log_,
1140 &crit_debug_, &debug_dump_.capture)); 1140 &crit_debug_, &debug_dump_.capture));
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 static_cast<int>(public_submodules_->noise_suppression->level()); 1947 static_cast<int>(public_submodules_->noise_suppression->level());
1948 1948
1949 apm_config.transient_suppression_enabled = 1949 apm_config.transient_suppression_enabled =
1950 capture_.transient_suppressor_enabled; 1950 capture_.transient_suppressor_enabled;
1951 apm_config.intelligibility_enhancer_enabled = 1951 apm_config.intelligibility_enhancer_enabled =
1952 capture_nonlocked_.intelligibility_enabled; 1952 capture_nonlocked_.intelligibility_enabled;
1953 apm_config.experiments_description = experiments_description; 1953 apm_config.experiments_description = experiments_description;
1954 return apm_config; 1954 return apm_config;
1955 } 1955 }
1956 1956
1957 std::unique_ptr<AecDump::CaptureStreamInfo> 1957 AecDump::CaptureStreamInfo* AudioProcessingImpl::RecordUnprocessedCaptureStream(
1958 AudioProcessingImpl::RecordUnprocessedCaptureStream(
1959 const float* const* src) const { 1958 const float* const* src) const {
1960 RTC_DCHECK(aec_dump_); 1959 RTC_DCHECK(aec_dump_);
1961 aec_dump_->WriteConfig(CollectApmConfig(), false); 1960 aec_dump_->WriteConfig(CollectApmConfig(), false);
1962 auto stream_info = aec_dump_->CreateCaptureStreamInfo(); 1961 auto* stream_info = aec_dump_->GetCaptureStreamInfo();
1963 RTC_DCHECK(stream_info); 1962 RTC_DCHECK(stream_info);
1964 1963
1965 const size_t channel_size = formats_.api_format.input_stream().num_frames(); 1964 const size_t channel_size = formats_.api_format.input_stream().num_frames();
1966 const size_t num_channels = formats_.api_format.input_stream().num_channels(); 1965 const size_t num_channels = formats_.api_format.input_stream().num_channels();
1967 stream_info->AddInput(FloatAudioFrame(src, num_channels, channel_size)); 1966 stream_info->AddInput(FloatAudioFrame(src, num_channels, channel_size));
1968 PopulateStreamInfoWithState(stream_info.get()); 1967 PopulateStreamInfoWithState(stream_info);
1969 return stream_info; 1968 return stream_info;
1970 } 1969 }
1971 1970
1972 std::unique_ptr<AecDump::CaptureStreamInfo> 1971 AecDump::CaptureStreamInfo* AudioProcessingImpl::RecordUnprocessedCaptureStream(
1973 AudioProcessingImpl::RecordUnprocessedCaptureStream(
1974 const AudioFrame& capture_frame) const { 1972 const AudioFrame& capture_frame) const {
1975 RTC_DCHECK(aec_dump_); 1973 RTC_DCHECK(aec_dump_);
1976 auto stream_info = aec_dump_->CreateCaptureStreamInfo(); 1974 auto* stream_info = aec_dump_->GetCaptureStreamInfo();
1977 RTC_DCHECK(stream_info); 1975 RTC_DCHECK(stream_info);
1978 1976
1979 stream_info->AddInput(capture_frame); 1977 stream_info->AddInput(capture_frame);
1980 PopulateStreamInfoWithState(stream_info.get()); 1978 PopulateStreamInfoWithState(stream_info);
1981 aec_dump_->WriteConfig(CollectApmConfig(), false); 1979 aec_dump_->WriteConfig(CollectApmConfig(), false);
1982 return stream_info; 1980 return stream_info;
1983 } 1981 }
1984 1982
1985 void AudioProcessingImpl::RecordProcessedCaptureStream( 1983 void AudioProcessingImpl::RecordProcessedCaptureStream(
1986 const float* const* processed_capture_stream, 1984 const float* const* processed_capture_stream,
1987 std::unique_ptr<AecDump::CaptureStreamInfo> stream_info) const { 1985 AecDump::CaptureStreamInfo* stream_info) const {
1988 RTC_DCHECK(stream_info); 1986 RTC_DCHECK(stream_info);
1989 RTC_DCHECK(aec_dump_); 1987 RTC_DCHECK(aec_dump_);
1990 1988
1991 const size_t channel_size = formats_.api_format.output_stream().num_frames(); 1989 const size_t channel_size = formats_.api_format.output_stream().num_frames();
1992 const size_t num_channels = 1990 const size_t num_channels =
1993 formats_.api_format.output_stream().num_channels(); 1991 formats_.api_format.output_stream().num_channels();
1994 stream_info->AddOutput( 1992 stream_info->AddOutput(
1995 FloatAudioFrame(processed_capture_stream, num_channels, channel_size)); 1993 FloatAudioFrame(processed_capture_stream, num_channels, channel_size));
1996 aec_dump_->WriteCaptureStreamMessage(std::move(stream_info)); 1994 aec_dump_->WriteCaptureStreamMessage();
1997 } 1995 }
1998 1996
1999 void AudioProcessingImpl::RecordProcessedCaptureStream( 1997 void AudioProcessingImpl::RecordProcessedCaptureStream(
2000 const AudioFrame& processed_capture_frame, 1998 const AudioFrame& processed_capture_frame,
2001 std::unique_ptr<AecDump::CaptureStreamInfo> stream_info) const { 1999 AecDump::CaptureStreamInfo* stream_info) const {
2002 RTC_DCHECK(stream_info); 2000 RTC_DCHECK(stream_info);
2003 RTC_DCHECK(aec_dump_); 2001 RTC_DCHECK(aec_dump_);
2004 2002
2005 stream_info->AddOutput(processed_capture_frame); 2003 stream_info->AddOutput(processed_capture_frame);
2006 aec_dump_->WriteCaptureStreamMessage(std::move(stream_info)); 2004 aec_dump_->WriteCaptureStreamMessage();
2007 } 2005 }
2008 2006
2009 void AudioProcessingImpl::PopulateStreamInfoWithState( 2007 void AudioProcessingImpl::PopulateStreamInfoWithState(
2010 AecDump::CaptureStreamInfo* stream_info) const { 2008 AecDump::CaptureStreamInfo* stream_info) const {
2011 RTC_DCHECK(stream_info); 2009 RTC_DCHECK(stream_info);
2012 2010
2013 stream_info->set_delay(capture_nonlocked_.stream_delay_ms); 2011 stream_info->set_delay(capture_nonlocked_.stream_delay_ms);
2014 stream_info->set_drift( 2012 stream_info->set_drift(
2015 public_submodules_->echo_cancellation->stream_drift_samples()); 2013 public_submodules_->echo_cancellation->stream_drift_samples());
2016 stream_info->set_level(gain_control()->stream_analog_level()); 2014 stream_info->set_level(gain_control()->stream_analog_level());
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2183 previous_agc_level(0), 2181 previous_agc_level(0),
2184 echo_path_gain_change(false) {} 2182 echo_path_gain_change(false) {}
2185 2183
2186 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; 2184 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default;
2187 2185
2188 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; 2186 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default;
2189 2187
2190 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; 2188 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default;
2191 2189
2192 } // namespace webrtc 2190 } // 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