OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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_MAIN_ACM2_ACM_RECEIVER_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_RECEIVER_H_ |
12 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_RECEIVER_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_RECEIVER_H_ |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
| 17 #include "webrtc/base/array_view.h" |
17 #include "webrtc/base/scoped_ptr.h" | 18 #include "webrtc/base/scoped_ptr.h" |
18 #include "webrtc/base/thread_annotations.h" | 19 #include "webrtc/base/thread_annotations.h" |
19 #include "webrtc/common_audio/vad/include/webrtc_vad.h" | 20 #include "webrtc/common_audio/vad/include/webrtc_vad.h" |
20 #include "webrtc/engine_configurations.h" | 21 #include "webrtc/engine_configurations.h" |
21 #include "webrtc/modules/audio_coding/main/include/audio_coding_module.h" | 22 #include "webrtc/modules/audio_coding/main/include/audio_coding_module.h" |
22 #include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h" | 23 #include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h" |
23 #include "webrtc/modules/audio_coding/main/acm2/acm_resampler.h" | 24 #include "webrtc/modules/audio_coding/main/acm2/acm_resampler.h" |
24 #include "webrtc/modules/audio_coding/main/acm2/call_statistics.h" | 25 #include "webrtc/modules/audio_coding/main/acm2/call_statistics.h" |
25 #include "webrtc/modules/audio_coding/main/acm2/initial_delay_manager.h" | 26 #include "webrtc/modules/audio_coding/main/acm2/initial_delay_manager.h" |
26 #include "webrtc/modules/audio_coding/neteq/include/neteq.h" | 27 #include "webrtc/modules/audio_coding/neteq/include/neteq.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // - rtp_header : RTP header for the incoming payload containing | 60 // - rtp_header : RTP header for the incoming payload containing |
60 // information about payload type, sequence number, | 61 // information about payload type, sequence number, |
61 // timestamp, SSRC and marker bit. | 62 // timestamp, SSRC and marker bit. |
62 // - incoming_payload : Incoming audio payload. | 63 // - incoming_payload : Incoming audio payload. |
63 // - length_payload : Length of incoming audio payload in bytes. | 64 // - length_payload : Length of incoming audio payload in bytes. |
64 // | 65 // |
65 // Return value : 0 if OK. | 66 // Return value : 0 if OK. |
66 // <0 if NetEq returned an error. | 67 // <0 if NetEq returned an error. |
67 // | 68 // |
68 int InsertPacket(const WebRtcRTPHeader& rtp_header, | 69 int InsertPacket(const WebRtcRTPHeader& rtp_header, |
69 const uint8_t* incoming_payload, | 70 rtc::ArrayView<const uint8_t> incoming_payload); |
70 size_t length_payload); | |
71 | 71 |
72 // | 72 // |
73 // Asks NetEq for 10 milliseconds of decoded audio. | 73 // Asks NetEq for 10 milliseconds of decoded audio. |
74 // | 74 // |
75 // Input: | 75 // Input: |
76 // -desired_freq_hz : specifies the sampling rate [Hz] of the output | 76 // -desired_freq_hz : specifies the sampling rate [Hz] of the output |
77 // audio. If set -1 indicates to resampling is | 77 // audio. If set -1 indicates to resampling is |
78 // is required and the audio returned at the | 78 // is required and the audio returned at the |
79 // sampling rate of the decoder. | 79 // sampling rate of the decoder. |
80 // | 80 // |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 // Return value : list of packets to be retransmitted. | 272 // Return value : list of packets to be retransmitted. |
273 // | 273 // |
274 std::vector<uint16_t> GetNackList(int64_t round_trip_time_ms) const; | 274 std::vector<uint16_t> GetNackList(int64_t round_trip_time_ms) const; |
275 | 275 |
276 // | 276 // |
277 // Get statistics of calls to GetAudio(). | 277 // Get statistics of calls to GetAudio(). |
278 void GetDecodingCallStatistics(AudioDecodingCallStats* stats) const; | 278 void GetDecodingCallStatistics(AudioDecodingCallStats* stats) const; |
279 | 279 |
280 private: | 280 private: |
281 const Decoder* RtpHeaderToDecoder(const RTPHeader& rtp_header, | 281 const Decoder* RtpHeaderToDecoder(const RTPHeader& rtp_header, |
282 const uint8_t* payload) const | 282 uint8_t payload_type) const |
283 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); | 283 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
284 | 284 |
285 uint32_t NowInTimestamp(int decoder_sampling_rate) const; | 285 uint32_t NowInTimestamp(int decoder_sampling_rate) const; |
286 | 286 |
287 rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; | 287 rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; |
288 int id_; // TODO(henrik.lundin) Make const. | 288 int id_; // TODO(henrik.lundin) Make const. |
289 const Decoder* last_audio_decoder_ GUARDED_BY(crit_sect_); | 289 const Decoder* last_audio_decoder_ GUARDED_BY(crit_sect_); |
290 AudioFrame::VADActivity previous_audio_activity_ GUARDED_BY(crit_sect_); | 290 AudioFrame::VADActivity previous_audio_activity_ GUARDED_BY(crit_sect_); |
291 int current_sample_rate_hz_ GUARDED_BY(crit_sect_); | 291 int current_sample_rate_hz_ GUARDED_BY(crit_sect_); |
292 ACMResampler resampler_ GUARDED_BY(crit_sect_); | 292 ACMResampler resampler_ GUARDED_BY(crit_sect_); |
293 // Used in GetAudio, declared as member to avoid allocating every 10ms. | 293 // Used in GetAudio, declared as member to avoid allocating every 10ms. |
294 // TODO(henrik.lundin) Stack-allocate in GetAudio instead? | 294 // TODO(henrik.lundin) Stack-allocate in GetAudio instead? |
295 rtc::scoped_ptr<int16_t[]> audio_buffer_ GUARDED_BY(crit_sect_); | 295 rtc::scoped_ptr<int16_t[]> audio_buffer_ GUARDED_BY(crit_sect_); |
296 rtc::scoped_ptr<int16_t[]> last_audio_buffer_ GUARDED_BY(crit_sect_); | 296 rtc::scoped_ptr<int16_t[]> last_audio_buffer_ GUARDED_BY(crit_sect_); |
297 CallStatistics call_stats_ GUARDED_BY(crit_sect_); | 297 CallStatistics call_stats_ GUARDED_BY(crit_sect_); |
298 NetEq* neteq_; | 298 NetEq* neteq_; |
299 // Decoders map is keyed by payload type | 299 // Decoders map is keyed by payload type |
300 std::map<uint8_t, Decoder> decoders_ GUARDED_BY(crit_sect_); | 300 std::map<uint8_t, Decoder> decoders_ GUARDED_BY(crit_sect_); |
301 bool vad_enabled_; | 301 bool vad_enabled_; |
302 Clock* clock_; // TODO(henrik.lundin) Make const if possible. | 302 Clock* clock_; // TODO(henrik.lundin) Make const if possible. |
303 bool resampled_last_output_frame_ GUARDED_BY(crit_sect_); | 303 bool resampled_last_output_frame_ GUARDED_BY(crit_sect_); |
304 }; | 304 }; |
305 | 305 |
306 } // namespace acm2 | 306 } // namespace acm2 |
307 | 307 |
308 } // namespace webrtc | 308 } // namespace webrtc |
309 | 309 |
310 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_RECEIVER_H_ | 310 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_RECEIVER_H_ |
OLD | NEW |