GstRTSPTransportMode transport_mode;
gboolean stop_on_disconnect;
gchar *multicast_iface;
+ guint max_mcast_ttl;
GstClockTime rtx_time;
guint latency;
GST_RTSP_LOWER_TRANS_TCP
#define DEFAULT_BUFFER_SIZE 0x80000
#define DEFAULT_LATENCY 200
+#define DEFAULT_MAX_MCAST_TTL 255
#define DEFAULT_TRANSPORT_MODE GST_RTSP_TRANSPORT_MODE_PLAY
#define DEFAULT_STOP_ON_DISCONNECT TRUE
#define DEFAULT_DO_RETRANSMISSION FALSE
PROP_TRANSPORT_MODE,
PROP_STOP_ON_DISCONNECT,
PROP_CLOCK,
+ PROP_MAX_MCAST_TTL,
PROP_LAST
};
"medias of this factory", GST_TYPE_CLOCK,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_MAX_MCAST_TTL,
+ g_param_spec_uint ("max-mcast-ttl", "Maximum multicast ttl",
+ "The maximum time-to-live value of outgoing multicast packets", 1,
+ 255, DEFAULT_MAX_MCAST_TTL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
gst_rtsp_media_factory_signals[SIGNAL_MEDIA_CONSTRUCTED] =
g_signal_new ("media-constructed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRTSPMediaFactoryClass,
priv->stop_on_disconnect = DEFAULT_STOP_ON_DISCONNECT;
priv->publish_clock_mode = GST_RTSP_PUBLISH_CLOCK_MODE_CLOCK;
priv->do_retransmission = DEFAULT_DO_RETRANSMISSION;
+ priv->max_mcast_ttl = DEFAULT_MAX_MCAST_TTL;
g_mutex_init (&priv->lock);
g_mutex_init (&priv->medias_lock);
case PROP_CLOCK:
g_value_take_object (value, gst_rtsp_media_factory_get_clock (factory));
break;
+ case PROP_MAX_MCAST_TTL:
+ g_value_set_uint (value,
+ gst_rtsp_media_factory_get_max_mcast_ttl (factory));
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
}
case PROP_CLOCK:
gst_rtsp_media_factory_set_clock (factory, g_value_get_object (value));
break;
+ case PROP_MAX_MCAST_TTL:
+ gst_rtsp_media_factory_set_max_mcast_ttl (factory,
+ g_value_get_uint (value));
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
}
return ret;
}
+/**
+ * gst_rtsp_media_factory_set_max_mcast_ttl:
+ * @factory: a #GstRTSPMedia
+ * @ttl: the new multicast ttl value
+ *
+ * Set the maximum time-to-live value of outgoing multicast packets.
+ *
+ * Returns: %TRUE if the requested ttl has been set successfully.
+ */
+gboolean
+gst_rtsp_media_factory_set_max_mcast_ttl (GstRTSPMediaFactory * factory,
+ guint ttl)
+{
+ GstRTSPMediaFactoryPrivate *priv;
+
+ g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), FALSE);
+
+ priv = factory->priv;
+
+ GST_RTSP_MEDIA_FACTORY_LOCK (factory);
+ if (ttl == 0 || ttl > DEFAULT_MAX_MCAST_TTL) {
+ GST_WARNING_OBJECT (factory, "The requested mcast TTL value is not valid.");
+ GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
+ return FALSE;
+ }
+ priv->max_mcast_ttl = ttl;
+ GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
+
+ return TRUE;
+}
+
+/**
+ * gst_rtsp_media_factory_get_max_mcast_ttl:
+ * @factory: a #GstRTSPMedia
+ *
+ * Get the the maximum time-to-live value of outgoing multicast packets.
+ *
+ * Returns: the maximum time-to-live value of outgoing multicast packets.
+ */
+guint
+gst_rtsp_media_factory_get_max_mcast_ttl (GstRTSPMediaFactory * factory)
+{
+ GstRTSPMediaFactoryPrivate *priv;
+ guint result;
+
+ g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), 0);
+
+ priv = factory->priv;
+
+ GST_RTSP_MEDIA_FACTORY_LOCK (factory);
+ result = priv->max_mcast_ttl;
+ GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
+
+ return result;
+}
+
static gchar *
default_gen_key (GstRTSPMediaFactory * factory, const GstRTSPUrl * url)
{
GstClock *clock;
gchar *multicast_iface;
GstRTSPPublishClockMode publish_clock_mode;
+ guint ttl;
/* configure the sharedness */
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
stop_on_disconnect = priv->stop_on_disconnect;
clock = priv->clock ? gst_object_ref (priv->clock) : NULL;
publish_clock_mode = priv->publish_clock_mode;
+ ttl = priv->max_mcast_ttl;
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
gst_rtsp_media_set_suspend_mode (media, suspend_mode);
gst_rtsp_media_set_transport_mode (media, transport_mode);
gst_rtsp_media_set_stop_on_disconnect (media, stop_on_disconnect);
gst_rtsp_media_set_publish_clock_mode (media, publish_clock_mode);
+ gst_rtsp_media_set_max_mcast_ttl (media, ttl);
if (clock) {
gst_rtsp_media_set_clock (media, clock);
GST_RTSP_SERVER_API
GstRTSPPublishClockMode gst_rtsp_media_factory_get_publish_clock_mode (GstRTSPMediaFactory * factory);
+GST_RTSP_SERVER_API
+gboolean gst_rtsp_media_factory_set_max_mcast_ttl (GstRTSPMediaFactory * factory,
+ guint ttl);
+
+GST_RTSP_SERVER_API
+guint gst_rtsp_media_factory_get_max_mcast_ttl (GstRTSPMediaFactory * factory);
+
/* creating the media from the factory and a url */
GST_RTSP_SERVER_API
guint buffer_size;
GstRTSPAddressPool *pool;
gchar *multicast_iface;
+ guint max_mcast_ttl;
gboolean blocked;
GstRTSPTransportMode transport_mode;
gboolean stop_on_disconnect;
#define DEFAULT_LATENCY 200
#define DEFAULT_TRANSPORT_MODE GST_RTSP_TRANSPORT_MODE_PLAY
#define DEFAULT_STOP_ON_DISCONNECT TRUE
+#define DEFAULT_MAX_MCAST_TTL 255
#define DEFAULT_DO_RETRANSMISSION FALSE
PROP_TRANSPORT_MODE,
PROP_STOP_ON_DISCONNECT,
PROP_CLOCK,
+ PROP_MAX_MCAST_TTL,
PROP_LAST
};
"Clock to be used by the media pipeline",
GST_TYPE_CLOCK, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_MAX_MCAST_TTL,
+ g_param_spec_uint ("max-mcast-ttl", "Maximum multicast ttl",
+ "The maximum time-to-live value of outgoing multicast packets", 1,
+ 255, DEFAULT_MAX_MCAST_TTL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
gst_rtsp_media_signals[SIGNAL_NEW_STREAM] =
g_signal_new ("new-stream", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstRTSPMediaClass, new_stream), NULL, NULL,
priv->stop_on_disconnect = DEFAULT_STOP_ON_DISCONNECT;
priv->publish_clock_mode = GST_RTSP_PUBLISH_CLOCK_MODE_CLOCK;
priv->do_retransmission = DEFAULT_DO_RETRANSMISSION;
+ priv->max_mcast_ttl = DEFAULT_MAX_MCAST_TTL;
}
static void
case PROP_CLOCK:
g_value_take_object (value, gst_rtsp_media_get_clock (media));
break;
+ case PROP_MAX_MCAST_TTL:
+ g_value_set_uint (value, gst_rtsp_media_get_max_mcast_ttl (media));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
}
case PROP_CLOCK:
gst_rtsp_media_set_clock (media, g_value_get_object (value));
break;
+ case PROP_MAX_MCAST_TTL:
+ gst_rtsp_media_set_max_mcast_ttl (media, g_value_get_uint (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
}
return result;
}
+/**
+ * gst_rtsp_media_set_max_mcast_ttl:
+ * @media: a #GstRTSPMedia
+ * @ttl: the new multicast ttl value
+ *
+ * Set the maximum time-to-live value of outgoing multicast packets.
+ *
+ * Returns: %TRUE if the requested ttl has been set successfully.
+ */
+gboolean
+gst_rtsp_media_set_max_mcast_ttl (GstRTSPMedia * media, guint ttl)
+{
+ GstRTSPMediaPrivate *priv;
+ guint i;
+
+ g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), FALSE);
+
+ GST_LOG_OBJECT (media, "set max mcast ttl %u", ttl);
+
+ priv = media->priv;
+
+ g_mutex_lock (&priv->lock);
+
+ if (ttl == 0 || ttl > DEFAULT_MAX_MCAST_TTL) {
+ GST_WARNING_OBJECT (media, "The reqested mcast TTL value is not valid.");
+ g_mutex_unlock (&priv->lock);
+ return FALSE;
+ }
+ priv->max_mcast_ttl = ttl;
+
+ for (i = 0; i < priv->streams->len; i++) {
+ GstRTSPStream *stream = g_ptr_array_index (priv->streams, i);
+ gst_rtsp_stream_set_max_mcast_ttl (stream, ttl);
+ }
+ g_mutex_unlock (&priv->lock);
+
+ return TRUE;
+}
+
+/**
+ * gst_rtsp_media_get_max_mcast_ttl:
+ * @media: a #GstRTSPMedia
+ *
+ * Get the the maximum time-to-live value of outgoing multicast packets.
+ *
+ * Returns: the maximum time-to-live value of outgoing multicast packets.
+ */
+guint
+gst_rtsp_media_get_max_mcast_ttl (GstRTSPMedia * media)
+{
+ GstRTSPMediaPrivate *priv;
+ guint res;
+
+ g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), FALSE);
+
+ priv = media->priv;
+
+ g_mutex_lock (&priv->lock);
+ res = priv->max_mcast_ttl;
+ g_mutex_unlock (&priv->lock);
+
+ return res;
+}
+
static GList *
_find_payload_types (GstRTSPMedia * media)
{
if (priv->pool)
gst_rtsp_stream_set_address_pool (stream, priv->pool);
gst_rtsp_stream_set_multicast_iface (stream, priv->multicast_iface);
+ gst_rtsp_stream_set_max_mcast_ttl (stream, priv->max_mcast_ttl);
gst_rtsp_stream_set_profiles (stream, priv->profiles);
gst_rtsp_stream_set_protocols (stream, priv->protocols);
gst_rtsp_stream_set_retransmission_time (stream, priv->rtx_time);
GST_RTSP_SERVER_API
GstRTSPPublishClockMode gst_rtsp_media_get_publish_clock_mode (GstRTSPMedia * media);
+GST_RTSP_SERVER_API
+gboolean gst_rtsp_media_set_max_mcast_ttl (GstRTSPMedia *media, guint ttl);
+
+GST_RTSP_SERVER_API
+guint gst_rtsp_media_get_max_mcast_ttl (GstRTSPMedia *media);
+
/* prepare the media for playback */
GST_RTSP_SERVER_API
GstRTSPAddress *mcast_addr_v6;
gchar *multicast_iface;
+ guint max_mcast_ttl;
/* the caps of the stream */
gulong caps_sig;
#define DEFAULT_PROFILES GST_RTSP_PROFILE_AVP
#define DEFAULT_PROTOCOLS GST_RTSP_LOWER_TRANS_UDP | GST_RTSP_LOWER_TRANS_UDP_MCAST | \
GST_RTSP_LOWER_TRANS_TCP
+#define DEFAULT_MAX_MCAST_TTL 255
enum
{
priv->allowed_protocols = DEFAULT_PROTOCOLS;
priv->configured_protocols = 0;
priv->publish_clock_mode = GST_RTSP_PUBLISH_CLOCK_MODE_CLOCK;
+ priv->max_mcast_ttl = DEFAULT_MAX_MCAST_TTL;
g_mutex_init (&priv->lock);
return buffer_size;
}
+/**
+ * gst_rtsp_stream_set_max_mcast_ttl:
+ * @stream: a #GstRTSPStream
+ * @ttl: the new multicast ttl value
+ *
+ * Set the maximum time-to-live value of outgoing multicast packets.
+ *
+ * Returns: %TRUE if the requested ttl has been set successfully.
+ *
+ */
+gboolean
+gst_rtsp_stream_set_max_mcast_ttl (GstRTSPStream * stream, guint ttl)
+{
+ g_return_val_if_fail (GST_IS_RTSP_STREAM (stream), FALSE);
+
+ g_mutex_lock (&stream->priv->lock);
+ if (ttl == 0 || ttl > DEFAULT_MAX_MCAST_TTL) {
+ GST_WARNING_OBJECT (stream, "The reqested mcast TTL value is not valid.");
+ g_mutex_unlock (&stream->priv->lock);
+ return FALSE;
+ }
+ stream->priv->max_mcast_ttl = ttl;
+ g_mutex_unlock (&stream->priv->lock);
+
+ return TRUE;
+}
+
+/**
+ * gst_rtsp_stream_get_max_mcast_ttl:
+ * @stream: a #GstRTSPStream
+ *
+ * Get the the maximum time-to-live value of outgoing multicast packets.
+ *
+ * Returns: the maximum time-to-live value of outgoing multicast packets.
+ *
+ */
+guint
+gst_rtsp_stream_get_max_mcast_ttl (GstRTSPStream * stream)
+{
+ guint ttl;
+
+ g_mutex_lock (&stream->priv->lock);
+ ttl = stream->priv->max_mcast_ttl;
+ g_mutex_unlock (&stream->priv->lock);
+
+ return ttl;
+}
+
/* executed from streaming thread */
static void
caps_notify (GstPad * pad, GParamSpec * unused, GstRTSPStream * stream)
GstRTSPPublishClockMode gst_rtsp_stream_get_publish_clock_mode (GstRTSPStream * stream);
GST_RTSP_SERVER_API
+gboolean gst_rtsp_stream_set_max_mcast_ttl (GstRTSPStream *stream, guint ttl);
+
+GST_RTSP_SERVER_API
+guint gst_rtsp_stream_get_max_mcast_ttl (GstRTSPStream *stream);
+
+GST_RTSP_SERVER_API
gboolean gst_rtsp_stream_complete_stream (GstRTSPStream * stream, const GstRTSPTransport * transport);
GST_RTSP_SERVER_API
GST_END_TEST;
+GST_START_TEST (test_mcast_ttl)
+{
+ GstRTSPMediaFactory *factory;
+ GstElement *element;
+ GstRTSPMedia *media;
+ GstRTSPUrl *url;
+ GstRTSPStream *stream;
+
+ factory = gst_rtsp_media_factory_new ();
+ gst_rtsp_media_factory_set_shared (factory, TRUE);
+ fail_unless (gst_rtsp_url_parse ("rtsp://localhost:8554/test",
+ &url) == GST_RTSP_OK);
+
+ gst_rtsp_media_factory_set_launch (factory,
+ "( videotestsrc ! rtpvrawpay pt=96 name=pay0 "
+ " audiotestsrc ! audioconvert ! rtpL16pay name=pay1 )");
+
+ /* try to set an invalid ttl and make sure that the default ttl value (255) is
+ * set */
+ gst_rtsp_media_factory_set_max_mcast_ttl (factory, 0);
+ fail_unless (gst_rtsp_media_factory_get_max_mcast_ttl (factory) == 255);
+ gst_rtsp_media_factory_set_max_mcast_ttl (factory, 300);
+ fail_unless (gst_rtsp_media_factory_get_max_mcast_ttl (factory) == 255);
+
+ /* set a valid ttl value */
+ gst_rtsp_media_factory_set_max_mcast_ttl (factory, 3);
+ fail_unless (gst_rtsp_media_factory_get_max_mcast_ttl (factory) == 3);
+
+ element = gst_rtsp_media_factory_create_element (factory, url);
+ fail_unless (GST_IS_BIN (element));
+ fail_if (GST_IS_PIPELINE (element));
+ gst_object_unref (element);
+
+ media = gst_rtsp_media_factory_construct (factory, url);
+ fail_unless (GST_IS_RTSP_MEDIA (media));
+
+ fail_unless (gst_rtsp_media_n_streams (media) == 2);
+ fail_unless (gst_rtsp_media_get_max_mcast_ttl (media) == 3);
+
+ /* verify that the correct ttl value has been propageted to the media
+ * streams */
+ stream = gst_rtsp_media_get_stream (media, 0);
+ fail_unless (stream != NULL);
+ fail_unless (gst_rtsp_stream_get_max_mcast_ttl (stream) == 3);
+
+ stream = gst_rtsp_media_get_stream (media, 1);
+ fail_unless (stream != NULL);
+ fail_unless (gst_rtsp_stream_get_max_mcast_ttl (stream) == 3);
+
+ g_object_unref (media);
+
+ gst_rtsp_url_free (url);
+ g_object_unref (factory);
+}
+
+GST_END_TEST;
+
static Suite *
rtspmediafactory_suite (void)
{
tcase_add_test (tc, test_addresspool);
tcase_add_test (tc, test_permissions);
tcase_add_test (tc, test_reset);
+ tcase_add_test (tc, test_mcast_ttl);
return s;
}