Chromium Code Reviews| Index: webrtc/audio/audio_transport_proxy.h |
| diff --git a/webrtc/audio/audio_transport_proxy.h b/webrtc/audio/audio_transport_proxy.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..35cb4c5eeae043c6d3ea292ccf0d1227c612fc67 |
| --- /dev/null |
| +++ b/webrtc/audio/audio_transport_proxy.h |
| @@ -0,0 +1,129 @@ |
| +/* |
| + * Copyright (c) 2016 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. |
| + */ |
| + |
| +#ifndef WEBRTC_AUDIO_AUDIO_TRANSPORT_PROXY_H_ |
| +#define WEBRTC_AUDIO_AUDIO_TRANSPORT_PROXY_H_ |
| + |
| +#include "webrtc/api/audio/audio_mixer.h" |
| +#include "webrtc/base/constructormagic.h" |
| +#include "webrtc/modules/audio_device/include/audio_device_defines.h" |
| +#include "webrtc/modules/audio_processing/include/audio_processing.h" |
| + |
| +namespace webrtc { |
| + |
| +class AudioTransportProxy : public AudioTransport { |
| + public: |
| + AudioTransportProxy(AudioTransport* voe_audio_transport, |
|
the sun
2016/11/09 09:41:52
Make a .cc file for this - this is too much implem
aleloi
2016/11/09 16:37:00
I've already done it in the dependent CL https://c
|
| + AudioProcessing* apm, |
|
the sun
2016/11/09 09:41:53
So, hooking up APM and mixer will be in a follow-u
aleloi
2016/11/09 16:37:01
I have a check for the mixer in the next dependent
|
| + AudioMixer* mixer) |
| + : voe_audio_transport_(voe_audio_transport) {} |
| + |
| + ~AudioTransportProxy() override {} |
| + |
| + int32_t RecordedDataIsAvailable(const void* audioSamples, |
| + const size_t nSamples, |
| + const size_t nBytesPerSample, |
| + const size_t nChannels, |
| + const uint32_t samplesPerSec, |
| + const uint32_t totalDelayMS, |
| + const int32_t clockDrift, |
| + const uint32_t currentMicLevel, |
| + const bool keyPressed, |
| + uint32_t& newMicLevel) override { |
| + // Pass call through to original audio transport instance. |
| + if (voe_audio_transport_) { |
|
the sun
2016/11/09 09:41:53
So this is to not have to set up the transport in
aleloi
2016/11/09 16:37:00
Acknowledged.
|
| + return voe_audio_transport_->RecordedDataIsAvailable( |
| + audioSamples, nSamples, nBytesPerSample, nChannels, samplesPerSec, |
| + totalDelayMS, clockDrift, currentMicLevel, keyPressed, newMicLevel); |
| + } |
| + |
| + RTC_NOTREACHED() |
| + << "AudioTransport proxy doesn't know where to send recorded data: " |
| + "no Audio Transport provided."; |
| + return -1; |
| + } |
| + |
| + int32_t NeedMorePlayData(const size_t nSamples, |
| + const size_t nBytesPerSample, |
| + const size_t nChannels, |
| + const uint32_t samplesPerSec, |
| + void* audioSamples, |
| + size_t& nSamplesOut, |
| + int64_t* elapsed_time_ms, |
| + int64_t* ntp_time_ms) override { |
| + RTC_DCHECK_EQ(sizeof(int16_t) * nChannels, nBytesPerSample); |
| + RTC_DCHECK_GE(nChannels, 1u); |
| + RTC_DCHECK_LE(nChannels, 2u); |
| + RTC_DCHECK_GE( |
| + samplesPerSec, |
| + static_cast<uint32_t>(AudioProcessing::NativeRate::kSampleRate8kHz)); |
| + RTC_DCHECK_EQ(nSamples * 100, samplesPerSec); |
| + RTC_DCHECK_LE(nBytesPerSample * nSamples * nChannels, |
| + sizeof(AudioFrame::data_)); |
| + |
| + // Pass call through to original audio transport instance. |
| + if (voe_audio_transport_) { |
| + return voe_audio_transport_->NeedMorePlayData( |
| + nSamples, nBytesPerSample, nChannels, samplesPerSec, audioSamples, |
| + nSamplesOut, elapsed_time_ms, ntp_time_ms); |
| + } |
| + |
| + RTC_NOTREACHED() |
| + << "AudioTransport proxy doesn't know from where to get play data: " |
| + "no Audio Transport provided."; |
| + return -1; |
| + } |
| + |
| + void PushCaptureData(int voe_channel, |
| + const void* audio_data, |
| + int bits_per_sample, |
| + int sample_rate, |
| + size_t number_of_channels, |
| + size_t number_of_frames) override { |
| + // This is part of deprecated VoE interface operating on specific |
| + // VoE channels. It should not be used. |
| + RTC_NOTREACHED(); |
| + } |
| + |
| + void PullRenderData(int bits_per_sample, |
| + int sample_rate, |
| + size_t number_of_channels, |
| + size_t number_of_frames, |
| + void* audio_data, |
| + int64_t* elapsed_time_ms, |
| + int64_t* ntp_time_ms) override { |
| + RTC_DCHECK_EQ(static_cast<size_t>(bits_per_sample), 8 * sizeof(int16_t)); |
| + RTC_DCHECK_GE(number_of_channels, 1u); |
| + RTC_DCHECK_LE(number_of_channels, 2u); |
| + RTC_DCHECK_GE(static_cast<int>(sample_rate), |
| + AudioProcessing::NativeRate::kSampleRate8kHz); |
| + RTC_DCHECK_EQ(static_cast<int>(number_of_frames * 100), sample_rate); |
| + RTC_DCHECK_LE(bits_per_sample / 8 * number_of_frames * number_of_channels, |
| + sizeof(AudioFrame::data_)); |
| + if (voe_audio_transport_) { |
| + return voe_audio_transport_->PullRenderData( |
| + bits_per_sample, sample_rate, number_of_channels, number_of_frames, |
| + audio_data, elapsed_time_ms, ntp_time_ms); |
| + } |
| + |
| + RTC_NOTREACHED() |
| + << "AudioTransport proxy doesn't know from where to get play data: " |
| + "no Audio Transport provided."; |
| + } |
| + |
| + private: |
| + AudioTransport* voe_audio_transport_; |
| + AudioFrame frame_for_mixing_; |
| + |
| + RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AudioTransportProxy); |
| +}; |
| +} // namespace webrtc |
| + |
| +#endif // WEBRTC_AUDIO_AUDIO_TRANSPORT_PROXY_H_ |