发送端两个sdp片段:SetLocalDescription,SetremoteDescription;SetLocalDescription:
b=AS:600
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:gY3K
a=ice-pwd:1HSgJcvP5SkTGcJ8uiixrdqe
a=ice-options:trickle
a=fingerprint:sha-256 BC:7A:18:73:C5:BF:A3:9D:06:BC:13:A6:AC:99:0C:6B:BE:C8:6A:B5:DF:78:2D:C9:CE:3C:22:0E:2B:02:53:20
a=setup:actpass
a=mid:1
a=extmap:14 urn:ietf:params:rtp-hdrext:toffset
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:13 urn:3gpp:video-orientation
a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:12 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
a=extmap:11 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type
a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing
a=extmap:8 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07
a=extmap:9 http://www.webrtc.org/experiments/rtp-hdrext/color-space
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=sendonly
a=msid:aG6LXeJdnm3w9XiAXNENCH2AsDWvZKmUrzot 3f2908cd-12b0-4158-a9fc-9cf7c285993fSetremoteDescription:
b=AS:600
a=rtpmap:125 H264/90000
a=rtpmap:107 rtx/90000
a=fmtp:125 level-asymmetry-allowed=1;packetization-mode=1;x-google-min-bitrate=400;x-google-max-bitrate=600;profile-level-id=42e01f
a=fmtp:107 apt=125
a=rtcp-fb:125 ccm fir
a=rtcp-fb:125 nack
a=rtcp-fb:125 nack pli
a=rtcp-fb:125 goog-remb
a=extmap:14 urn:ietf:params:rtp-hdrext:toffset
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=setup:active
a=mid:1
a=recvonly
a=ice-ufrag:4689494443441386ohoc
a=ice-pwd:orts7pigqcfgxy51906986jdz5wtizq2
a=ice-options:renomination
a=rtcp-mux
a=rtcp-rsize
webrtc::VideoEncoderConfig
WebRtcVideoChannel::WebRtcVideoSendStream::CreateVideoEncoderConfig(const VideoCodec& codec) const {RTC_DCHECK_RUN_ON(&thread_checker_);webrtc::VideoEncoderConfig encoder_config;encoder_config.codec_type = webrtc::PayloadStringToCodecType(codec.name);encoder_config.video_format =webrtc::SdpVideoFormat(codec.name, codec.params);bool is_screencast = parameters_.options.is_screencast.value_or(false);if (is_screencast) {encoder_config.min_transmit_bitrate_bps =1000 * parameters_.options.screencast_min_bitrate_kbps.value_or(0);encoder_config.content_type =webrtc::VideoEncoderConfig::ContentType::kScreen;} else {encoder_config.min_transmit_bitrate_bps = 0;encoder_config.content_type =webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo;}// By default, the stream count for the codec configuration should match the// number of negotiated ssrcs. But if the codec is blacklisted for simulcast// or a screencast (and not in simulcast screenshare experiment), only// configure a single stream.encoder_config.number_of_streams = parameters_.config.rtp.ssrcs.size();if (IsCodecBlacklistedForSimulcast(codec.name)) {encoder_config.number_of_streams = 1;}// parameters_.max_bitrate comes from the max bitrate set at the SDP// (m-section) level with the attribute "b=AS." Note that we override this// value below if the RtpParameters max bitrate set with// RtpSender::SetParameters has a lower value.int stream_max_bitrate = parameters_.max_bitrate_bps;// When simulcast is enabled (when there are multiple encodings),// encodings[i].max_bitrate_bps will be enforced by// encoder_config.simulcast_layers[i].max_bitrate_bps. Otherwise, it's// enforced by stream_max_bitrate, taking the minimum of the two maximums// (one coming from SDP, the other coming from RtpParameters).if (rtp_parameters_.encodings[0].max_bitrate_bps &&rtp_parameters_.encodings.size() == 1) {stream_max_bitrate =MinPositive(*(rtp_parameters_.encodings[0].max_bitrate_bps),parameters_.max_bitrate_bps);}// The codec max bitrate comes from the "x-google-max-bitrate" parameter// attribute set in the SDP for a specific codec. As done in// WebRtcVideoChannel::SetSendParameters, this value does not override the// stream max_bitrate set above.int codec_max_bitrate_kbps;if (codec.GetParam(kCodecParamMaxBitrate, &codec_max_bitrate_kbps) &&stream_max_bitrate == -1) {stream_max_bitrate = codec_max_bitrate_kbps * 1000;}encoder_config.max_bitrate_bps = stream_max_bitrate;// The encoder config's default bitrate priority is set to 1.0,// unless it is set through the sender's encoding parameters.// The bitrate priority, which is used in the bitrate allocation, is done// on a per sender basis, so we use the first encoding's value.encoder_config.bitrate_priority =rtp_parameters_.encodings[0].bitrate_priority;// Application-controlled state is held in the encoder_config's// simulcast_layers. Currently this is used to control which simulcast layers// are active and for configuring the min/max bitrate and max framerate.// The encoder_config's simulcast_layers is also used for non-simulcast (when// there is a single layer).RTC_DCHECK_GE(rtp_parameters_.encodings.size(),encoder_config.number_of_streams);RTC_DCHECK_GT(encoder_config.number_of_streams, 0);// Copy all provided constraints.encoder_config.simulcast_layers.resize(rtp_parameters_.encodings.size());for (size_t i = 0; i < encoder_config.simulcast_layers.size(); ++i) {encoder_config.simulcast_layers[i].active =rtp_parameters_.encodings[i].active;if (rtp_parameters_.encodings[i].min_bitrate_bps) {encoder_config.simulcast_layers[i].min_bitrate_bps =*rtp_parameters_.encodings[i].min_bitrate_bps;}if (rtp_parameters_.encodings[i].max_bitrate_bps) {encoder_config.simulcast_layers[i].max_bitrate_bps =*rtp_parameters_.encodings[i].max_bitrate_bps;}if (rtp_parameters_.encodings[i].max_framerate) {encoder_config.simulcast_layers[i].max_framerate =*rtp_parameters_.encodings[i].max_framerate;}if (rtp_parameters_.encodings[i].scale_resolution_down_by) {encoder_config.simulcast_layers[i].scale_resolution_down_by =*rtp_parameters_.encodings[i].scale_resolution_down_by;}if (rtp_parameters_.encodings[i].num_temporal_layers) {encoder_config.simulcast_layers[i].num_temporal_layers =*rtp_parameters_.encodings[i].num_temporal_layers;}}int max_qp = kDefaultQpMax;codec.GetParam(kCodecParamMaxQuantization, &max_qp);encoder_config.video_stream_factory =new rtc::RefCountedObject<EncoderStreamFactory>(codec.name, max_qp, is_screencast, parameters_.conference_mode);return encoder_config;
}

