WEBRTC Transmit Bandwidth Estimation __web

Source: Internet
Author: User
Tags min printf

Several questions
1, WEBRTC transmit bandwidth is estimated for each stream or the total bandwidth
2, WebRTC Remb is the overall bandwidth of statistics.
3, if WEBRTC at the same time to watch the multi-channel flow, how to for each stream feedback bandwidth, packet loss and other information
5, if the WEBRTC simultaneously sends the multi-channel flow, how to estimate each road bandwidth situation

The tracking code is designed to adjust the bandwidth of the sender when there are multiple views and sends.

void  Processthreadimpl::P rocess ()
{
        ...
        M.module->process ();
        ...
}

This piece of code has no information, just the thread is running

void Congestioncontroller::P rocess () {
  bitrate_controller_->process ();
  Remote_bitrate_estimator_->process ();
  Maybetriggeronnetworkchanged ();
}

Bandwidth detection started
First look at this maybetriggeronnetworkchanged ();

void Congestioncontroller::maybetriggeronnetworkchanged () {
 ...
  BOOL estimate_changed = bitrate_controller_->getnetworkparameters (
      &bitrate_bps, &fraction_loss, &RTT);

 ...

  if (hasnetworkparameterstoreportchanged (bitrate_bps, Fraction_loss, RTT)) {
    observer_->onnetworkchanged ( bitrate_bps, Fraction_loss, RTT);
    Remote_estimator_proxy_. Onbitratechanged (bitrate_bps);
  }
}

Bitrate_controller_ from here to get sent bandwidth packet drop rate RTT and callback notification

void Call::onnetworkchanged (uint32_t target_bitrate_bps, uint8_t fraction_loss,
                            int64_t rtt_ms) {
   ...
  Bitrate_allocator_->onnetworkchanged (target_bitrate_bps, Fraction_loss,
                                       Rtt_ms);
  ...
}

Callback to call Enter Bitrate_allocator_

void Bitrateallocator::onnetworkchanged (uint32_t target_bitrate_bps, uint8_t fract Ion_loss, int64_t RTT) {rtc_dcheck_called_sequentially (&sequenced_checker_)
  ;
  Last_bitrate_bps_ = target_bitrate_bps; Last_non_zero_bitrate_bps_ = target_bitrate_bps > 0?
  Target_bitrate_bps:last_non_zero_bitrate_bps_;
  Last_fraction_loss_ = Fraction_loss;

  Last_rtt_ = RTT;
  Periodically log the incoming BWE.
  int64_t now = Clock_->timeinmilliseconds ();
  if (now > last_bwe_log_time_ + kbwelogintervalms) {last_bwe_log_time_ = now; } printf ("%s%d%s bitrate_bps:%d fraction_loss:%d rtt:%d\n", __file__, __line__, __function__, Target_bitr
  ate_bps, Fraction_loss, RTT);

  observerallocation allocation = allocatebitrates (target_bitrate_bps);
    for (auto& config:bitrate_observer_configs_) {uint32_t allocated_bitrate = Allocation[config.observer]; uint32_t ProTection_bitrate = config.observer->onbitrateupdated (Allocated_bitrate, Last_fraction_loss_, Last_rtt_); printf ("%s%d%s allocated_bitrate:%d fraction_loss:%d rtt:%d\n", __file__, __line__, __function__, Allocated_bi

    Trate, Fraction_loss, RTT);
        if (allocated_bitrate = = 0 && config.allocated_bitrate_bps > 0) {if (target_bitrate_bps > 0)
      ++num_pause_events_; The protection bitrate is a estimate based on the ratio between media//and protection used before this observe
      R was muted.

    uint32_t predicted_protection_bps = (1.0-config.media_ratio) * config.min_bitrate_bps;
        } else if (allocated_bitrate > 0 && config.allocated_bitrate_bps = = 0) {if (target_bitrate_bps > 0)

    ++num_pause_events_;
    }//Only update the media ratio if the observer got an allocation. if (allocated_bitrate > 0) config.media_ratio = Mediaratio (Allocated_bitrate, Protection_bitrate);
  config.allocated_bitrate_bps = allocated_bitrate;
 }
}

