summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2011-08-16 13:13:36 +0200
committerWim Taymans <wim.taymans@collabora.co.uk>2011-08-16 14:49:59 +0200
commit514728864a34459b52a48e8bd805cde0dc2a3685 (patch)
tree8f23fed4d29fd97a99c131b91aba26884f3df488
parentb881dc66690f81b5928f859e43c202440b85ab97 (diff)
media-factory: add property for multicast group
Add a property to configure the multicast group in the media factory. Based on patches from Marc Leeman and Robert Krakora.
-rw-r--r--gst/rtsp-server/rtsp-media-factory.c66
-rw-r--r--gst/rtsp-server/rtsp-media-factory.h3
2 files changed, 65 insertions, 4 deletions
diff --git a/gst/rtsp-server/rtsp-media-factory.c b/gst/rtsp-server/rtsp-media-factory.c
index 1d86c70..3dd6559 100644
--- a/gst/rtsp-server/rtsp-media-factory.c
+++ b/gst/rtsp-server/rtsp-media-factory.c
@@ -19,10 +19,11 @@
#include "rtsp-media-factory.h"
-#define DEFAULT_LAUNCH NULL
-#define DEFAULT_SHARED FALSE
-#define DEFAULT_EOS_SHUTDOWN FALSE
-#define DEFAULT_BUFFER_SIZE 0x80000
+#define DEFAULT_LAUNCH NULL
+#define DEFAULT_SHARED FALSE
+#define DEFAULT_EOS_SHUTDOWN FALSE
+#define DEFAULT_BUFFER_SIZE 0x80000
+#define DEFAULT_MULTICAST_GROUP "224.2.0.1"
enum
{
@@ -31,6 +32,7 @@ enum
PROP_SHARED,
PROP_EOS_SHUTDOWN,
PROP_BUFFER_SIZE,
+ PROP_MULTICAST_GROUP,
PROP_LAST
};
@@ -111,6 +113,11 @@ gst_rtsp_media_factory_class_init (GstRTSPMediaFactoryClass * klass)
"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_MULTICAST_GROUP,
+ g_param_spec_string ("multicast-group", "Multicast Group",
+ "The Multicast group to send media to",
+ DEFAULT_MULTICAST_GROUP, 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,
@@ -134,6 +141,7 @@ gst_rtsp_media_factory_init (GstRTSPMediaFactory * factory)
factory->shared = DEFAULT_SHARED;
factory->eos_shutdown = DEFAULT_EOS_SHUTDOWN;
factory->buffer_size = DEFAULT_BUFFER_SIZE;
+ factory->multicast_group = g_strdup (DEFAULT_MULTICAST_GROUP);
factory->lock = g_mutex_new ();
factory->medias_lock = g_mutex_new ();
@@ -149,6 +157,7 @@ gst_rtsp_media_factory_finalize (GObject * obj)
g_hash_table_unref (factory->medias);
g_mutex_free (factory->medias_lock);
g_free (factory->launch);
+ g_free (factory->multicast_group);
g_mutex_free (factory->lock);
if (factory->auth)
g_object_unref (factory->auth);
@@ -177,6 +186,10 @@ gst_rtsp_media_factory_get_property (GObject * object, guint propid,
g_value_set_uint (value,
gst_rtsp_media_factory_get_buffer_size (factory));
break;
+ case PROP_MULTICAST_GROUP:
+ g_value_take_string (value,
+ gst_rtsp_media_factory_get_multicast_group (factory));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
}
@@ -203,6 +216,10 @@ gst_rtsp_media_factory_set_property (GObject * object, guint propid,
gst_rtsp_media_factory_set_buffer_size (factory,
g_value_get_uint (value));
break;
+ case PROP_MULTICAST_GROUP:
+ gst_rtsp_media_factory_set_multicast_group (factory,
+ g_value_get_string (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
}
@@ -400,6 +417,47 @@ gst_rtsp_media_factory_get_buffer_size (GstRTSPMediaFactory * factory)
}
/**
+ * gst_rtsp_media_factory_set_multicast_group:
+ * @factory: a #GstRTSPMedia
+ * @mc: the new multicast group
+ *
+ * Set the multicast group that media from @factory will be streamed to.
+ */
+void
+gst_rtsp_media_factory_set_multicast_group (GstRTSPMediaFactory * factory,
+ const gchar * mc)
+{
+ g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
+
+ GST_RTSP_MEDIA_FACTORY_LOCK (factory);
+ g_free (factory->multicast_group);
+ factory->multicast_group = g_strdup (mc);
+ GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
+}
+
+/**
+ * gst_rtsp_media_factory_get_multicast_group:
+ * @factory: a #GstRTSPMedia
+ *
+ * Get the multicast group that media from @factory will be streamed to.
+ *
+ * Returns: the multicast group
+ */
+gchar *
+gst_rtsp_media_factory_get_multicast_group (GstRTSPMediaFactory * factory)
+{
+ gchar *result;
+
+ g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), NULL);
+
+ GST_RTSP_MEDIA_FACTORY_LOCK (factory);
+ result = g_strdup (factory->multicast_group);
+ GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
+
+ return result;
+}
+
+/**
* gst_rtsp_media_factory_set_auth:
* @factory: a #GstRTSPMediaFactory
* @auth: a #GstRTSPAuth
diff --git a/gst/rtsp-server/rtsp-media-factory.h b/gst/rtsp-server/rtsp-media-factory.h
index 1c7bab9..d2b8ee9 100644
--- a/gst/rtsp-server/rtsp-media-factory.h
+++ b/gst/rtsp-server/rtsp-media-factory.h
@@ -65,6 +65,7 @@ struct _GstRTSPMediaFactory {
gboolean eos_shutdown;
GstRTSPAuth *auth;
guint buffer_size;
+ gchar *multicast_group;
GMutex *medias_lock;
GHashTable *medias;
@@ -128,6 +129,8 @@ GstRTSPAuth * gst_rtsp_media_factory_get_auth (GstRTSPMediaFactory *
void gst_rtsp_media_factory_set_buffer_size (GstRTSPMediaFactory * factory, guint size);
guint gst_rtsp_media_factory_get_buffer_size (GstRTSPMediaFactory * factory);
+void gst_rtsp_media_factory_set_multicast_group (GstRTSPMediaFactory * factory, const gchar *mc);
+gchar * gst_rtsp_media_factory_get_multicast_group (GstRTSPMediaFactory * factory);
/* creating the media from the factory and a url */
GstRTSPMedia * gst_rtsp_media_factory_construct (GstRTSPMediaFactory *factory,