Channel中的SetSendParameters
WebRtcVideoChannel::GetChangedSendParameters

negotiated_codecs:获取协商好的编码器,就是从本端获取跟远端匹配的视频编码器。
WebRtcVideoChannel::MapCodecs
std::vector<WebRtcVideoChannel::VideoCodecSettings>WebRtcVideoChannel::MapCodecs(const std::vector<VideoCodec>& codecs) {if (codecs.empty()) {return {};}std::vector<VideoCodecSettings> video_codecs;std::map<int, VideoCodec::CodecType> payload_codec_type;// |rtx_mapping| maps video payload type to rtx payload type.std::map<int, int> rtx_mapping;webrtc::UlpfecConfig ulpfec_config;absl::optional<int> flexfec_payload_type;for (const VideoCodec& in_codec : codecs) {const int payload_type = in_codec.id;if (payload_codec_type.find(payload_type) != payload_codec_type.end()) {RTC_LOG(LS_ERROR) << "Payload type already registered: "<< in_codec.ToString();return {};}payload_codec_type[payload_type] = in_codec.GetCodecType();switch (in_codec.GetCodecType()) {****case VideoCodec::CODEC_VIDEO: {video_codecs.emplace_back();video_codecs.back().codec = in_codec;break;}}}// One of these codecs should have been a video codec. Only having FEC// parameters into this code is a logic error.RTC_DCHECK(!video_codecs.empty());*****for (VideoCodecSettings& codec_settings : video_codecs) {const int payload_type = codec_settings.codec.id;codec_settings.ulpfec = ulpfec_config;codec_settings.flexfec_payload_type = flexfec_payload_type.value_or(-1);auto it = rtx_mapping.find(payload_type);if (it != rtx_mapping.end()) {const int rtx_payload_type = it->second;codec_settings.rtx_payload_type = rtx_payload_type;}}return video_codecs;}
WebRtcVideoChannel::SelectSendVideoCodecs
std::vector<WebRtcVideoChannel::VideoCodecSettings>WebRtcVideoChannel::SelectSendVideoCodecs(const std::vector<VideoCodecSettings>& remote_mapped_codecs) const {std::vector<webrtc::SdpVideoFormat> sdp_formats =encoder_factory_ ? encoder_factory_->GetImplementations(): std::vector<webrtc::SdpVideoFormat>();// The returned vector holds the VideoCodecSettings in term of preference.// They are orderd by receive codec preference first and local implementation// preference second.std::vector<VideoCodecSettings> encoders;for (const VideoCodecSettings& remote_codec : remote_mapped_codecs) {for (auto format_it = sdp_formats.begin();format_it != sdp_formats.end();) {// For H264, we will limit the encode level to the remote offered level// regardless if level asymmetry is allowed or not. This is strictly not// following the spec in https://tools.ietf.org/html/rfc6184#section-8.2.2// since we should limit the encode level to the lower of local and remote// level when level asymmetry is not allowed.if (IsSameCodec(format_it->name, format_it->parameters,remote_codec.codec.name, remote_codec.codec.params)) {encoders.push_back(remote_codec);// To allow the VideoEncoderFactory to keep information about which// implementation to instantitate when CreateEncoder is called the two// parmeter sets are merged.encoders.back().codec.params.insert(format_it->parameters.begin(),format_it->parameters.end());format_it = sdp_formats.erase(format_it);} else {++format_it;}}}return encoders;}


对比结果
发现都支持输入的4个编码器。后面会使用第一个作为视频编码器设置。
Stream中的SetSendParameters

