2015-11-06 15:34:49 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "audio/audio_state.h"
|
2015-11-06 15:34:49 -08:00
|
|
|
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
#include <algorithm>
|
|
|
|
|
#include <utility>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_device/include/audio_device.h"
|
|
|
|
|
#include "rtc_base/atomicops.h"
|
|
|
|
|
#include "rtc_base/checks.h"
|
|
|
|
|
#include "rtc_base/logging.h"
|
2017-11-01 11:06:56 +01:00
|
|
|
#include "rtc_base/ptr_util.h"
|
|
|
|
|
#include "rtc_base/thread.h"
|
2015-11-06 15:34:49 -08:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
|
|
AudioState::AudioState(const AudioState::Config& config)
|
2016-11-17 06:28:59 -08:00
|
|
|
: config_(config),
|
|
|
|
|
voe_base_(config.voice_engine),
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
audio_transport_(config_.audio_mixer,
|
|
|
|
|
config_.audio_processing.get(),
|
|
|
|
|
config_.audio_device_module.get()) {
|
2015-11-06 15:34:49 -08:00
|
|
|
process_thread_checker_.DetachFromThread();
|
2016-11-17 06:48:48 -08:00
|
|
|
RTC_DCHECK(config_.audio_mixer);
|
2015-11-06 15:34:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AudioState::~AudioState() {
|
|
|
|
|
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
RTC_DCHECK(sending_streams_.empty());
|
2015-11-06 15:34:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VoiceEngine* AudioState::voice_engine() {
|
|
|
|
|
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
|
|
return config_.voice_engine;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-17 06:28:59 -08:00
|
|
|
rtc::scoped_refptr<AudioMixer> AudioState::mixer() {
|
2016-11-17 06:48:48 -08:00
|
|
|
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
2016-11-17 06:28:59 -08:00
|
|
|
return config_.audio_mixer;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-06 15:34:49 -08:00
|
|
|
bool AudioState::typing_noise_detected() const {
|
|
|
|
|
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
return audio_transport_.typing_noise_detected();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioState::AddSendingStream(webrtc::AudioSendStream* stream,
|
|
|
|
|
int sample_rate_hz, size_t num_channels) {
|
|
|
|
|
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
|
|
auto& properties = sending_streams_[stream];
|
|
|
|
|
properties.sample_rate_hz = sample_rate_hz;
|
|
|
|
|
properties.num_channels = num_channels;
|
|
|
|
|
UpdateAudioTransportWithSendingStreams();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioState::RemoveSendingStream(webrtc::AudioSendStream* stream) {
|
|
|
|
|
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
|
|
auto count = sending_streams_.erase(stream);
|
|
|
|
|
RTC_DCHECK_EQ(1, count);
|
|
|
|
|
UpdateAudioTransportWithSendingStreams();
|
2015-11-06 15:34:49 -08:00
|
|
|
}
|
|
|
|
|
|
2017-11-01 11:06:56 +01:00
|
|
|
void AudioState::SetPlayout(bool enabled) {
|
2017-11-09 11:09:25 +01:00
|
|
|
RTC_LOG(INFO) << "SetPlayout(" << enabled << ")";
|
2017-11-01 11:06:56 +01:00
|
|
|
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
|
|
const bool currently_enabled = (null_audio_poller_ == nullptr);
|
|
|
|
|
if (enabled == currently_enabled) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (enabled) {
|
|
|
|
|
null_audio_poller_.reset();
|
|
|
|
|
}
|
|
|
|
|
// Will stop/start playout of the underlying device, if necessary, and
|
|
|
|
|
// remember the setting for when it receives subsequent calls of
|
|
|
|
|
// StartPlayout.
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
voe_base_->SetPlayout(enabled);
|
2017-11-01 11:06:56 +01:00
|
|
|
if (!enabled) {
|
|
|
|
|
null_audio_poller_ =
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
rtc::MakeUnique<NullAudioPoller>(&audio_transport_);
|
2017-11-01 11:06:56 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioState::SetRecording(bool enabled) {
|
2017-11-09 11:09:25 +01:00
|
|
|
RTC_LOG(INFO) << "SetRecording(" << enabled << ")";
|
2017-11-01 11:06:56 +01:00
|
|
|
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
|
|
// TODO(henrika): keep track of state as in SetPlayout().
|
|
|
|
|
// Will stop/start recording of the underlying device, if necessary, and
|
|
|
|
|
// remember the setting for when it receives subsequent calls of
|
|
|
|
|
// StartPlayout.
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
voe_base_->SetRecording(enabled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AudioState::Stats AudioState::GetAudioInputStats() const {
|
|
|
|
|
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
|
|
const voe::AudioLevel& audio_level = audio_transport_.audio_level();
|
|
|
|
|
Stats result;
|
|
|
|
|
result.audio_level = audio_level.LevelFullRange();
|
|
|
|
|
RTC_DCHECK_LE(0, result.audio_level);
|
|
|
|
|
RTC_DCHECK_GE(32767, result.audio_level);
|
|
|
|
|
result.quantized_audio_level = audio_level.Level();
|
|
|
|
|
RTC_DCHECK_LE(0, result.quantized_audio_level);
|
|
|
|
|
RTC_DCHECK_GE(9, result.quantized_audio_level);
|
|
|
|
|
result.total_energy = audio_level.TotalEnergy();
|
|
|
|
|
result.total_duration = audio_level.TotalDuration();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioState::SetStereoChannelSwapping(bool enable) {
|
|
|
|
|
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
|
|
audio_transport_.SetStereoChannelSwapping(enable);
|
2017-11-01 11:06:56 +01:00
|
|
|
}
|
|
|
|
|
|
2015-11-06 15:34:49 -08:00
|
|
|
// Reference count; implementation copied from rtc::RefCountedObject.
|
2017-10-19 13:15:17 +02:00
|
|
|
void AudioState::AddRef() const {
|
|
|
|
|
rtc::AtomicOps::Increment(&ref_count_);
|
2015-11-06 15:34:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reference count; implementation copied from rtc::RefCountedObject.
|
2017-10-19 13:15:17 +02:00
|
|
|
rtc::RefCountReleaseStatus AudioState::Release() const {
|
|
|
|
|
if (rtc::AtomicOps::Decrement(&ref_count_) == 0) {
|
2015-11-06 15:34:49 -08:00
|
|
|
delete this;
|
2017-10-19 13:15:17 +02:00
|
|
|
return rtc::RefCountReleaseStatus::kDroppedLastRef;
|
2015-11-06 15:34:49 -08:00
|
|
|
}
|
2017-10-19 13:15:17 +02:00
|
|
|
return rtc::RefCountReleaseStatus::kOtherRefsRemained;
|
2015-11-06 15:34:49 -08:00
|
|
|
}
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
|
|
|
|
|
void AudioState::UpdateAudioTransportWithSendingStreams() {
|
|
|
|
|
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
|
|
std::vector<AudioSendStream*> sending_streams;
|
|
|
|
|
int max_sample_rate_hz = 8000;
|
|
|
|
|
size_t max_num_channels = 1;
|
|
|
|
|
for (const auto& kv : sending_streams_) {
|
|
|
|
|
sending_streams.push_back(kv.first);
|
|
|
|
|
max_sample_rate_hz = std::max(max_sample_rate_hz, kv.second.sample_rate_hz);
|
|
|
|
|
max_num_channels = std::max(max_num_channels, kv.second.num_channels);
|
|
|
|
|
}
|
|
|
|
|
audio_transport_.UpdateSendingStreams(std::move(sending_streams),
|
|
|
|
|
max_sample_rate_hz, max_num_channels);
|
|
|
|
|
}
|
2015-11-06 15:34:49 -08:00
|
|
|
} // namespace internal
|
|
|
|
|
|
|
|
|
|
rtc::scoped_refptr<AudioState> AudioState::Create(
|
|
|
|
|
const AudioState::Config& config) {
|
|
|
|
|
return rtc::scoped_refptr<AudioState>(new internal::AudioState(config));
|
|
|
|
|
}
|
|
|
|
|
} // namespace webrtc
|