From e259c8ab18ce53bd58d022b2c6a193b4a2ec5b1b Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Wed, 18 Apr 2018 19:10:20 +0200 Subject: osmux: Set Marker bit on osmux frame loss detected Until this patch, we didn't notify in any way to the RTP reader when an Osmux frame was lost. Instead, we updated the seq×tamp as if there was no lost, and as a result the RTP reader would only see a steady increase of delay every time an osmux frame was lost. As the batch_factor for the lost packet is unknown, we cannot assume any number of amr payloads lost, and thus we cannot simply increment seq and timestamp for a specific amount. Instead, the only viable solution seems to set the M marker bit in the first rtp packet generated after a non-consecutive osmux frame is received. The implementation may act differently with the first generated RTP packet based on the first osmux seq number used for the stream. In case 0 it's used as first osmux seq number, M will be set depending on request from original RTP packet having the M bit set. If it's not 0, the first RTP packer will unconditionally have the M bit. That's not an issue because it's anyway expect for receiver to sync on the first packet. Related: OS#3185 Change-Id: I2efed6d726a1b8e77e686c7a5fe1940d3f4901a7 --- src/osmux.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/osmux.c b/src/osmux.c index a7339c6..872588d 100644 --- a/src/osmux.c +++ b/src/osmux.c @@ -151,8 +151,14 @@ osmux_rebuild_rtp(struct osmux_out_handle *h, struct osmux_hdr *osmuxh, rtph->timestamp = htonl(h->rtp_timestamp); rtph->sequence = htons(h->rtp_seq); rtph->ssrc = htonl(h->rtp_ssrc); - /* rtp packet with the marker bit is always warranted to be the first one */ - rtph->marker = first_pkt && osmuxh->rtp_m; + /* rtp packet with the marker bit is always guaranteed to be the first + * one. We want to notify with marker in 2 scenarios: + * 1- Sender told us through osmux frame rtp_m. + * 2- Sntermediate osmux frame lost (seq gap), otherwise rtp receiver only sees + * steady increase of delay + */ + rtph->marker = first_pkt && + (osmuxh->rtp_m || (osmuxh->seq != h->osmux_seq_ack + 1)); msgb_put(out_msg, sizeof(struct rtp_hdr)); @@ -218,6 +224,10 @@ int osmux_xfrm_output(struct osmux_hdr *osmuxh, struct osmux_out_handle *h, #endif llist_add_tail(&msg->list, list); } + + /* Update last seen seq number: */ + h->osmux_seq_ack = osmuxh->seq; + return i; } @@ -291,6 +301,10 @@ int osmux_xfrm_output_sched(struct osmux_out_handle *h, struct osmux_hdr *osmuxh llist_add_tail(&msg->list, &h->list); } + + /* Update last seen seq number: */ + h->osmux_seq_ack = osmuxh->seq; + /* In case list is still empty after parsing messages, no need to rearm */ if(was_empty && !llist_empty(&h->list)) osmux_xfrm_output_trigger(h); -- cgit v1.2.3