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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 decoder.channels = channels; | 238 decoder.channels = channels; |
239 decoder.sample_rate_hz = sample_rate_hz; | 239 decoder.sample_rate_hz = sample_rate_hz; |
240 decoders_[payload_type] = decoder; | 240 decoders_[payload_type] = decoder; |
241 return 0; | 241 return 0; |
242 } | 242 } |
243 | 243 |
244 void AcmReceiver::FlushBuffers() { | 244 void AcmReceiver::FlushBuffers() { |
245 neteq_->FlushBuffers(); | 245 neteq_->FlushBuffers(); |
246 } | 246 } |
247 | 247 |
248 void AcmReceiver::RemoveAllCodecs() { | 248 // If failed in removing one of the codecs, this method continues to remove as |
| 249 // many as it can. |
| 250 int AcmReceiver::RemoveAllCodecs() { |
| 251 int ret_val = 0; |
249 rtc::CritScope lock(&crit_sect_); | 252 rtc::CritScope lock(&crit_sect_); |
250 neteq_->RemoveAllPayloadTypes(); | 253 for (auto it = decoders_.begin(); it != decoders_.end(); ) { |
251 decoders_.clear(); | 254 auto cur = it; |
| 255 ++it; // it will be valid even if we erase cur |
| 256 if (neteq_->RemovePayloadType(cur->second.payload_type) == 0) { |
| 257 decoders_.erase(cur); |
| 258 } else { |
| 259 LOG_F(LS_ERROR) << "Cannot remove payload " |
| 260 << static_cast<int>(cur->second.payload_type); |
| 261 ret_val = -1; |
| 262 } |
| 263 } |
| 264 |
| 265 // No codec is registered, invalidate last audio decoder. |
252 last_audio_decoder_ = rtc::Optional<CodecInst>(); | 266 last_audio_decoder_ = rtc::Optional<CodecInst>(); |
253 last_packet_sample_rate_hz_ = rtc::Optional<int>(); | 267 last_packet_sample_rate_hz_ = rtc::Optional<int>(); |
| 268 return ret_val; |
254 } | 269 } |
255 | 270 |
256 int AcmReceiver::RemoveCodec(uint8_t payload_type) { | 271 int AcmReceiver::RemoveCodec(uint8_t payload_type) { |
257 rtc::CritScope lock(&crit_sect_); | 272 rtc::CritScope lock(&crit_sect_); |
258 auto it = decoders_.find(payload_type); | 273 auto it = decoders_.find(payload_type); |
259 if (it == decoders_.end()) { // Such a payload-type is not registered. | 274 if (it == decoders_.end()) { // Such a payload-type is not registered. |
260 return 0; | 275 return 0; |
261 } | 276 } |
262 if (neteq_->RemovePayloadType(payload_type) != NetEq::kOK) { | 277 if (neteq_->RemovePayloadType(payload_type) != NetEq::kOK) { |
263 LOG(LERROR) << "AcmReceiver::RemoveCodec" << static_cast<int>(payload_type); | 278 LOG(LERROR) << "AcmReceiver::RemoveCodec" << static_cast<int>(payload_type); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 389 |
375 void AcmReceiver::GetDecodingCallStatistics( | 390 void AcmReceiver::GetDecodingCallStatistics( |
376 AudioDecodingCallStats* stats) const { | 391 AudioDecodingCallStats* stats) const { |
377 rtc::CritScope lock(&crit_sect_); | 392 rtc::CritScope lock(&crit_sect_); |
378 *stats = call_stats_.GetDecodingStatistics(); | 393 *stats = call_stats_.GetDecodingStatistics(); |
379 } | 394 } |
380 | 395 |
381 } // namespace acm2 | 396 } // namespace acm2 |
382 | 397 |
383 } // namespace webrtc | 398 } // namespace webrtc |
OLD | NEW |