The big characters are here.

...
 observerallocation allocation = allocatebitrates (target_bitrate_bps);

  for (auto& config:bitrate_observer_configs_)
  {
    uint32_t allocated_bitrate = Allocation[config.observer] ;
    uint32_t protection_bitrate = config.observer->onbitrateupdated (
        allocated_bitrate, Last_fraction_loss_, Last_rtt_);
...

This code is not read
From the printed log to see statistics is target_bitrate_bps should be the full bandwidth, allocated_bitrate seems to be Dan Lu, this code exactly what to do.

Bitrateallocator::observerallocation bitrateallocator::allocatebitrates (uint32_t bitrate) {RTC_DCHECK_CALLED_SEQU
  Entially (&sequenced_checker_);

  if (Bitrate_observer_configs_.empty ()) return observerallocation ();

  if (bitrate = = 0) return zerorateallocation ();
  uint32_t sum_min_bitrates = 0;
  uint32_t sum_max_bitrates = 0; for (const auto& observer_config:bitrate_observer_configs_) {sum_min_bitrates + = OBSERVER_CONFIG.MIN_BITRATE_BP
    S
  Sum_max_bitrates + = observer_config.max_bitrate_bps; }//Not enough-observers to get a allocation, allocate according to://enforced min bitrate-allocate
  D Bitrate previous round, restart paused//streams. if (!

  Enoughbitrateforallobservers (bitrate, sum_min_bitrates)) return lowrateallocation (bitrate);
  All observers'll get their min bitrate plus an even share of the rest.

if (bitrate <= sum_max_bitrates) return normalrateallocation (bitrate, sum_min_bitrates);  All observers would get up to Ktransmissionmaxbitratemultiplier x max.
Return maxrateallocation (bitrate, sum_max_bitrates); }

Look at the three return, the note is clear, but it's too rough, let's go inside.

Bitrateallocator::observerallocation bitrateallocator::normalrateallocation (
    uint32_t bitrate,
    uint32_t sum_min_bitrates) {
  rtc_dcheck_called_sequentially (&sequenced_checker_);
  observerallocation allocation;
  for (const auto& OBSERVER_CONFIG:BITRATE_OBSERVER_CONFIGS_)
    Allocation[observer_config.observer] = Observer _config.min_bitrate_bps;

  bitrate-= sum_min_bitrates;
  if (bitrate > 0)
    distributebitrateevenly (bitrate, true, 1, &allocation);

  return allocation;
}

Look at this first, a bit like the guaranteed (observer_config.min_bitrate_bps) + performance AH.
Performance is calculated.

void Bitrateallocator::D istributebitrateevenly (uint32_t bitrate, bool inclu
                                               de_zero_allocations, int max_multiplier,
  observerallocation* allocation) {rtc_dcheck_called_sequentially (&sequenced_checker_);

  Rtc_dcheck_eq (Allocation->size (), bitrate_observer_configs_.size ());
  Observersortingmap list_max_bitrates;
        for (const auto& observer_config:bitrate_observer_configs_) {if (Include_zero_allocations | | Allocation->at (observer_config.observer)! = 0) {list_max_bitrates.insert (std::p air<uint32_t, const OBSERVERCO
    Nfig*> (observer_config.max_bitrate_bps, &observer_config));
  }} Auto it = List_max_bitrates.begin ();
    while (It! = List_max_bitrates.end ()) {rtc_dcheck_gt (bitrate, 0u); uint32_t extra_allocation = bitrate/static_cast<uint32_t> (list_max_bitrates.siZe ());
    uint32_t total_allocation = extra_allocation + allocation->at (it->second->observer);
    bitrate-= extra_allocation;  if (Total_allocation > Max_multiplier * it->first) {//There is + than we can fit for this observer, carry
      Over to the//remaining observers.
      Bitrate + = Total_allocation-max_multiplier * it->first;
    total_allocation = Max_multiplier * it->first;
    }//Finally, update the allocation for this observer.
    Allocation->at (it->second->observer) = total_allocation;
  it = list_max_bitrates.erase (it); }
}

