| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 bool DecoderDatabase::Empty() const { return decoders_.empty(); } | 116 bool DecoderDatabase::Empty() const { return decoders_.empty(); } |
| 117 | 117 |
| 118 int DecoderDatabase::Size() const { return static_cast<int>(decoders_.size()); } | 118 int DecoderDatabase::Size() const { return static_cast<int>(decoders_.size()); } |
| 119 | 119 |
| 120 void DecoderDatabase::Reset() { | 120 void DecoderDatabase::Reset() { |
| 121 decoders_.clear(); | 121 decoders_.clear(); |
| 122 active_decoder_type_ = -1; | 122 active_decoder_type_ = -1; |
| 123 active_cng_decoder_type_ = -1; | 123 active_cng_decoder_type_ = -1; |
| 124 } | 124 } |
| 125 | 125 |
| 126 std::vector<int> DecoderDatabase::SetCodecs( |
| 127 const std::map<int, SdpAudioFormat>& codecs) { |
| 128 // First collect all payload types that we'll remove or reassign, then remove |
| 129 // them from the database. |
| 130 std::vector<int> changed_payload_types; |
| 131 for (const std::pair<uint8_t, const DecoderInfo&> kv : decoders_) { |
| 132 auto i = codecs.find(kv.first); |
| 133 if (i == codecs.end() || i->second != kv.second.GetFormat()) { |
| 134 changed_payload_types.push_back(kv.first); |
| 135 } |
| 136 } |
| 137 for (int pl_type : changed_payload_types) { |
| 138 Remove(pl_type); |
| 139 } |
| 140 |
| 141 // Enter the new and changed payload type mappings into the database. |
| 142 for (const auto& kv : codecs) { |
| 143 const int& rtp_payload_type = kv.first; |
| 144 const SdpAudioFormat& audio_format = kv.second; |
| 145 RTC_DCHECK_GE(rtp_payload_type, 0); |
| 146 RTC_DCHECK_LE(rtp_payload_type, 0x7f); |
| 147 if (decoders_.count(rtp_payload_type) == 0) { |
| 148 decoders_.insert(std::make_pair( |
| 149 rtp_payload_type, DecoderInfo(audio_format, decoder_factory_.get()))); |
| 150 } else { |
| 151 // The mapping for this payload type hasn't changed. |
| 152 } |
| 153 } |
| 154 |
| 155 return changed_payload_types; |
| 156 } |
| 157 |
| 126 int DecoderDatabase::RegisterPayload(uint8_t rtp_payload_type, | 158 int DecoderDatabase::RegisterPayload(uint8_t rtp_payload_type, |
| 127 NetEqDecoder codec_type, | 159 NetEqDecoder codec_type, |
| 128 const std::string& name) { | 160 const std::string& name) { |
| 129 if (rtp_payload_type > 0x7F) { | 161 if (rtp_payload_type > 0x7F) { |
| 130 return kInvalidRtpPayloadType; | 162 return kInvalidRtpPayloadType; |
| 131 } | 163 } |
| 132 // kCodecArbitrary is only supported through InsertExternal. | 164 // kCodecArbitrary is only supported through InsertExternal. |
| 133 if (codec_type == NetEqDecoder::kDecoderArbitrary || | 165 if (codec_type == NetEqDecoder::kDecoderArbitrary || |
| 134 !CodecSupported(codec_type)) { | 166 !CodecSupported(codec_type)) { |
| 135 return kCodecNotSupported; | 167 return kCodecNotSupported; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 // Payload type is not found. | 346 // Payload type is not found. |
| 315 LOG(LS_WARNING) << "CheckPayloadTypes: unknown RTP payload type " | 347 LOG(LS_WARNING) << "CheckPayloadTypes: unknown RTP payload type " |
| 316 << static_cast<int>(it->payload_type); | 348 << static_cast<int>(it->payload_type); |
| 317 return kDecoderNotFound; | 349 return kDecoderNotFound; |
| 318 } | 350 } |
| 319 } | 351 } |
| 320 return kOK; | 352 return kOK; |
| 321 } | 353 } |
| 322 | 354 |
| 323 } // namespace webrtc | 355 } // namespace webrtc |
| OLD | NEW |