OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 if (error != 0) { | 167 if (error != 0) { |
168 error_code_ = error; | 168 error_code_ = error; |
169 return kFail; | 169 return kFail; |
170 } | 170 } |
171 if (type) { | 171 if (type) { |
172 *type = LastOutputType(); | 172 *type = LastOutputType(); |
173 } | 173 } |
174 return kOK; | 174 return kOK; |
175 } | 175 } |
176 | 176 |
177 int NetEqImpl::RegisterPayloadType(enum NetEqDecoder codec, | 177 int NetEqImpl::RegisterPayloadType(NetEqDecoder codec, |
178 uint8_t rtp_payload_type) { | 178 uint8_t rtp_payload_type) { |
179 CriticalSectionScoped lock(crit_sect_.get()); | 179 CriticalSectionScoped lock(crit_sect_.get()); |
180 LOG(LS_VERBOSE) << "RegisterPayloadType " | 180 LOG(LS_VERBOSE) << "RegisterPayloadType " |
181 << static_cast<int>(rtp_payload_type) << " " << codec; | 181 << static_cast<int>(rtp_payload_type) << " " |
| 182 << static_cast<int>(codec); |
182 int ret = decoder_database_->RegisterPayload(rtp_payload_type, codec); | 183 int ret = decoder_database_->RegisterPayload(rtp_payload_type, codec); |
183 if (ret != DecoderDatabase::kOK) { | 184 if (ret != DecoderDatabase::kOK) { |
184 switch (ret) { | 185 switch (ret) { |
185 case DecoderDatabase::kInvalidRtpPayloadType: | 186 case DecoderDatabase::kInvalidRtpPayloadType: |
186 error_code_ = kInvalidRtpPayloadType; | 187 error_code_ = kInvalidRtpPayloadType; |
187 break; | 188 break; |
188 case DecoderDatabase::kCodecNotSupported: | 189 case DecoderDatabase::kCodecNotSupported: |
189 error_code_ = kCodecNotSupported; | 190 error_code_ = kCodecNotSupported; |
190 break; | 191 break; |
191 case DecoderDatabase::kDecoderExists: | 192 case DecoderDatabase::kDecoderExists: |
192 error_code_ = kDecoderExists; | 193 error_code_ = kDecoderExists; |
193 break; | 194 break; |
194 default: | 195 default: |
195 error_code_ = kOtherError; | 196 error_code_ = kOtherError; |
196 } | 197 } |
197 return kFail; | 198 return kFail; |
198 } | 199 } |
199 return kOK; | 200 return kOK; |
200 } | 201 } |
201 | 202 |
202 int NetEqImpl::RegisterExternalDecoder(AudioDecoder* decoder, | 203 int NetEqImpl::RegisterExternalDecoder(AudioDecoder* decoder, |
203 enum NetEqDecoder codec, | 204 NetEqDecoder codec, |
204 uint8_t rtp_payload_type, | 205 uint8_t rtp_payload_type, |
205 int sample_rate_hz) { | 206 int sample_rate_hz) { |
206 CriticalSectionScoped lock(crit_sect_.get()); | 207 CriticalSectionScoped lock(crit_sect_.get()); |
207 LOG(LS_VERBOSE) << "RegisterExternalDecoder " | 208 LOG(LS_VERBOSE) << "RegisterExternalDecoder " |
208 << static_cast<int>(rtp_payload_type) << " " << codec; | 209 << static_cast<int>(rtp_payload_type) << " " |
| 210 << static_cast<int>(codec); |
209 if (!decoder) { | 211 if (!decoder) { |
210 LOG(LS_ERROR) << "Cannot register external decoder with NULL pointer"; | 212 LOG(LS_ERROR) << "Cannot register external decoder with NULL pointer"; |
211 assert(false); | 213 assert(false); |
212 return kFail; | 214 return kFail; |
213 } | 215 } |
214 int ret = decoder_database_->InsertExternal(rtp_payload_type, codec, | 216 int ret = decoder_database_->InsertExternal(rtp_payload_type, codec, |
215 sample_rate_hz, decoder); | 217 sample_rate_hz, decoder); |
216 if (ret != DecoderDatabase::kOK) { | 218 if (ret != DecoderDatabase::kOK) { |
217 switch (ret) { | 219 switch (ret) { |
218 case DecoderDatabase::kInvalidRtpPayloadType: | 220 case DecoderDatabase::kInvalidRtpPayloadType: |
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 Packet* packet = packet_list->front(); | 1640 Packet* packet = packet_list->front(); |
1639 packet_list->pop_front(); | 1641 packet_list->pop_front(); |
1640 if (!decoder_database_->IsComfortNoise(packet->header.payloadType)) { | 1642 if (!decoder_database_->IsComfortNoise(packet->header.payloadType)) { |
1641 #ifdef LEGACY_BITEXACT | 1643 #ifdef LEGACY_BITEXACT |
1642 // This can happen due to a bug in GetDecision. Change the payload type | 1644 // This can happen due to a bug in GetDecision. Change the payload type |
1643 // to a CNG type, and move on. Note that this means that we are in fact | 1645 // to a CNG type, and move on. Note that this means that we are in fact |
1644 // sending a non-CNG payload to the comfort noise decoder for decoding. | 1646 // sending a non-CNG payload to the comfort noise decoder for decoding. |
1645 // Clearly wrong, but will maintain bit-exactness with legacy. | 1647 // Clearly wrong, but will maintain bit-exactness with legacy. |
1646 if (fs_hz_ == 8000) { | 1648 if (fs_hz_ == 8000) { |
1647 packet->header.payloadType = | 1649 packet->header.payloadType = |
1648 decoder_database_->GetRtpPayloadType(kDecoderCNGnb); | 1650 decoder_database_->GetRtpPayloadType(NetEqDecoder::kDecoderCNGnb); |
1649 } else if (fs_hz_ == 16000) { | 1651 } else if (fs_hz_ == 16000) { |
1650 packet->header.payloadType = | 1652 packet->header.payloadType = |
1651 decoder_database_->GetRtpPayloadType(kDecoderCNGwb); | 1653 decoder_database_->GetRtpPayloadType(NetEqDecoder::kDecoderCNGwb); |
1652 } else if (fs_hz_ == 32000) { | 1654 } else if (fs_hz_ == 32000) { |
1653 packet->header.payloadType = | 1655 packet->header.payloadType = decoder_database_->GetRtpPayloadType( |
1654 decoder_database_->GetRtpPayloadType(kDecoderCNGswb32kHz); | 1656 NetEqDecoder::kDecoderCNGswb32kHz); |
1655 } else if (fs_hz_ == 48000) { | 1657 } else if (fs_hz_ == 48000) { |
1656 packet->header.payloadType = | 1658 packet->header.payloadType = decoder_database_->GetRtpPayloadType( |
1657 decoder_database_->GetRtpPayloadType(kDecoderCNGswb48kHz); | 1659 NetEqDecoder::kDecoderCNGswb48kHz); |
1658 } | 1660 } |
1659 assert(decoder_database_->IsComfortNoise(packet->header.payloadType)); | 1661 assert(decoder_database_->IsComfortNoise(packet->header.payloadType)); |
1660 #else | 1662 #else |
1661 LOG(LS_ERROR) << "Trying to decode non-CNG payload as CNG."; | 1663 LOG(LS_ERROR) << "Trying to decode non-CNG payload as CNG."; |
1662 return kOtherError; | 1664 return kOtherError; |
1663 #endif | 1665 #endif |
1664 } | 1666 } |
1665 // UpdateParameters() deletes |packet|. | 1667 // UpdateParameters() deletes |packet|. |
1666 if (comfort_noise_->UpdateParameters(packet) == | 1668 if (comfort_noise_->UpdateParameters(packet) == |
1667 ComfortNoise::kInternalError) { | 1669 ComfortNoise::kInternalError) { |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2026 | 2028 |
2027 void NetEqImpl::CreateDecisionLogic() { | 2029 void NetEqImpl::CreateDecisionLogic() { |
2028 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, | 2030 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, |
2029 playout_mode_, | 2031 playout_mode_, |
2030 decoder_database_.get(), | 2032 decoder_database_.get(), |
2031 *packet_buffer_.get(), | 2033 *packet_buffer_.get(), |
2032 delay_manager_.get(), | 2034 delay_manager_.get(), |
2033 buffer_level_filter_.get())); | 2035 buffer_level_filter_.get())); |
2034 } | 2036 } |
2035 } // namespace webrtc | 2037 } // namespace webrtc |
OLD | NEW |