static GMutex tunnels_lock;
static GHashTable *tunnels;
+#define DEFAULT_SESSION_POOL NULL
+#define DEFAULT_MEDIA_MAPPING NULL
+#define DEFAULT_USE_CLIENT_SETTINGS FALSE
+
enum
{
PROP_0,
PROP_SESSION_POOL,
PROP_MEDIA_MAPPING,
+ PROP_USE_CLIENT_SETTINGS,
PROP_LAST
};
GST_TYPE_RTSP_MEDIA_MAPPING,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ 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 and destination in multicast",
+ DEFAULT_USE_CLIENT_SETTINGS,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
gst_rtsp_client_signals[SIGNAL_CLOSED] =
g_signal_new ("closed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstRTSPClientClass, closed), NULL, NULL,
static void
gst_rtsp_client_init (GstRTSPClient * client)
{
+ client->use_client_settings = DEFAULT_USE_CLIENT_SETTINGS;
}
static void
case PROP_MEDIA_MAPPING:
g_value_take_object (value, gst_rtsp_client_get_media_mapping (client));
break;
+ case PROP_USE_CLIENT_SETTINGS:
+ g_value_set_boolean (value,
+ gst_rtsp_client_get_use_client_settings (client));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
}
case PROP_MEDIA_MAPPING:
gst_rtsp_client_set_media_mapping (client, g_value_get_object (value));
break;
+ case PROP_USE_CLIENT_SETTINGS:
+ gst_rtsp_client_set_use_client_settings (client,
+ g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
}
goto invalid_blocksize;
/* we have a valid transport now, set the destination of the client. */
- g_free (ct->destination);
if (ct->lower_transport == GST_RTSP_LOWER_TRANS_UDP_MCAST) {
- ct->destination = gst_rtsp_media_get_multicast_group (media->media);
+ if (ct->destination == NULL || !client->use_client_settings) {
+ g_free (ct->destination);
+ ct->destination = gst_rtsp_media_get_multicast_group (media->media);
+ }
+ /* reset ttl if client settings are not allowed */
+ if (!client->use_client_settings) {
+ ct->ttl = 0;
+ }
} else {
GstRTSPUrl *url;
url = gst_rtsp_connection_get_url (client->connection);
+ g_free (ct->destination);
ct->destination = g_strdup (url->host);
if (ct->lower_transport & GST_RTSP_LOWER_TRANS_TCP) {
}
/**
+ * gst_rtsp_client_set_use_client_settings:
+ * @client: a #GstRTSPClient
+ * @use_client_settings: whether to use client settings for multicast
+ *
+ * Use client transport settings (destination and ttl) for multicast.
+ * When @use_client_settings is %FALSE, the server settings will be
+ * used.
+ */
+void
+gst_rtsp_client_set_use_client_settings (GstRTSPClient * client,
+ gboolean use_client_settings)
+{
+ client->use_client_settings = use_client_settings;
+}
+
+/**
+ * gst_rtsp_client_get_use_client_settings:
+ * @client: a #GstRTSPClient
+ *
+ * Check if client transport settings (destination and ttl) for multicast
+ * will be used.
+ */
+gboolean
+gst_rtsp_client_get_use_client_settings (GstRTSPClient * client)
+{
+ return client->use_client_settings;
+}
+
+/**
* gst_rtsp_client_set_auth:
* @client: a #GstRTSPClient
* @auth: a #GstRTSPAuth
* @watch: watch for the connection
* @watchid: id of the watch
* @ip: ip address used by the client to connect to us
+ * @use_client_settings: whether to allow client transport settings for multicast
* @session_pool: handle to the session pool used by the client.
* @media_mapping: handle to the media mapping used by the client.
* @uri: cached uri
guint watchid;
gchar *server_ip;
gboolean is_ipv6;
+ gboolean use_client_settings;
GstRTSPServer *server;
GstRTSPSessionPool *session_pool;
GstRTSPMediaMapping *mapping);
GstRTSPMediaMapping * gst_rtsp_client_get_media_mapping (GstRTSPClient *client);
+void gst_rtsp_client_set_use_client_settings (GstRTSPClient * client,
+ gboolean use_client_settings);
+gboolean gst_rtsp_client_get_use_client_settings (GstRTSPClient * client);
+
void gst_rtsp_client_set_auth (GstRTSPClient *client, GstRTSPAuth *auth);
GstRTSPAuth * gst_rtsp_client_get_auth (GstRTSPClient *client);
g_signal_emit_by_name (stream->udpsink[1], "remove", dest, max, NULL);
}
+static void
+set_multicast_ttl (GstRTSPMedia * media, GstRTSPMediaStream * stream, guint ttl)
+{
+ GST_INFO ("setting ttl-mc %d", ttl);
+ g_object_set (G_OBJECT (stream->udpsink[0]), "ttl-mc", ttl, NULL);
+ g_object_set (G_OBJECT (stream->udpsink[1]), "ttl-mc", ttl, NULL);
+}
+
/**
* gst_rtsp_media_set_state:
* @media: a #GstRTSPMedia
{
gchar *dest;
gint min, max;
+ guint ttl = 0;
dest = trans->destination;
if (trans->lower_transport == GST_RTSP_LOWER_TRANS_UDP_MCAST) {
min = trans->port.min;
max = trans->port.max;
+ ttl = trans->ttl;
} else {
min = trans->client_port.min;
max = trans->client_port.max;
if (add && !tr->active) {
add_udp_destination (media, stream, dest, min, max);
+ if (ttl > 0) {
+ set_multicast_ttl (media, stream, ttl);
+ }
stream->transports = g_list_prepend (stream->transports, tr);
tr->active = TRUE;
media->active++;