GstRTSPAddressPool *pool;
GstClockTime rtx_time;
+ guint latency;
GMutex medias_lock;
GHashTable *medias; /* protected by medias_lock */
#define DEFAULT_PROTOCOLS GST_RTSP_LOWER_TRANS_UDP | GST_RTSP_LOWER_TRANS_UDP_MCAST | \
GST_RTSP_LOWER_TRANS_TCP
#define DEFAULT_BUFFER_SIZE 0x80000
+#define DEFAULT_LATENCY 200
#define DEFAULT_RECORD FALSE
enum
PROP_PROFILES,
PROP_PROTOCOLS,
PROP_BUFFER_SIZE,
+ PROP_LATENCY,
PROP_RECORD,
PROP_LAST
};
"The kernel UDP buffer size to use", 0, G_MAXUINT,
DEFAULT_BUFFER_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_LATENCY,
+ g_param_spec_uint ("latency", "Latency",
+ "Latency used for receiving media in milliseconds", 0, G_MAXUINT,
+ DEFAULT_LATENCY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
/* FIXME: Should this be a flag property to allow RECORD and PLAY?
* Or just another boolean PLAY property that default to TRUE?
*/
priv->profiles = DEFAULT_PROFILES;
priv->protocols = DEFAULT_PROTOCOLS;
priv->buffer_size = DEFAULT_BUFFER_SIZE;
+ priv->latency = DEFAULT_LATENCY;
g_mutex_init (&priv->lock);
g_mutex_init (&priv->medias_lock);
g_value_set_uint (value,
gst_rtsp_media_factory_get_buffer_size (factory));
break;
+ case PROP_LATENCY:
+ g_value_set_uint (value, gst_rtsp_media_factory_get_latency (factory));
+ break;
case PROP_RECORD:
g_value_set_boolean (value, gst_rtsp_media_factory_is_record (factory));
break;
gst_rtsp_media_factory_set_buffer_size (factory,
g_value_get_uint (value));
break;
+ case PROP_LATENCY:
+ gst_rtsp_media_factory_set_latency (factory, g_value_get_uint (value));
+ break;
case PROP_RECORD:
gst_rtsp_media_factory_set_record (factory, g_value_get_boolean (value));
break;
return res;
}
+/**
+ * gst_rtsp_media_factory_set_latency:
+ * @factory: a #GstRTSPMediaFactory
+ * @latency: latency in milliseconds
+ *
+ * Configure the latency used for receiving media
+ */
+void
+gst_rtsp_media_factory_set_latency (GstRTSPMediaFactory * factory,
+ guint latency)
+{
+ GstRTSPMediaFactoryPrivate *priv;
+
+ g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
+
+ priv = factory->priv;
+
+ GST_DEBUG_OBJECT (factory, "latency %ums", latency);
+
+ GST_RTSP_MEDIA_FACTORY_LOCK (factory);
+ priv->latency = latency;
+ GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
+}
+
+/**
+ * gst_rtsp_media_factory_get_latency:
+ * @factory: a #GstRTSPMediaFactory
+ *
+ * Get the latency that is used for receiving media
+ *
+ * Returns: latency in milliseconds
+ */
+guint
+gst_rtsp_media_factory_get_latency (GstRTSPMediaFactory * factory)
+{
+ GstRTSPMediaFactoryPrivate *priv;
+ guint res;
+
+ g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), 0);
+
+ priv = factory->priv;
+
+ GST_RTSP_MEDIA_FACTORY_LOCK (factory);
+ res = priv->latency;
+ GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
+
+ return res;
+}
+
static gboolean
compare_media (gpointer key, GstRTSPMedia * media1, GstRTSPMedia * media2)
{
GstRTSPAddressPool *pool;
GstRTSPPermissions *perms;
GstClockTime rtx_time;
+ guint latency;
gboolean record;
/* configure the sharedness */
profiles = priv->profiles;
protocols = priv->protocols;
rtx_time = priv->rtx_time;
+ latency = priv->latency;
record = priv->record;
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
gst_rtsp_media_set_profiles (media, profiles);
gst_rtsp_media_set_protocols (media, protocols);
gst_rtsp_media_set_retransmission_time (media, rtx_time);
+ gst_rtsp_media_set_latency (media, latency);
gst_rtsp_media_set_record (media, record);
if ((pool = gst_rtsp_media_factory_get_address_pool (factory))) {
GstClockTime time);
GstClockTime gst_rtsp_media_factory_get_retransmission_time (GstRTSPMediaFactory * factory);
+void gst_rtsp_media_factory_set_latency (GstRTSPMediaFactory * factory,
+ guint latency);
+guint gst_rtsp_media_factory_get_latency (GstRTSPMediaFactory * factory);
+
void gst_rtsp_media_factory_set_record (GstRTSPMediaFactory *factory,
gboolean record);
gboolean gst_rtsp_media_factory_is_record (GstRTSPMediaFactory *factory);
GList *payloads; /* protected by lock */
GstClockTime rtx_time; /* protected by lock */
+ guint latency; /* protected by lock */
};
#define DEFAULT_SHARED FALSE
#define DEFAULT_EOS_SHUTDOWN FALSE
#define DEFAULT_BUFFER_SIZE 0x80000
#define DEFAULT_TIME_PROVIDER FALSE
+#define DEFAULT_LATENCY 200
#define DEFAULT_RECORD FALSE
/* define to dump received RTCP packets */
PROP_BUFFER_SIZE,
PROP_ELEMENT,
PROP_TIME_PROVIDER,
+ PROP_LATENCY,
PROP_RECORD,
PROP_LAST
};
"Use a NetTimeProvider for clients",
DEFAULT_TIME_PROVIDER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_LATENCY,
+ g_param_spec_uint ("latency", "Latency",
+ "Latency used for receiving media in milliseconds", 0, G_MAXUINT,
+ DEFAULT_BUFFER_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
g_object_class_install_property (gobject_class, PROP_RECORD,
g_param_spec_boolean ("record", "Record",
"If this media pipeline can be used for PLAY or RECORD",
case PROP_TIME_PROVIDER:
g_value_set_boolean (value, gst_rtsp_media_is_time_provider (media));
break;
+ case PROP_LATENCY:
+ g_value_set_uint (value, gst_rtsp_media_get_latency (media));
+ break;
case PROP_RECORD:
g_value_set_boolean (value, gst_rtsp_media_is_record (media));
break;
case PROP_TIME_PROVIDER:
gst_rtsp_media_use_time_provider (media, g_value_get_boolean (value));
break;
+ case PROP_LATENCY:
+ gst_rtsp_media_set_latency (media, g_value_get_uint (value));
+ break;
case PROP_RECORD:
gst_rtsp_media_set_record (media, g_value_get_boolean (value));
break;
}
/**
+ * gst_rtsp_media_set_latncy:
+ * @media: a #GstRTSPMedia
+ * @latency: latency in milliseconds
+ *
+ * Configure the latency used for receiving media.
+ */
+void
+gst_rtsp_media_set_latency (GstRTSPMedia * media, guint latency)
+{
+ GstRTSPMediaPrivate *priv;
+
+ g_return_if_fail (GST_IS_RTSP_MEDIA (media));
+
+ GST_LOG_OBJECT (media, "set latency %ums", latency);
+
+ priv = media->priv;
+
+ g_mutex_lock (&priv->lock);
+ priv->latency = latency;
+ if (priv->rtpbin)
+ g_object_set (priv->rtpbin, "latency", latency, NULL);
+ g_mutex_unlock (&priv->lock);
+}
+
+/**
+ * gst_rtsp_media_get_latency:
+ * @media: a #GstRTSPMedia
+ *
+ * Get the latency that is used for receiving media.
+ *
+ * Returns: latency in milliseconds
+ */
+guint
+gst_rtsp_media_get_latency (GstRTSPMedia * media)
+{
+ GstRTSPMediaPrivate *priv;
+ guint res;
+
+ g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), FALSE);
+
+ priv = media->priv;
+
+ g_mutex_unlock (&priv->lock);
+ res = priv->latency;
+ g_mutex_unlock (&priv->lock);
+
+ return res;
+}
+
+/**
* gst_rtsp_media_use_time_provider:
* @media: a #GstRTSPMedia
* @time_provider: if a #GstNetTimeProvider should be used
if (priv->rtpbin != NULL) {
gboolean success = TRUE;
+ g_object_set (priv->rtpbin, "latency", priv->latency, NULL);
+
if (klass->setup_rtpbin)
success = klass->setup_rtpbin (media, priv->rtpbin);
void gst_rtsp_media_set_retransmission_time (GstRTSPMedia *media, GstClockTime time);
GstClockTime gst_rtsp_media_get_retransmission_time (GstRTSPMedia *media);
+void gst_rtsp_media_set_latency (GstRTSPMedia *media, guint latency);
+guint gst_rtsp_media_get_latency (GstRTSPMedia *media);
+
void gst_rtsp_media_use_time_provider (GstRTSPMedia *media, gboolean time_provider);
gboolean gst_rtsp_media_is_time_provider (GstRTSPMedia *media);
GstNetTimeProvider * gst_rtsp_media_get_time_provider (GstRTSPMedia *media,