2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_ISAC_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_ISAC_H_
14 #include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h"
15 #include "webrtc/modules/audio_coding/neteq/interface/audio_decoder.h"
16 #include "webrtc/system_wrappers/interface/scoped_ptr.h"
17 #include "webrtc/system_wrappers/interface/thread_annotations.h"
21 class CriticalSectionWrapper;
32 class ACMISAC : public ACMGenericCodec, AudioDecoder {
34 explicit ACMISAC(int16_t codec_id);
37 int16_t InternalInitDecoder(WebRtcACMCodecParams* codec_params)
38 EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_);
40 // Methods below are inherited from ACMGenericCodec.
41 ACMGenericCodec* CreateInstance(void) OVERRIDE;
43 int16_t InternalEncode(uint8_t* bitstream,
44 int16_t* bitstream_len_byte) OVERRIDE
45 EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_);
47 int16_t InternalInitEncoder(WebRtcACMCodecParams* codec_params) OVERRIDE
48 EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_);
50 int16_t UpdateDecoderSampFreq(int16_t codec_id) OVERRIDE;
52 int16_t UpdateEncoderSampFreq(uint16_t samp_freq_hz) OVERRIDE
53 EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_);
55 int16_t EncoderSampFreq(uint16_t* samp_freq_hz) OVERRIDE;
57 int32_t ConfigISACBandwidthEstimator(const uint8_t init_frame_size_msec,
58 const uint16_t init_rate_bit_per_sec,
59 const bool enforce_frame_size) OVERRIDE;
61 int32_t SetISACMaxPayloadSize(const uint16_t max_payload_len_bytes) OVERRIDE;
63 int32_t SetISACMaxRate(const uint32_t max_rate_bit_per_sec) OVERRIDE;
65 int16_t REDPayloadISAC(const int32_t isac_rate,
66 const int16_t isac_bw_estimate,
68 int16_t* payload_len_bytes) OVERRIDE;
70 // Methods below are inherited from AudioDecoder.
71 virtual int Decode(const uint8_t* encoded,
74 SpeechType* speech_type) OVERRIDE;
76 virtual bool HasDecodePlc() const OVERRIDE { return true; }
78 virtual int DecodePlc(int num_frames, int16_t* decoded) OVERRIDE;
80 virtual int Init() OVERRIDE { return 0; }
82 virtual int IncomingPacket(const uint8_t* payload,
84 uint16_t rtp_sequence_number,
85 uint32_t rtp_timestamp,
86 uint32_t arrival_timestamp) OVERRIDE;
88 virtual int DecodeRedundant(const uint8_t* encoded,
91 SpeechType* speech_type) OVERRIDE;
93 virtual int ErrorCode() OVERRIDE;
96 int16_t Transcode(uint8_t* bitstream,
97 int16_t* bitstream_len_byte,
102 void UpdateFrameLen() EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_);
104 // Methods below are inherited from ACMGenericCodec.
105 void DestructEncoderSafe() OVERRIDE
106 EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_);
108 int16_t SetBitRateSafe(const int32_t bit_rate) OVERRIDE
109 EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_);
111 int32_t GetEstimatedBandwidthSafe() OVERRIDE;
113 int32_t SetEstimatedBandwidthSafe(int32_t estimated_bandwidth) OVERRIDE;
115 int32_t GetRedPayloadSafe(uint8_t* red_payload,
116 int16_t* payload_bytes) OVERRIDE;
118 int16_t InternalCreateEncoder() OVERRIDE;
120 void InternalDestructEncoderInst(void* ptr_inst) OVERRIDE;
122 void CurrentRate(int32_t* rate_bit_per_sec) OVERRIDE;
124 virtual AudioDecoder* Decoder(int codec_id) OVERRIDE;
126 // |codec_inst_crit_sect_| protects |codec_inst_ptr_|.
127 const scoped_ptr<CriticalSectionWrapper> codec_inst_crit_sect_;
128 ACMISACInst* codec_inst_ptr_ GUARDED_BY(codec_inst_crit_sect_);
129 bool is_enc_initialized_;
130 IsacCodingMode isac_coding_mode_;
131 bool enforce_frame_size_;
132 int32_t isac_current_bn_;
133 uint16_t samples_in_10ms_audio_;
134 bool decoder_initialized_;
139 } // namespace webrtc
141 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_ISAC_H_