| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 #include "webrtc/modules/audio_coding/codecs/isac/main/interface/audio_encoder_i
sac.h" | 11 #include "webrtc/modules/audio_coding/codecs/isac/main/interface/audio_encoder_i
sac.h" |
| 12 | 12 |
| 13 #include "webrtc/common_types.h" | 13 #include "webrtc/common_types.h" |
| 14 #include "webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h" | 14 #include "webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h" |
| 15 | 15 |
| 16 namespace webrtc { | 16 namespace webrtc { |
| 17 | 17 |
| 18 // Explicit instantiation of AudioEncoderDecoderIsacT<IsacFloat>, a.k.a. | 18 // Explicit instantiation: |
| 19 // AudioEncoderDecoderIsac. | 19 template class AudioEncoderIsacT<IsacFloat>; |
| 20 template class AudioEncoderDecoderIsacT<IsacFloat>; | 20 template class AudioDecoderIsacT<IsacFloat>; |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 AudioEncoderDecoderIsac::Config CreateConfig(const CodecInst& codec_inst) { | 23 AudioEncoderIsac::Config CreateConfig(const CodecInst& codec_inst, |
| 24 AudioEncoderDecoderIsac::Config config; | 24 LockedIsacBandwidthInfo* bwinfo) { |
| 25 AudioEncoderIsac::Config config; |
| 26 config.bwinfo = bwinfo; |
| 25 config.payload_type = codec_inst.pltype; | 27 config.payload_type = codec_inst.pltype; |
| 26 config.sample_rate_hz = codec_inst.plfreq; | 28 config.sample_rate_hz = codec_inst.plfreq; |
| 27 config.frame_size_ms = | 29 config.frame_size_ms = |
| 28 rtc::CheckedDivExact(1000 * codec_inst.pacsize, config.sample_rate_hz); | 30 rtc::CheckedDivExact(1000 * codec_inst.pacsize, config.sample_rate_hz); |
| 29 if (codec_inst.rate != -1) | 31 if (codec_inst.rate != -1) |
| 30 config.bit_rate = codec_inst.rate; | 32 config.bit_rate = codec_inst.rate; |
| 31 config.adaptive_mode = (codec_inst.rate == -1); | 33 config.adaptive_mode = (codec_inst.rate == -1); |
| 32 return config; | 34 return config; |
| 33 } | 35 } |
| 34 } // namespace | 36 } // namespace |
| 35 | 37 |
| 36 AudioEncoderDecoderMutableIsacFloat::AudioEncoderDecoderMutableIsacFloat( | 38 AudioEncoderMutableIsacFloat::AudioEncoderMutableIsacFloat( |
| 37 const CodecInst& codec_inst) | 39 const CodecInst& codec_inst, |
| 38 : AudioEncoderMutableImpl<AudioEncoderDecoderIsac, | 40 LockedIsacBandwidthInfo* bwinfo) |
| 39 AudioEncoderDecoderMutableIsac>( | 41 : AudioEncoderMutableImpl<AudioEncoderIsac>( |
| 40 CreateConfig(codec_inst)) { | 42 CreateConfig(codec_inst, bwinfo)) { |
| 41 } | 43 } |
| 42 | 44 |
| 43 void AudioEncoderDecoderMutableIsacFloat::UpdateSettings( | 45 void AudioEncoderMutableIsacFloat::SetMaxPayloadSize( |
| 44 const CodecInst& codec_inst) { | |
| 45 bool success = Reconstruct(CreateConfig(codec_inst)); | |
| 46 DCHECK(success); | |
| 47 } | |
| 48 | |
| 49 void AudioEncoderDecoderMutableIsacFloat::SetMaxPayloadSize( | |
| 50 int max_payload_size_bytes) { | 46 int max_payload_size_bytes) { |
| 51 auto conf = config(); | 47 auto conf = config(); |
| 52 conf.max_payload_size_bytes = max_payload_size_bytes; | 48 conf.max_payload_size_bytes = max_payload_size_bytes; |
| 53 Reconstruct(conf); | 49 Reconstruct(conf); |
| 54 } | 50 } |
| 55 | 51 |
| 56 void AudioEncoderDecoderMutableIsacFloat::SetMaxRate(int max_rate_bps) { | 52 void AudioEncoderMutableIsacFloat::SetMaxRate(int max_rate_bps) { |
| 57 auto conf = config(); | 53 auto conf = config(); |
| 58 conf.max_bit_rate = max_rate_bps; | 54 conf.max_bit_rate = max_rate_bps; |
| 59 Reconstruct(conf); | 55 Reconstruct(conf); |
| 60 } | 56 } |
| 61 | 57 |
| 62 int AudioEncoderDecoderMutableIsacFloat::Decode(const uint8_t* encoded, | |
| 63 size_t encoded_len, | |
| 64 int sample_rate_hz, | |
| 65 size_t max_decoded_bytes, | |
| 66 int16_t* decoded, | |
| 67 SpeechType* speech_type) { | |
| 68 CriticalSectionScoped cs(encoder_lock_.get()); | |
| 69 return encoder()->Decode(encoded, encoded_len, sample_rate_hz, | |
| 70 max_decoded_bytes, decoded, speech_type); | |
| 71 } | |
| 72 | |
| 73 int AudioEncoderDecoderMutableIsacFloat::DecodeRedundant( | |
| 74 const uint8_t* encoded, | |
| 75 size_t encoded_len, | |
| 76 int sample_rate_hz, | |
| 77 size_t max_decoded_bytes, | |
| 78 int16_t* decoded, | |
| 79 SpeechType* speech_type) { | |
| 80 CriticalSectionScoped cs(encoder_lock_.get()); | |
| 81 return encoder()->DecodeRedundant(encoded, encoded_len, sample_rate_hz, | |
| 82 max_decoded_bytes, decoded, speech_type); | |
| 83 } | |
| 84 | |
| 85 bool AudioEncoderDecoderMutableIsacFloat::HasDecodePlc() const { | |
| 86 CriticalSectionScoped cs(encoder_lock_.get()); | |
| 87 return encoder()->HasDecodePlc(); | |
| 88 } | |
| 89 | |
| 90 int AudioEncoderDecoderMutableIsacFloat::DecodePlc(int num_frames, | |
| 91 int16_t* decoded) { | |
| 92 CriticalSectionScoped cs(encoder_lock_.get()); | |
| 93 return encoder()->DecodePlc(num_frames, decoded); | |
| 94 } | |
| 95 | |
| 96 int AudioEncoderDecoderMutableIsacFloat::Init() { | |
| 97 CriticalSectionScoped cs(encoder_lock_.get()); | |
| 98 return encoder()->Init(); | |
| 99 } | |
| 100 | |
| 101 int AudioEncoderDecoderMutableIsacFloat::IncomingPacket( | |
| 102 const uint8_t* payload, | |
| 103 size_t payload_len, | |
| 104 uint16_t rtp_sequence_number, | |
| 105 uint32_t rtp_timestamp, | |
| 106 uint32_t arrival_timestamp) { | |
| 107 CriticalSectionScoped cs(encoder_lock_.get()); | |
| 108 return encoder()->IncomingPacket(payload, payload_len, rtp_sequence_number, | |
| 109 rtp_timestamp, arrival_timestamp); | |
| 110 } | |
| 111 | |
| 112 int AudioEncoderDecoderMutableIsacFloat::ErrorCode() { | |
| 113 CriticalSectionScoped cs(encoder_lock_.get()); | |
| 114 return encoder()->ErrorCode(); | |
| 115 } | |
| 116 | |
| 117 int AudioEncoderDecoderMutableIsacFloat::PacketDuration( | |
| 118 const uint8_t* encoded, | |
| 119 size_t encoded_len) const { | |
| 120 CriticalSectionScoped cs(encoder_lock_.get()); | |
| 121 return encoder()->PacketDuration(encoded, encoded_len); | |
| 122 } | |
| 123 | |
| 124 int AudioEncoderDecoderMutableIsacFloat::PacketDurationRedundant( | |
| 125 const uint8_t* encoded, | |
| 126 size_t encoded_len) const { | |
| 127 CriticalSectionScoped cs(encoder_lock_.get()); | |
| 128 return encoder()->PacketDurationRedundant(encoded, encoded_len); | |
| 129 } | |
| 130 | |
| 131 bool AudioEncoderDecoderMutableIsacFloat::PacketHasFec( | |
| 132 const uint8_t* encoded, | |
| 133 size_t encoded_len) const { | |
| 134 CriticalSectionScoped cs(encoder_lock_.get()); | |
| 135 return encoder()->PacketHasFec(encoded, encoded_len); | |
| 136 } | |
| 137 | |
| 138 size_t AudioEncoderDecoderMutableIsacFloat::Channels() const { | |
| 139 CriticalSectionScoped cs(encoder_lock_.get()); | |
| 140 return encoder()->Channels(); | |
| 141 } | |
| 142 | |
| 143 } // namespace webrtc | 58 } // namespace webrtc |
| OLD | NEW |