ristrtxsend: Use externally given seqnum extension when available

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1153>
This commit is contained in:
Olivier Crête 2019-07-26 17:14:14 -04:00 committed by Olivier Crête
parent 58e31e116b
commit e873780a1f
2 changed files with 43 additions and 3 deletions

View file

@ -74,4 +74,8 @@ GType gst_rist_rtp_deext_get_type (void);
guint32 gst_rist_rtp_ext_seq (guint32 * extseqnum, guint16 seqnum); 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 #endif

View file

@ -146,6 +146,10 @@ typedef struct
/* history of rtp packets */ /* history of rtp packets */
GSequence *queue; GSequence *queue;
guint32 max_extseqnum; guint32 max_extseqnum;
/* current rtcp app seqnum extension */
gboolean has_seqnum_ext;
guint16 seqnum_ext;
} SSRCRtxData; } SSRCRtxData;
static SSRCRtxData * static SSRCRtxData *
@ -407,7 +411,6 @@ gst_rist_rtx_send_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
GSequenceIter *iter; GSequenceIter *iter;
BufferQueueItem search_item; BufferQueueItem search_item;
guint32 extseqnum; guint32 extseqnum;
guint32 max_extseqnum;
/* update statistics */ /* update statistics */
++rtx->num_rtx_requests; ++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); data = gst_rist_rtx_send_get_ssrc_data (rtx, ssrc);
max_extseqnum = data->max_extseqnum; 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); extseqnum = gst_rist_rtp_ext_seq (&max_extseqnum, seqnum);
}
search_item.extseqnum = extseqnum; search_item.extseqnum = extseqnum;
iter = g_sequence_lookup (data->queue, &search_item, iter = g_sequence_lookup (data->queue, &search_item,
@ -797,3 +804,32 @@ gst_rist_rtx_send_change_state (GstElement * element, GstStateChange transition)
return ret; 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);
}