OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_INCLUDE_NETEQ_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_INCLUDE_NETEQ_H_ |
12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_INCLUDE_NETEQ_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_INCLUDE_NETEQ_H_ |
13 | 13 |
14 #include <string.h> // Provide access to size_t. | 14 #include <string.h> // Provide access to size_t. |
15 | 15 |
16 #include <string> | 16 #include <string> |
17 | 17 |
18 #include "webrtc/base/constructormagic.h" | 18 #include "webrtc/base/constructormagic.h" |
19 #include "webrtc/common_types.h" | 19 #include "webrtc/common_types.h" |
20 #include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h" | 20 #include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h" |
21 #include "webrtc/typedefs.h" | 21 #include "webrtc/typedefs.h" |
22 | 22 |
23 namespace webrtc { | 23 namespace webrtc { |
24 | 24 |
25 // Forward declarations. | 25 // Forward declarations. |
| 26 class AudioFrame; |
26 struct WebRtcRTPHeader; | 27 struct WebRtcRTPHeader; |
27 | 28 |
28 struct NetEqNetworkStatistics { | 29 struct NetEqNetworkStatistics { |
29 uint16_t current_buffer_size_ms; // Current jitter buffer size in ms. | 30 uint16_t current_buffer_size_ms; // Current jitter buffer size in ms. |
30 uint16_t preferred_buffer_size_ms; // Target buffer size in ms. | 31 uint16_t preferred_buffer_size_ms; // Target buffer size in ms. |
31 uint16_t jitter_peaks_found; // 1 if adding extra delay due to peaky | 32 uint16_t jitter_peaks_found; // 1 if adding extra delay due to peaky |
32 // jitter; 0 otherwise. | 33 // jitter; 0 otherwise. |
33 uint16_t packet_loss_rate; // Loss rate (network + late) in Q14. | 34 uint16_t packet_loss_rate; // Loss rate (network + late) in Q14. |
34 uint16_t packet_discard_rate; // Late loss rate in Q14. | 35 uint16_t packet_discard_rate; // Late loss rate in Q14. |
35 uint16_t expand_rate; // Fraction (of original stream) of synthesized | 36 uint16_t expand_rate; // Fraction (of original stream) of synthesized |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // might insert sync-packet when they observe that buffer level of NetEq is | 157 // might insert sync-packet when they observe that buffer level of NetEq is |
157 // decreasing below a certain threshold, defined by the application. | 158 // decreasing below a certain threshold, defined by the application. |
158 // Sync-packets should have the same payload type as the last audio payload | 159 // Sync-packets should have the same payload type as the last audio payload |
159 // type, i.e. they cannot have DTMF or CNG payload type, nor a codec change | 160 // type, i.e. they cannot have DTMF or CNG payload type, nor a codec change |
160 // can be implied by inserting a sync-packet. | 161 // can be implied by inserting a sync-packet. |
161 // Returns kOk on success, kFail on failure. | 162 // Returns kOk on success, kFail on failure. |
162 virtual int InsertSyncPacket(const WebRtcRTPHeader& rtp_header, | 163 virtual int InsertSyncPacket(const WebRtcRTPHeader& rtp_header, |
163 uint32_t receive_timestamp) = 0; | 164 uint32_t receive_timestamp) = 0; |
164 | 165 |
165 // Instructs NetEq to deliver 10 ms of audio data. The data is written to | 166 // Instructs NetEq to deliver 10 ms of audio data. The data is written to |
166 // |output_audio|, which can hold (at least) |max_length| elements. | 167 // |audio_frame|. All data in |audio_frame| is wiped; |data_|, |interleaved_|, |
167 // The number of channels that were written to the output is provided in | 168 // |num_channels_|, and |samples_per_channel_| are updated upon success. If |
168 // the output variable |num_channels|, and each channel contains | 169 // an error is returned, some fields may not have been updated. |
169 // |samples_per_channel| elements. If more than one channel is written, | |
170 // the samples are interleaved. | |
171 // The speech type is written to |type|, if |type| is not NULL. | 170 // The speech type is written to |type|, if |type| is not NULL. |
172 // Returns kOK on success, or kFail in case of an error. | 171 // Returns kOK on success, or kFail in case of an error. |
173 virtual int GetAudio(size_t max_length, int16_t* output_audio, | 172 virtual int GetAudio(AudioFrame* audio_frame, NetEqOutputType* type) = 0; |
174 size_t* samples_per_channel, size_t* num_channels, | |
175 NetEqOutputType* type) = 0; | |
176 | 173 |
177 // Associates |rtp_payload_type| with |codec| and |codec_name|, and stores the | 174 // Associates |rtp_payload_type| with |codec| and |codec_name|, and stores the |
178 // information in the codec database. Returns 0 on success, -1 on failure. | 175 // information in the codec database. Returns 0 on success, -1 on failure. |
179 // The name is only used to provide information back to the caller about the | 176 // The name is only used to provide information back to the caller about the |
180 // decoders. Hence, the name is arbitrary, and may be empty. | 177 // decoders. Hence, the name is arbitrary, and may be empty. |
181 virtual int RegisterPayloadType(NetEqDecoder codec, | 178 virtual int RegisterPayloadType(NetEqDecoder codec, |
182 const std::string& codec_name, | 179 const std::string& codec_name, |
183 uint8_t rtp_payload_type) = 0; | 180 uint8_t rtp_payload_type) = 0; |
184 | 181 |
185 // Provides an externally created decoder object |decoder| to insert in the | 182 // Provides an externally created decoder object |decoder| to insert in the |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 296 |
300 protected: | 297 protected: |
301 NetEq() {} | 298 NetEq() {} |
302 | 299 |
303 private: | 300 private: |
304 RTC_DISALLOW_COPY_AND_ASSIGN(NetEq); | 301 RTC_DISALLOW_COPY_AND_ASSIGN(NetEq); |
305 }; | 302 }; |
306 | 303 |
307 } // namespace webrtc | 304 } // namespace webrtc |
308 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_INCLUDE_NETEQ_H_ | 305 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_INCLUDE_NETEQ_H_ |
OLD | NEW |