webrtc視頻接收端帶寬預測(一)---參數(shù)輸入

收包到觸發(fā)遠端估算流程:

->bool UdpSocket2WorkerWindows::Process()
->void UdpSocket2Windows::IOCompleted
->void UdpTransportImpl::IncomingRTPCallback
->void UdpTransportImpl::IncomingRTPFunction
->void VideoChannelTransport::IncomingRTPPacket
->int ViENetworkImpl::ReceivedRTPPacket
->int32_t ViEChannel::ReceivedRTPPacket
->int ViEReceiver::ReceivedRTPPacket
->int ViEReceiver::InsertRTPPacket
  ->void IncomingPacket
  ->bool ViEReceiver::ReceivePacket//這一步是對媒體處理激捏,即插入jitterbuffer
->void RemoteBitrateEstimatorImpl::IncomingPacket

inter_arrival.cc中函數(shù)分析如下:

timestamp:rtp包中的時間戳
first_timestamp:當前幀第一個包中的時間戳
size:當前幀累計的包大小
complete_time_ms:包到達的時間
calculated_deltas:表示計算了一些delta耳胎,用來做返回值

bool InterArrival::ComputeDeltas(uint32_t timestamp,
                                 int64_t arrival_time_ms,
                                 size_t packet_size,
                                 uint32_t* timestamp_delta,
                                 int64_t* arrival_time_delta_ms,
                                 int* packet_size_delta) {
  assert(timestamp_delta != NULL);
  assert(arrival_time_delta_ms != NULL);
  assert(packet_size_delta != NULL);
  bool calculated_deltas = false;
  if (current_timestamp_group_.IsFirstPacket()) {//開始階段
    // We don't have enough data to update the filter, so we store it until we
    // have two frames of data to process.
    current_timestamp_group_.timestamp = timestamp;
    current_timestamp_group_.first_timestamp = timestamp;
  } else if (!PacketInOrder(timestamp)) {//不亂序
    return false;
  } else if (NewTimestampGroup(arrival_time_ms, timestamp)) {//新的一幀
    // First packet of a later frame, the previous frame sample is ready.
    if (prev_timestamp_group_.complete_time_ms >= 0) {//prev_timestamp_group_這里是上上一個
      *timestamp_delta = current_timestamp_group_.timestamp -
                         prev_timestamp_group_.timestamp;//上一幀和上上一幀的時間戳之差
      *arrival_time_delta_ms = current_timestamp_group_.complete_time_ms -
                               prev_timestamp_group_.complete_time_ms;
      assert(*arrival_time_delta_ms >= 0);
      *packet_size_delta = static_cast<int>(current_timestamp_group_.size) -
          static_cast<int>(prev_timestamp_group_.size);
      calculated_deltas = true;
    }
    prev_timestamp_group_ = current_timestamp_group_;
    // The new timestamp is now the current frame.
    current_timestamp_group_.first_timestamp = timestamp;
    current_timestamp_group_.timestamp = timestamp;
    current_timestamp_group_.size = 0;
  }
  else {
    current_timestamp_group_.timestamp = LatestTimestamp(
        current_timestamp_group_.timestamp, timestamp);
//同一個幀,這里會根據(jù)有沒有時間戳的拓展包頭,決定timestamp有沒有變化
  }
  // Accumulate the frame size.
  current_timestamp_group_.size += packet_size;
  current_timestamp_group_.complete_time_ms = arrival_time_ms;

  return calculated_deltas;
}

BelongsToBurst大概意思是兩個包之間收到的間隔很小或者傳輸時延小于0

