summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
Diffstat (limited to 'gst')
-rw-r--r--gst/rtsp/URLS13
-rw-r--r--gst/rtsp/gstrtpdec.c26
-rw-r--r--gst/rtsp/gstrtpdec.h25
-rw-r--r--gst/rtsp/gstrtsp.c24
-rw-r--r--gst/rtsp/gstrtsp.h25
-rw-r--r--gst/rtsp/gstrtspsrc.c166
-rw-r--r--gst/rtsp/gstrtspsrc.h26
-rw-r--r--gst/rtsp/rtsp.h25
-rw-r--r--gst/rtsp/rtspconnection.c284
-rw-r--r--gst/rtsp/rtspconnection.h42
-rw-r--r--gst/rtsp/rtspdefs.c25
-rw-r--r--gst/rtsp/rtspdefs.h44
-rw-r--r--gst/rtsp/rtspmessage.c90
-rw-r--r--gst/rtsp/rtspmessage.h25
-rw-r--r--gst/rtsp/rtsptransport.c26
-rw-r--r--gst/rtsp/rtsptransport.h25
-rw-r--r--gst/rtsp/rtspurl.c55
-rw-r--r--gst/rtsp/rtspurl.h28
-rw-r--r--gst/rtsp/sdp.h25
-rw-r--r--gst/rtsp/sdpmessage.c94
-rw-r--r--gst/rtsp/sdpmessage.h44
-rw-r--r--gst/rtsp/test.c10
22 files changed, 946 insertions, 201 deletions
diff --git a/gst/rtsp/URLS b/gst/rtsp/URLS
new file mode 100644
index 000000000..bb16ce553
--- /dev/null
+++ b/gst/rtsp/URLS
@@ -0,0 +1,13 @@
+Some test URLS:
+
+SVQ3 video:
+ rtsp://cumulus.creative.auckland.ac.nz/~shado/nelson_iv_512k.mov
+
+ASF (audio/video):
+ rtsp://aod.mylisten.com/aod/8/03/069803_0903135.wma
+ rtsp://195.246.8.69/dur_pull_hi
+ rtsp://195.219.160.200/mcp?chid=25&pid=196&vid=2402201&br=800&tid=1&void=2844&muk=H1J4yFr0mJB
+ rtsp://a1174.v26630f.c26630.g.vm.akamaistream.net/7/1174/26630/361/od-video.msn.com/8/mbr/rs_perf_dilana_091206_finale9135.wmv
+
+MP4V-ES/mpeg4-generic(ACC):
+ rtsp://vod.nwec.jp/quicktime/505.mov
diff --git a/gst/rtsp/gstrtpdec.c b/gst/rtsp/gstrtpdec.c
index a8d6ddddd..728a13812 100644
--- a/gst/rtsp/gstrtpdec.c
+++ b/gst/rtsp/gstrtpdec.c
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,6 +16,29 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
/* Element-Checklist-Version: 5 */
/**
@@ -30,7 +53,6 @@
* Last reviewed on 2006-06-20 (0.10.4)
*/
-
#include "gstrtpdec.h"
GST_DEBUG_CATEGORY_STATIC (rtpdec_debug);
diff --git a/gst/rtsp/gstrtpdec.h b/gst/rtsp/gstrtpdec.h
index bd29c8042..3475f4c4c 100644
--- a/gst/rtsp/gstrtpdec.h
+++ b/gst/rtsp/gstrtpdec.h
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,6 +16,29 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
#ifndef __GST_RTPDEC_H__
#define __GST_RTPDEC_H__
diff --git a/gst/rtsp/gstrtsp.c b/gst/rtsp/gstrtsp.c
index 1990622e1..311fe713b 100644
--- a/gst/rtsp/gstrtsp.c
+++ b/gst/rtsp/gstrtsp.c
@@ -1,5 +1,6 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * <2006> Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,6 +17,29 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
#ifdef HAVE_CONFIG_H
#include "config.h"
diff --git a/gst/rtsp/gstrtsp.h b/gst/rtsp/gstrtsp.h
index 1b4f6a699..f29c35994 100644
--- a/gst/rtsp/gstrtsp.h
+++ b/gst/rtsp/gstrtsp.h
@@ -1,5 +1,6 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * <2006> Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,7 +17,29 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
#ifndef __GST_RTSP_H__
#define __GST_RTSP_H__
diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c
index 7a39e0399..11279c38a 100644
--- a/gst/rtsp/gstrtspsrc.c
+++ b/gst/rtsp/gstrtspsrc.c
@@ -1,5 +1,6 @@
/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005,2006> Wim Taymans <wim at fluendo dot com>
+ * <2006> Lutz Mueller <lutz at topfrose dot de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,6 +17,29 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
/**
* SECTION:element-rtspsrc
*
@@ -307,11 +331,17 @@ find_stream_by_pt (GstRTSPStream * stream, gconstpointer a)
}
static GstRTSPStream *
-gst_rtspsrc_create_stream (GstRTSPSrc * src, SDPMedia * media)
+gst_rtspsrc_create_stream (GstRTSPSrc * src, SDPMessage * sdp, gint idx)
{
GstRTSPStream *stream;
gchar *control_url;
gchar *payload;
+ SDPMedia *media;
+
+ /* get media, should not return NULL */
+ media = sdp_message_get_media (sdp, idx);
+ if (media == NULL)
+ return NULL;
stream = g_new0 (GstRTSPStream, 1);
stream->parent = src;
@@ -891,6 +921,7 @@ gst_rtspsrc_loop (GstRTSPSrc * src)
guint size;
GstFlowReturn ret = GST_FLOW_OK;
GstCaps *caps = NULL;
+ GstBuffer *buf;
do {
GST_DEBUG_OBJECT (src, "doing receive");
@@ -922,7 +953,7 @@ gst_rtspsrc_loop (GstRTSPSrc * src)
/* channels are not correct on some servers, do extra check */
if (data[1] >= 200 && data[1] <= 204) {
- /* hmm RTCP message */
+ /* hmm RTCP message switch to the RTCP pad of the same stream. */
outpad = stream->rtpdecrtcp;
}
@@ -931,45 +962,58 @@ gst_rtspsrc_loop (GstRTSPSrc * src)
goto unknown_stream;
/* and chain buffer to internal element */
- {
- GstBuffer *buf;
+ rtsp_message_steal_body (&response, &data, &size);
- rtsp_message_steal_body (&response, &data, &size);
+ /* strip the trailing \0 */
+ size -= 1;
- /* strip the trailing \0 */
- size -= 1;
+ buf = gst_buffer_new ();
+ GST_BUFFER_DATA (buf) = data;
+ GST_BUFFER_MALLOCDATA (buf) = data;
+ GST_BUFFER_SIZE (buf) = size;
- buf = gst_buffer_new_and_alloc (size);
- GST_BUFFER_DATA (buf) = data;
- GST_BUFFER_MALLOCDATA (buf) = data;
- GST_BUFFER_SIZE (buf) = size;
+ /* don't need message anymore */
+ rtsp_message_unset (&response);
- if (caps)
- gst_buffer_set_caps (buf, caps);
+ if (caps)
+ gst_buffer_set_caps (buf, caps);
- GST_DEBUG_OBJECT (src, "pushing data of size %d on channel %d", size,
- channel);
+ GST_DEBUG_OBJECT (src, "pushing data of size %d on channel %d", size,
+ channel);
- /* chain to the peer pad */
- ret = gst_pad_chain (outpad, buf);
+ /* chain to the peer pad */
+ ret = gst_pad_chain (outpad, buf);
+
+ /* combine all stream flows */
+ ret = gst_rtspsrc_combine_flows (src, stream, ret);
+ if (ret != GST_FLOW_OK)
+ goto need_pause;
- /* combine all stream flows */
- ret = gst_rtspsrc_combine_flows (src, stream, ret);
- if (ret != GST_FLOW_OK)
- goto need_pause;
- }
return;
/* ERRORS */
unknown_stream:
{
GST_DEBUG_OBJECT (src, "unknown stream on channel %d, ignored", channel);
+ rtsp_message_unset (&response);
return;
}
receive_error:
{
- GST_ELEMENT_ERROR (src, RESOURCE, READ,
- ("Could not receive message."), (NULL));
+ switch (res) {
+ case RTSP_ESYS:
+ GST_ELEMENT_ERROR (src, RESOURCE, READ,
+ ("Could not receive message. (%d: %s)", res, strerror (errno)),
+ GST_ERROR_SYSTEM);
+ break;
+ default:
+ GST_ELEMENT_ERROR (src, RESOURCE, READ,
+ ("Could not receive message. (%d)", res), (NULL));
+ break;
+ }
+ if (src->debug)
+ rtsp_message_dump (&response);
+ rtsp_message_unset (&response);
ret = GST_FLOW_UNEXPECTED;
goto need_pause;
}
@@ -977,6 +1021,7 @@ invalid_length:
{
GST_ELEMENT_WARNING (src, RESOURCE, READ,
("Short message received."), (NULL));
+ rtsp_message_unset (&response);
return;
}
need_pause:
@@ -1175,10 +1220,15 @@ gst_rtspsrc_open (GstRTSPSrc * src)
if (G_UNLIKELY (src->url == NULL))
goto no_url;
- /* open connection */
- GST_DEBUG_OBJECT (src, "opening connection (%s)...", src->location);
- if ((res = rtsp_connection_open (src->url, &src->connection)) < 0)
- goto could_not_open;
+ /* create connection */
+ GST_DEBUG_OBJECT (src, "creating connection (%s)...", src->location);
+ if ((res = rtsp_connection_create (src->url, &src->connection)) < 0)
+ goto could_not_create;
+
+ /* connect */
+ GST_DEBUG_OBJECT (src, "connecting (%s)...", src->location);
+ if ((res = rtsp_connection_connect (src->connection)) < 0)
+ goto could_not_connect;
/* create OPTIONS */
GST_DEBUG_OBJECT (src, "create options...");
@@ -1232,6 +1282,30 @@ gst_rtspsrc_open (GstRTSPSrc * src)
if (src->debug)
sdp_message_dump (&sdp);
+ /* prepare global stream caps properties */
+ if (src->props)
+ gst_structure_remove_all_fields (src->props);
+ else
+ src->props = gst_structure_empty_new ("RTSP Properties");
+
+ /* FIXME, WMServer specific, move to extensions */
+#define HEADER_PREFIX "data:application/vnd.ms.wms-hdr.asfv1;base64,"
+ {
+ gchar *config, *maxps;
+
+ for (i = 0; (config = sdp_message_get_attribute_val_n (&sdp, "pgmpu", i));
+ i++) {
+ if (g_str_has_prefix (config, HEADER_PREFIX)) {
+ config += strlen (HEADER_PREFIX);
+ gst_structure_set (src->props, "config", G_TYPE_STRING, config, NULL);
+ break;
+ }
+ }
+ maxps = sdp_message_get_attribute_val (&sdp, "maxps");
+ if (maxps)
+ gst_structure_set (src->props, "maxps", G_TYPE_STRING, maxps, NULL);
+ }
+
/* we initially allow all configured protocols. based on the replies from the
* server we narrow them down. */
protocols = src->protocols;
@@ -1239,13 +1313,28 @@ gst_rtspsrc_open (GstRTSPSrc * src)
/* setup streams */
n_streams = sdp_message_medias_len (&sdp);
for (i = 0; i < n_streams; i++) {
- SDPMedia *media;
gchar *transports;
- media = sdp_message_get_media (&sdp, i);
+ /* create stream from the media, can never return NULL */
+ stream = gst_rtspsrc_create_stream (src, &sdp, i);
- /* create stream from the media */
- stream = gst_rtspsrc_create_stream (src, media);
+ /* merge global caps */
+ if (stream->caps) {
+ guint j, num;
+ GstStructure *s;
+
+ s = gst_caps_get_structure (stream->caps, 0);
+
+ num = gst_structure_n_fields (src->props);
+ for (j = 0; j < num; j++) {
+ const gchar *name;
+ const GValue *val;
+
+ name = gst_structure_nth_field_name (src->props, j);
+ val = gst_structure_get_value (src->props, name);
+ gst_structure_set_value (s, name, val);
+ }
+ }
/* skip setup if we have no URL for it */
if (stream->setup_url == NULL)
@@ -1358,6 +1447,7 @@ gst_rtspsrc_open (GstRTSPSrc * src)
rtsp_transport_init (&transport);
}
}
+
/* if we got here all was configured. We have dynamic pads so we notify that
* we are done */
gst_element_no_more_pads (GST_ELEMENT_CAST (src));
@@ -1375,10 +1465,16 @@ no_url:
("No valid RTSP url was provided"), (NULL));
goto cleanup_error;
}
-could_not_open:
+could_not_create:
+ {
+ GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ_WRITE,
+ ("Could not create connection."), (NULL));
+ goto cleanup_error;
+ }
+could_not_connect:
{
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ_WRITE,
- ("Could not open connection."), (NULL));
+ ("Could not connect to server."), (NULL));
goto cleanup_error;
}
create_request_failed:
diff --git a/gst/rtsp/gstrtspsrc.h b/gst/rtsp/gstrtspsrc.h
index ab85dbfc2..53504cff0 100644
--- a/gst/rtsp/gstrtspsrc.h
+++ b/gst/rtsp/gstrtspsrc.h
@@ -1,5 +1,6 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * <2006> Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,7 +17,29 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
#ifndef __GST_RTSPSRC_H__
#define __GST_RTSPSRC_H__
@@ -105,6 +128,7 @@ struct _GstRTSPSrc {
gint numstreams;
GList *streams;
+ GstStructure *props;
gchar *location;
RTSPUrl *url;
diff --git a/gst/rtsp/rtsp.h b/gst/rtsp/rtsp.h
index 0141c8a0c..bb01be51f 100644
--- a/gst/rtsp/rtsp.h
+++ b/gst/rtsp/rtsp.h
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,6 +16,29 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
#ifndef __RTSP_H__
#define __RTSP_H__
diff --git a/gst/rtsp/rtspconnection.c b/gst/rtsp/rtspconnection.c
index 5d1ab22cf..41a374fe8 100644
--- a/gst/rtsp/rtspconnection.c
+++ b/gst/rtsp/rtspconnection.c
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,12 +16,37 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
/* we include this here to get the G_OS_* defines */
#include <glib.h>
@@ -35,9 +60,27 @@
#include <arpa/inet.h>
#endif
-
#include "rtspconnection.h"
+/* the select call is also performed on the control sockets, that way
+ * we can send special commands to unlock or restart the select call */
+#define CONTROL_RESTART 'R' /* restart the select call */
+#define CONTROL_STOP 'S' /* stop the select call */
+#define CONTROL_SOCKETS(conn) conn->control_sock
+#define WRITE_SOCKET(conn) conn->control_sock[1]
+#define READ_SOCKET(conn) conn->control_sock[0]
+
+#define SEND_COMMAND(conn, command) \
+G_STMT_START { \
+ unsigned char c; c = command; \
+ write (WRITE_SOCKET(conn), &c, 1); \
+} G_STMT_END
+
+#define READ_COMMAND(conn, command, res) \
+G_STMT_START { \
+ res = read(READ_SOCKET(conn), &command, 1); \
+} G_STMT_END
+
#ifdef G_OS_WIN32
#define CLOSE_SOCKET(sock) closesocket(sock);
#else
@@ -61,7 +104,52 @@ inet_aton (const char *c, struct in_addr *paddr)
#endif
RTSPResult
-rtsp_connection_open (RTSPUrl * url, RTSPConnection ** conn)
+rtsp_connection_create (RTSPUrl * url, RTSPConnection ** conn)
+{
+ gint ret;
+ RTSPConnection *newconn;
+
+ g_return_val_if_fail (url != NULL, RTSP_EINVAL);
+ g_return_val_if_fail (conn != NULL, RTSP_EINVAL);
+
+ if (url->protocol != RTSP_PROTO_TCP)
+ return RTSP_ENOTIMPL;
+
+ newconn = g_new (RTSPConnection, 1);
+
+#ifdef G_OS_WIN32
+ /* This should work on UNIX too. PF_UNIX sockets replaced with pipe */
+ /* pipe( CONTROL_SOCKETS(newconn) ) */
+ if ((ret = pipe (CONTROL_SOCKETS (newconn))) < 0)
+ goto no_socket_pair;
+#else
+ if ((ret =
+ socketpair (PF_UNIX, SOCK_STREAM, 0, CONTROL_SOCKETS (newconn))) < 0)
+ goto no_socket_pair;
+
+ fcntl (READ_SOCKET (newconn), F_SETFL, O_NONBLOCK);
+ fcntl (WRITE_SOCKET (newconn), F_SETFL, O_NONBLOCK);
+#endif
+
+ newconn->url = url;
+ newconn->cseq = 0;
+ newconn->session_id[0] = 0;
+ newconn->state = RTSP_STATE_INIT;
+
+ *conn = newconn;
+
+ return RTSP_OK;
+
+ /* ERRORS */
+no_socket_pair:
+ {
+ g_free (newconn);
+ return RTSP_ESYS;
+ }
+}
+
+RTSPResult
+rtsp_connection_connect (RTSPConnection * conn)
{
gint fd;
struct sockaddr_in sin;
@@ -70,12 +158,12 @@ rtsp_connection_open (RTSPUrl * url, RTSPConnection ** conn)
gchar *ip;
struct in_addr addr;
gint ret;
+ guint16 port;
+ RTSPUrl *url;
- g_return_val_if_fail (url != NULL, RTSP_EINVAL);
g_return_val_if_fail (conn != NULL, RTSP_EINVAL);
- if (url->protocol != RTSP_PROTO_TCP)
- return RTSP_ENOTIMPL;
+ url = conn->url;
/* first check if it already is an IP address */
if (inet_aton (url->host, &addr)) {
@@ -92,20 +180,25 @@ rtsp_connection_open (RTSPUrl * url, RTSPConnection ** conn)
ip = inet_ntoa (*(struct in_addr *) *addrs);
}
- fd = socket (AF_INET, SOCK_STREAM, 0);
- if (fd == -1)
- goto sys_error;
+ /* get the port from the url */
+ rtsp_url_get_port (url, &port);
memset (&sin, 0, sizeof (sin));
sin.sin_family = AF_INET; /* network socket */
- sin.sin_port = htons (url->port); /* on port */
+ sin.sin_port = htons (port); /* on port */
sin.sin_addr.s_addr = inet_addr (ip); /* on host ip */
+ fd = socket (AF_INET, SOCK_STREAM, 0);
+ if (fd == -1)
+ goto sys_error;
+
ret = connect (fd, (struct sockaddr *) &sin, sizeof (sin));
if (ret != 0)
goto sys_error;
- return rtsp_connection_create (fd, conn);
+ conn->fd = fd;
+
+ return RTSP_OK;
sys_error:
{
@@ -123,27 +216,6 @@ not_ip:
}
}
-RTSPResult
-rtsp_connection_create (gint fd, RTSPConnection ** conn)
-{
- RTSPConnection *newconn;
-
- g_return_val_if_fail (conn != NULL, RTSP_EINVAL);
-
- /* FIXME check fd, must be connected SOCK_STREAM */
-
- newconn = g_new (RTSPConnection, 1);
-
- newconn->fd = fd;
- newconn->cseq = 0;
- newconn->session_id[0] = 0;
- newconn->state = RTSP_STATE_INIT;
-
- *conn = newconn;
-
- return RTSP_OK;
-}
-
static void
append_header (gint key, gchar * value, GString * str)
{
@@ -408,11 +480,99 @@ parse_line (gchar * buffer, RTSPMessage * msg)
return RTSP_OK;
}
+RTSPResult
+rtsp_connection_read (RTSPConnection * conn, gpointer data, guint size)
+{
+ fd_set readfds;
+ guint toread;
+ gint retval;
+ gint avail;
+
+ g_return_val_if_fail (conn != NULL, RTSP_EINVAL);
+ g_return_val_if_fail (data != NULL, RTSP_EINVAL);
+
+ if (size == 0)
+ return RTSP_OK;
+
+ toread = size;
+
+ /* if the call fails, just go in the select.. it should not fail. Else if
+ * there is enough data to read, skip the select call al together.*/
+ if (ioctl (conn->fd, FIONREAD, &avail) < 0)
+ avail = 0;
+ else if (avail >= toread)
+ goto do_read;
+
+ FD_ZERO (&readfds);
+ FD_SET (conn->fd, &readfds);
+ FD_SET (READ_SOCKET (conn), &readfds);
+
+ while (toread > 0) {
+ gint bytes;
+
+ do {
+ retval = select (FD_SETSIZE, &readfds, NULL, NULL, NULL);
+ } while ((retval == -1 && errno == EINTR));
+
+ if (retval == -1)
+ goto select_error;
+
+ if (FD_ISSET (READ_SOCKET (conn), &readfds)) {
+ /* read all stop commands */
+ while (TRUE) {
+ gchar command;
+ int res;
+
+ READ_COMMAND (conn, command, res);
+ if (res < 0) {
+ /* no more commands */
+ break;
+ }
+ }
+ goto stopped;
+ }
+
+ do_read:
+ /* if we get here there is activity on the real fd since the select
+ * completed and the control socket was not readable. */
+ bytes = read (conn->fd, data, toread);
+
+ if (bytes == 0) {
+ goto eof;
+ } else if (bytes < 0) {
+ if (errno != EAGAIN && errno != EINTR)
+ goto read_error;
+ } else {
+ toread -= bytes;
+ data += bytes;
+ }
+ }
+ return RTSP_OK;
+
+ /* ERRORS */
+select_error:
+ {
+ return RTSP_ESYS;
+ }
+stopped:
+ {
+ return RTSP_EINTR;
+ }
+eof:
+ {
+ return RTSP_EEOF;
+ }
+read_error:
+ {
+ return RTSP_ESYS;
+ }
+}
+
static RTSPResult
-read_body (gint fd, glong content_length, RTSPMessage * msg)
+read_body (RTSPConnection * conn, glong content_length, RTSPMessage * msg)
{
- gchar *body, *bodyptr;
- gint to_read, r;
+ gchar *body;
+ RTSPResult res;
if (content_length <= 0) {
body = NULL;
@@ -422,29 +582,19 @@ read_body (gint fd, glong content_length, RTSPMessage * msg)
body = g_malloc (content_length + 1);
body[content_length] = '\0';
- bodyptr = body;
- to_read = content_length;
- while (to_read > 0) {
- r = read (fd, bodyptr, to_read);
- if (r < 0) {
- if (errno != EAGAIN && errno != EINTR)
- goto read_error;
- } else {
- to_read -= r;
- bodyptr += r;
- }
- }
- content_length += 1;
+
+ RTSP_CHECK (rtsp_connection_read (conn, body, content_length), read_error);
done:
- rtsp_message_set_body (msg, (guint8 *) body, content_length);
+ rtsp_message_take_body (msg, (guint8 *) body, content_length + 1);
return RTSP_OK;
+ /* ERRORS */
read_error:
{
g_free (body);
- return RTSP_ESYS;
+ return res;
}
}
@@ -469,14 +619,9 @@ rtsp_connection_receive (RTSPConnection * conn, RTSPMessage * msg)
/* parse first line and headers */
while (res == RTSP_OK) {
gchar c;
- gint ret;
/* read first character, this identifies data messages */
- ret = read (conn->fd, &c, 1);
- if (ret < 0)
- goto read_error;
- if (ret < 1)
- break;
+ RTSP_CHECK (rtsp_connection_read (conn, &c, 1), read_error);
/* check for data packet, first character is $ */
if (c == '$') {
@@ -485,26 +630,18 @@ rtsp_connection_receive (RTSPConnection * conn, RTSPMessage * msg)
/* data packets are $<1 byte channel><2 bytes length,BE><data bytes> */
/* read channel, which is the next char */
- ret = read (conn->fd, &c, 1);
- if (ret < 0)
- goto read_error;
- if (ret < 1)
- goto error;
+ RTSP_CHECK (rtsp_connection_read (conn, &c, 1), read_error);
/* now we create a data message */
rtsp_message_init_data (msg, (gint) c);
/* next two bytes are the length of the data */
- ret = read (conn->fd, &size, 2);
- if (ret < 0)
- goto read_error;
- if (ret < 2)
- goto error;
+ RTSP_CHECK (rtsp_connection_read (conn, &size, 2), read_error);
size = GUINT16_FROM_BE (size);
/* and read the body */
- res = read_body (conn->fd, size, msg);
+ res = read_body (conn, size, msg);
need_body = FALSE;
break;
} else {
@@ -520,9 +657,8 @@ rtsp_connection_receive (RTSPConnection * conn, RTSPMessage * msg)
break;
/* read lines */
- res = read_line (conn->fd, buffer + offset, sizeof (buffer) - offset);
- if (res != RTSP_OK)
- goto read_error;
+ RTSP_CHECK (read_line (conn->fd, buffer + offset,
+ sizeof (buffer) - offset), read_error);
if (buffer[0] == '\0')
break;
@@ -549,7 +685,7 @@ rtsp_connection_receive (RTSPConnection * conn, RTSPMessage * msg)
&hdrval) == RTSP_OK) {
/* there is, read the body */
content_length = atol (hdrval);
- res = read_body (conn->fd, content_length, msg);
+ RTSP_CHECK (read_body (conn, content_length, msg), read_error);
}
/* save session id in the connection for further use */
@@ -577,13 +713,9 @@ rtsp_connection_receive (RTSPConnection * conn, RTSPMessage * msg)
}
return res;
-error:
- {
- return RTSP_EPARSE;
- }
read_error:
{
- return RTSP_ESYS;
+ return res;
}
}
diff --git a/gst/rtsp/rtspconnection.h b/gst/rtsp/rtspconnection.h
index 6af3fde90..36532fd0f 100644
--- a/gst/rtsp/rtspconnection.h
+++ b/gst/rtsp/rtspconnection.h
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,6 +16,29 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
#ifndef __RTSP_CONNECTION_H__
#define __RTSP_CONNECTION_H__
@@ -30,17 +53,22 @@ G_BEGIN_DECLS
typedef struct _RTSPConnection
{
- gint fd; /* our socket */
+ /* URL for the connection */
+ RTSPUrl *url;
+
+ /* connection state */
+ gint fd;
+ gint control_sock[2];
+ /* Session state */
+ RTSPState state;
gint cseq; /* sequence number */
gchar session_id[512]; /* session id */
-
- RTSPState state; /* state of the connection */
} RTSPConnection;
/* opening/closing a connection */
-RTSPResult rtsp_connection_open (RTSPUrl *url, RTSPConnection **conn);
-RTSPResult rtsp_connection_create (gint fd, RTSPConnection **conn);
+RTSPResult rtsp_connection_create (RTSPUrl *url, RTSPConnection **conn);
+RTSPResult rtsp_connection_connect (RTSPConnection *conn);
RTSPResult rtsp_connection_close (RTSPConnection *conn);
RTSPResult rtsp_connection_free (RTSPConnection *conn);
@@ -48,6 +76,8 @@ RTSPResult rtsp_connection_free (RTSPConnection *conn);
RTSPResult rtsp_connection_send (RTSPConnection *conn, RTSPMessage *message);
RTSPResult rtsp_connection_receive (RTSPConnection *conn, RTSPMessage *message);
+RTSPResult rtsp_connection_flush (RTSPConnection *conn, gboolean flush);
+
G_END_DECLS
#endif /* __RTSP_CONNECTION_H__ */
diff --git a/gst/rtsp/rtspdefs.c b/gst/rtsp/rtspdefs.c
index ebc848def..414abbe77 100644
--- a/gst/rtsp/rtspdefs.c
+++ b/gst/rtsp/rtspdefs.c
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,6 +16,29 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
#include "rtspdefs.h"
diff --git a/gst/rtsp/rtspdefs.h b/gst/rtsp/rtspdefs.h
index a7e89320a..fb303eaaf 100644
--- a/gst/rtsp/rtspdefs.h
+++ b/gst/rtsp/rtspdefs.h
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,6 +16,29 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
#ifndef __RTSP_DEFS_H__
#define __RTSP_DEFS_H__
@@ -24,17 +47,22 @@
G_BEGIN_DECLS
+#define RTSP_CHECK(stmt, label) \
+if (G_UNLIKELY ((res = (stmt)) != RTSP_OK)) goto label
+
typedef enum {
RTSP_OK = 0,
/* errors */
RTSP_EINVAL = -1,
- RTSP_ENOMEM = -2,
- RTSP_ERESOLV = -3,
- RTSP_ENOTIMPL = -4,
- RTSP_ESYS = -5,
- RTSP_EPARSE = -6,
- RTSP_EWSASTART = -7,
- RTSP_EWSAVERSION = -8,
+ RTSP_EINTR = -2,
+ RTSP_ENOMEM = -3,
+ RTSP_ERESOLV = -4,
+ RTSP_ENOTIMPL = -5,
+ RTSP_ESYS = -6,
+ RTSP_EPARSE = -7,
+ RTSP_EWSASTART = -8,
+ RTSP_EWSAVERSION = -9,
+ RTSP_EEOF = -10,
} RTSPResult;
diff --git a/gst/rtsp/rtspmessage.c b/gst/rtsp/rtspmessage.c
index bd1473bba..333661d09 100644
--- a/gst/rtsp/rtspmessage.c
+++ b/gst/rtsp/rtspmessage.c
@@ -1,5 +1,6 @@
/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
+ * <2006> Lutz Mueller <lutz at topfrose dot de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,6 +17,29 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
#include "rtspmessage.h"
@@ -282,36 +306,40 @@ rtsp_message_dump (RTSPMessage * msg)
g_return_val_if_fail (msg != NULL, RTSP_EINVAL);
- if (msg->type == RTSP_MESSAGE_REQUEST) {
- g_print ("request message %p\n", msg);
- g_print (" request line:\n");
- g_print (" method: '%s'\n",
- rtsp_method_as_text (msg->type_data.request.method));
- g_print (" uri: '%s'\n", msg->type_data.request.uri);
- g_print (" headers:\n");
- g_hash_table_foreach (msg->hdr_fields, dump_key_value, NULL);
- g_print (" body:\n");
- rtsp_message_get_body (msg, &data, &size);
- dump_mem (data, size);
- } else if (msg->type == RTSP_MESSAGE_RESPONSE) {
- g_print ("response message %p\n", msg);
- g_print (" status line:\n");
- g_print (" code: '%d'\n", msg->type_data.response.code);
- g_print (" reason: '%s'\n", msg->type_data.response.reason);
- g_print (" headers:\n");
- g_hash_table_foreach (msg->hdr_fields, dump_key_value, NULL);
- rtsp_message_get_body (msg, &data, &size);
- g_print (" body: length %d\n", size);
- dump_mem (data, size);
- } else if (msg->type == RTSP_MESSAGE_DATA) {
- g_print ("data message %p\n", msg);
- g_print (" channel: '%d'\n", msg->type_data.data.channel);
- g_print (" size: '%d'\n", msg->body_size);
- rtsp_message_get_body (msg, &data, &size);
- dump_mem (data, size);
- } else {
- g_print ("unsupported packet type %d\n", msg->type);
- return RTSP_EINVAL;
+ switch (msg->type) {
+ case RTSP_MESSAGE_REQUEST:
+ g_print ("request message %p\n", msg);
+ g_print (" request line:\n");
+ g_print (" method: '%s'\n",
+ rtsp_method_as_text (msg->type_data.request.method));
+ g_print (" uri: '%s'\n", msg->type_data.request.uri);
+ g_print (" headers:\n");
+ g_hash_table_foreach (msg->hdr_fields, dump_key_value, NULL);
+ g_print (" body:\n");
+ rtsp_message_get_body (msg, &data, &size);
+ dump_mem (data, size);
+ break;
+ case RTSP_MESSAGE_RESPONSE:
+ g_print ("response message %p\n", msg);
+ g_print (" status line:\n");
+ g_print (" code: '%d'\n", msg->type_data.response.code);
+ g_print (" reason: '%s'\n", msg->type_data.response.reason);
+ g_print (" headers:\n");
+ g_hash_table_foreach (msg->hdr_fields, dump_key_value, NULL);
+ rtsp_message_get_body (msg, &data, &size);
+ g_print (" body: length %d\n", size);
+ dump_mem (data, size);
+ break;
+ case RTSP_MESSAGE_DATA:
+ g_print ("data message %p\n", msg);
+ g_print (" channel: '%d'\n", msg->type_data.data.channel);
+ g_print (" size: '%d'\n", msg->body_size);
+ rtsp_message_get_body (msg, &data, &size);
+ dump_mem (data, size);
+ break;
+ default:
+ g_print ("unsupported message type %d\n", msg->type);
+ return RTSP_EINVAL;
}
return RTSP_OK;
}
diff --git a/gst/rtsp/rtspmessage.h b/gst/rtsp/rtspmessage.h
index ced3f8402..111f4fe8c 100644
--- a/gst/rtsp/rtspmessage.h
+++ b/gst/rtsp/rtspmessage.h
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,6 +16,29 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
#ifndef __RTSP_MESSAGE_H__
#define __RTSP_MESSAGE_H__
diff --git a/gst/rtsp/rtsptransport.c b/gst/rtsp/rtsptransport.c
index 57ec92044..2eaaa5b1b 100644
--- a/gst/rtsp/rtsptransport.c
+++ b/gst/rtsp/rtsptransport.c
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,6 +16,29 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
#include <string.h>
#include <stdlib.h>
@@ -146,5 +169,6 @@ rtsp_transport_free (RTSPTransport * transport)
rtsp_transport_init (transport);
g_free (transport);
+
return RTSP_OK;
}
diff --git a/gst/rtsp/rtsptransport.h b/gst/rtsp/rtsptransport.h
index e746f5010..40e16d504 100644
--- a/gst/rtsp/rtsptransport.h
+++ b/gst/rtsp/rtsptransport.h
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,6 +16,29 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
#ifndef __RTSP_TRANSPORT_H__
#define __RTSP_TRANSPORT_H__
diff --git a/gst/rtsp/rtspurl.c b/gst/rtsp/rtspurl.c
index dc861fd08..04b455ac8 100644
--- a/gst/rtsp/rtspurl.c
+++ b/gst/rtsp/rtspurl.c
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,6 +16,30 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
#include <stdlib.h>
#include <string.h>
@@ -78,7 +102,8 @@ rtsp_url_parse (const gchar * urlstr, RTSPUrl ** url)
if (slash)
p = slash + 1;
} else {
- res->port = RTSP_DEFAULT_PORT;
+ /* no port specified, set to 0. _get_port() will return the default port. */
+ res->port = 0;
if (!slash) {
res->host = g_strdup (p);
p = NULL;
@@ -87,6 +112,7 @@ rtsp_url_parse (const gchar * urlstr, RTSPUrl ** url)
p = slash + 1;
}
}
+ /* FIXME, this strips the slash from the absolute path */
if (p)
res->abspath = g_strdup (p);
@@ -114,3 +140,28 @@ rtsp_url_free (RTSPUrl * url)
g_free (url->abspath);
g_free (url);
}
+
+RTSPResult
+rtsp_url_set_port (RTSPUrl * url, guint16 port)
+{
+ g_return_val_if_fail (url != NULL, RTSP_EINVAL);
+
+ url->port = port;
+
+ return RTSP_OK;
+}
+
+RTSPResult
+rtsp_url_get_port (RTSPUrl * url, guint16 * port)
+{
+ g_return_val_if_fail (url != NULL, RTSP_EINVAL);
+ g_return_val_if_fail (port != NULL, RTSP_EINVAL);
+
+ /* if a port was specified, use that else use the default port. */
+ if (url->port != 0)
+ *port = url->port;
+ else
+ *port = RTSP_DEFAULT_PORT;
+
+ return RTSP_OK;
+}
diff --git a/gst/rtsp/rtspurl.h b/gst/rtsp/rtspurl.h
index 1fae3003b..27b537d84 100644
--- a/gst/rtsp/rtspurl.h
+++ b/gst/rtsp/rtspurl.h
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,6 +16,29 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
#ifndef __RTSP_URL_H__
#define __RTSP_URL_H__
@@ -41,6 +64,9 @@ typedef struct _RTSPUrl {
RTSPResult rtsp_url_parse (const gchar *urlstr, RTSPUrl **url);
void rtsp_url_free (RTSPUrl *url);
+RTSPResult rtsp_url_set_port (RTSPUrl *url, guint16 port);
+RTSPResult rtsp_url_get_port (RTSPUrl *url, guint16 *port);
+
G_END_DECLS
#endif /* __RTSP_URL_H__ */
diff --git a/gst/rtsp/sdp.h b/gst/rtsp/sdp.h
index 6efb9f8b3..0bcf26ce0 100644
--- a/gst/rtsp/sdp.h
+++ b/gst/rtsp/sdp.h
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,6 +16,29 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
#ifndef __SDP_H__
#define __SDP_H__
diff --git a/gst/rtsp/sdpmessage.c b/gst/rtsp/sdpmessage.c
index 23aab927f..a9430cf07 100644
--- a/gst/rtsp/sdpmessage.c
+++ b/gst/rtsp/sdpmessage.c
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,12 +16,38 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
#include <stdlib.h>
#include <string.h>
#include "sdpmessage.h"
+/* FIXME, is currently allocated on the stack */
+#define MAX_LINE_LEN 1024 * 16
+
#define FREE_STRING(field) g_free ((field)); (field) = NULL;
#define FREE_ARRAY(field) \
G_STMT_START { \
@@ -54,15 +80,15 @@ char* sdp_message_get_##field (SDPMessage *msg) { \
gint sdp_message_##field##_len (SDPMessage *msg) { \
return ((msg)->field->len); \
}
-#define DEFINE_ARRAY_GETTER(method,field,type) \
-type sdp_message_get_##method (SDPMessage *msg, gint i) { \
- return g_array_index ((msg)->field, type, i); \
+#define DEFINE_ARRAY_GETTER(method,field,type) \
+type sdp_message_get_##method (SDPMessage *msg, guint idx) { \
+ return g_array_index ((msg)->field, type, idx); \
}
-#define DEFINE_ARRAY_P_GETTER(method,field,type) \
-type * sdp_message_get_##method (SDPMessage *msg, gint i) { \
- return &g_array_index ((msg)->field, type, i); \
+#define DEFINE_ARRAY_P_GETTER(method,field,type) \
+type * sdp_message_get_##method (SDPMessage *msg, guint idx) { \
+ return &g_array_index ((msg)->field, type, idx); \
}
-#define DEFINE_ARRAY_ADDER(method,field,type,dup_method) \
+#define DEFINE_ARRAY_ADDER(method,field,type,dup_method) \
RTSPResult sdp_message_add_##method (SDPMessage *msg, type val) { \
type v = dup_method(val); \
g_array_append_val((msg)->field, v); \
@@ -294,7 +320,7 @@ sdp_message_get_key (SDPMessage * msg)
DEFINE_ARRAY_LEN (attributes);
DEFINE_ARRAY_P_GETTER (attribute, attributes, SDPAttribute);
gchar *
-sdp_message_get_attribute_val (SDPMessage * msg, gchar * key)
+sdp_message_get_attribute_val_n (SDPMessage * msg, gchar * key, guint nth)
{
gint i;
@@ -302,12 +328,22 @@ sdp_message_get_attribute_val (SDPMessage * msg, gchar * key)
SDPAttribute *attr;
attr = &g_array_index (msg->attributes, SDPAttribute, i);
- if (!strcmp (attr->key, key))
- return attr->value;
+ if (!strcmp (attr->key, key)) {
+ if (nth == 0)
+ return attr->value;
+ else
+ nth--;
+ }
}
return NULL;
}
+gchar *
+sdp_message_get_attribute_val (SDPMessage * msg, gchar * key)
+{
+ return sdp_message_get_attribute_val_n (msg, key, 0);
+}
+
RTSPResult
sdp_message_add_attribute (SDPMessage * msg, gchar * key, gchar * value)
{
@@ -378,8 +414,14 @@ sdp_media_add_format (SDPMedia * media, gchar * format)
return RTSP_OK;
}
+SDPAttribute *
+sdp_media_get_attribute (SDPMedia * media, guint idx)
+{
+ return &g_array_index (media->attributes, SDPAttribute, idx);
+}
+
gchar *
-sdp_media_get_attribute_val (SDPMedia * media, gchar * key)
+sdp_media_get_attribute_val_n (SDPMedia * media, gchar * key, guint nth)
{
gint i;
@@ -387,18 +429,28 @@ sdp_media_get_attribute_val (SDPMedia * media, gchar * key)
SDPAttribute *attr;
attr = &g_array_index (media->attributes, SDPAttribute, i);
- if (!strcmp (attr->key, key))
- return attr->value;
+ if (!strcmp (attr->key, key)) {
+ if (nth == 0)
+ return attr->value;
+ else
+ nth--;
+ }
}
return NULL;
}
gchar *
-sdp_media_get_format (SDPMedia * media, gint i)
+sdp_media_get_attribute_val (SDPMedia * media, gchar * key)
+{
+ return sdp_media_get_attribute_val_n (media, key, 0);
+}
+
+gchar *
+sdp_media_get_format (SDPMedia * media, guint idx)
{
- if (i >= media->fmts->len)
+ if (idx >= media->fmts->len)
return NULL;
- return g_array_index (media->fmts, gchar *, i);
+ return g_array_index (media->fmts, gchar *, idx);
}
static void
@@ -455,7 +507,7 @@ typedef struct
static gboolean
sdp_parse_line (SDPContext * c, gchar type, gchar * buffer)
{
- gchar str[4096];
+ gchar str[8192];
gchar *p = buffer;
#define READ_STRING(field) read_string (str, sizeof(str), &p);REPLACE_STRING (field, str);
@@ -503,7 +555,7 @@ sdp_parse_line (SDPContext * c, gchar type, gchar * buffer)
break;
case 'b':
{
- gchar str2[4096];
+ gchar str2[MAX_LINE_LEN];
read_string_del (str, sizeof (str), ':', &p);
read_string (str2, sizeof (str2), &p);
@@ -520,7 +572,7 @@ sdp_parse_line (SDPContext * c, gchar type, gchar * buffer)
break;
case 'a':
read_string_del (str, sizeof (str), ':', &p);
- if (p != '\0')
+ if (*p != '\0')
p++;
if (c->state == SDP_SESSION)
sdp_message_add_attribute (c->msg, str, p);
@@ -569,7 +621,7 @@ sdp_message_parse_buffer (guint8 * data, guint size, SDPMessage * msg)
gchar *p;
SDPContext c;
gchar type;
- gchar buffer[4096];
+ gchar buffer[MAX_LINE_LEN];
gint idx = 0;
g_return_val_if_fail (msg != NULL, RTSP_EINVAL);
diff --git a/gst/rtsp/sdpmessage.h b/gst/rtsp/sdpmessage.h
index 6360138f5..97014bcdd 100644
--- a/gst/rtsp/sdpmessage.h
+++ b/gst/rtsp/sdpmessage.h
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -16,6 +16,29 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+/*
+ * Unless otherwise indicated, Source Code is licensed under MIT license.
+ * See further explanation attached in License Statement (distributed in the file
+ * LICENSE).
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
#ifndef __SDP_MESSAGE_H__
#define __SDP_MESSAGE_H__
@@ -125,31 +148,32 @@ gchar* sdp_message_get_information (SDPMessage *msg);
RTSPResult sdp_message_set_uri (SDPMessage *msg, gchar *uri);
gchar* sdp_message_get_uri (SDPMessage *msg);
gint sdp_message_emails_len (SDPMessage *msg);
-gchar* sdp_message_get_email (SDPMessage *msg, gint i);
+gchar* sdp_message_get_email (SDPMessage *msg, guint idx);
RTSPResult sdp_message_add_email (SDPMessage *msg, gchar *email);
gint sdp_message_phones_len (SDPMessage *msg);
-gchar* sdp_message_get_phone (SDPMessage *msg, gint i);
+gchar* sdp_message_get_phone (SDPMessage *msg, guint idx);
RTSPResult sdp_message_add_phone (SDPMessage *msg, gchar *phone);
RTSPResult sdp_message_set_connection (SDPMessage *msg, gchar *nettype, gchar *addrtype,
gchar *address, gint ttl, gint addr_number);
SDPConnection* sdp_message_get_connection (SDPMessage *msg);
gint sdp_message_bandwidths_len (SDPMessage *msg);
-SDPBandwidth* sdp_message_get_bandwidth (SDPMessage *msg, gint i);
+SDPBandwidth* sdp_message_get_bandwidth (SDPMessage *msg, guint idx);
RTSPResult sdp_message_add_bandwidth (SDPMessage *msg, gchar *bwtype, gint bandwidth);
gint sdp_message_times_len (SDPMessage *msg);
-SDPTime* sdp_message_get_time (SDPMessage *msg, gint i);
+SDPTime* sdp_message_get_time (SDPMessage *msg, guint idx);
RTSPResult sdp_message_add_time (SDPMessage *msg, gchar *time);
gint sdp_message_zones_len (SDPMessage *msg);
-SDPZone* sdp_message_get_zone (SDPMessage *msg, gint i);
+SDPZone* sdp_message_get_zone (SDPMessage *msg, guint idx);
RTSPResult sdp_message_add_zone (SDPMessage *msg, gchar *time, gchar *typed_time);
RTSPResult sdp_message_set_key (SDPMessage *msg, gchar *type, gchar *data);
SDPKey* sdp_message_get_key (SDPMessage *msg);
gint sdp_message_attributes_len (SDPMessage *msg);
-SDPAttribute* sdp_message_get_attribute (SDPMessage *msg, gint i);
+SDPAttribute* sdp_message_get_attribute (SDPMessage *msg, guint idx);
gchar* sdp_message_get_attribute_val (SDPMessage *msg, gchar *key);
+gchar* sdp_message_get_attribute_val_n (SDPMessage *msg, gchar *key, guint nth);
RTSPResult sdp_message_add_attribute (SDPMessage *msg, gchar *key, gchar *value);
gint sdp_message_medias_len (SDPMessage *msg);
-SDPMedia* sdp_message_get_media (SDPMessage *msg, gint i);
+SDPMedia* sdp_message_get_media (SDPMessage *msg, guint idx);
RTSPResult sdp_message_add_media (SDPMessage *msg, SDPMedia *media);
@@ -161,8 +185,10 @@ RTSPResult sdp_media_init (SDPMedia *media);
RTSPResult sdp_media_clean (SDPMedia *media);
RTSPResult sdp_media_free (SDPMedia *media);
+SDPAttribute * sdp_media_get_attribute (SDPMedia *media, guint idx);
gchar* sdp_media_get_attribute_val (SDPMedia *media, gchar *key);
-gchar* sdp_media_get_format (SDPMedia *media, gint i);
+gchar* sdp_media_get_attribute_val_n (SDPMedia *media, gchar *key, guint nth);
+gchar* sdp_media_get_format (SDPMedia *media, guint idx);
G_END_DECLS
diff --git a/gst/rtsp/test.c b/gst/rtsp/test.c
index 3e2f2fddd..de7ffdde4 100644
--- a/gst/rtsp/test.c
+++ b/gst/rtsp/test.c
@@ -47,9 +47,17 @@ main (int argc, gchar * argv[])
g_print (" url port: %d\n", url->port);
g_print (" url path: %s\n", url->abspath);
+ /* create and open connection */
+ g_print ("creating connection...\n");
+ res = rtsp_connection_create (url, &conn);
+ if (res != RTSP_OK) {
+ g_print ("error creating connection to \"%s\"\n", urlstr);
+ return (-1);
+ }
+
/* open connection */
g_print ("opening connection...\n");
- res = rtsp_connection_open (url, &conn);
+ res = rtsp_connection_connect (conn);
if (res != RTSP_OK) {
g_print ("error opening connection to \"%s\"\n", urlstr);
return (-1);