Skip to content

Commit

Permalink
roc-streaminggh-675 Implement reports from RFC 6776 and RFC 6843
Browse files Browse the repository at this point in the history
- Add support for Delay Metrics XR block (RFC 6843) and
  Measurement Info XR block (RFC 6776)

- Send these blocks from receiver and handle them on sender

This allows to obtain e2e latency on sender and use it for sender-side
clock adjustment, which will be added in future commits.

Currently, receiver doesn't calculate min/max/avg RTT, and just
sends the latest value. This will be fixed in future commits.
  • Loading branch information
gavv committed Jan 23, 2024
1 parent 0a78934 commit 99d363f
Show file tree
Hide file tree
Showing 17 changed files with 1,431 additions and 660 deletions.
3 changes: 3 additions & 0 deletions src/internal_modules/roc_pipeline/receiver_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ void ReceiverSession::generate_reports(const char* report_cname,

if (n_reports > 0 && packet_router_->has_source_id(packet::Packet::FlagAudio)
&& source_meter_->has_metrics()) {
const audio::LatencyMonitorMetrics latency_metrics = latency_monitor_->metrics();
const rtp::LinkMetrics link_metrics = source_meter_->metrics();

rtcp::RecvReport& report = *reports;
Expand All @@ -312,6 +313,7 @@ void ReceiverSession::generate_reports(const char* report_cname,
report.fract_loss = link_metrics.fract_loss;
report.cum_loss = link_metrics.cum_loss;
report.jitter = link_metrics.jitter;
report.e2e_latency = latency_metrics.e2e_latency;

reports++;
n_reports--;
Expand All @@ -333,6 +335,7 @@ void ReceiverSession::generate_reports(const char* report_cname,
report.fract_loss = link_metrics.fract_loss;
report.cum_loss = link_metrics.cum_loss;
report.jitter = link_metrics.jitter;
report.e2e_latency = 0;

reports++;
n_reports--;
Expand Down
29 changes: 29 additions & 0 deletions src/internal_modules/roc_rtcp/builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,35 @@ void Builder::end_xr_dlrr() {
size_t(cur_pkt_slice_.data_end() - (uint8_t*)cur_xr_block_header_));
}

void Builder::add_xr_measurement_info(
const header::XrMeasurementInfoBlock& measurement_info) {
roc_panic_if_msg(state_ != XR_HEAD, "rtcp builder: wrong call order");

header::XrMeasurementInfoBlock* p =
(header::XrMeasurementInfoBlock*)add_block_(sizeof(measurement_info));
if (!p) {
return;
}
memcpy(p, &measurement_info, sizeof(measurement_info));

cur_xr_block_header_ = &p->header();
cur_xr_block_header_->set_len_bytes(sizeof(measurement_info));
}

void Builder::add_xr_delay_metrics(const header::XrDelayMetricsBlock& delay_metrics) {
roc_panic_if_msg(state_ != XR_HEAD, "rtcp builder: wrong call order");

header::XrDelayMetricsBlock* p =
(header::XrDelayMetricsBlock*)add_block_(sizeof(delay_metrics));
if (!p) {
return;
}
memcpy(p, &delay_metrics, sizeof(delay_metrics));

cur_xr_block_header_ = &p->header();
cur_xr_block_header_->set_len_bytes(sizeof(delay_metrics));
}

void Builder::end_xr() {
roc_panic_if_msg(state_ != XR_HEAD, "rtcp builder: wrong call order");

Expand Down
6 changes: 6 additions & 0 deletions src/internal_modules/roc_rtcp/builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ class Builder : public core::NonCopyable<> {
//! Add DLRR report to current DLRR block.
void add_xr_dlrr_report(const header::XrDlrrSubblock& report);

//! Add measurement info block.to current XR packet.
void add_xr_measurement_info(const header::XrMeasurementInfoBlock& measurement_info);

//! Add delay metrics block.to current XR packet.
void add_xr_delay_metrics(const header::XrDelayMetricsBlock& delay_metrics);

//! Finish current DLRR block.
void end_xr_dlrr();

Expand Down
Loading

0 comments on commit 99d363f

Please sign in to comment.