bool InterArrival::BelongsToBurst(int64_t arrival_time_ms,
                                  uint32_t timestamp) const {
  if (!burst_grouping_) {
    return false;
  }
  assert(current_timestamp_group_.complete_time_ms >= 0);
  int64_t arrival_time_delta_ms = arrival_time_ms -
      current_timestamp_group_.complete_time_ms;
  uint32_t timestamp_diff = timestamp - current_timestamp_group_.timestamp;
  int64_t ts_delta_ms = timestamp_to_ms_coeff_ * timestamp_diff + 0.5;
  if (ts_delta_ms == 0)
    return true;
  int propagation_delta_ms = arrival_time_delta_ms - ts_delta_ms;
  return propagation_delta_ms < 0 &&
      arrival_time_delta_ms <= kBurstDeltaThresholdMs;
}
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末虫碉,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子悬槽,更是在濱河造成了極大的恐慌穗酥,老刑警劉巖,帶你破解...
    沈念sama閱讀 211,194評論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件框仔,死亡現(xiàn)場離奇詭異舀武,居然都是意外死亡,警方通過查閱死者的電腦和手機离斩,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,058評論 2 385
  • 文/潘曉璐 我一進店門银舱,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人捐腿,你說我怎么就攤上這事纵朋。” “怎么了茄袖?”我有些...
    開封第一講書人閱讀 156,780評論 0 346
  • 文/不壞的土叔 我叫張陵操软,是天一觀的道長。 經常有香客問我宪祥,道長聂薪,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,388評論 1 283
  • 正文 為了忘掉前任蝗羊,我火速辦了婚禮藏澳,結果婚禮上,老公的妹妹穿的比我還像新娘耀找。我一直安慰自己翔悠,他們只是感情好,可當我...
    茶點故事閱讀 65,430評論 5 384
  • 文/花漫 我一把揭開白布野芒。 她就那樣靜靜地躺著蓄愁,像睡著了一般。 火紅的嫁衣襯著肌膚如雪狞悲。 梳的紋絲不亂的頭發(fā)上撮抓,一...
    開封第一講書人閱讀 49,764評論 1 290
  • 那天,我揣著相機與錄音摇锋,去河邊找鬼丹拯。 笑死,一個胖子當著我的面吹牛荸恕,可吹牛的內容都是我干的乖酬。 我是一名探鬼主播,決...
    沈念sama閱讀 38,907評論 3 406
  • 文/蒼蘭香墨 我猛地睜開眼融求,長吁一口氣:“原來是場噩夢啊……” “哼剑刑!你這毒婦竟也來了?” 一聲冷哼從身側響起双肤,我...
    開封第一講書人閱讀 37,679評論 0 266
  • 序言:老撾萬榮一對情侶失蹤施掏,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后茅糜,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體七芭,經...
    沈念sama閱讀 44,122評論 1 303
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 36,459評論 2 325
  • 正文 我和宋清朗相戀三年蔑赘,在試婚紗的時候發(fā)現(xiàn)自己被綠了狸驳。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 38,605評論 1 340
  • 序言:一個原本活蹦亂跳的男人離奇死亡缩赛,死狀恐怖耙箍,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情酥馍,我是刑警寧澤辩昆,帶...
    沈念sama閱讀 34,270評論 4 329
  • 正文 年R本政府宣布,位于F島的核電站旨袒,受9級特大地震影響汁针,放射性物質發(fā)生泄漏。R本人自食惡果不足惜砚尽,卻給世界環(huán)境...
    茶點故事閱讀 39,867評論 3 312
  • 文/蒙蒙 一施无、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧必孤,春花似錦猾骡、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,734評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至购啄,卻和暖如春襟企,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背狮含。 一陣腳步聲響...
    開封第一講書人閱讀 31,961評論 1 265
  • 我被黑心中介騙來泰國打工顽悼, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人几迄。 一個月前我還...
    沈念sama閱讀 46,297評論 2 360
  • 正文 我出身青樓蔚龙,卻偏偏與公主長得像,于是被迫代替她去往敵國和親映胁。 傳聞我的和親對象是個殘疾皇子木羹,可洞房花燭夜當晚...
    茶點故事閱讀 43,472評論 2 348

推薦閱讀更多精彩內容