From c5b3066c3389105099646042f598eda1ddb2969c Mon Sep 17 00:00:00 2001 From: Ognyan Tonchev Date: Mon, 3 Jun 2013 12:04:44 +0200 Subject: [PATCH] rtsp-server: Expose the use_client_settings API Fixes https://bugzilla.gnome.org/show_bug.cgi?id=699935 --- gst/rtsp-server/rtsp-server.c | 74 +++++++++++++++++++++++++++++++++++ gst/rtsp-server/rtsp-server.h | 4 ++ 2 files changed, 78 insertions(+) diff --git a/gst/rtsp-server/rtsp-server.c b/gst/rtsp-server/rtsp-server.c index 8e3acb3d0b..f056d7d756 100644 --- a/gst/rtsp-server/rtsp-server.c +++ b/gst/rtsp-server/rtsp-server.c @@ -39,6 +39,7 @@ struct _GstRTSPServerPrivate gchar *service; gint backlog; gint max_threads; + gboolean use_client_settings; GSocket *socket; @@ -65,6 +66,7 @@ struct _GstRTSPServerPrivate #define DEFAULT_SERVICE "8554" #define DEFAULT_BACKLOG 5 #define DEFAULT_MAX_THREADS 0 +#define DEFAULT_USE_CLIENT_SETTINGS FALSE /* Define to use the SO_LINGER option so that the server sockets can be resused * sooner. Disabled for now because it is not very well implemented by various @@ -82,6 +84,7 @@ enum PROP_SESSION_POOL, PROP_MOUNT_POINTS, PROP_MAX_THREADS, + PROP_USE_CLIENT_SETTINGS, PROP_LAST }; @@ -206,6 +209,17 @@ gst_rtsp_server_class_init (GstRTSPServerClass * klass) "The maximum amount of threads to use for client connections " "(0 = only mainloop, -1 = unlimited)", -1, G_MAXINT, DEFAULT_MAX_THREADS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + * GstRTSPServer::use-client-settings: + * + * Use client transport settings (destination, port pair and ttl for + * multicast. FALSE means that the server settings will be used. + */ + g_object_class_install_property (gobject_class, PROP_USE_CLIENT_SETTINGS, + g_param_spec_boolean ("use-client-settings", "Use Client Settings", + "Use client settings for ttl, destination and port pair in multicast", + DEFAULT_USE_CLIENT_SETTINGS, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); gst_rtsp_server_signals[SIGNAL_CLIENT_CONNECTED] = g_signal_new ("client-connected", G_TYPE_FROM_CLASS (gobject_class), @@ -236,6 +250,7 @@ gst_rtsp_server_init (GstRTSPServer * server) priv->session_pool = gst_rtsp_session_pool_new (); priv->mount_points = gst_rtsp_mount_points_new (); priv->max_threads = DEFAULT_MAX_THREADS; + priv->use_client_settings = DEFAULT_USE_CLIENT_SETTINGS; g_queue_init (&priv->loops); } @@ -687,6 +702,55 @@ gst_rtsp_server_get_max_threads (GstRTSPServer * server) return res; } +/** + * gst_rtsp_server_set_use_client_settings: + * @server: a #GstRTSPServer + * @use_client_settings: whether to use client settings for multicast + * + * Use client transport settings (destination, port pair and ttl) for + * multicast. + * When @use_client_settings is %FALSE, the server settings will be + * used. + */ +void +gst_rtsp_server_set_use_client_settings (GstRTSPServer * server, + gboolean use_client_settings) +{ + GstRTSPServerPrivate *priv; + + g_return_if_fail (GST_IS_RTSP_SERVER (server)); + + priv = server->priv; + + GST_RTSP_SERVER_LOCK (server); + priv->use_client_settings = use_client_settings; + GST_RTSP_SERVER_UNLOCK (server); +} + +/** + * gst_rtsp_server_get_use_client_settings: + * @server: a #GstRTSPServer + * + * Check if client transport settings (destination, port pair and ttl) for + * multicast will be used. + */ +gboolean +gst_rtsp_server_get_use_client_settings (GstRTSPServer * server) +{ + GstRTSPServerPrivate *priv; + gboolean res; + + g_return_val_if_fail (GST_IS_RTSP_SERVER (server), FALSE); + + priv = server->priv; + + GST_RTSP_SERVER_LOCK (server); + res = priv->use_client_settings; + GST_RTSP_SERVER_UNLOCK (server); + + return res; +} + /** * gst_rtsp_server_set_tls_certificate: * @server: a #GstRTSPServer @@ -773,6 +837,10 @@ gst_rtsp_server_get_property (GObject * object, guint propid, case PROP_MAX_THREADS: g_value_set_int (value, gst_rtsp_server_get_max_threads (server)); break; + case PROP_USE_CLIENT_SETTINGS: + g_value_set_boolean (value, + gst_rtsp_server_get_use_client_settings (server)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec); } @@ -803,6 +871,10 @@ gst_rtsp_server_set_property (GObject * object, guint propid, case PROP_MAX_THREADS: gst_rtsp_server_set_max_threads (server, g_value_get_int (value)); break; + case PROP_USE_CLIENT_SETTINGS: + gst_rtsp_server_set_use_client_settings (server, + g_value_get_boolean (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec); } @@ -1148,6 +1220,8 @@ default_create_client (GstRTSPServer * server) gst_rtsp_client_set_mount_points (client, priv->mount_points); /* set authentication manager */ gst_rtsp_client_set_auth (client, priv->auth); + /* check if client transport settings for multicast are allowed */ + gst_rtsp_client_set_use_client_settings (client, priv->use_client_settings); GST_RTSP_SERVER_UNLOCK (server); return client; diff --git a/gst/rtsp-server/rtsp-server.h b/gst/rtsp-server/rtsp-server.h index 3d24e0b6d9..a71c27f47f 100644 --- a/gst/rtsp-server/rtsp-server.h +++ b/gst/rtsp-server/rtsp-server.h @@ -103,6 +103,10 @@ GstRTSPAuth * gst_rtsp_server_get_auth (GstRTSPServer *serve void gst_rtsp_server_set_max_threads (GstRTSPServer *server, gint max_threads); gint gst_rtsp_server_get_max_threads (GstRTSPServer *server); +void gst_rtsp_server_set_use_client_settings (GstRTSPServer *server, + gboolean use_client_settings); +gboolean gst_rtsp_server_get_use_client_settings (GstRTSPServer *server); + void gst_rtsp_server_set_tls_certificate (GstRTSPServer *server, GTlsCertificate *cert); GTlsCertificate * gst_rtsp_server_get_tls_certificate (GstRTSPServer *server);