WebRTC[14]-WebRTC如何通过参数控制编码模式切换(DIsabled模式)
目录
前言
WebRTC的编码模式有很多种,其实是可以通过参数进行控制的,今天我们就来一探究竟,本文以M67为例。
正文
直接看关键函数:bool WebRtcVideoChannel::AddSendStream(const StreamParams& sp)
调用AddSendStream()方法时,WebRTC首先会检验StreamParams参数是否有效,然后判断SSRC是否可用。创建WebRtcVideoSendStream实例的时候,将参数传递给WebRtcVideoSendStream对象。参数sp经过CreateRtpParametersWithEncodings处理后,赋值给rtp_parameters_。
webrtc::DegradationPreference WebRtcVideoChannel::WebRtcVideoSendStream::GetDegradationPreference() const { // Do not adapt resolution for screen content as this will likely // result in blurry and unreadable text. // |this| acts like a VideoSource to make sure SinkWants are handled on the // correct thread. webrtc::DegradationPreference degradation_preference; if (rtp_parameters_.degradation_preference != webrtc::DegradationPreference::BALANCED) { // If the degradationPreference is different from the default value, assume // it is what we want, regardless of trials or other internal settings. degradation_preference = rtp_parameters_.degradation_preference; } else if (!enable_cpu_overuse_detection_) { degradation_preference = webrtc::DegradationPreference::DISABLED; } else if (parameters_.options.is_screencast.value_or(false)) { degradation_preference = webrtc::DegradationPreference::MAINTAIN_RESOLUTION; } else if (webrtc::field_trial::IsEnabled( "WebRTC-Video-BalancedDegradation")) { degradation_preference = webrtc::DegradationPreference::BALANCED; } else { // TODO(orphis): The default should be BALANCED as the standard mandates. // Right now, there is no way to degradation_preference = webrtc::DegradationPreference::MAINTAIN_FRAMERATE; } degradation_preference; }
剩余60%内容,订阅专栏后可继续查看/也可单篇购买
WebRTC工作原理精讲 文章被收录于专栏
WebRTC 作为当下最热门的实时音视频通讯框架,涉及非常多的过程,比如采集、编码、组包、发包、传输、收包、丢包重传、解封装、解码、音视频同步、渲染等,同时还包括很多功能特性,比如ANS、AGC、AEC,REMB、GCC、CNG、FEC、PLI、SVC等,需要一点点深入理解其中的奥秘。