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) {//遍历远端的codec
for (auto format_it = sdp_formats.begin();
format_it != sdp_formats.end();) {//遍历本地的codec
// 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)) {//本地与远端的codec是否相同
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;//本地与远端都支持的codecs
}
webrtc音视频
最新推荐文章于 2024-04-29 22:24:45 发布