OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 } | 223 } |
224 if (ret_val != NetEq::kOK) { | 224 if (ret_val != NetEq::kOK) { |
225 LOG(LERROR) << "AcmReceiver::AddCodec " << acm_codec_id | 225 LOG(LERROR) << "AcmReceiver::AddCodec " << acm_codec_id |
226 << static_cast<int>(payload_type) | 226 << static_cast<int>(payload_type) |
227 << " channels: " << channels; | 227 << " channels: " << channels; |
228 return -1; | 228 return -1; |
229 } | 229 } |
230 return 0; | 230 return 0; |
231 } | 231 } |
232 | 232 |
| 233 bool AcmReceiver::AddCodec(int rtp_payload_type, |
| 234 const SdpAudioFormat& audio_format) { |
| 235 const auto old_format = neteq_->GetDecoderFormat(rtp_payload_type); |
| 236 if (old_format && *old_format == audio_format) { |
| 237 // Re-registering the same codec. Do nothing and return. |
| 238 return true; |
| 239 } |
| 240 |
| 241 if (neteq_->RemovePayloadType(rtp_payload_type) != NetEq::kOK && |
| 242 neteq_->LastError() != NetEq::kDecoderNotFound) { |
| 243 LOG(LERROR) << "AcmReceiver::AddCodec: Could not remove existing decoder" |
| 244 " for payload type " |
| 245 << rtp_payload_type; |
| 246 return false; |
| 247 } |
| 248 |
| 249 const bool success = |
| 250 neteq_->RegisterPayloadType(rtp_payload_type, audio_format); |
| 251 if (!success) { |
| 252 LOG(LERROR) << "AcmReceiver::AddCodec failed for payload type " |
| 253 << rtp_payload_type << ", decoder format " << audio_format; |
| 254 } |
| 255 return success; |
| 256 } |
| 257 |
233 void AcmReceiver::FlushBuffers() { | 258 void AcmReceiver::FlushBuffers() { |
234 neteq_->FlushBuffers(); | 259 neteq_->FlushBuffers(); |
235 } | 260 } |
236 | 261 |
237 void AcmReceiver::RemoveAllCodecs() { | 262 void AcmReceiver::RemoveAllCodecs() { |
238 rtc::CritScope lock(&crit_sect_); | 263 rtc::CritScope lock(&crit_sect_); |
239 neteq_->RemoveAllPayloadTypes(); | 264 neteq_->RemoveAllPayloadTypes(); |
240 last_audio_decoder_ = rtc::Optional<CodecInst>(); | 265 last_audio_decoder_ = rtc::Optional<CodecInst>(); |
241 last_packet_sample_rate_hz_ = rtc::Optional<int>(); | 266 last_packet_sample_rate_hz_ = rtc::Optional<int>(); |
242 } | 267 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 379 |
355 void AcmReceiver::GetDecodingCallStatistics( | 380 void AcmReceiver::GetDecodingCallStatistics( |
356 AudioDecodingCallStats* stats) const { | 381 AudioDecodingCallStats* stats) const { |
357 rtc::CritScope lock(&crit_sect_); | 382 rtc::CritScope lock(&crit_sect_); |
358 *stats = call_stats_.GetDecodingStatistics(); | 383 *stats = call_stats_.GetDecodingStatistics(); |
359 } | 384 } |
360 | 385 |
361 } // namespace acm2 | 386 } // namespace acm2 |
362 | 387 |
363 } // namespace webrtc | 388 } // namespace webrtc |
OLD | NEW |