| 131 | } |
| 132 | |
| 133 | std::vector<int> DecoderDatabase::SetCodecs( |
| 134 | const std::map<int, SdpAudioFormat>& codecs) { |
| 135 | // First collect all payload types that we'll remove or reassign, then remove |
| 136 | // them from the database. |
| 137 | std::vector<int> changed_payload_types; |
| 138 | for (const std::pair<uint8_t, const DecoderInfo&> kv : decoders_) { |
| 139 | auto i = codecs.find(kv.first); |
| 140 | if (i == codecs.end() || i->second != kv.second.GetFormat()) { |
| 141 | changed_payload_types.push_back(kv.first); |
| 142 | } |
| 143 | } |
| 144 | for (int pl_type : changed_payload_types) { |
| 145 | Remove(pl_type); |
| 146 | } |
| 147 | |
| 148 | // Enter the new and changed payload type mappings into the database. |
| 149 | for (const auto& kv : codecs) { |
| 150 | const int& rtp_payload_type = kv.first; |
| 151 | const SdpAudioFormat& audio_format = kv.second; |
| 152 | RTC_DCHECK_GE(rtp_payload_type, 0); |
| 153 | RTC_DCHECK_LE(rtp_payload_type, 0x7f); |
| 154 | if (decoders_.count(rtp_payload_type) == 0) { |
| 155 | decoders_.insert(std::make_pair( |
| 156 | rtp_payload_type, |
| 157 | DecoderInfo(audio_format, codec_pair_id_, decoder_factory_.get()))); |
| 158 | } else { |
| 159 | // The mapping for this payload type hasn't changed. |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | return changed_payload_types; |
| 164 | } |
| 165 | |
| 166 | int DecoderDatabase::RegisterPayload(int rtp_payload_type, |
| 167 | const SdpAudioFormat& audio_format) { |
nothing calls this directly
no test coverage detected