From e873780a1f615235a41464a378adae32524de7bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= Date: Fri, 26 Jul 2019 17:14:14 -0400 Subject: [PATCH] ristrtxsend: Use externally given seqnum extension when available Part-of: --- gst/rist/gstrist.h | 4 ++++ gst/rist/gstristrtxsend.c | 42 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/gst/rist/gstrist.h b/gst/rist/gstrist.h index d53ef415dd..1f74044e2b 100644 --- a/gst/rist/gstrist.h +++ b/gst/rist/gstrist.h @@ -74,4 +74,8 @@ GType gst_rist_rtp_deext_get_type (void); guint32 gst_rist_rtp_ext_seq (guint32 * extseqnum, guint16 seqnum); +void gst_rist_rtx_send_set_extseqnum (GstRistRtxSend *self, guint32 ssrc, + guint16 seqnum_ext); +void gst_rist_rtx_send_clear_extseqnum (GstRistRtxSend *self, guint32 ssrc); + #endif diff --git a/gst/rist/gstristrtxsend.c b/gst/rist/gstristrtxsend.c index 0a28fb4216..3c4d404748 100644 --- a/gst/rist/gstristrtxsend.c +++ b/gst/rist/gstristrtxsend.c @@ -146,6 +146,10 @@ typedef struct /* history of rtp packets */ GSequence *queue; guint32 max_extseqnum; + + /* current rtcp app seqnum extension */ + gboolean has_seqnum_ext; + guint16 seqnum_ext; } SSRCRtxData; static SSRCRtxData * @@ -407,7 +411,6 @@ gst_rist_rtx_send_src_event (GstPad * pad, GstObject * parent, GstEvent * event) GSequenceIter *iter; BufferQueueItem search_item; guint32 extseqnum; - guint32 max_extseqnum; /* update statistics */ ++rtx->num_rtx_requests; @@ -415,8 +418,12 @@ gst_rist_rtx_send_src_event (GstPad * pad, GstObject * parent, GstEvent * event) data = gst_rist_rtx_send_get_ssrc_data (rtx, ssrc); - max_extseqnum = data->max_extseqnum; - extseqnum = gst_rist_rtp_ext_seq (&max_extseqnum, seqnum); + if (data->has_seqnum_ext) { + extseqnum = data->seqnum_ext << 16 | seqnum; + } else { + guint32 max_extseqnum = data->max_extseqnum; + extseqnum = gst_rist_rtp_ext_seq (&max_extseqnum, seqnum); + } search_item.extseqnum = extseqnum; iter = g_sequence_lookup (data->queue, &search_item, @@ -797,3 +804,32 @@ gst_rist_rtx_send_change_state (GstElement * element, GstStateChange transition) return ret; } + +void +gst_rist_rtx_send_set_extseqnum (GstRistRtxSend * rtx, guint32 ssrc, + guint16 seqnum_ext) +{ + SSRCRtxData *data; + + GST_OBJECT_LOCK (rtx); + data = g_hash_table_lookup (rtx->ssrc_data, GUINT_TO_POINTER (ssrc)); + + if (data) { + data->has_seqnum_ext = TRUE; + data->seqnum_ext = seqnum_ext; + } + GST_OBJECT_UNLOCK (rtx); +} + +void +gst_rist_rtx_send_clear_extseqnum (GstRistRtxSend * rtx, guint32 ssrc) +{ + SSRCRtxData *data; + + GST_OBJECT_LOCK (rtx); + data = g_hash_table_lookup (rtx->ssrc_data, GUINT_TO_POINTER (ssrc)); + + if (data) + data->has_seqnum_ext = FALSE; + GST_OBJECT_UNLOCK (rtx); +}