rtpbin/rtpjitterbuffer/rtspsrc: Add property to set maximum ms between RTCP SR RTP time and last observed RTP time

https://bugzilla.gnome.org/show_bug.cgi?id=755125
This commit is contained in:
Sebastian Dröge 2015-09-21 13:47:21 +02:00
parent a0ae6b5b5a
commit 01c0f8723f
5 changed files with 84 additions and 4 deletions

View file

@ -291,6 +291,7 @@ enum
#define DEFAULT_RTP_PROFILE GST_RTP_PROFILE_AVP #define DEFAULT_RTP_PROFILE GST_RTP_PROFILE_AVP
#define DEFAULT_NTP_TIME_SOURCE GST_RTP_NTP_TIME_SOURCE_NTP #define DEFAULT_NTP_TIME_SOURCE GST_RTP_NTP_TIME_SOURCE_NTP
#define DEFAULT_RTCP_SYNC_SEND_TIME TRUE #define DEFAULT_RTCP_SYNC_SEND_TIME TRUE
#define DEFAULT_MAX_RTCP_RTP_TIME_DIFF 1000
enum enum
{ {
@ -310,7 +311,8 @@ enum
PROP_DO_RETRANSMISSION, PROP_DO_RETRANSMISSION,
PROP_RTP_PROFILE, PROP_RTP_PROFILE,
PROP_NTP_TIME_SOURCE, PROP_NTP_TIME_SOURCE,
PROP_RTCP_SYNC_SEND_TIME PROP_RTCP_SYNC_SEND_TIME,
PROP_MAX_RTCP_RTP_TIME_DIFF
}; };
#define GST_RTP_BIN_RTCP_SYNC_TYPE (gst_rtp_bin_rtcp_sync_get_type()) #define GST_RTP_BIN_RTCP_SYNC_TYPE (gst_rtp_bin_rtcp_sync_get_type())
@ -1552,6 +1554,8 @@ create_stream (GstRtpBinSession * session, guint32 ssrc)
g_object_set (buffer, "do-lost", rtpbin->do_lost, NULL); g_object_set (buffer, "do-lost", rtpbin->do_lost, NULL);
g_object_set (buffer, "mode", rtpbin->buffer_mode, NULL); g_object_set (buffer, "mode", rtpbin->buffer_mode, NULL);
g_object_set (buffer, "do-retransmission", rtpbin->do_retransmission, NULL); g_object_set (buffer, "do-retransmission", rtpbin->do_retransmission, NULL);
g_object_set (buffer, "max-rtcp-rtp-time-diff",
rtpbin->max_rtcp_rtp_time_diff, NULL);
g_signal_emit (rtpbin, gst_rtp_bin_signals[SIGNAL_NEW_JITTERBUFFER], 0, g_signal_emit (rtpbin, gst_rtp_bin_signals[SIGNAL_NEW_JITTERBUFFER], 0,
buffer, session->id, ssrc); buffer, session->id, ssrc);
@ -2181,6 +2185,13 @@ gst_rtp_bin_class_init (GstRtpBinClass * klass)
DEFAULT_RTCP_SYNC_SEND_TIME, DEFAULT_RTCP_SYNC_SEND_TIME,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_MAX_RTCP_RTP_TIME_DIFF,
g_param_spec_int ("max-rtcp-rtp-time-diff", "Max RTCP RTP Time Diff",
"Maximum amount of time in ms that the RTP time in RTCP SRs "
"is allowed to be ahead (-1 disabled)", -1, G_MAXINT,
DEFAULT_MAX_RTCP_RTP_TIME_DIFF,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_rtp_bin_change_state); gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_rtp_bin_change_state);
gstelement_class->request_new_pad = gstelement_class->request_new_pad =
GST_DEBUG_FUNCPTR (gst_rtp_bin_request_new_pad); GST_DEBUG_FUNCPTR (gst_rtp_bin_request_new_pad);
@ -2246,6 +2257,7 @@ gst_rtp_bin_init (GstRtpBin * rtpbin)
rtpbin->rtp_profile = DEFAULT_RTP_PROFILE; rtpbin->rtp_profile = DEFAULT_RTP_PROFILE;
rtpbin->ntp_time_source = DEFAULT_NTP_TIME_SOURCE; rtpbin->ntp_time_source = DEFAULT_NTP_TIME_SOURCE;
rtpbin->rtcp_sync_send_time = DEFAULT_RTCP_SYNC_SEND_TIME; rtpbin->rtcp_sync_send_time = DEFAULT_RTCP_SYNC_SEND_TIME;
rtpbin->max_rtcp_rtp_time_diff = DEFAULT_MAX_RTCP_RTP_TIME_DIFF;
/* some default SDES entries */ /* some default SDES entries */
cname = g_strdup_printf ("user%u@host-%x", g_random_int (), g_random_int ()); cname = g_strdup_printf ("user%u@host-%x", g_random_int (), g_random_int ());
@ -2437,6 +2449,13 @@ gst_rtp_bin_set_property (GObject * object, guint prop_id,
GST_RTP_BIN_UNLOCK (rtpbin); GST_RTP_BIN_UNLOCK (rtpbin);
break; break;
} }
case PROP_MAX_RTCP_RTP_TIME_DIFF:
GST_RTP_BIN_LOCK (rtpbin);
rtpbin->max_rtcp_rtp_time_diff = g_value_get_int (value);
GST_RTP_BIN_UNLOCK (rtpbin);
gst_rtp_bin_propagate_property_to_jitterbuffer (rtpbin,
"max-rtcp-rtp-time-diff", value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -2508,6 +2527,11 @@ gst_rtp_bin_get_property (GObject * object, guint prop_id,
case PROP_RTCP_SYNC_SEND_TIME: case PROP_RTCP_SYNC_SEND_TIME:
g_value_set_boolean (value, rtpbin->rtcp_sync_send_time); g_value_set_boolean (value, rtpbin->rtcp_sync_send_time);
break; break;
case PROP_MAX_RTCP_RTP_TIME_DIFF:
GST_RTP_BIN_LOCK (rtpbin);
g_value_set_int (value, rtpbin->max_rtcp_rtp_time_diff);
GST_RTP_BIN_UNLOCK (rtpbin);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;

View file

@ -70,6 +70,7 @@ struct _GstRtpBin {
gboolean do_retransmission; gboolean do_retransmission;
GstRTPProfile rtp_profile; GstRTPProfile rtp_profile;
gboolean rtcp_sync_send_time; gboolean rtcp_sync_send_time;
gint max_rtcp_rtp_time_diff;
/* a list of session */ /* a list of session */
GSList *sessions; GSList *sessions;

View file

@ -136,6 +136,7 @@ enum
#define DEFAULT_RTX_MIN_RETRY_TIMEOUT -1 #define DEFAULT_RTX_MIN_RETRY_TIMEOUT -1
#define DEFAULT_RTX_RETRY_PERIOD -1 #define DEFAULT_RTX_RETRY_PERIOD -1
#define DEFAULT_RTX_MAX_RETRIES -1 #define DEFAULT_RTX_MAX_RETRIES -1
#define DEFAULT_MAX_RTCP_RTP_TIME_DIFF 1000
#define DEFAULT_AUTO_RTX_DELAY (20 * GST_MSECOND) #define DEFAULT_AUTO_RTX_DELAY (20 * GST_MSECOND)
#define DEFAULT_AUTO_RTX_TIMEOUT (40 * GST_MSECOND) #define DEFAULT_AUTO_RTX_TIMEOUT (40 * GST_MSECOND)
@ -158,7 +159,8 @@ enum
PROP_RTX_MIN_RETRY_TIMEOUT, PROP_RTX_MIN_RETRY_TIMEOUT,
PROP_RTX_RETRY_PERIOD, PROP_RTX_RETRY_PERIOD,
PROP_RTX_MAX_RETRIES, PROP_RTX_MAX_RETRIES,
PROP_STATS PROP_STATS,
PROP_MAX_RTCP_RTP_TIME_DIFF
}; };
#define JBUF_LOCK(priv) (g_mutex_lock (&(priv)->jbuf_lock)) #define JBUF_LOCK(priv) (g_mutex_lock (&(priv)->jbuf_lock))
@ -255,6 +257,7 @@ struct _GstRtpJitterBufferPrivate
gint rtx_min_retry_timeout; gint rtx_min_retry_timeout;
gint rtx_retry_period; gint rtx_retry_period;
gint rtx_max_retries; gint rtx_max_retries;
gint max_rtcp_rtp_time_diff;
/* the last seqnum we pushed out */ /* the last seqnum we pushed out */
guint32 last_popped_seqnum; guint32 last_popped_seqnum;
@ -705,6 +708,22 @@ gst_rtp_jitter_buffer_class_init (GstRtpJitterBufferClass * klass)
"Various statistics", GST_TYPE_STRUCTURE, "Various statistics", GST_TYPE_STRUCTURE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
* GstRtpJitterBuffer:max-rtcp-rtp-time-diff
*
* The maximum amount of time in ms that the RTP time in the RTCP SRs
* is allowed to be ahead of the last RTP packet we received. Use
* -1 to disable ignoring of RTCP packets.
*
* Since: 1.8
*/
g_object_class_install_property (gobject_class, PROP_MAX_RTCP_RTP_TIME_DIFF,
g_param_spec_int ("max-rtcp-rtp-time-diff", "Max RTCP RTP Time Diff",
"Maximum amount of time in ms that the RTP time in RTCP SRs "
"is allowed to be ahead (-1 disabled)", -1, G_MAXINT,
DEFAULT_MAX_RTCP_RTP_TIME_DIFF,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/** /**
* GstRtpJitterBuffer::request-pt-map: * GstRtpJitterBuffer::request-pt-map:
* @buffer: the object which received the signal * @buffer: the object which received the signal
@ -822,6 +841,7 @@ gst_rtp_jitter_buffer_init (GstRtpJitterBuffer * jitterbuffer)
priv->rtx_min_retry_timeout = DEFAULT_RTX_MIN_RETRY_TIMEOUT; priv->rtx_min_retry_timeout = DEFAULT_RTX_MIN_RETRY_TIMEOUT;
priv->rtx_retry_period = DEFAULT_RTX_RETRY_PERIOD; priv->rtx_retry_period = DEFAULT_RTX_RETRY_PERIOD;
priv->rtx_max_retries = DEFAULT_RTX_MAX_RETRIES; priv->rtx_max_retries = DEFAULT_RTX_MAX_RETRIES;
priv->max_rtcp_rtp_time_diff = DEFAULT_MAX_RTCP_RTP_TIME_DIFF;
priv->last_dts = -1; priv->last_dts = -1;
priv->last_rtptime = -1; priv->last_rtptime = -1;
@ -3552,7 +3572,10 @@ do_handle_sync (GstRtpJitterBuffer * jitterbuffer)
/* check how far ahead it is to our RTP timestamps */ /* check how far ahead it is to our RTP timestamps */
diff = ext_rtptime - last_rtptime; diff = ext_rtptime - last_rtptime;
/* if bigger than 1 second, we drop it */ /* if bigger than 1 second, we drop it */
if (diff > clock_rate) { if (jitterbuffer->priv->max_rtcp_rtp_time_diff != -1 &&
diff >
gst_util_uint64_scale (jitterbuffer->priv->max_rtcp_rtp_time_diff,
clock_rate, 1000)) {
GST_DEBUG_OBJECT (jitterbuffer, "too far ahead"); GST_DEBUG_OBJECT (jitterbuffer, "too far ahead");
/* should drop this, but some RTSP servers end up with bogus /* should drop this, but some RTSP servers end up with bogus
* way too ahead RTCP packet when repeated PAUSE/PLAY, * way too ahead RTCP packet when repeated PAUSE/PLAY,
@ -3929,6 +3952,11 @@ gst_rtp_jitter_buffer_set_property (GObject * object,
priv->rtx_max_retries = g_value_get_int (value); priv->rtx_max_retries = g_value_get_int (value);
JBUF_UNLOCK (priv); JBUF_UNLOCK (priv);
break; break;
case PROP_MAX_RTCP_RTP_TIME_DIFF:
JBUF_LOCK (priv);
priv->max_rtcp_rtp_time_diff = g_value_get_int (value);
JBUF_UNLOCK (priv);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -4034,6 +4062,11 @@ gst_rtp_jitter_buffer_get_property (GObject * object,
g_value_take_boxed (value, g_value_take_boxed (value,
gst_rtp_jitter_buffer_create_stats (jitterbuffer)); gst_rtp_jitter_buffer_create_stats (jitterbuffer));
break; break;
case PROP_MAX_RTCP_RTP_TIME_DIFF:
JBUF_LOCK (priv);
g_value_set_int (value, priv->max_rtcp_rtp_time_diff);
JBUF_UNLOCK (priv);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;

View file

@ -232,6 +232,7 @@ gst_rtsp_src_ntp_time_source_get_type (void)
#define DEFAULT_DO_RETRANSMISSION TRUE #define DEFAULT_DO_RETRANSMISSION TRUE
#define DEFAULT_NTP_TIME_SOURCE NTP_TIME_SOURCE_NTP #define DEFAULT_NTP_TIME_SOURCE NTP_TIME_SOURCE_NTP
#define DEFAULT_USER_AGENT "GStreamer/" PACKAGE_VERSION #define DEFAULT_USER_AGENT "GStreamer/" PACKAGE_VERSION
#define DEFAULT_MAX_RTCP_RTP_TIME_DIFF 1000
enum enum
{ {
@ -269,7 +270,8 @@ enum
PROP_TLS_INTERACTION, PROP_TLS_INTERACTION,
PROP_DO_RETRANSMISSION, PROP_DO_RETRANSMISSION,
PROP_NTP_TIME_SOURCE, PROP_NTP_TIME_SOURCE,
PROP_USER_AGENT PROP_USER_AGENT,
PROP_MAX_RTCP_RTP_TIME_DIFF
}; };
#define GST_TYPE_RTSP_NAT_METHOD (gst_rtsp_nat_method_get_type()) #define GST_TYPE_RTSP_NAT_METHOD (gst_rtsp_nat_method_get_type())
@ -732,6 +734,13 @@ gst_rtspsrc_class_init (GstRTSPSrcClass * klass)
"The User-Agent string to send to the server", "The User-Agent string to send to the server",
DEFAULT_USER_AGENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); DEFAULT_USER_AGENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_MAX_RTCP_RTP_TIME_DIFF,
g_param_spec_int ("max-rtcp-rtp-time-diff", "Max RTCP RTP Time Diff",
"Maximum amount of time in ms that the RTP time in RTCP SRs "
"is allowed to be ahead (-1 disabled)", -1, G_MAXINT,
DEFAULT_MAX_RTCP_RTP_TIME_DIFF,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/** /**
* GstRTSPSrc::handle-request: * GstRTSPSrc::handle-request:
* @rtspsrc: a #GstRTSPSrc * @rtspsrc: a #GstRTSPSrc
@ -879,6 +888,7 @@ gst_rtspsrc_init (GstRTSPSrc * src)
src->do_retransmission = DEFAULT_DO_RETRANSMISSION; src->do_retransmission = DEFAULT_DO_RETRANSMISSION;
src->ntp_time_source = DEFAULT_NTP_TIME_SOURCE; src->ntp_time_source = DEFAULT_NTP_TIME_SOURCE;
src->user_agent = g_strdup (DEFAULT_USER_AGENT); src->user_agent = g_strdup (DEFAULT_USER_AGENT);
src->max_rtcp_rtp_time_diff = DEFAULT_MAX_RTCP_RTP_TIME_DIFF;
/* get a list of all extensions */ /* get a list of all extensions */
src->extensions = gst_rtsp_ext_list_get (); src->extensions = gst_rtsp_ext_list_get ();
@ -1161,6 +1171,9 @@ gst_rtspsrc_set_property (GObject * object, guint prop_id, const GValue * value,
g_free (rtspsrc->user_agent); g_free (rtspsrc->user_agent);
rtspsrc->user_agent = g_value_dup_string (value); rtspsrc->user_agent = g_value_dup_string (value);
break; break;
case PROP_MAX_RTCP_RTP_TIME_DIFF:
rtspsrc->max_rtcp_rtp_time_diff = g_value_get_int (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -1304,6 +1317,9 @@ gst_rtspsrc_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_USER_AGENT: case PROP_USER_AGENT:
g_value_set_string (value, rtspsrc->user_agent); g_value_set_string (value, rtspsrc->user_agent);
break; break;
case PROP_MAX_RTCP_RTP_TIME_DIFF:
g_value_set_int (value, rtspsrc->max_rtcp_rtp_time_diff);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -3493,6 +3509,11 @@ gst_rtspsrc_stream_configure_manager (GstRTSPSrc * src, GstRTSPStream * stream,
NULL); NULL);
} }
if (g_object_class_find_property (klass, "max-rtcp-rtp-time-diff")) {
g_object_set (src->manager, "max-rtcp-rtp-time-diff",
src->max_rtcp_rtp_time_diff, NULL);
}
/* buffer mode pauses are handled by adding offsets to buffer times, /* buffer mode pauses are handled by adding offsets to buffer times,
* but some depayloaders may have a hard time syncing output times * but some depayloaders may have a hard time syncing output times
* with such input times, e.g. container ones, most notably ASF */ * with such input times, e.g. container ones, most notably ASF */

View file

@ -238,6 +238,7 @@ struct _GstRTSPSrc {
gboolean do_retransmission; gboolean do_retransmission;
gint ntp_time_source; gint ntp_time_source;
gchar *user_agent; gchar *user_agent;
GstClockTime max_rtcp_rtp_time_diff;
/* state */ /* state */
GstRTSPState state; GstRTSPState state;