tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

report_block_data.cc (1865B)


      1 /*
      2 *  Copyright 2019 The WebRTC Project Authors. All rights reserved.
      3 *
      4 *  Use of this source code is governed by a BSD-style license
      5 *  that can be found in the LICENSE file in the root of the source
      6 *  tree. An additional intellectual property rights grant can be found
      7 *  in the file PATENTS.  All contributing project authors may
      8 *  be found in the AUTHORS file in the root of the source tree.
      9 */
     10 
     11 #include "modules/rtp_rtcp/include/report_block_data.h"
     12 
     13 #include <cstdint>
     14 
     15 #include "api/units/time_delta.h"
     16 #include "api/units/timestamp.h"
     17 #include "modules/rtp_rtcp/source/rtcp_packet/report_block.h"
     18 #include "rtc_base/checks.h"
     19 
     20 namespace webrtc {
     21 
     22 TimeDelta ReportBlockData::jitter(int rtp_clock_rate_hz) const {
     23  RTC_DCHECK_GT(rtp_clock_rate_hz, 0);
     24  // Conversion to TimeDelta and division are swapped to avoid conversion
     25  // to/from floating point types.
     26  return TimeDelta::Seconds(jitter()) / rtp_clock_rate_hz;
     27 }
     28 
     29 // TODO: bugs.webrtc.org/370535296 - Remove the utc timestamp when linked
     30 // issue is fixed.
     31 void ReportBlockData::SetReportBlock(uint32_t sender_ssrc,
     32                                     const rtcp::ReportBlock& report_block,
     33                                     Timestamp report_block_timestamp_utc,
     34                                     Timestamp report_block_timestamp) {
     35  sender_ssrc_ = sender_ssrc;
     36  source_ssrc_ = report_block.source_ssrc();
     37  fraction_lost_raw_ = report_block.fraction_lost();
     38  cumulative_lost_ = report_block.cumulative_lost();
     39  extended_highest_sequence_number_ = report_block.extended_high_seq_num();
     40  jitter_ = report_block.jitter();
     41  report_block_timestamp_utc_ = report_block_timestamp_utc;
     42  report_block_timestamp_ = report_block_timestamp;
     43 }
     44 
     45 void ReportBlockData::AddRoundTripTimeSample(TimeDelta rtt) {
     46  last_rtt_ = rtt;
     47  sum_rtt_ += rtt;
     48  ++num_rtts_;
     49 }
     50 
     51 }  // namespace webrtc