typedef struct
{
- guint16 seqnum;
+ guint32 extseqnum;
guint32 timestamp;
GstBuffer *buffer;
} BufferQueueItem;
/* history of rtp packets */
GSequence *queue;
+ guint32 max_extseqnum;
} SSRCRtxData;
static SSRCRtxData *
data->rtx_ssrc = rtx_ssrc;
data->next_seqnum = data->seqnum_base = g_random_int_range (0, G_MAXUINT16);
data->queue = g_sequence_new ((GDestroyNotify) buffer_queue_item_free);
+ data->max_extseqnum = -1;
return data;
}
/* gst_rtp_buffer_compare_seqnum returns the opposite of what we want,
* it returns negative when seqnum1 > seqnum2 and we want negative
* when b > a, i.e. a is smaller, so it comes first in the sequence */
- return gst_rtp_buffer_compare_seqnum (b->seqnum, a->seqnum);
+ return a->extseqnum - b->extseqnum;
}
static gboolean
SSRCRtxData *data;
GSequenceIter *iter;
BufferQueueItem search_item;
+ guint32 extseqnum;
+ guint32 max_extseqnum;
/* update statistics */
++rtx->num_rtx_requests;
data = gst_rist_rtx_send_get_ssrc_data (rtx, ssrc);
- search_item.seqnum = seqnum;
+
+ 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,
(GCompareDataFunc) buffer_queue_items_cmp, NULL);
if (iter) {
BufferQueueItem *item = g_sequence_get (iter);
- GST_LOG_OBJECT (rtx, "found %u", item->seqnum);
+ GST_LOG_OBJECT (rtx, "found %u (%u:%u)", item->extseqnum,
+ item->extseqnum >> 16, item->extseqnum & 0xFFFF);
rtx_buf = gst_rtp_rist_buffer_new (rtx, item->buffer, ssrc);
}
#ifndef GST_DISABLE_DEBUG
if (!g_sequence_iter_is_end (iter))
item = g_sequence_get (iter);
- if (item && seqnum < item->seqnum) {
+ if (item && extseqnum < item->extseqnum) {
GST_DEBUG_OBJECT (rtx, "requested seqnum %u has already been "
"removed from the rtx queue; the first available is %u",
- seqnum, item->seqnum);
+ seqnum, item->extseqnum);
} else {
GST_WARNING_OBJECT (rtx, "requested seqnum %u has not been "
"transmitted yet in the original stream; either the remote end "
SSRCRtxData *data;
guint16 seqnum;
guint32 ssrc, rtptime;
+ guint16 bits;
+ gpointer extdata;
+ guint extlen;
+ gboolean has_seqnum_ext = FALSE;
+ guint32 extseqnum;
/* read the information we want from the buffer */
gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp);
seqnum = gst_rtp_buffer_get_seq (&rtp);
ssrc = gst_rtp_buffer_get_ssrc (&rtp);
rtptime = gst_rtp_buffer_get_timestamp (&rtp);
+ if (gst_rtp_buffer_get_extension_data (&rtp, &bits, &extdata, &extlen)) {
+ /* Has header extension */
+ has_seqnum_ext = (bits >> 14) & 1; /* E */
+ if (extlen != 1)
+ has_seqnum_ext = FALSE;
+ if (has_seqnum_ext)
+ extseqnum = GST_READ_UINT16_BE (extdata) << 16 | seqnum;
+ }
gst_rtp_buffer_unmap (&rtp);
GST_TRACE_OBJECT (rtx, "Processing buffer seqnum: %u, ssrc: %X", seqnum,
data = gst_rist_rtx_send_get_ssrc_data (rtx, ssrc);
+ if (has_seqnum_ext)
+ data->max_extseqnum = MAX (data->max_extseqnum, extseqnum);
+ else
+ extseqnum = gst_rist_rtp_ext_seq (&data->max_extseqnum, seqnum);
+
/* add current rtp buffer to queue history */
item = g_slice_new0 (BufferQueueItem);
- item->seqnum = seqnum;
+ item->extseqnum = extseqnum;
item->timestamp = rtptime;
item->buffer = gst_buffer_ref (buffer);
g_sequence_append (data->queue, item);