rtspsrc: make jitterbuffer drop-on-latency available (fix #682055)

Conflicts:

	gst/rtsp/gstrtspsrc.h
This commit is contained in:
Aleix Conchillo Flaque 2012-08-16 16:51:16 -07:00 committed by Wim Taymans
parent 05d4f81834
commit 8d864dbbfc
4 changed files with 45 additions and 0 deletions

View file

@ -243,6 +243,7 @@ enum
};
#define DEFAULT_LATENCY_MS 200
#define DEFAULT_DROP_ON_LATENCY FALSE
#define DEFAULT_SDES NULL
#define DEFAULT_DO_LOST FALSE
#define DEFAULT_IGNORE_PT FALSE
@ -257,6 +258,7 @@ enum
{
PROP_0,
PROP_LATENCY,
PROP_DROP_ON_LATENCY,
PROP_SDES,
PROP_DO_LOST,
PROP_IGNORE_PT,
@ -1428,6 +1430,7 @@ create_stream (GstRtpBinSession * session, guint32 ssrc)
/* configure latency and packet lost */
g_object_set (buffer, "latency", rtpbin->latency_ms, NULL);
g_object_set (buffer, "drop-on-latency", rtpbin->drop_on_latency, NULL);
g_object_set (buffer, "do-lost", rtpbin->do_lost, NULL);
g_object_set (buffer, "mode", rtpbin->buffer_mode, NULL);
@ -1553,6 +1556,12 @@ gst_rtp_bin_class_init (GstRtpBinClass * klass)
G_MAXUINT, DEFAULT_LATENCY_MS,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_DROP_ON_LATENCY,
g_param_spec_boolean ("drop-on-latency",
"Drop buffers when maximum latency is reached",
"Tells the jitterbuffer to never exceed the given latency in size",
DEFAULT_DROP_ON_LATENCY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstRtpBin::request-pt-map:
* @rtpbin: the object which received the signal
@ -1878,6 +1887,7 @@ gst_rtp_bin_init (GstRtpBin * rtpbin)
rtpbin->latency_ms = DEFAULT_LATENCY_MS;
rtpbin->latency_ns = DEFAULT_LATENCY_MS * GST_MSECOND;
rtpbin->drop_on_latency = DEFAULT_DROP_ON_LATENCY;
rtpbin->do_lost = DEFAULT_DO_LOST;
rtpbin->ignore_pt = DEFAULT_IGNORE_PT;
rtpbin->ntp_sync = DEFAULT_NTP_SYNC;
@ -1986,6 +1996,14 @@ gst_rtp_bin_set_property (GObject * object, guint prop_id,
/* propagate the property down to the jitterbuffer */
gst_rtp_bin_propagate_property_to_jitterbuffer (rtpbin, "latency", value);
break;
case PROP_DROP_ON_LATENCY:
GST_RTP_BIN_LOCK (rtpbin);
rtpbin->drop_on_latency = g_value_get_boolean (value);
GST_RTP_BIN_UNLOCK (rtpbin);
/* propagate the property down to the jitterbuffer */
gst_rtp_bin_propagate_property_to_jitterbuffer (rtpbin,
"drop-on-latency", value);
break;
case PROP_SDES:
gst_rtp_bin_set_sdes_struct (rtpbin, g_value_get_boxed (value));
break;
@ -2052,6 +2070,11 @@ gst_rtp_bin_get_property (GObject * object, guint prop_id,
g_value_set_uint (value, rtpbin->latency_ms);
GST_RTP_BIN_UNLOCK (rtpbin);
break;
case PROP_DROP_ON_LATENCY:
GST_RTP_BIN_LOCK (rtpbin);
g_value_set_boolean (value, rtpbin->drop_on_latency);
GST_RTP_BIN_UNLOCK (rtpbin);
break;
case PROP_SDES:
g_value_take_boxed (value, gst_rtp_bin_get_sdes_struct (rtpbin));
break;

View file

@ -47,6 +47,7 @@ struct _GstRtpBin {
/* default latency for sessions */
guint latency_ms;
guint64 latency_ns;
gboolean drop_on_latency;
gboolean do_lost;
gboolean ignore_pt;
gboolean ntp_sync;

View file

@ -167,6 +167,7 @@ gst_rtsp_src_buffer_mode_get_type (void)
#define DEFAULT_UDP_BUFFER_SIZE 0x80000
#define DEFAULT_TCP_TIMEOUT 20000000
#define DEFAULT_LATENCY_MS 2000
#define DEFAULT_DROP_ON_LATENCY FALSE
#define DEFAULT_CONNECTION_SPEED 0
#define DEFAULT_NAT_METHOD GST_RTSP_NAT_DUMMY
#define DEFAULT_DO_RTCP TRUE
@ -189,6 +190,7 @@ enum
PROP_TIMEOUT,
PROP_TCP_TIMEOUT,
PROP_LATENCY,
PROP_DROP_ON_LATENCY,
PROP_CONNECTION_SPEED,
PROP_NAT_METHOD,
PROP_DO_RTCP,
@ -347,6 +349,12 @@ gst_rtspsrc_class_init (GstRTSPSrcClass * klass)
"Amount of ms to buffer", 0, G_MAXUINT, DEFAULT_LATENCY_MS,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_DROP_ON_LATENCY,
g_param_spec_boolean ("drop-on-latency",
"Drop buffers when maximum latency is reached",
"Tells the jitterbuffer to never exceed the given latency in size",
DEFAULT_DROP_ON_LATENCY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_CONNECTION_SPEED,
g_param_spec_uint64 ("connection-speed", "Connection Speed",
"Network connection speed in kbps (0 = unknown)",
@ -503,6 +511,7 @@ gst_rtspsrc_init (GstRTSPSrc * src)
src->udp_timeout = DEFAULT_TIMEOUT;
gst_rtspsrc_set_tcp_timeout (src, DEFAULT_TCP_TIMEOUT);
src->latency = DEFAULT_LATENCY_MS;
src->drop_on_latency = DEFAULT_DROP_ON_LATENCY;
src->connection_speed = DEFAULT_CONNECTION_SPEED;
src->nat_method = DEFAULT_NAT_METHOD;
src->do_rtcp = DEFAULT_DO_RTCP;
@ -656,6 +665,9 @@ gst_rtspsrc_set_property (GObject * object, guint prop_id, const GValue * value,
case PROP_LATENCY:
rtspsrc->latency = g_value_get_uint (value);
break;
case PROP_DROP_ON_LATENCY:
rtspsrc->drop_on_latency = g_value_get_boolean (value);
break;
case PROP_CONNECTION_SPEED:
rtspsrc->connection_speed = g_value_get_uint64 (value);
break;
@ -749,6 +761,9 @@ gst_rtspsrc_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_LATENCY:
g_value_set_uint (value, rtspsrc->latency);
break;
case PROP_DROP_ON_LATENCY:
g_value_set_boolean (value, rtspsrc->drop_on_latency);
break;
case PROP_CONNECTION_SPEED:
g_value_set_uint64 (value, rtspsrc->connection_speed);
break;
@ -2370,6 +2385,11 @@ gst_rtspsrc_stream_configure_manager (GstRTSPSrc * src, GstRTSPStream * stream,
g_object_set (src->manager, "latency", src->latency, NULL);
klass = G_OBJECT_GET_CLASS (G_OBJECT (src->manager));
if (g_object_class_find_property (klass, "drop-on-latency")) {
g_object_set (src->manager, "drop-on-latency", src->drop_on_latency,
NULL);
}
if (g_object_class_find_property (klass, "buffer-mode")) {
if (src->buffer_mode != BUFFER_MODE_AUTO) {
g_object_set (src->manager, "buffer-mode", src->buffer_mode, NULL);

View file

@ -201,6 +201,7 @@ struct _GstRTSPSrc {
GTimeVal tcp_timeout;
GTimeVal *ptcp_timeout;
guint latency;
gboolean drop_on_latency;
guint64 connection_speed;
GstRTSPNatMethod nat_method;
gboolean do_rtcp;