OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_AUDIO_AUDIO_TRANSPORT_PROXY_H_ | |
12 #define WEBRTC_AUDIO_AUDIO_TRANSPORT_PROXY_H_ | |
13 | |
14 #include "webrtc/api/audio/audio_mixer.h" | |
15 #include "webrtc/base/constructormagic.h" | |
16 #include "webrtc/modules/audio_device/include/audio_device_defines.h" | |
17 #include "webrtc/modules/audio_processing/include/audio_processing.h" | |
18 | |
19 namespace webrtc { | |
20 | |
21 class AudioTransportProxy : public AudioTransport { | |
22 public: | |
23 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
| |
24 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
| |
25 AudioMixer* mixer) | |
26 : voe_audio_transport_(voe_audio_transport) {} | |
27 | |
28 ~AudioTransportProxy() override {} | |
29 | |
30 int32_t RecordedDataIsAvailable(const void* audioSamples, | |
31 const size_t nSamples, | |
32 const size_t nBytesPerSample, | |
33 const size_t nChannels, | |
34 const uint32_t samplesPerSec, | |
35 const uint32_t totalDelayMS, | |
36 const int32_t clockDrift, | |
37 const uint32_t currentMicLevel, | |
38 const bool keyPressed, | |
39 uint32_t& newMicLevel) override { | |
40 // Pass call through to original audio transport instance. | |
41 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.
| |
42 return voe_audio_transport_->RecordedDataIsAvailable( | |
43 audioSamples, nSamples, nBytesPerSample, nChannels, samplesPerSec, | |
44 totalDelayMS, clockDrift, currentMicLevel, keyPressed, newMicLevel); | |
45 } | |
46 | |
47 RTC_NOTREACHED() | |
48 << "AudioTransport proxy doesn't know where to send recorded data: " | |
49 "no Audio Transport provided."; | |
50 return -1; | |
51 } | |
52 | |
53 int32_t NeedMorePlayData(const size_t nSamples, | |
54 const size_t nBytesPerSample, | |
55 const size_t nChannels, | |
56 const uint32_t samplesPerSec, | |
57 void* audioSamples, | |
58 size_t& nSamplesOut, | |
59 int64_t* elapsed_time_ms, | |
60 int64_t* ntp_time_ms) override { | |
61 RTC_DCHECK_EQ(sizeof(int16_t) * nChannels, nBytesPerSample); | |
62 RTC_DCHECK_GE(nChannels, 1u); | |
63 RTC_DCHECK_LE(nChannels, 2u); | |
64 RTC_DCHECK_GE( | |
65 samplesPerSec, | |
66 static_cast<uint32_t>(AudioProcessing::NativeRate::kSampleRate8kHz)); | |
67 RTC_DCHECK_EQ(nSamples * 100, samplesPerSec); | |
68 RTC_DCHECK_LE(nBytesPerSample * nSamples * nChannels, | |
69 sizeof(AudioFrame::data_)); | |
70 | |
71 // Pass call through to original audio transport instance. | |
72 if (voe_audio_transport_) { | |
73 return voe_audio_transport_->NeedMorePlayData( | |
74 nSamples, nBytesPerSample, nChannels, samplesPerSec, audioSamples, | |
75 nSamplesOut, elapsed_time_ms, ntp_time_ms); | |
76 } | |
77 | |
78 RTC_NOTREACHED() | |
79 << "AudioTransport proxy doesn't know from where to get play data: " | |
80 "no Audio Transport provided."; | |
81 return -1; | |
82 } | |
83 | |
84 void PushCaptureData(int voe_channel, | |
85 const void* audio_data, | |
86 int bits_per_sample, | |
87 int sample_rate, | |
88 size_t number_of_channels, | |
89 size_t number_of_frames) override { | |
90 // This is part of deprecated VoE interface operating on specific | |
91 // VoE channels. It should not be used. | |
92 RTC_NOTREACHED(); | |
93 } | |
94 | |
95 void PullRenderData(int bits_per_sample, | |
96 int sample_rate, | |
97 size_t number_of_channels, | |
98 size_t number_of_frames, | |
99 void* audio_data, | |
100 int64_t* elapsed_time_ms, | |
101 int64_t* ntp_time_ms) override { | |
102 RTC_DCHECK_EQ(static_cast<size_t>(bits_per_sample), 8 * sizeof(int16_t)); | |
103 RTC_DCHECK_GE(number_of_channels, 1u); | |
104 RTC_DCHECK_LE(number_of_channels, 2u); | |
105 RTC_DCHECK_GE(static_cast<int>(sample_rate), | |
106 AudioProcessing::NativeRate::kSampleRate8kHz); | |
107 RTC_DCHECK_EQ(static_cast<int>(number_of_frames * 100), sample_rate); | |
108 RTC_DCHECK_LE(bits_per_sample / 8 * number_of_frames * number_of_channels, | |
109 sizeof(AudioFrame::data_)); | |
110 if (voe_audio_transport_) { | |
111 return voe_audio_transport_->PullRenderData( | |
112 bits_per_sample, sample_rate, number_of_channels, number_of_frames, | |
113 audio_data, elapsed_time_ms, ntp_time_ms); | |
114 } | |
115 | |
116 RTC_NOTREACHED() | |
117 << "AudioTransport proxy doesn't know from where to get play data: " | |
118 "no Audio Transport provided."; | |
119 } | |
120 | |
121 private: | |
122 AudioTransport* voe_audio_transport_; | |
123 AudioFrame frame_for_mixing_; | |
124 | |
125 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AudioTransportProxy); | |
126 }; | |
127 } // namespace webrtc | |
128 | |
129 #endif // WEBRTC_AUDIO_AUDIO_TRANSPORT_PROXY_H_ | |
OLD | NEW |