1.sdp 中有些关于带宽码率的设置,AS:行,x-google-max-bitrate,x-google-start-bitrate,x-google-min-bitrate等等,这些参数有什么作用呢?

AS:代表可用带宽,代表这路音频或者视频最多可以占用多大的带宽,比如b=AS:600就代表这路媒体流可使用多少带宽。

x-google-max-bitrate和AS作用差不多,但是有一定差异,看上面代码段,当同时设置AS行和x-google-max-bitrate时,x-google-max-bitrate会覆盖AS行,另外一点值得注意的是x-google-max-bitrate代表编码器可使用最大码率,而AS行不仅是编码器输出码率,还包括重传带宽,比如当上行网络不好时,带宽分配模块会 将AS值分给编码码率以及重传带宽。

2.如果setLocalDescription和setRemoteDescription同时设置了AS值,发送端会以哪个为准?

这时候发送端会以较小的AS值为准。

webrtc::VideoEncoderConfig
WebRtcVideoChannel::WebRtcVideoSendStream::CreateVideoEncoderConfig(const VideoCodec& codec) const {RTC_DCHECK_RUN_ON(&thread_checker_);webrtc::VideoEncoderConfig encoder_config;encoder_config.codec_type = webrtc::PayloadStringToCodecType(codec.name);encoder_config.video_format =webrtc::SdpVideoFormat(codec.name, codec.params);bool is_screencast = parameters_.options.is_screencast.value_or(false);if (is_screencast) {encoder_config.min_transmit_bitrate_bps =1000 * parameters_.options.screencast_min_bitrate_kbps.value_or(0);encoder_config.content_type =webrtc::VideoEncoderConfig::ContentType::kScreen;} else {encoder_config.min_transmit_bitrate_bps = 0;encoder_config.content_type =webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo;}// By default, the stream count for the codec configuration should match the// number of negotiated ssrcs. But if the codec is disabled for simulcast// or a screencast (and not in simulcast screenshare experiment), only// configure a single stream.encoder_config.number_of_streams = parameters_.config.rtp.ssrcs.size();if (IsCodecDisabledForSimulcast(codec.name, call_->trials())) {encoder_config.number_of_streams = 1;}// parameters_.max_bitrate comes from the max bitrate set at the SDP// (m-section) level with the attribute "b=AS." Note that we override this// value below if the RtpParameters max bitrate set with// RtpSender::SetParameters has a lower value.int stream_max_bitrate = parameters_.max_bitrate_bps;// When simulcast is enabled (when there are multiple encodings),// encodings[i].max_bitrate_bps will be enforced by// encoder_config.simulcast_layers[i].max_bitrate_bps. Otherwise, it's// enforced by stream_max_bitrate, taking the minimum of the two maximums// (one coming from SDP, the other coming from RtpParameters).if (rtp_parameters_.encodings[0].max_bitrate_bps &&rtp_parameters_.encodings.size() == 1) {stream_max_bitrate =MinPositive(*(rtp_parameters_.encodings[0].max_bitrate_bps),parameters_.max_bitrate_bps);}// The codec max bitrate comes from the "x-google-max-bitrate" parameter// attribute set in the SDP for a specific codec. As done in// WebRtcVideoChannel::SetSendParameters, this value does not override the// stream max_bitrate set above.int codec_max_bitrate_kbps;if (codec.GetParam(kCodecParamMaxBitrate, &codec_max_bitrate_kbps) &&stream_max_bitrate == -1) {stream_max_bitrate = codec_max_bitrate_kbps * 1000;}encoder_config.max_bitrate_bps = stream_max_bitrate;// The encoder config's default bitrate priority is set to 1.0,// unless it is set through the sender's encoding parameters.// The bitrate priority, which is used in the bitrate allocation, is done// on a per sender basis, so we use the first encoding's value.encoder_config.bitrate_priority =rtp_parameters_.encodings[0].bitrate_priority;// Application-controlled state is held in the encoder_config's// simulcast_layers. Currently this is used to control which simulcast layers// are active and for configuring the min/max bitrate and max framerate.// The encoder_config's simulcast_layers is also used for non-simulcast (when// there is a single layer).RTC_DCHECK_GE(rtp_parameters_.encodings.size(),encoder_config.number_of_streams);RTC_DCHECK_GT(encoder_config.number_of_streams, 0);// Copy all provided constraints.encoder_config.simulcast_layers.resize(rtp_parameters_.encodings.size());for (size_t i = 0; i < encoder_config.simulcast_layers.size(); ++i) {encoder_config.simulcast_layers[i].active =rtp_parameters_.encodings[i].active;encoder_config.simulcast_layers[i].scalability_mode =rtp_parameters_.encodings[i].scalability_mode;if (rtp_parameters_.encodings[i].min_bitrate_bps) {encoder_config.simulcast_layers[i].min_bitrate_bps =*rtp_parameters_.encodings[i].min_bitrate_bps;}if (rtp_parameters_.encodings[i].max_bitrate_bps) {encoder_config.simulcast_layers[i].max_bitrate_bps =*rtp_parameters_.encodings[i].max_bitrate_bps;}if (rtp_parameters_.encodings[i].max_framerate) {encoder_config.simulcast_layers[i].max_framerate =*rtp_parameters_.encodings[i].max_framerate;}if (rtp_parameters_.encodings[i].scale_resolution_down_by) {encoder_config.simulcast_layers[i].scale_resolution_down_by =*rtp_parameters_.encodings[i].scale_resolution_down_by;}if (rtp_parameters_.encodings[i].num_temporal_layers) {encoder_config.simulcast_layers[i].num_temporal_layers =*rtp_parameters_.encodings[i].num_temporal_layers;}}encoder_config.legacy_conference_mode = parameters_.conference_mode;encoder_config.is_quality_scaling_allowed =!disable_automatic_resize_ && !is_screencast &&(parameters_.config.rtp.ssrcs.size() == 1 ||NumActiveStreams(rtp_parameters_) == 1);int max_qp = kDefaultQpMax;codec.GetParam(kCodecParamMaxQuantization, &max_qp);// wx add begin// encoder_config.min_transmit_bitrate_bps = 800*1000;// encoder_config.max_bitrate_bps = 1200*1000;RTC_LOG(LS_ERROR) << "wx_test:"<< "codec:" << codec.ToString().c_str() << "encoder_config"<< encoder_config.ToString();// wx add startencoder_config.video_stream_factory =rtc::make_ref_counted<EncoderStreamFactory>(codec.name, max_qp, is_screencast, parameters_.conference_mode);return encoder_config;
}

