Webrtc delay-base-bwe代码分析(5): AimdRateControl模块

@(webrtc)[webrtc, congestion control]

Webrtc delay-base-bwe代码分析(5): AimdRateControl模块

0. 简介

这个模块是根据OveruseDetector模块计算出来的状态来维护码率控制模块的自动状态机,并更新估算出来的对端发送速率,提供给REMB进行反馈。

1. 原理

一共维持三个状态,增长、保持、衰减,状态转换根据OveruseDetector的三个状态(Normal, Overuse, Underuse)来进行判断。

  • 当Overuse发生时,无论什么状态都进入衰减。
  • 当Underuse发生时,无论什么状态都进入保持状态。
  • 在保持和增长阶段,Normal状态将保持继续增长。
  • 在衰减阶段,Normal状态会将状态拉回保持状态。

2. 代码

核心函数为ChangeBitrate,其他部分代码比较简单这里不贴了。

uint32_t AimdRateControl::ChangeBitrate(uint32_t current_bitrate_bps,
                                        uint32_t incoming_bitrate_bps,
                                        int64_t now_ms) {
  // 在调用函数update更新对应的链路状态估计,累积码率,噪声值后
  // 会将updated置位,如果没置位则不会去更新码率。
  if (!updated_) {
    return current_bitrate_bps_;
  }
  // An over-use should always trigger us to reduce the bitrate, even though
  // we have not yet established our first estimate. By acting on the over-use,
  // we will end up with a valid estimate.
  // 初始化未完成,如果不是一开始就Overuse,直接返回初始的码率即可。
  if (!bitrate_is_initialized_ && current_input_.bw_state != kBwOverusing)
    return current_bitrate_bps_;
  updated_ = false;
  // 这里对状态进行转换,这个函数是状态机状态转换函数
  // 1. Underuse总是进入Hold状态。
  // 2. Overuse总是进入Dec状态。
  // 3. Normal状态维持,除非当前在Hold状态,此时会进入Inc状态。
  ChangeState(current_input_, now_ms);
  // Calculated here because it's used in multiple places.
  const float incoming_bitrate_kbps = incoming_bitrate_bps / 1000.0f;
  // Calculate the max bit rate std dev given the normalized
  // variance and the current incoming bit rate.
  const float std_max_bit_rate
  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值