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, | |
24 AudioProcessing* apm, | |
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_) { | |
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_LE(1u, nChannels); | |
ossu
2016/11/03 14:02:04
I'd prefer if the parameters in the two nChannels
aleloi
2016/11/08 11:46:41
Done.
| |
63 RTC_DCHECK_LE(nChannels, 2u); | |
64 RTC_DCHECK_LE( | |
ossu
2016/11/03 14:02:04
Alright, so maybe a bit nitpicky, but don't we usu
aleloi
2016/11/08 11:46:41
I made comparisons to constants consistent in the
| |
65 static_cast<uint32_t>(AudioProcessing::NativeRate::kSampleRate8kHz), | |
66 samplesPerSec); | |
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(8 * sizeof(int16_t), | |
103 static_cast<size_t>(bits_per_sample)); | |
104 RTC_DCHECK_LE(1u, number_of_frames); | |
105 RTC_DCHECK_LE(number_of_frames, 2u); | |
106 RTC_DCHECK_LE(AudioProcessing::NativeRate::kSampleRate8kHz, | |
107 static_cast<int>(sample_rate)); | |
108 RTC_DCHECK_EQ(static_cast<int>(number_of_frames * 100), sample_rate); | |
109 RTC_DCHECK_LE(bits_per_sample / 8 * number_of_frames * number_of_channels, | |
110 sizeof(AudioFrame::data_)); | |
111 if (voe_audio_transport_) { | |
112 return voe_audio_transport_->PullRenderData( | |
113 bits_per_sample, sample_rate, number_of_channels, number_of_frames, | |
114 audio_data, elapsed_time_ms, ntp_time_ms); | |
115 } | |
116 | |
117 RTC_NOTREACHED() | |
118 << "AudioTransport proxy doesn't know from where to get play data: " | |
119 "no Audio Transport provided."; | |
120 } | |
121 | |
122 private: | |
123 AudioTransport* voe_audio_transport_; | |
124 AudioFrame frame_for_mixing_; | |
125 | |
126 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AudioTransportProxy); | |
127 }; | |
128 } // namespace webrtc | |
129 | |
130 #endif // WEBRTC_AUDIO_AUDIO_TRANSPORT_PROXY_H_ | |
OLD | NEW |