mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-23 15:48:23 +00:00
rtprtxsend: do not keep history of packets with an unknown payload type
This allows to disable retransmission per payload type by not putting a certain payload type in the map.
This commit is contained in:
parent
130ad1b1fa
commit
c8a04bc7b2
1 changed files with 29 additions and 24 deletions
|
@ -607,6 +607,7 @@ gst_rtp_rtx_send_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
BufferQueueItem *item;
|
||||
SSRCRtxData *data;
|
||||
guint16 seqnum;
|
||||
guint8 payload_type;
|
||||
guint32 ssrc, rtptime;
|
||||
|
||||
rtx = GST_RTP_RTX_SEND (parent);
|
||||
|
@ -614,29 +615,41 @@ gst_rtp_rtx_send_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
/* read the information we want from the buffer */
|
||||
gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp);
|
||||
seqnum = gst_rtp_buffer_get_seq (&rtp);
|
||||
payload_type = gst_rtp_buffer_get_payload_type (&rtp);
|
||||
ssrc = gst_rtp_buffer_get_ssrc (&rtp);
|
||||
rtptime = gst_rtp_buffer_get_timestamp (&rtp);
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
||||
g_mutex_lock (&rtx->lock);
|
||||
|
||||
data = gst_rtp_rtx_send_get_ssrc_data (rtx, ssrc);
|
||||
|
||||
/* add current rtp buffer to queue history */
|
||||
item = g_new0 (BufferQueueItem, 1);
|
||||
item->seqnum = seqnum;
|
||||
item->timestamp = rtptime;
|
||||
item->buffer = gst_buffer_ref (buffer);
|
||||
g_sequence_append (data->queue, item);
|
||||
|
||||
/* remove oldest packets from history if they are too many */
|
||||
if (rtx->max_size_packets) {
|
||||
while (g_sequence_get_length (data->queue) > rtx->max_size_packets)
|
||||
g_sequence_remove (g_sequence_get_begin_iter (data->queue));
|
||||
/* transfer payload type while holding the lock */
|
||||
if (rtx->rtx_pt_map_changed) {
|
||||
g_hash_table_remove_all (rtx->rtx_pt_map);
|
||||
gst_structure_foreach (rtx->pending_rtx_pt_map, structure_to_hash_table,
|
||||
rtx->rtx_pt_map);
|
||||
rtx->rtx_pt_map_changed = FALSE;
|
||||
}
|
||||
if (rtx->max_size_time) {
|
||||
while (gst_rtp_rtx_send_get_ts_diff (data) > rtx->max_size_time)
|
||||
g_sequence_remove (g_sequence_get_begin_iter (data->queue));
|
||||
|
||||
/* do not store the buffer if it's payload type is unknown */
|
||||
if (g_hash_table_contains (rtx->rtx_pt_map, GUINT_TO_POINTER (payload_type))) {
|
||||
data = gst_rtp_rtx_send_get_ssrc_data (rtx, ssrc);
|
||||
|
||||
/* add current rtp buffer to queue history */
|
||||
item = g_new0 (BufferQueueItem, 1);
|
||||
item->seqnum = seqnum;
|
||||
item->timestamp = rtptime;
|
||||
item->buffer = gst_buffer_ref (buffer);
|
||||
g_sequence_append (data->queue, item);
|
||||
|
||||
/* remove oldest packets from history if they are too many */
|
||||
if (rtx->max_size_packets) {
|
||||
while (g_sequence_get_length (data->queue) > rtx->max_size_packets)
|
||||
g_sequence_remove (g_sequence_get_begin_iter (data->queue));
|
||||
}
|
||||
if (rtx->max_size_time) {
|
||||
while (gst_rtp_rtx_send_get_ts_diff (data) > rtx->max_size_time)
|
||||
g_sequence_remove (g_sequence_get_begin_iter (data->queue));
|
||||
}
|
||||
}
|
||||
|
||||
/* within lock, get packets that have to be retransmited */
|
||||
|
@ -648,14 +661,6 @@ gst_rtp_rtx_send_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
rtx->num_rtx_packets += g_queue_get_length (pending);
|
||||
}
|
||||
|
||||
/* transfer payload type while holding the lock */
|
||||
if (rtx->rtx_pt_map_changed) {
|
||||
g_hash_table_remove_all (rtx->rtx_pt_map);
|
||||
gst_structure_foreach (rtx->pending_rtx_pt_map, structure_to_hash_table,
|
||||
rtx->rtx_pt_map);
|
||||
rtx->rtx_pt_map_changed = FALSE;
|
||||
}
|
||||
|
||||
/* no need to hold the lock to push rtx packets */
|
||||
g_mutex_unlock (&rtx->lock);
|
||||
|
||||
|
|
Loading…
Reference in a new issue