webrtc_m130/modules/rtp_rtcp/include/report_block_data.cc
Olov Brändström 4baeed3b97 Use environment monotonic timestamps (i.e. not UTC) in RTCStats.
Add media config for using environment monotonic timestamps (i.e. not UTC) in RTCStats constructor, and implemented the usage of the flag.

Bug: chromium:369369568
Change-Id: Ia93d048742c28af201164fe7b2152b791bb6d0b6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/363946
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Olov Brändström <brandstrom@google.com>
Cr-Commit-Position: refs/heads/main@{#43156}
2024-10-03 09:07:17 +00:00

47 lines
1.7 KiB
C++

/*
* Copyright 2019 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/rtp_rtcp/include/report_block_data.h"
#include "rtc_base/checks.h"
namespace webrtc {
TimeDelta ReportBlockData::jitter(int rtp_clock_rate_hz) const {
RTC_DCHECK_GT(rtp_clock_rate_hz, 0);
// Conversion to TimeDelta and division are swapped to avoid conversion
// to/from floating point types.
return TimeDelta::Seconds(jitter()) / rtp_clock_rate_hz;
}
// TODO(webrtc:370535296): When (webrtc:370535296) is fixed, we don't need the
// utc timestamp.
void ReportBlockData::SetReportBlock(uint32_t sender_ssrc,
const rtcp::ReportBlock& report_block,
Timestamp report_block_timestamp_utc,
Timestamp report_block_timestamp) {
sender_ssrc_ = sender_ssrc;
source_ssrc_ = report_block.source_ssrc();
fraction_lost_raw_ = report_block.fraction_lost();
cumulative_lost_ = report_block.cumulative_lost();
extended_highest_sequence_number_ = report_block.extended_high_seq_num();
jitter_ = report_block.jitter();
report_block_timestamp_utc_ = report_block_timestamp_utc;
report_block_timestamp_ = report_block_timestamp;
}
void ReportBlockData::AddRoundTripTimeSample(TimeDelta rtt) {
last_rtt_ = rtt;
sum_rtt_ += rtt;
++num_rtts_;
}
} // namespace webrtc