media: add property for multicast group

Add a property to configure the multicast group in the media.

Based on patches from Marc Leeman and Robert Krakora.
This commit is contained in:
Wim Taymans 2011-08-16 13:25:16 +02:00
parent 514728864a
commit c079325169
2 changed files with 65 additions and 5 deletions

View file

@ -26,12 +26,13 @@
#include "rtsp-funnel.h"
#include "rtsp-media.h"
#define DEFAULT_SHARED FALSE
#define DEFAULT_REUSABLE FALSE
#define DEFAULT_PROTOCOLS GST_RTSP_LOWER_TRANS_UDP | GST_RTSP_LOWER_TRANS_TCP
#define DEFAULT_SHARED FALSE
#define DEFAULT_REUSABLE FALSE
#define DEFAULT_PROTOCOLS GST_RTSP_LOWER_TRANS_UDP | GST_RTSP_LOWER_TRANS_TCP
//#define DEFAULT_PROTOCOLS GST_RTSP_LOWER_TRANS_UDP_MCAST
#define DEFAULT_EOS_SHUTDOWN FALSE
#define DEFAULT_BUFFER_SIZE 0x80000
#define DEFAULT_EOS_SHUTDOWN FALSE
#define DEFAULT_BUFFER_SIZE 0x80000
#define DEFAULT_MULTICAST_GROUP "224.2.0.1"
/* define to dump received RTCP packets */
#undef DUMP_STATS
@ -44,6 +45,7 @@ enum
PROP_PROTOCOLS,
PROP_EOS_SHUTDOWN,
PROP_BUFFER_SIZE,
PROP_MULTICAST_GROUP,
PROP_LAST
};
@ -113,6 +115,11 @@ gst_rtsp_media_class_init (GstRTSPMediaClass * 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_signals[SIGNAL_PREPARED] =
g_signal_new ("prepared", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstRTSPMediaClass, prepared), NULL, NULL,
@ -158,6 +165,7 @@ gst_rtsp_media_init (GstRTSPMedia * media)
media->protocols = DEFAULT_PROTOCOLS;
media->eos_shutdown = DEFAULT_EOS_SHUTDOWN;
media->buffer_size = DEFAULT_BUFFER_SIZE;
media->multicast_group = g_strdup (DEFAULT_MULTICAST_GROUP);
}
void
@ -230,6 +238,7 @@ gst_rtsp_media_finalize (GObject * obj)
g_source_destroy (media->source);
g_source_unref (media->source);
}
g_free (media->multicast_group);
g_mutex_free (media->lock);
g_cond_free (media->cond);
@ -258,6 +267,9 @@ gst_rtsp_media_get_property (GObject * object, guint propid,
case PROP_BUFFER_SIZE:
g_value_set_uint (value, gst_rtsp_media_get_buffer_size (media));
break;
case PROP_MULTICAST_GROUP:
g_value_take_string (value, gst_rtsp_media_get_multicast_group (media));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
}
@ -285,6 +297,9 @@ gst_rtsp_media_set_property (GObject * object, guint propid,
case PROP_BUFFER_SIZE:
gst_rtsp_media_set_buffer_size (media, g_value_get_uint (value));
break;
case PROP_MULTICAST_GROUP:
gst_rtsp_media_set_multicast_group (media, g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
}
@ -528,6 +543,46 @@ gst_rtsp_media_get_buffer_size (GstRTSPMedia * media)
return media->buffer_size;
}
/**
* gst_rtsp_media_set_multicast_group:
* @media: a #GstRTSPMedia
* @mc: the new multicast group
*
* Set the multicast group that media from @media will be streamed to.
*/
void
gst_rtsp_media_set_multicast_group (GstRTSPMedia * media, const gchar * mc)
{
g_return_if_fail (GST_IS_RTSP_MEDIA (media));
g_mutex_lock (media->lock);
g_free (media->multicast_group);
media->multicast_group = g_strdup (mc);
g_mutex_unlock (media->lock);
}
/**
* gst_rtsp_media_get_multicast_group:
* @media: a #GstRTSPMedia
*
* Get the multicast group that media from @media will be streamed to.
*
* Returns: the multicast group
*/
gchar *
gst_rtsp_media_get_multicast_group (GstRTSPMedia * media)
{
gchar *result;
g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), NULL);
g_mutex_lock (media->lock);
result = g_strdup (media->multicast_group);
g_mutex_unlock (media->lock);
return result;
}
/**
* gst_rtsp_media_set_auth:
* @media: a #GstRTSPMedia

View file

@ -203,6 +203,7 @@ struct _GstRTSPMedia {
gboolean eos_shutdown;
guint buffer_size;
GstRTSPAuth *auth;
gchar *multicast_group;
GstElement *element;
GArray *streams;
@ -282,6 +283,10 @@ GstRTSPAuth * gst_rtsp_media_get_auth (GstRTSPMedia *media);
void gst_rtsp_media_set_buffer_size (GstRTSPMedia *media, guint size);
guint gst_rtsp_media_get_buffer_size (GstRTSPMedia *media);
void gst_rtsp_media_set_multicast_group (GstRTSPMedia *media, const gchar * mc);
gchar * gst_rtsp_media_get_multicast_group (GstRTSPMedia *media);
/* prepare the media for playback */
gboolean gst_rtsp_media_prepare (GstRTSPMedia *media);
gboolean gst_rtsp_media_is_prepared (GstRTSPMedia *media);