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 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // Instructs NetEq to deliver 10 ms of audio data. The data is written to | 99 // Instructs NetEq to deliver 10 ms of audio data. The data is written to |
100 // |output_audio|, which can hold (at least) |max_length| elements. | 100 // |output_audio|, which can hold (at least) |max_length| elements. |
101 // The number of channels that were written to the output is provided in | 101 // The number of channels that were written to the output is provided in |
102 // the output variable |num_channels|, and each channel contains | 102 // the output variable |num_channels|, and each channel contains |
103 // |samples_per_channel| elements. If more than one channel is written, | 103 // |samples_per_channel| elements. If more than one channel is written, |
104 // the samples are interleaved. | 104 // the samples are interleaved. |
105 // The speech type is written to |type|, if |type| is not NULL. | 105 // The speech type is written to |type|, if |type| is not NULL. |
106 // Returns kOK on success, or kFail in case of an error. | 106 // Returns kOK on success, or kFail in case of an error. |
107 int GetAudio(size_t max_length, | 107 int GetAudio(size_t max_length, |
108 int16_t* output_audio, | 108 int16_t* output_audio, |
109 int* samples_per_channel, | 109 size_t* samples_per_channel, |
110 int* num_channels, | 110 int* num_channels, |
111 NetEqOutputType* type) override; | 111 NetEqOutputType* type) override; |
112 | 112 |
113 // Associates |rtp_payload_type| with |codec| and stores the information in | 113 // Associates |rtp_payload_type| with |codec| and stores the information in |
114 // the codec database. Returns kOK on success, kFail on failure. | 114 // the codec database. Returns kOK on success, kFail on failure. |
115 int RegisterPayloadType(enum NetEqDecoder codec, | 115 int RegisterPayloadType(enum NetEqDecoder codec, |
116 uint8_t rtp_payload_type) override; | 116 uint8_t rtp_payload_type) override; |
117 | 117 |
118 // Provides an externally created decoder object |decoder| to insert in the | 118 // Provides an externally created decoder object |decoder| to insert in the |
119 // decoder database. The decoder implements a decoder of type |codec| and | 119 // decoder database. The decoder implements a decoder of type |codec| and |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 196 |
197 // Get sequence number and timestamp of the latest RTP. | 197 // Get sequence number and timestamp of the latest RTP. |
198 // This method is to facilitate NACK. | 198 // This method is to facilitate NACK. |
199 int DecodedRtpInfo(int* sequence_number, uint32_t* timestamp) const override; | 199 int DecodedRtpInfo(int* sequence_number, uint32_t* timestamp) const override; |
200 | 200 |
201 // This accessor method is only intended for testing purposes. | 201 // This accessor method is only intended for testing purposes. |
202 const SyncBuffer* sync_buffer_for_test() const; | 202 const SyncBuffer* sync_buffer_for_test() const; |
203 | 203 |
204 protected: | 204 protected: |
205 static const int kOutputSizeMs = 10; | 205 static const int kOutputSizeMs = 10; |
206 static const int kMaxFrameSize = 2880; // 60 ms @ 48 kHz. | 206 static const size_t kMaxFrameSize = 2880; // 60 ms @ 48 kHz. |
207 // TODO(hlundin): Provide a better value for kSyncBufferSize. | 207 // TODO(hlundin): Provide a better value for kSyncBufferSize. |
208 static const int kSyncBufferSize = 2 * kMaxFrameSize; | 208 static const size_t kSyncBufferSize = 2 * kMaxFrameSize; |
209 | 209 |
210 // Inserts a new packet into NetEq. This is used by the InsertPacket method | 210 // Inserts a new packet into NetEq. This is used by the InsertPacket method |
211 // above. Returns 0 on success, otherwise an error code. | 211 // above. Returns 0 on success, otherwise an error code. |
212 // TODO(hlundin): Merge this with InsertPacket above? | 212 // TODO(hlundin): Merge this with InsertPacket above? |
213 int InsertPacketInternal(const WebRtcRTPHeader& rtp_header, | 213 int InsertPacketInternal(const WebRtcRTPHeader& rtp_header, |
214 const uint8_t* payload, | 214 const uint8_t* payload, |
215 size_t length_bytes, | 215 size_t length_bytes, |
216 uint32_t receive_timestamp, | 216 uint32_t receive_timestamp, |
217 bool is_sync_packet) | 217 bool is_sync_packet) |
218 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); | 218 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
219 | 219 |
220 // Delivers 10 ms of audio data. The data is written to |output|, which can | 220 // Delivers 10 ms of audio data. The data is written to |output|, which can |
221 // hold (at least) |max_length| elements. The number of channels that were | 221 // hold (at least) |max_length| elements. The number of channels that were |
222 // written to the output is provided in the output variable |num_channels|, | 222 // written to the output is provided in the output variable |num_channels|, |
223 // and each channel contains |samples_per_channel| elements. If more than one | 223 // and each channel contains |samples_per_channel| elements. If more than one |
224 // channel is written, the samples are interleaved. | 224 // channel is written, the samples are interleaved. |
225 // Returns 0 on success, otherwise an error code. | 225 // Returns 0 on success, otherwise an error code. |
226 int GetAudioInternal(size_t max_length, | 226 int GetAudioInternal(size_t max_length, |
227 int16_t* output, | 227 int16_t* output, |
228 int* samples_per_channel, | 228 size_t* samples_per_channel, |
229 int* num_channels) EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); | 229 int* num_channels) EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
230 | 230 |
231 // Provides a decision to the GetAudioInternal method. The decision what to | 231 // Provides a decision to the GetAudioInternal method. The decision what to |
232 // do is written to |operation|. Packets to decode are written to | 232 // do is written to |operation|. Packets to decode are written to |
233 // |packet_list|, and a DTMF event to play is written to |dtmf_event|. When | 233 // |packet_list|, and a DTMF event to play is written to |dtmf_event|. When |
234 // DTMF should be played, |play_dtmf| is set to true by the method. | 234 // DTMF should be played, |play_dtmf| is set to true by the method. |
235 // Returns 0 on success, otherwise an error code. | 235 // Returns 0 on success, otherwise an error code. |
236 int GetDecision(Operations* operation, | 236 int GetDecision(Operations* operation, |
237 PacketList* packet_list, | 237 PacketList* packet_list, |
238 DtmfEvent* dtmf_event, | 238 DtmfEvent* dtmf_event, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 311 |
312 // Overdub DTMF on top of |output|. | 312 // Overdub DTMF on top of |output|. |
313 int DtmfOverdub(const DtmfEvent& dtmf_event, | 313 int DtmfOverdub(const DtmfEvent& dtmf_event, |
314 size_t num_channels, | 314 size_t num_channels, |
315 int16_t* output) const EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); | 315 int16_t* output) const EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
316 | 316 |
317 // Extracts packets from |packet_buffer_| to produce at least | 317 // Extracts packets from |packet_buffer_| to produce at least |
318 // |required_samples| samples. The packets are inserted into |packet_list|. | 318 // |required_samples| samples. The packets are inserted into |packet_list|. |
319 // Returns the number of samples that the packets in the list will produce, or | 319 // Returns the number of samples that the packets in the list will produce, or |
320 // -1 in case of an error. | 320 // -1 in case of an error. |
321 int ExtractPackets(int required_samples, PacketList* packet_list) | 321 int ExtractPackets(size_t required_samples, PacketList* packet_list) |
322 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); | 322 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
323 | 323 |
324 // Resets various variables and objects to new values based on the sample rate | 324 // Resets various variables and objects to new values based on the sample rate |
325 // |fs_hz| and |channels| number audio channels. | 325 // |fs_hz| and |channels| number audio channels. |
326 void SetSampleRateAndChannels(int fs_hz, size_t channels) | 326 void SetSampleRateAndChannels(int fs_hz, size_t channels) |
327 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); | 327 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
328 | 328 |
329 // Returns the output type for the audio produced by the latest call to | 329 // Returns the output type for the audio produced by the latest call to |
330 // GetAudio(). | 330 // GetAudio(). |
331 NetEqOutputType LastOutputType() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); | 331 NetEqOutputType LastOutputType() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 rtc::scoped_ptr<Normal> normal_ GUARDED_BY(crit_sect_); | 368 rtc::scoped_ptr<Normal> normal_ GUARDED_BY(crit_sect_); |
369 rtc::scoped_ptr<Merge> merge_ GUARDED_BY(crit_sect_); | 369 rtc::scoped_ptr<Merge> merge_ GUARDED_BY(crit_sect_); |
370 rtc::scoped_ptr<Accelerate> accelerate_ GUARDED_BY(crit_sect_); | 370 rtc::scoped_ptr<Accelerate> accelerate_ GUARDED_BY(crit_sect_); |
371 rtc::scoped_ptr<PreemptiveExpand> preemptive_expand_ GUARDED_BY(crit_sect_); | 371 rtc::scoped_ptr<PreemptiveExpand> preemptive_expand_ GUARDED_BY(crit_sect_); |
372 RandomVector random_vector_ GUARDED_BY(crit_sect_); | 372 RandomVector random_vector_ GUARDED_BY(crit_sect_); |
373 rtc::scoped_ptr<ComfortNoise> comfort_noise_ GUARDED_BY(crit_sect_); | 373 rtc::scoped_ptr<ComfortNoise> comfort_noise_ GUARDED_BY(crit_sect_); |
374 Rtcp rtcp_ GUARDED_BY(crit_sect_); | 374 Rtcp rtcp_ GUARDED_BY(crit_sect_); |
375 StatisticsCalculator stats_ GUARDED_BY(crit_sect_); | 375 StatisticsCalculator stats_ GUARDED_BY(crit_sect_); |
376 int fs_hz_ GUARDED_BY(crit_sect_); | 376 int fs_hz_ GUARDED_BY(crit_sect_); |
377 int fs_mult_ GUARDED_BY(crit_sect_); | 377 int fs_mult_ GUARDED_BY(crit_sect_); |
378 int output_size_samples_ GUARDED_BY(crit_sect_); | 378 size_t output_size_samples_ GUARDED_BY(crit_sect_); |
379 int decoder_frame_length_ GUARDED_BY(crit_sect_); | 379 size_t decoder_frame_length_ GUARDED_BY(crit_sect_); |
380 Modes last_mode_ GUARDED_BY(crit_sect_); | 380 Modes last_mode_ GUARDED_BY(crit_sect_); |
381 rtc::scoped_ptr<int16_t[]> mute_factor_array_ GUARDED_BY(crit_sect_); | 381 rtc::scoped_ptr<int16_t[]> mute_factor_array_ GUARDED_BY(crit_sect_); |
382 size_t decoded_buffer_length_ GUARDED_BY(crit_sect_); | 382 size_t decoded_buffer_length_ GUARDED_BY(crit_sect_); |
383 rtc::scoped_ptr<int16_t[]> decoded_buffer_ GUARDED_BY(crit_sect_); | 383 rtc::scoped_ptr<int16_t[]> decoded_buffer_ GUARDED_BY(crit_sect_); |
384 uint32_t playout_timestamp_ GUARDED_BY(crit_sect_); | 384 uint32_t playout_timestamp_ GUARDED_BY(crit_sect_); |
385 bool new_codec_ GUARDED_BY(crit_sect_); | 385 bool new_codec_ GUARDED_BY(crit_sect_); |
386 uint32_t timestamp_ GUARDED_BY(crit_sect_); | 386 uint32_t timestamp_ GUARDED_BY(crit_sect_); |
387 bool reset_decoder_ GUARDED_BY(crit_sect_); | 387 bool reset_decoder_ GUARDED_BY(crit_sect_); |
388 uint8_t current_rtp_payload_type_ GUARDED_BY(crit_sect_); | 388 uint8_t current_rtp_payload_type_ GUARDED_BY(crit_sect_); |
389 uint8_t current_cng_rtp_payload_type_ GUARDED_BY(crit_sect_); | 389 uint8_t current_cng_rtp_payload_type_ GUARDED_BY(crit_sect_); |
(...skipping 14 matching lines...) Expand all Loading... |
404 // module is designed to compensate for this. | 404 // module is designed to compensate for this. |
405 int decoded_packet_sequence_number_ GUARDED_BY(crit_sect_); | 405 int decoded_packet_sequence_number_ GUARDED_BY(crit_sect_); |
406 uint32_t decoded_packet_timestamp_ GUARDED_BY(crit_sect_); | 406 uint32_t decoded_packet_timestamp_ GUARDED_BY(crit_sect_); |
407 | 407 |
408 private: | 408 private: |
409 DISALLOW_COPY_AND_ASSIGN(NetEqImpl); | 409 DISALLOW_COPY_AND_ASSIGN(NetEqImpl); |
410 }; | 410 }; |
411 | 411 |
412 } // namespace webrtc | 412 } // namespace webrtc |
413 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_NETEQ_IMPL_H_ | 413 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_NETEQ_IMPL_H_ |
OLD | NEW |