3.x-google-min-bitrate这个只有什么作用?

这个参数是控制最小可用带宽的,比如现在x-google-max-bitrate=600,x-google-min-bitrate=400;(使用GCC时)当上行网络不好出现丢包时,接收端会反馈给发送端丢包率,接收端会根据丢包率来调整发送端带宽,如果不对最小带宽限制,GCC出的码率会降的很低,这时候如果需要发送关键帧将会卡主很久,因此这里设置最小码率对GCC做些限制,这也是为什么使用Remb而不是Transport-cc的探测带宽主要原因,可能T-cc会探测的更准确些,但是服务器控制不了,还是使用了Remb。

struct BitrateConstraints {int min_bitrate_bps = 0;int start_bitrate_bps = kDefaultStartBitrateBps;int max_bitrate_bps = -1;private:static constexpr int kDefaultStartBitrateBps = 300000;
};webrtc::BitrateConstraints GetBitrateConfigForCodec(const Codec& codec) {webrtc::BitrateConstraints config;int bitrate_kbps = 0;if (codec.GetParam(kCodecParamMinBitrate, &bitrate_kbps) &&bitrate_kbps > 0) {config.min_bitrate_bps = bitrate_kbps * 1000;} else {config.min_bitrate_bps = 0;}if (codec.GetParam(kCodecParamStartBitrate, &bitrate_kbps) &&bitrate_kbps > 0) {config.start_bitrate_bps = bitrate_kbps * 1000;} else {// Do not reconfigure start bitrate unless it's specified and positive.config.start_bitrate_bps = -1;}if (codec.GetParam(kCodecParamMaxBitrate, &bitrate_kbps) &&bitrate_kbps > 0) {config.max_bitrate_bps = bitrate_kbps * 1000;} else {config.max_bitrate_bps = -1;}return config;
}

改图是发送端的videoBwe图,最开始设置总带宽为600,实际编码码率在600以下波动,当发送端设置丢包时,GCC估计出的带宽迅速下降到400,因为我设置了x-google-min-bitrate=400,不然根据GCC的带宽估计算法持续反馈丢包率的时候会降到十几K。这时总带宽会降到400之后不在下降,然后码率分配模块会将总带宽分配给编码码率和重传带宽,这块带宽怎么分配的后面再讲。

webRTC sdp b=AS:600 x-google-min-bitrate 带宽码率那些事相关推荐

  1. 硬货专栏 |WebRTC SDP 详解和剖析

    WebRTC 是 Web Real-Time Communication,即网页实时通信的缩写,是 RTC 协议的一种Web实现,项目由 Google 开源,并和 IETF 和 W3C 制定了行业标准 ...

  2. webRTC——SDP(Session Description Protocal)

    SDP(Session Description Protocal),说直白点就是用文本描述的各端(PC 端.Mac 端.Android 端.iOS 端等)的能力. 这里的能力指的是各端所支持的音频编解 ...

  3. Android IOS WebRTC 音视频开发总结(七四)-- WebRTC开源5周年了,Google怎么看?

    本文最早发表在我们的微信公众号上(微信ID:blackerteam),支持原创,详见这里, 2016年6月9日是WebRTC开源5周年的日子,Google WebRTC负责人Harald在社区里面写了 ...

  4. Google百度和谷歌的那些事

    这篇文章很棒,我读了多遍.觉得应该让更多人读到,所以转载了. -- Google百度和谷歌的那些事 作者: virushuo 发表于 2010-01-14 22:01 最后更新于 2010-01-14 ...

  5. 从WebRTC SDP实现源码中寻找video codec的来源

    近期因为需要修改一下WebRTC源码里的sdp信息,主要是音频和视频部分,所以看了一下native部分的实现,这里简单记录一下分析过程,主要是根据sdp字符串查找video codec的来源.注意本文 ...

  6. android log 码率,webrtc之Android视频质量提升:保帧率降码率

    前言: 我们的产品是在一款跑着Android系统的特定芯片上使用webrtc开发的一个视频通话业务,当前的情况是在网络正常的情况下帧率也比较低,弱网环境下适应能力较差.基于此,我了解了webrtc A ...

  7. Google Hangouts支持使用Firefox WebRTC

    自去年4月Firefox 53删除NPAPI以来,该插件一直无法被正常访问.而就在去年年末,Google Hangouts(环聊)重新支持使用Firefox WebRTC.本文深度剖析了Firefox ...

  8. SDP协议基本分析(RTSP、WebRTC使用)

    目录 一.介绍 二.标准 SDP 规范 1. SDP 的格式 2. SDP 的结构 (1)会话描述 (2)媒体描述 三.WebRTC 中的 SDP 一.介绍 SDP(Session Descripti ...

  9. WebRTC 中 SDP 信息解析

    TL;NR 更详细的 WebRTC SDP 解析请参考 https://tools.ietf.org/html/draft-ietf-rtcweb-sdp-14 0x00 前言 SDP (Sessio ...

最新文章

  1. myeclipse html选取包含元素的标签_HTML基础2019-1-21
  2. eclipse复制代码连接数据库404_推荐一款免费的数据库管理工具,比Navicat还要好用,功能还很强大...
  3. SpringBoot启动一下就结束了
  4. BZOJ 1607 [Usaco2008 Dec]Patting Heads 轻拍牛头:统计 + 筛法【调和级数】
  5. hibernate的Configuration对象的configure()方法的作用
  6. Surface平面计算机
  7. 一般的病毒通过注册表自启动的方式不断完善中。。。。
  8. iOS非越狱自动化脚本的方案
  9. 网络空间安全和计算机科学与技术的区别,密码与网络空间安全学科有什么区别...
  10. layui 主动验证表单规则
  11. vivo浏览器缓存视频如何拷贝到电脑上
  12. 炫酷的2022网页特效网站源码
  13. win7升级RDP至8.1
  14. opencv半透明填充不规则区域
  15. macos可以升级到指定版本吗_[macOS]如何升级更新 Mac 系统
  16. redis灵魂拷问:为什么响应变慢了
  17. php调用和风天气api,推荐一个免费7天天气预报API服务:和风天气
  18. [MTK]LCD 调试总结
  19. 最好用的jpg转pdf软件
  20. 自制PMW3901光流模块

热门文章

  1. .NET/C#大型项目研发必备(7)--DataAccess数据库访问技术
  2. [操作系统] 操作系统真相还原读书笔记三:MBR加载loader到内存并跳转到loader执行
  3. Tekla图纸二次开发 第4节-打开与删除图纸、视图、对象
  4. 2022年广东工业大学文远知行杯新生程序设计竞赛(10/13)
  5. windows下实现校园网自动登陆
  6. 应用统计学学什么科目_科目二:学什么?考什么?怎么练?最详细的解答来了!...
  7. Cointelegraph中文HUB | Roxe:全球支付网络的倡导者和领先者暨团队亚太见面会
  8. 【CMAC小脑网络】基于CMAC的目标分类matlab仿真
  9. 第一新声专访泰瑞数创:超38%复合年增长率,数字孪生赋能工业智能化
  10. 谁说菜鸟不会数据分析python下载_《谁说菜鸟不会数据分..._30天学会Pytho_职场_小打卡...