summaryrefslogtreecommitdiffstats
path: root/gst/udp/gstudpsink.c
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2007-04-29 14:43:37 +0000
committerWim Taymans <wim.taymans@gmail.com>2007-04-29 14:43:37 +0000
commit066598d8de5530a153adde3e457deb1734df5ea8 (patch)
tree283fa5e9db302e729aec3de776d9755c58ee6ce7 /gst/udp/gstudpsink.c
parent96b4ce16929b6e937cc353930a221c3459c99464 (diff)
gst/udp/gstmultiudpsink.c: Add code to drop membership of a multicast group.
Original commit message from CVS: * gst/udp/gstmultiudpsink.c: (leave_multicast), (gst_multiudpsink_add), (gst_multiudpsink_remove): Add code to drop membership of a multicast group. * gst/udp/gstudpsink.c: (gst_udpsink_update_uri), (gst_udpsink_set_uri): Implement URI handler. * gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_stream_configure_transport), (gst_rtspsrc_parse_rtpinfo): Use URI handler to make udpsink instace. Improve code to configure port and destination.
Diffstat (limited to 'gst/udp/gstudpsink.c')
-rw-r--r--gst/udp/gstudpsink.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/gst/udp/gstudpsink.c b/gst/udp/gstudpsink.c
index 583827dd..78386062 100644
--- a/gst/udp/gstudpsink.c
+++ b/gst/udp/gstudpsink.c
@@ -153,10 +153,59 @@ gst_udpsink_finalize (GstUDPSink * udpsink)
G_OBJECT_CLASS (parent_class)->finalize ((GObject *) udpsink);
}
+static void
+gst_udpsink_update_uri (GstUDPSink * sink)
+{
+ g_free (sink->uri);
+ sink->uri = g_strdup_printf ("udp://%s:%d", sink->host, sink->port);
+
+ GST_DEBUG_OBJECT (sink, "updated uri to %s", sink->uri);
+}
+
static gboolean
gst_udpsink_set_uri (GstUDPSink * sink, const gchar * uri)
{
- return FALSE;
+ gchar *protocol;
+ gchar *location;
+ gchar *colptr;
+
+ protocol = gst_uri_get_protocol (uri);
+ if (strcmp (protocol, "udp") != 0)
+ goto wrong_protocol;
+ g_free (protocol);
+
+ location = gst_uri_get_location (uri);
+ if (!location)
+ return FALSE;
+ colptr = strstr (location, ":");
+
+ gst_multiudpsink_remove (GST_MULTIUDPSINK (sink), sink->host, sink->port);
+
+ if (colptr != NULL) {
+ g_free (sink->host);
+ sink->host = g_strndup (location, colptr - location);
+ sink->port = atoi (colptr + 1);
+ } else {
+ g_free (sink->host);
+ sink->host = g_strdup (location);
+ sink->port = UDP_DEFAULT_PORT;
+ }
+ g_free (location);
+
+ gst_multiudpsink_add (GST_MULTIUDPSINK (sink), sink->host, sink->port);
+
+ gst_udpsink_update_uri (sink);
+
+ return TRUE;
+
+ /* ERRORS */
+wrong_protocol:
+ {
+ g_free (protocol);
+ GST_ELEMENT_ERROR (sink, RESOURCE, READ, (NULL),
+ ("error parsing uri %s: wrong protocol (%s != udp)", uri, protocol));
+ return FALSE;
+ }
}
static void
@@ -216,6 +265,7 @@ gst_udpsink_uri_get_type (void)
{
return GST_URI_SINK;
}
+
static gchar **
gst_udpsink_uri_get_protocols (void)
{