音视频编解码器的ID列表
Codec ID,就是PayloadType类型。
因为每种CodecID必须是只对应视频或者音频的编解码类型。如果PayloadType类型一样,则无法区分是视频还是音频,所以音频和视频不能同时使用102,103,104 其中一个Codec ID 。
设置编解码器ID
MergeCodecs
h:\webrtc-20210315\webrtc-20210315\webrtc\webrtc-checkout\src\pc\media_session.cc
// Adds all codecs from |reference_codecs| to |offered_codecs| that don't// already exist in |offered_codecs| and ensure the payload types don't// collide.template <class C>static void MergeCodecs(const std::vector<C>& reference_codecs,std::vector<C>* offered_codecs,UsedPayloadTypes* used_pltypes) {// Add all new codecs that are not RTX codecs.for (const C& reference_codec : reference_codecs) {if (!IsRtxCodec(reference_codec) &&!FindMatchingCodec<C>(reference_codecs, *offered_codecs,reference_codec, nullptr)) {C codec = reference_codec;used_pltypes->FindAndSetIdUsed(&codec);offered_codecs->push_back(codec);}}// Add all new RTX codecs.for (const C& reference_codec : reference_codecs) {if (IsRtxCodec(reference_codec) &&!FindMatchingCodec<C>(reference_codecs, *offered_codecs,reference_codec, nullptr)) {C rtx_codec = reference_codec;const C* associated_codec =GetAssociatedCodec(reference_codecs, rtx_codec);if (!associated_codec) {continue;}// Find a codec in the offered list that matches the reference codec.// Its payload type may be different than the reference codec.C matching_codec;if (!FindMatchingCodec<C>(reference_codecs, *offered_codecs,*associated_codec, &matching_codec)) {RTC_LOG(LS_WARNING)<< "Couldn't find matching " << associated_codec->name << " codec.";continue;}rtx_codec.params[kCodecParamAssociatedPayloadType] =rtc::ToString(matching_codec.id);used_pltypes->FindAndSetIdUsed(&rtx_codec);offered_codecs->push_back(rtx_codec);}}}
FindAndSetIdUsed
H:\webrtc-20210315\webrtc-20210315\webrtc\webrtc-checkout\src\pc\used_ids.h
// Loops through all Id in |ids| and changes its id if it is// already in use by another IdStruct. Call this methods with all Id// in a session description to make sure no duplicate ids exists.// Note that typename Id must be a type of IdStruct.template <typename Id>void FindAndSetIdUsed(std::vector<Id>* ids) {for (const Id& id : *ids) {FindAndSetIdUsed(&id);}}// Finds and sets an unused id if the |idstruct| id is already in use.void FindAndSetIdUsed(IdStruct* idstruct) {const int original_id = idstruct->id;int new_id = idstruct->id;if (original_id > max_allowed_id_ || original_id < min_allowed_id_) {// If the original id is not in range - this is an id that can't be// dynamically changed.return;}if (IsIdUsed(original_id)) {new_id = FindUnusedId();RTC_LOG(LS_WARNING) << "Duplicate id found. Reassigning from "<< original_id << " to " << new_id;idstruct->id = new_id;}SetIdUsed(new_id);}
编解码器ID范围
编解码器获取新的ID算法
结论

H:\webrtc-20210315\webrtc-20210315\webrtc\webrtc-checkout\src\pc\session_description.h
SessionDescription