The

is poisonous, observersortingmap list_max_bitrates; Sort by the maximum bit rate per path
while inside is assigned
from the start of setting the maximum bitrate, from the rate pool to take an average to add, The discovery exceeds the maximum set, then the excess is placed in the pool of the rate, the average distribution of the following
this is not a bit of violence. did not consider which way to lose the package.

uint32_t videosendstreamimpl::onbitrateupdated (uint32_t bitrate_bps, uint8_
      T Fraction_loss, int64_t RTT) {Rtc_dcheck (payload_router_.active ())
  << "Videosendstream::start have not been called."; Get the encoder target rate.
  It's The estimated network rate-//protection overhead.
  uint32_t target = Encoder_target_rate_bps_; Encoder_target_rate_bps_ = Protection_bitrate_calculator_.

  Settargetrates (bitrate_bps, Stats_proxy_->getsendframerate (), Fraction_loss, RTT);


  uint32_t protection_bitrate = Bitrate_bps-encoder_target_rate_bps_;

  Encoder_target_rate_bps_ = Std::min (Encoder_max_bitrate_bps_, Encoder_target_rate_bps_); Config_->band_width_callback_ printf ("%s%d%s bitrate_bps:%d encoder_target_rate_bps:%d protection_bitrate:%d\

 N ", __file__, __line__, __function__, bitrate_bps, Encoder_target_rate_bps_, protection_bitrate); IF (band_width_callback_ = NULL && encoder_target_rate_bps_! = target) {Band_width_callback_->onreceivede
 Stimatedbitrate (local_ssrc_, 0, Encoder_target_rate_bps_);

  } vie_encoder_->onbitrateupdated (Encoder_target_rate_bps_, Fraction_loss, RTT);
  Stats_proxy_->onsetencodertargetrate (Encoder_target_rate_bps_);
return protection_bitrate; }

The code rate is over, and here we are, ready to set up
Wait a minute, there's a scene of annoyance.

  Encoder_target_rate_bps_ = Protection_bitrate_calculator_. Settargetrates (
      bitrate_bps, Stats_proxy_->getsendframerate (), Fraction_loss, RTT);

Feels like it's not so easy to end
By taking the base salary plus commission, to the here has to calculate, see if you want to tax, Encoder_target_rate_bps_ code rate calculation

uint32_t protectionbitratecalculator::settargetrates (uint32_t estimated_bitrate_bps, int actual_framerate_fps, uint8_t fraction_lost, int64_t round_trip_time_ms) {...//TODO (Marco): Pass FEC protection values per la
  Yer.
      Protection_callback_->protectionrequest (&delta_fec_params, &key_fec_params, &sent_video_rate_bps,

  &sent_nack_rate_bps, &sent_fec_rate_bps);
  uint32_t sent_total_rate_bps = sent_video_rate_bps + sent_nack_rate_bps + sent_fec_rate_bps;
  Estimate the overhead costs of the next second as staying the same//wrt the source bitrate. if (sent_total_rate_bps > 0) {protection_overhead_rate = static_cast<float> (sent_nack_rate_bps + sen
  t_fec_rate_bps)/sent_total_rate_bps;
  }//Cap The overhead estimate to 50%.

  if (Protection_overhead_rate > 0.5) protection_overhead_rate = 0.5;
  Source coding rate:total rate-protection overhead. Return Estimated_bitrate_bps * (1.0-protection_overhead_rate); ...
}

Gets the stream bandwidth of a single stream, nack bandwidth FEC bandwidth, calculates the bandwidth to be adjusted

End:
Always feel weird, all the flow of packet loss rate statistics are used overall. If there is a person looking at the card, will affect the overall.

Come here first.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.