Commit 11651441 authored by George Kiagiadakis's avatar George Kiagiadakis

Add env variable to choose nack method

parent 1ce0cd4d
......@@ -3561,9 +3561,7 @@ session_nack (const gchar * key, RTPSource * source, ReportData * data)
nacks = rtp_source_get_nacks (source, &n_nacks);
rist_nacks = rtp_source_get_rist_nacks (source, &n_rist_nacks);
if (n_rist_nacks < n_nacks) {
GST_INFO ("Doing RIST range-based NACK, due to smaller size: %d vs %d",
n_rist_nacks, n_nacks);
if ((n_rist_nacks != 0 && n_rist_nacks < n_nacks) || n_nacks == 0) {
nacks = rist_nacks;
n_nacks = n_rist_nacks;
......@@ -3573,7 +3571,7 @@ session_nack (const gchar * key, RTPSource * source, ReportData * data)
gst_rtcp_packet_app_set_ssrc (packet, source->ssrc);
gst_rtcp_packet_app_set_name (packet, "RIST");
GST_DEBUG ("%u RIST NACKs", n_nacks);
GST_DEBUG ("%u RIST range-based NACKs", n_nacks);
if (!gst_rtcp_packet_app_set_data_length (packet, n_nacks)) {
gst_rtcp_packet_remove (packet);
GST_WARNING ("nacks don't fit in the packet");
......@@ -3586,7 +3584,7 @@ session_nack (const gchar * key, RTPSource * source, ReportData * data)
gst_rtcp_packet_fb_set_sender_ssrc (packet, data->source->ssrc);
gst_rtcp_packet_fb_set_media_ssrc (packet, source->ssrc);
GST_DEBUG ("%u NACKs", n_nacks);
GST_DEBUG ("%u bitmask NACKs", n_nacks);
if (!gst_rtcp_packet_fb_set_fci_length (packet, n_nacks)) {
gst_rtcp_packet_remove (packet);
GST_WARNING ("nacks don't fit in the packet");
......
......@@ -307,6 +307,20 @@ rtp_source_init (RTPSource * src)
rtp_source_reset (src);
src->pt_set = FALSE;
{
const gchar *env = g_getenv ("NACK_METHOD");
if (!env)
src->nack_method = RistNackMethodAuto;
else if (!g_strcmp0 (env, "bitmask"))
src->nack_method = RistNackMethodBitmask;
else if (!g_strcmp0 (env, "range"))
src->nack_method = RistNackMethodRange;
else {
g_warning ("Unknown nack method %s", env);
src->nack_method = RistNackMethodAuto;
}
}
}
void
......@@ -1936,23 +1950,13 @@ rtp_source_register_rist_nack (RTPSource * src, guint16 seqnum)
g_array_append_val (src->rist_nacks, dword);
}
/**
* rtp_source_register_nack:
* @src: The #RTPSource
* @seqnum: a seqnum
*
* Register that @seqnum has not been received from @src.
*/
void
rtp_source_register_nack (RTPSource * src, guint16 seqnum)
static void
rtp_source_register_bitmask_nack (RTPSource * src, guint16 seqnum)
{
guint i, len;
guint32 dword = seqnum << 16;
gint diff = 16;
/* store in both formats */
rtp_source_register_rist_nack (src, seqnum);
len = src->nacks->len;
for (i = 0; i < len; i++) {
guint32 tdword;
......@@ -1984,6 +1988,24 @@ rtp_source_register_nack (RTPSource * src, guint16 seqnum)
GST_DEBUG ("append NACK #%u", seqnum);
g_array_append_val (src->nacks, dword);
}
}
/**
* rtp_source_register_nack:
* @src: The #RTPSource
* @seqnum: a seqnum
*
* Register that @seqnum has not been received from @src.
*/
void
rtp_source_register_nack (RTPSource * src, guint16 seqnum)
{
if (src->nack_method == RistNackMethodRange ||
src->nack_method == RistNackMethodAuto)
rtp_source_register_rist_nack (src, seqnum);
if (src->nack_method == RistNackMethodBitmask ||
src->nack_method == RistNackMethodAuto)
rtp_source_register_bitmask_nack (src, seqnum);
src->send_nack = TRUE;
}
......
......@@ -124,6 +124,13 @@ typedef struct {
GstClockTime time;
} RTPConflictingAddress;
typedef enum {
RistNackMethodUndefined,
RistNackMethodBitmask,
RistNackMethodRange,
RistNackMethodAuto
} RistNackMethod;
/**
* RTPSource:
*
......@@ -202,6 +209,8 @@ struct _RTPSource {
gboolean pt_set;
guint8 pt;
RistNackMethod nack_method;
};
struct _RTPSourceClass {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment