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_ACM2_ACM_RECEIVER_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_ACM2_ACM_RECEIVER_H_ |
12 #define WEBRTC_MODULES_AUDIO_CODING_ACM2_ACM_RECEIVER_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_ACM2_ACM_RECEIVER_H_ |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <string> | 15 #include <string> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "webrtc/base/array_view.h" | 18 #include "webrtc/base/array_view.h" |
| 19 #include "webrtc/base/criticalsection.h" |
19 #include "webrtc/base/optional.h" | 20 #include "webrtc/base/optional.h" |
20 #include "webrtc/base/scoped_ptr.h" | 21 #include "webrtc/base/scoped_ptr.h" |
21 #include "webrtc/base/thread_annotations.h" | 22 #include "webrtc/base/thread_annotations.h" |
22 #include "webrtc/common_audio/vad/include/webrtc_vad.h" | 23 #include "webrtc/common_audio/vad/include/webrtc_vad.h" |
23 #include "webrtc/engine_configurations.h" | 24 #include "webrtc/engine_configurations.h" |
24 #include "webrtc/modules/audio_coding/include/audio_coding_module.h" | |
25 #include "webrtc/modules/audio_coding/acm2/acm_resampler.h" | 25 #include "webrtc/modules/audio_coding/acm2/acm_resampler.h" |
26 #include "webrtc/modules/audio_coding/acm2/call_statistics.h" | 26 #include "webrtc/modules/audio_coding/acm2/call_statistics.h" |
27 #include "webrtc/modules/audio_coding/acm2/initial_delay_manager.h" | 27 #include "webrtc/modules/audio_coding/acm2/initial_delay_manager.h" |
| 28 #include "webrtc/modules/audio_coding/include/audio_coding_module.h" |
28 #include "webrtc/modules/audio_coding/neteq/include/neteq.h" | 29 #include "webrtc/modules/audio_coding/neteq/include/neteq.h" |
29 #include "webrtc/modules/include/module_common_types.h" | 30 #include "webrtc/modules/include/module_common_types.h" |
30 #include "webrtc/typedefs.h" | 31 #include "webrtc/typedefs.h" |
31 | 32 |
32 namespace webrtc { | 33 namespace webrtc { |
33 | 34 |
34 struct CodecInst; | 35 struct CodecInst; |
35 class CriticalSectionWrapper; | |
36 class NetEq; | 36 class NetEq; |
37 | 37 |
38 namespace acm2 { | 38 namespace acm2 { |
39 | 39 |
40 class AcmReceiver { | 40 class AcmReceiver { |
41 public: | 41 public: |
42 struct Decoder { | 42 struct Decoder { |
43 int acm_codec_id; | 43 int acm_codec_id; |
44 uint8_t payload_type; | 44 uint8_t payload_type; |
45 // This field is meaningful for codecs where both mono and | 45 // This field is meaningful for codecs where both mono and |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 // Get statistics of calls to GetAudio(). | 274 // Get statistics of calls to GetAudio(). |
275 void GetDecodingCallStatistics(AudioDecodingCallStats* stats) const; | 275 void GetDecodingCallStatistics(AudioDecodingCallStats* stats) const; |
276 | 276 |
277 private: | 277 private: |
278 const Decoder* RtpHeaderToDecoder(const RTPHeader& rtp_header, | 278 const Decoder* RtpHeaderToDecoder(const RTPHeader& rtp_header, |
279 uint8_t payload_type) const | 279 uint8_t payload_type) const |
280 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); | 280 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
281 | 281 |
282 uint32_t NowInTimestamp(int decoder_sampling_rate) const; | 282 uint32_t NowInTimestamp(int decoder_sampling_rate) const; |
283 | 283 |
284 rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; | 284 mutable rtc::CriticalSection crit_sect_; |
285 int id_; // TODO(henrik.lundin) Make const. | 285 int id_; // TODO(henrik.lundin) Make const. |
286 const Decoder* last_audio_decoder_ GUARDED_BY(crit_sect_); | 286 const Decoder* last_audio_decoder_ GUARDED_BY(crit_sect_); |
287 AudioFrame::VADActivity previous_audio_activity_ GUARDED_BY(crit_sect_); | 287 AudioFrame::VADActivity previous_audio_activity_ GUARDED_BY(crit_sect_); |
288 ACMResampler resampler_ GUARDED_BY(crit_sect_); | 288 ACMResampler resampler_ GUARDED_BY(crit_sect_); |
289 // Used in GetAudio, declared as member to avoid allocating every 10ms. | 289 // Used in GetAudio, declared as member to avoid allocating every 10ms. |
290 // TODO(henrik.lundin) Stack-allocate in GetAudio instead? | 290 // TODO(henrik.lundin) Stack-allocate in GetAudio instead? |
291 rtc::scoped_ptr<int16_t[]> audio_buffer_ GUARDED_BY(crit_sect_); | 291 rtc::scoped_ptr<int16_t[]> audio_buffer_ GUARDED_BY(crit_sect_); |
292 rtc::scoped_ptr<int16_t[]> last_audio_buffer_ GUARDED_BY(crit_sect_); | 292 rtc::scoped_ptr<int16_t[]> last_audio_buffer_ GUARDED_BY(crit_sect_); |
293 CallStatistics call_stats_ GUARDED_BY(crit_sect_); | 293 CallStatistics call_stats_ GUARDED_BY(crit_sect_); |
294 NetEq* neteq_; | 294 NetEq* neteq_; |
295 // Decoders map is keyed by payload type | 295 // Decoders map is keyed by payload type |
296 std::map<uint8_t, Decoder> decoders_ GUARDED_BY(crit_sect_); | 296 std::map<uint8_t, Decoder> decoders_ GUARDED_BY(crit_sect_); |
297 bool vad_enabled_; | 297 bool vad_enabled_; |
298 Clock* clock_; // TODO(henrik.lundin) Make const if possible. | 298 Clock* clock_; // TODO(henrik.lundin) Make const if possible. |
299 bool resampled_last_output_frame_ GUARDED_BY(crit_sect_); | 299 bool resampled_last_output_frame_ GUARDED_BY(crit_sect_); |
300 rtc::Optional<int> last_packet_sample_rate_hz_ GUARDED_BY(crit_sect_); | 300 rtc::Optional<int> last_packet_sample_rate_hz_ GUARDED_BY(crit_sect_); |
301 }; | 301 }; |
302 | 302 |
303 } // namespace acm2 | 303 } // namespace acm2 |
304 | 304 |
305 } // namespace webrtc | 305 } // namespace webrtc |
306 | 306 |
307 #endif // WEBRTC_MODULES_AUDIO_CODING_ACM2_ACM_RECEIVER_H_ | 307 #endif // WEBRTC_MODULES_AUDIO_CODING_ACM2_ACM_RECEIVER_H_ |
OLD | NEW |