Commit 5c467656 authored by Ghislain MARY's avatar Ghislain MARY

Define accessors for content of RTCP XR packets.

parent d054fc42
......@@ -194,10 +194,14 @@ typedef struct rtcp_xr_header {
uint32_t ssrc;
} rtcp_xr_header_t;
typedef struct rtcp_xr_rcvr_rtt_report_block {
typedef struct rtcp_xr_generic_block_header {
uint8_t bt;
uint8_t reserved;
uint8_t flags;
uint16_t length;
} rtcp_xr_generic_block_header_t;
typedef struct rtcp_xr_rcvr_rtt_report_block {
rtcp_xr_generic_block_header_t bh;
uint32_t ntp_timestamp_msw;
uint32_t ntp_timestamp_lsw;
} rtcp_xr_rcvr_rtt_report_block_t;
......@@ -209,16 +213,12 @@ typedef struct rtcp_xr_dlrr_report_subblock {
} rtcp_xr_dlrr_report_subblock_t;
typedef struct rtcp_xr_dlrr_report_block {
uint8_t bt;
uint8_t reserved;
uint16_t length;
rtcp_xr_generic_block_header_t bh;
rtcp_xr_dlrr_report_subblock_t content[1];
} rtcp_xr_dlrr_report_block_t;
typedef struct rtcp_xr_stat_summary_report_block {
uint8_t bt;
uint8_t flags;
uint16_t length;
rtcp_xr_generic_block_header_t bh;
uint32_t ssrc;
uint16_t begin_seq;
uint16_t end_seq;
......@@ -235,9 +235,7 @@ typedef struct rtcp_xr_stat_summary_report_block {
} rtcp_xr_stat_summary_report_block_t;
typedef struct rtcp_xr_voip_metrics_report_block {
uint8_t bt;
uint8_t reserved;
uint16_t length;
rtcp_xr_generic_block_header_t bh;
uint32_t ssrc;
uint8_t loss_rate;
uint8_t discard_rate;
......@@ -336,6 +334,47 @@ ORTP_PUBLIC void rtcp_APP_get_data(const mblk_t *m, uint8_t **data, int *len);
/* RTCP XR accessors */
ORTP_PUBLIC bool_t rtcp_is_XR(const mblk_t *m);
ORTP_PUBLIC rtcp_xr_block_type_t rtcp_XR_get_block_type(const mblk_t *m);
ORTP_PUBLIC uint32_t rtcp_XR_get_ssrc(const mblk_t *m);
ORTP_PUBLIC uint64_t rtcp_XR_rcvr_rtt_get_ntp_timestamp(const mblk_t *m);
ORTP_PUBLIC uint32_t rtcp_XR_dlrr_get_ssrc(const mblk_t *m);
ORTP_PUBLIC uint32_t rtcp_XR_dlrr_get_lrr(const mblk_t *m);
ORTP_PUBLIC uint32_t rtcp_XR_dlrr_get_dlrr(const mblk_t *m);
ORTP_PUBLIC uint8_t rtcp_XR_stat_summary_get_flags(const mblk_t *m);
ORTP_PUBLIC uint32_t rtcp_XR_stat_summary_get_ssrc(const mblk_t *m);
ORTP_PUBLIC uint16_t rtcp_XR_stat_summary_get_begin_seq(const mblk_t *m);
ORTP_PUBLIC uint16_t rtcp_XR_stat_summary_get_end_seq(const mblk_t *m);
ORTP_PUBLIC uint32_t rtcp_XR_stat_summary_get_lost_packets(const mblk_t *m);
ORTP_PUBLIC uint32_t rtcp_XR_stat_summary_get_dup_packets(const mblk_t *m);
ORTP_PUBLIC uint32_t rtcp_XR_stat_summary_get_min_jitter(const mblk_t *m);
ORTP_PUBLIC uint32_t rtcp_XR_stat_summary_get_max_jitter(const mblk_t *m);
ORTP_PUBLIC uint32_t rtcp_XR_stat_summary_get_mean_jitter(const mblk_t *m);
ORTP_PUBLIC uint32_t rtcp_XR_stat_summary_get_dev_jitter(const mblk_t *m);
ORTP_PUBLIC uint8_t rtcp_XR_stat_summary_get_min_ttl_or_hl(const mblk_t *m);
ORTP_PUBLIC uint8_t rtcp_XR_stat_summary_get_max_ttl_or_hl(const mblk_t *m);
ORTP_PUBLIC uint8_t rtcp_XR_stat_summary_get_mean_ttl_or_hl(const mblk_t *m);
ORTP_PUBLIC uint8_t rtcp_XR_stat_summary_get_dev_ttl_or_hl(const mblk_t *m);
ORTP_PUBLIC uint32_t rtcp_XR_voip_metrics_get_ssrc(const mblk_t *m);
ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_loss_rate(const mblk_t *m);
ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_discard_rate(const mblk_t *m);
ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_burst_density(const mblk_t *m);
ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_gap_density(const mblk_t *m);
ORTP_PUBLIC uint16_t rtcp_XR_voip_metrics_get_burst_duration(const mblk_t *m);
ORTP_PUBLIC uint16_t rtcp_XR_voip_metrics_get_gap_duration(const mblk_t *m);
ORTP_PUBLIC uint16_t rtcp_XR_voip_metrics_get_round_trip_delay(const mblk_t *m);
ORTP_PUBLIC uint16_t rtcp_XR_voip_metrics_get_end_system_delay(const mblk_t *m);
ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_signal_level(const mblk_t *m);
ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_noise_level(const mblk_t *m);
ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_rerl(const mblk_t *m);
ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_gmin(const mblk_t *m);
ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_r_factor(const mblk_t *m);
ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_ext_r_factor(const mblk_t *m);
ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_mos_lq(const mblk_t *m);
ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_mos_cq(const mblk_t *m);
ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_rx_config(const mblk_t *m);
ORTP_PUBLIC uint16_t rtcp_XR_voip_metrics_get_jb_nominal(const mblk_t *m);
ORTP_PUBLIC uint16_t rtcp_XR_voip_metrics_get_jb_maximum(const mblk_t *m);
ORTP_PUBLIC uint16_t rtcp_XR_voip_metrics_get_jb_abs_max(const mblk_t *m);
#ifdef __cplusplus
......
......@@ -532,9 +532,9 @@ static int rtcp_xr_rcvr_rtt_init(uint8_t *buf, RtpSession *session) {
uint64_t ntp;
rtcp_xr_rcvr_rtt_report_block_t *block = (rtcp_xr_rcvr_rtt_report_block_t *)buf;
block->bt = RTCP_XR_RCVR_RTT;
block->reserved = 0;
block->length = htons(2);
block->bh.bt = RTCP_XR_RCVR_RTT;
block->bh.flags = 0; // Reserved bits
block->bh.length = htons(2);
ortp_gettimeofday(&tv, NULL);
ntp = ortp_timeval_to_ntp(&tv);
block->ntp_timestamp_msw = htonl(ntp >> 32);
......@@ -545,9 +545,9 @@ static int rtcp_xr_rcvr_rtt_init(uint8_t *buf, RtpSession *session) {
static int rtcp_xr_dlrr_init(uint8_t *buf, RtpSession *session) {
rtcp_xr_dlrr_report_block_t *block = (rtcp_xr_dlrr_report_block_t *)buf;
block->bt = RTCP_XR_DLRR;
block->reserved = 0;
block->length = htons(3);
block->bh.bt = RTCP_XR_DLRR;
block->bh.flags = 0; // Reserved bits
block->bh.length = htons(3);
// TODO: Fill the rest of the block and handle multiple subblocks
return sizeof(rtcp_xr_dlrr_report_block_t);
}
......@@ -555,9 +555,9 @@ static int rtcp_xr_dlrr_init(uint8_t *buf, RtpSession *session) {
static int rtcp_xr_stat_summary_init(uint8_t *buf, RtpSession *session) {
rtcp_xr_stat_summary_report_block_t *block = (rtcp_xr_stat_summary_report_block_t *)buf;
block->bt = RTCP_XR_STAT_SUMMARY;
block->flags = session->rtcp.xr_conf.stat_summary_flags;
block->length = htons(9);
block->bh.bt = RTCP_XR_STAT_SUMMARY;
block->bh.flags = session->rtcp.xr_conf.stat_summary_flags;
block->bh.length = htons(9);
// TODO: Fill other fields from info in the session
return sizeof(rtcp_xr_stat_summary_report_block_t);
}
......@@ -565,9 +565,9 @@ static int rtcp_xr_stat_summary_init(uint8_t *buf, RtpSession *session) {
static int rtcp_xr_voip_metrics_init(uint8_t *buf, RtpSession *session) {
rtcp_xr_voip_metrics_report_block_t *block = (rtcp_xr_voip_metrics_report_block_t *)buf;
block->bt = RTCP_XR_VOIP_METRICS;
block->reserved = 0;
block->length = htons(8);
block->bh.bt = RTCP_XR_VOIP_METRICS;
block->bh.flags = 0; // Reserved bits
block->bh.length = htons(8);
// TODO: Fill other fields from info in the session
return sizeof(rtcp_xr_voip_metrics_report_block_t);
}
......
......@@ -297,3 +297,212 @@ bool_t rtcp_is_XR(const mblk_t *m) {
}
return FALSE;
}
rtcp_xr_block_type_t rtcp_XR_get_block_type(const mblk_t *m) {
rtcp_xr_generic_block_header_t *bh = (rtcp_xr_generic_block_header_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return bh->bt;
}
uint32_t rtcp_XR_get_ssrc(const mblk_t *m) {
rtcp_xr_header_t *xh = (rtcp_xr_header_t *)m->b_rptr;
return ntohl(xh->ssrc);
}
uint64_t rtcp_XR_rcvr_rtt_get_ntp_timestamp(const mblk_t *m) {
uint64_t ts = 0;
rtcp_xr_rcvr_rtt_report_block_t *b = (rtcp_xr_rcvr_rtt_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
ts = ntohl(b->ntp_timestamp_msw);
ts <<= 32;
ts |= ntohl(b->ntp_timestamp_lsw);
return ts;
}
uint32_t rtcp_XR_dlrr_get_ssrc(const mblk_t *m) {
rtcp_xr_dlrr_report_subblock_t *b = (rtcp_xr_dlrr_report_subblock_t *)(m->b_rptr + sizeof(rtcp_xr_header_t) + sizeof(rtcp_xr_generic_block_header_t));
return ntohl(b->ssrc);
}
uint32_t rtcp_XR_dlrr_get_lrr(const mblk_t *m) {
rtcp_xr_dlrr_report_subblock_t *b = (rtcp_xr_dlrr_report_subblock_t *)(m->b_rptr + sizeof(rtcp_xr_header_t) + sizeof(rtcp_xr_generic_block_header_t));
return ntohl(b->lrr);
}
uint32_t rtcp_XR_dlrr_get_dlrr(const mblk_t *m) {
rtcp_xr_dlrr_report_subblock_t *b = (rtcp_xr_dlrr_report_subblock_t *)(m->b_rptr + sizeof(rtcp_xr_header_t) + sizeof(rtcp_xr_generic_block_header_t));
return ntohl(b->dlrr);
}
uint8_t rtcp_XR_stat_summary_get_flags(const mblk_t *m) {
rtcp_xr_generic_block_header_t *bh = (rtcp_xr_generic_block_header_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return bh->flags;
}
uint32_t rtcp_XR_stat_summary_get_ssrc(const mblk_t *m) {
rtcp_xr_stat_summary_report_block_t *b = (rtcp_xr_stat_summary_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return ntohl(b->ssrc);
}
uint16_t rtcp_XR_stat_summary_get_begin_seq(const mblk_t *m) {
rtcp_xr_stat_summary_report_block_t *b = (rtcp_xr_stat_summary_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return ntohs(b->begin_seq);
}
uint16_t rtcp_XR_stat_summary_get_end_seq(const mblk_t *m) {
rtcp_xr_stat_summary_report_block_t *b = (rtcp_xr_stat_summary_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return ntohs(b->end_seq);
}
uint32_t rtcp_XR_stat_summary_get_lost_packets(const mblk_t *m) {
rtcp_xr_stat_summary_report_block_t *b = (rtcp_xr_stat_summary_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return ntohl(b->lost_packets);
}
uint32_t rtcp_XR_stat_summary_get_dup_packets(const mblk_t *m) {
rtcp_xr_stat_summary_report_block_t *b = (rtcp_xr_stat_summary_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return ntohl(b->dup_packets);
}
uint32_t rtcp_XR_stat_summary_get_min_jitter(const mblk_t *m) {
rtcp_xr_stat_summary_report_block_t *b = (rtcp_xr_stat_summary_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return ntohl(b->min_jitter);
}
uint32_t rtcp_XR_stat_summary_get_max_jitter(const mblk_t *m) {
rtcp_xr_stat_summary_report_block_t *b = (rtcp_xr_stat_summary_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return ntohl(b->max_jitter);
}
uint32_t rtcp_XR_stat_summary_get_mean_jitter(const mblk_t *m) {
rtcp_xr_stat_summary_report_block_t *b = (rtcp_xr_stat_summary_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return ntohl(b->mean_jitter);
}
uint32_t rtcp_XR_stat_summary_get_dev_jitter(const mblk_t *m) {
rtcp_xr_stat_summary_report_block_t *b = (rtcp_xr_stat_summary_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return ntohl(b->dev_jitter);
}
uint8_t rtcp_XR_stat_summary_get_min_ttl_or_hl(const mblk_t *m) {
rtcp_xr_stat_summary_report_block_t *b = (rtcp_xr_stat_summary_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return b->min_ttl_or_hl;
}
uint8_t rtcp_XR_stat_summary_get_max_ttl_or_hl(const mblk_t *m) {
rtcp_xr_stat_summary_report_block_t *b = (rtcp_xr_stat_summary_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return b->max_ttl_or_hl;
}
uint8_t rtcp_XR_stat_summary_get_mean_ttl_or_hl(const mblk_t *m) {
rtcp_xr_stat_summary_report_block_t *b = (rtcp_xr_stat_summary_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return b->mean_ttl_or_hl;
}
uint8_t rtcp_XR_stat_summary_get_dev_ttl_or_hl(const mblk_t *m) {
rtcp_xr_stat_summary_report_block_t *b = (rtcp_xr_stat_summary_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return b->dev_ttl_or_hl;
}
uint32_t rtcp_XR_voip_metrics_get_ssrc(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return ntohl(b->ssrc);
}
uint8_t rtcp_XR_voip_metrics_get_loss_rate(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return b->loss_rate;
}
uint8_t rtcp_XR_voip_metrics_get_discard_rate(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return b->discard_rate;
}
uint8_t rtcp_XR_voip_metrics_get_burst_density(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return b->burst_density;
}
uint8_t rtcp_XR_voip_metrics_get_gap_density(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return b->gap_density;
}
uint16_t rtcp_XR_voip_metrics_get_burst_duration(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return ntohs(b->burst_duration);
}
uint16_t rtcp_XR_voip_metrics_get_gap_duration(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return ntohs(b->gap_duration);
}
uint16_t rtcp_XR_voip_metrics_get_round_trip_delay(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return ntohs(b->round_trip_delay);
}
uint16_t rtcp_XR_voip_metrics_get_end_system_delay(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return ntohs(b->end_system_delay);
}
uint8_t rtcp_XR_voip_metrics_get_signal_level(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return b->signal_level;
}
uint8_t rtcp_XR_voip_metrics_get_noise_level(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return b->noise_level;
}
uint8_t rtcp_XR_voip_metrics_get_rerl(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return b->rerl;
}
uint8_t rtcp_XR_voip_metrics_get_gmin(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return b->gmin;
}
uint8_t rtcp_XR_voip_metrics_get_r_factor(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return b->r_factor;
}
uint8_t rtcp_XR_voip_metrics_get_ext_r_factor(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return b->ext_r_factor;
}
uint8_t rtcp_XR_voip_metrics_get_mos_lq(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return b->mos_lq;
}
uint8_t rtcp_XR_voip_metrics_get_mos_cq(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return b->mos_cq;
}
uint8_t rtcp_XR_voip_metrics_get_rx_config(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return b->rx_config;
}
uint16_t rtcp_XR_voip_metrics_get_jb_nominal(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return ntohs(b->jb_nominal);
}
uint16_t rtcp_XR_voip_metrics_get_jb_maximum(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return ntohs(b->jb_maximum);
}
uint16_t rtcp_XR_voip_metrics_get_jb_abs_max(const mblk_t *m) {
rtcp_xr_voip_metrics_report_block_t *b = (rtcp_xr_voip_metrics_report_block_t *)(m->b_rptr + sizeof(rtcp_xr_header_t));
return ntohs(b->jb_abs_max);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment