OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 virtual int32_t NeedMorePlayData(const size_t nSamples, | 60 virtual int32_t NeedMorePlayData(const size_t nSamples, |
61 const size_t nBytesPerSample, | 61 const size_t nBytesPerSample, |
62 const size_t nChannels, | 62 const size_t nChannels, |
63 const uint32_t samplesPerSec, | 63 const uint32_t samplesPerSec, |
64 void* audioSamples, | 64 void* audioSamples, |
65 size_t& nSamplesOut, | 65 size_t& nSamplesOut, |
66 int64_t* elapsed_time_ms, | 66 int64_t* elapsed_time_ms, |
67 int64_t* ntp_time_ms) = 0; | 67 int64_t* ntp_time_ms) = 0; |
68 | 68 |
69 // Method to pass captured data directly and unmixed to network channels. | |
70 // |channel_ids| contains a list of VoE channels which are the | |
71 // sinks to the capture data. |audio_delay_milliseconds| is the sum of | |
72 // recording delay and playout delay of the hardware. |current_volume| is | |
73 // in the range of [0, 255], representing the current microphone analog | |
74 // volume. |key_pressed| is used by the typing detection. | |
75 // |need_audio_processing| specify if the data needs to be processed by APM. | |
76 // Currently WebRtc supports only one APM, and Chrome will make sure only | |
77 // one stream goes through APM. When |need_audio_processing| is false, the | |
78 // values of |audio_delay_milliseconds|, |current_volume| and |key_pressed| | |
79 // will be ignored. | |
80 // The return value is the new microphone volume, in the range of |0, 255]. | |
81 // When the volume does not need to be updated, it returns 0. | |
82 // TODO(xians): Remove this interface after Chrome and Libjingle switches | |
83 // to OnData(). | |
84 virtual int OnDataAvailable(const int voe_channels[], | |
85 size_t number_of_voe_channels, | |
86 const int16_t* audio_data, | |
87 int sample_rate, | |
88 size_t number_of_channels, | |
89 size_t number_of_frames, | |
90 int audio_delay_milliseconds, | |
91 int current_volume, | |
92 bool key_pressed, | |
93 bool need_audio_processing) { | |
94 return 0; | |
95 } | |
96 | |
97 // Method to pass the captured audio data to the specific VoE channel. | |
98 // |voe_channel| is the id of the VoE channel which is the sink to the | |
99 // capture data. | |
100 // TODO(xians): Remove this interface after Libjingle switches to | |
101 // PushCaptureData(). | |
102 virtual void OnData(int voe_channel, | |
103 const void* audio_data, | |
104 int bits_per_sample, | |
105 int sample_rate, | |
106 size_t number_of_channels, | |
107 size_t number_of_frames) {} | |
108 | |
109 // Method to push the captured audio data to the specific VoE channel. | 69 // Method to push the captured audio data to the specific VoE channel. |
110 // The data will not undergo audio processing. | 70 // The data will not undergo audio processing. |
111 // |voe_channel| is the id of the VoE channel which is the sink to the | 71 // |voe_channel| is the id of the VoE channel which is the sink to the |
112 // capture data. | 72 // capture data. |
113 // TODO(xians): Make the interface pure virtual after Libjingle | |
114 // has its implementation. | |
115 virtual void PushCaptureData(int voe_channel, | 73 virtual void PushCaptureData(int voe_channel, |
116 const void* audio_data, | 74 const void* audio_data, |
117 int bits_per_sample, | 75 int bits_per_sample, |
118 int sample_rate, | 76 int sample_rate, |
119 size_t number_of_channels, | 77 size_t number_of_channels, |
120 size_t number_of_frames) {} | 78 size_t number_of_frames); |
121 | 79 |
122 // Method to pull mixed render audio data from all active VoE channels. | 80 // Method to pull mixed render audio data from all active VoE channels. |
123 // The data will not be passed as reference for audio processing internally. | 81 // The data will not be passed as reference for audio processing internally. |
124 // TODO(xians): Support getting the unmixed render data from specific VoE | 82 // TODO(xians): Support getting the unmixed render data from specific VoE |
125 // channel. | 83 // channel. |
126 virtual void PullRenderData(int bits_per_sample, | 84 virtual void PullRenderData(int bits_per_sample, |
127 int sample_rate, | 85 int sample_rate, |
128 size_t number_of_channels, | 86 size_t number_of_channels, |
129 size_t number_of_frames, | 87 size_t number_of_frames, |
130 void* audio_data, | 88 void* audio_data, |
131 int64_t* elapsed_time_ms, | 89 int64_t* elapsed_time_ms, |
132 int64_t* ntp_time_ms) {} | 90 int64_t* ntp_time_ms); |
133 | 91 |
134 protected: | 92 protected: |
135 virtual ~AudioTransport() {} | 93 virtual ~AudioTransport() {} |
136 }; | 94 }; |
137 | 95 |
138 // Helper class for storage of fundamental audio parameters such as sample rate, | 96 // Helper class for storage of fundamental audio parameters such as sample rate, |
139 // number of channels, native buffer size etc. | 97 // number of channels, native buffer size etc. |
140 // Note that one audio frame can contain more than one channel sample and each | 98 // Note that one audio frame can contain more than one channel sample and each |
141 // sample is assumed to be a 16-bit PCM sample. Hence, one audio frame in | 99 // sample is assumed to be a 16-bit PCM sample. Hence, one audio frame in |
142 // stereo contains 2 * (16/8) = 4 bytes of data. | 100 // stereo contains 2 * (16/8) = 4 bytes of data. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 private: | 159 private: |
202 int sample_rate_; | 160 int sample_rate_; |
203 size_t channels_; | 161 size_t channels_; |
204 size_t frames_per_buffer_; | 162 size_t frames_per_buffer_; |
205 size_t frames_per_10ms_buffer_; | 163 size_t frames_per_10ms_buffer_; |
206 }; | 164 }; |
207 | 165 |
208 } // namespace webrtc | 166 } // namespace webrtc |
209 | 167 |
210 #endif // WEBRTC_MODULES_AUDIO_DEVICE_INCLUDE_AUDIO_DEVICE_DEFINES_H_ | 168 #endif // WEBRTC_MODULES_AUDIO_DEVICE_INCLUDE_AUDIO_DEVICE_DEFINES_H_ |
OLD | NEW |