OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 case VADVeryAggr: | 70 case VADVeryAggr: |
71 config.vad_mode = Vad::kVadVeryAggressive; | 71 config.vad_mode = Vad::kVadVeryAggressive; |
72 break; | 72 break; |
73 default: | 73 default: |
74 FATAL(); | 74 FATAL(); |
75 } | 75 } |
76 cng_encoder->reset(new AudioEncoderCng(config)); | 76 cng_encoder->reset(new AudioEncoderCng(config)); |
77 } | 77 } |
78 } // namespace | 78 } // namespace |
79 | 79 |
80 bool CodecOwner::SetEncoders(const CodecInst& speech_inst, | |
81 int cng_payload_type, | |
82 ACMVADMode vad_mode, | |
83 int red_payload_type) { | |
84 AudioEncoder* speech_encoder = rent_a_codec_.RentEncoder(speech_inst); | |
85 if (!speech_encoder) | |
86 return false; | |
87 SetEncoders(speech_encoder, cng_payload_type, vad_mode, red_payload_type); | |
88 return true; | |
89 } | |
90 | |
91 void CodecOwner::SetEncoders(AudioEncoder* external_speech_encoder, | 80 void CodecOwner::SetEncoders(AudioEncoder* external_speech_encoder, |
92 int cng_payload_type, | 81 int cng_payload_type, |
93 ACMVADMode vad_mode, | 82 ACMVADMode vad_mode, |
94 int red_payload_type) { | 83 int red_payload_type) { |
95 speech_encoder_ = external_speech_encoder; | 84 speech_encoder_ = external_speech_encoder; |
96 ChangeCngAndRed(cng_payload_type, vad_mode, red_payload_type); | 85 ChangeCngAndRed(cng_payload_type, vad_mode, red_payload_type); |
97 } | 86 } |
98 | 87 |
99 void CodecOwner::ChangeCngAndRed(int cng_payload_type, | 88 void CodecOwner::ChangeCngAndRed(int cng_payload_type, |
100 ACMVADMode vad_mode, | 89 ACMVADMode vad_mode, |
101 int red_payload_type) { | 90 int red_payload_type) { |
102 RTC_DCHECK(speech_encoder_); | 91 RTC_DCHECK(speech_encoder_); |
103 if (cng_payload_type != -1 || red_payload_type != -1) { | 92 if (cng_payload_type != -1 || red_payload_type != -1) { |
104 // The RED and CNG encoders need to be in sync with the speech encoder, so | 93 // The RED and CNG encoders need to be in sync with the speech encoder, so |
105 // reset the latter to ensure its buffer is empty. | 94 // reset the latter to ensure its buffer is empty. |
106 speech_encoder_->Reset(); | 95 speech_encoder_->Reset(); |
107 } | 96 } |
108 AudioEncoder* encoder = CreateRedEncoder( | 97 AudioEncoder* encoder = CreateRedEncoder( |
109 red_payload_type, speech_encoder_, &red_encoder_); | 98 red_payload_type, speech_encoder_, &red_encoder_); |
110 CreateCngEncoder(cng_payload_type, vad_mode, encoder, &cng_encoder_); | 99 CreateCngEncoder(cng_payload_type, vad_mode, encoder, &cng_encoder_); |
111 } | 100 } |
112 | 101 |
113 AudioDecoder* CodecOwner::GetIsacDecoder() { | |
114 return rent_a_codec_.RentIsacDecoder(); | |
115 } | |
116 | |
117 AudioEncoder* CodecOwner::Encoder() { | 102 AudioEncoder* CodecOwner::Encoder() { |
118 const auto& const_this = *this; | 103 const auto& const_this = *this; |
119 return const_cast<AudioEncoder*>(const_this.Encoder()); | 104 return const_cast<AudioEncoder*>(const_this.Encoder()); |
120 } | 105 } |
121 | 106 |
122 const AudioEncoder* CodecOwner::Encoder() const { | 107 const AudioEncoder* CodecOwner::Encoder() const { |
123 if (cng_encoder_) | 108 if (cng_encoder_) |
124 return cng_encoder_.get(); | 109 return cng_encoder_.get(); |
125 if (red_encoder_) | 110 if (red_encoder_) |
126 return red_encoder_.get(); | 111 return red_encoder_.get(); |
127 return speech_encoder_; | 112 return speech_encoder_; |
128 } | 113 } |
129 | 114 |
130 } // namespace acm2 | 115 } // namespace acm2 |
131 } // namespace webrtc | 116 } // namespace webrtc |
OLD | NEW |