Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: webrtc/modules/audio_coding/codecs/isac/fix/source/audio_encoder_isacfix.cc

Issue 1208993010: iSAC: Make separate AudioEncoder and AudioDecoder objects (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: review fixes Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/fix/interface/audio_encoder_is acfix.h" 11 #include "webrtc/modules/audio_coding/codecs/isac/fix/interface/audio_encoder_is acfix.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 const uint16_t IsacFix::kFixSampleRate; 18 const uint16_t IsacFix::kFixSampleRate;
19 19
20 // Explicit instantiation of AudioEncoderDecoderIsacT<IsacFix>, a.k.a. 20 // Explicit instantiation:
21 // AudioEncoderDecoderIsacFix. 21 template class AudioEncoderIsacT<IsacFix>;
22 template class AudioEncoderDecoderIsacT<IsacFix>; 22 template class AudioDecoderIsacT<IsacFix>;
23 23
24 namespace { 24 namespace {
25 AudioEncoderDecoderIsacFix::Config CreateConfig(const CodecInst& codec_inst) { 25 AudioEncoderIsacFix::Config CreateConfig(const CodecInst& codec_inst,
26 AudioEncoderDecoderIsacFix::Config config; 26 LockedIsacBandwidthInfo* bwinfo) {
27 AudioEncoderIsacFix::Config config;
28 config.bwinfo = bwinfo;
27 config.payload_type = codec_inst.pltype; 29 config.payload_type = codec_inst.pltype;
28 config.sample_rate_hz = codec_inst.plfreq; 30 config.sample_rate_hz = codec_inst.plfreq;
29 config.frame_size_ms = 31 config.frame_size_ms =
30 rtc::CheckedDivExact(1000 * codec_inst.pacsize, config.sample_rate_hz); 32 rtc::CheckedDivExact(1000 * codec_inst.pacsize, config.sample_rate_hz);
31 if (codec_inst.rate != -1) 33 if (codec_inst.rate != -1)
32 config.bit_rate = codec_inst.rate; 34 config.bit_rate = codec_inst.rate;
33 config.adaptive_mode = (codec_inst.rate == -1); 35 config.adaptive_mode = (codec_inst.rate == -1);
34 return config; 36 return config;
35 } 37 }
36 } // namespace 38 } // namespace
37 39
38 AudioEncoderDecoderMutableIsacFix::AudioEncoderDecoderMutableIsacFix( 40 AudioEncoderMutableIsacFix::AudioEncoderMutableIsacFix(
39 const CodecInst& codec_inst) 41 const CodecInst& codec_inst,
40 : AudioEncoderMutableImpl<AudioEncoderDecoderIsacFix, 42 LockedIsacBandwidthInfo* bwinfo)
41 AudioEncoderDecoderMutableIsac>( 43 : AudioEncoderMutableImpl<AudioEncoderIsacFix>(
42 CreateConfig(codec_inst)) { 44 CreateConfig(codec_inst, bwinfo)) {}
43 }
44 45
45 void AudioEncoderDecoderMutableIsacFix::UpdateSettings( 46 void AudioEncoderMutableIsacFix::SetMaxPayloadSize(int max_payload_size_bytes) {
46 const CodecInst& codec_inst) {
47 bool success = Reconstruct(CreateConfig(codec_inst));
48 DCHECK(success);
49 }
50
51 void AudioEncoderDecoderMutableIsacFix::SetMaxPayloadSize(
52 int max_payload_size_bytes) {
53 auto conf = config(); 47 auto conf = config();
54 conf.max_payload_size_bytes = max_payload_size_bytes; 48 conf.max_payload_size_bytes = max_payload_size_bytes;
55 Reconstruct(conf); 49 Reconstruct(conf);
56 } 50 }
57 51
58 void AudioEncoderDecoderMutableIsacFix::SetMaxRate(int max_rate_bps) { 52 void AudioEncoderMutableIsacFix::SetMaxRate(int max_rate_bps) {
59 auto conf = config(); 53 auto conf = config();
60 conf.max_bit_rate = max_rate_bps; 54 conf.max_bit_rate = max_rate_bps;
61 Reconstruct(conf); 55 Reconstruct(conf);
62 } 56 }
63 57
64 int AudioEncoderDecoderMutableIsacFix::Decode(const uint8_t* encoded,
65 size_t encoded_len,
66 int sample_rate_hz,
67 size_t max_decoded_bytes,
68 int16_t* decoded,
69 SpeechType* speech_type) {
70 CriticalSectionScoped cs(encoder_lock_.get());
71 return encoder()->Decode(encoded, encoded_len, sample_rate_hz,
72 max_decoded_bytes, decoded, speech_type);
73 }
74
75 int AudioEncoderDecoderMutableIsacFix::DecodeRedundant(
76 const uint8_t* encoded,
77 size_t encoded_len,
78 int sample_rate_hz,
79 size_t max_decoded_bytes,
80 int16_t* decoded,
81 SpeechType* speech_type) {
82 CriticalSectionScoped cs(encoder_lock_.get());
83 return encoder()->DecodeRedundant(encoded, encoded_len, sample_rate_hz,
84 max_decoded_bytes, decoded, speech_type);
85 }
86
87 bool AudioEncoderDecoderMutableIsacFix::HasDecodePlc() const {
88 CriticalSectionScoped cs(encoder_lock_.get());
89 return encoder()->HasDecodePlc();
90 }
91
92 int AudioEncoderDecoderMutableIsacFix::DecodePlc(int num_frames,
93 int16_t* decoded) {
94 CriticalSectionScoped cs(encoder_lock_.get());
95 return encoder()->DecodePlc(num_frames, decoded);
96 }
97
98 int AudioEncoderDecoderMutableIsacFix::Init() {
99 CriticalSectionScoped cs(encoder_lock_.get());
100 return encoder()->Init();
101 }
102
103 int AudioEncoderDecoderMutableIsacFix::IncomingPacket(
104 const uint8_t* payload,
105 size_t payload_len,
106 uint16_t rtp_sequence_number,
107 uint32_t rtp_timestamp,
108 uint32_t arrival_timestamp) {
109 CriticalSectionScoped cs(encoder_lock_.get());
110 return encoder()->IncomingPacket(payload, payload_len, rtp_sequence_number,
111 rtp_timestamp, arrival_timestamp);
112 }
113
114 int AudioEncoderDecoderMutableIsacFix::ErrorCode() {
115 CriticalSectionScoped cs(encoder_lock_.get());
116 return encoder()->ErrorCode();
117 }
118
119 int AudioEncoderDecoderMutableIsacFix::PacketDuration(
120 const uint8_t* encoded,
121 size_t encoded_len) const {
122 CriticalSectionScoped cs(encoder_lock_.get());
123 return encoder()->PacketDuration(encoded, encoded_len);
124 }
125
126 int AudioEncoderDecoderMutableIsacFix::PacketDurationRedundant(
127 const uint8_t* encoded,
128 size_t encoded_len) const {
129 CriticalSectionScoped cs(encoder_lock_.get());
130 return encoder()->PacketDurationRedundant(encoded, encoded_len);
131 }
132
133 bool AudioEncoderDecoderMutableIsacFix::PacketHasFec(const uint8_t* encoded,
134 size_t encoded_len) const {
135 CriticalSectionScoped cs(encoder_lock_.get());
136 return encoder()->PacketHasFec(encoded, encoded_len);
137 }
138
139 size_t AudioEncoderDecoderMutableIsacFix::Channels() const {
140 CriticalSectionScoped cs(encoder_lock_.get());
141 return encoder()->Channels();
142 }
143
144 } // namespace webrtc 58 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698