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:
George Kiagiadakis 2013-11-29 19:58:26 +01:00 committed by Wim Taymans
parent 130ad1b1fa
commit c8a04bc7b2

View file

@ -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,12 +615,23 @@ 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);
/* 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;
}
/* 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 */
@ -638,6 +650,7 @@ gst_rtp_rtx_send_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
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 */
if (g_queue_get_length (rtx->pending) > 0) {
@ -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);