+2006-09-20 Wim Taymans <wim@fluendo.com>
+
+ * gst/rtsp/URLS:
+ Added some test URLS.
+
+ * gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_create_stream),
+ (gst_rtspsrc_loop), (gst_rtspsrc_open):
+ * gst/rtsp/gstrtspsrc.h:
+ When creating streams, give access to the complete SDP.
+ Fix some leaks.
+ Collect and merge global stream properties in stream caps.
+ Preliminary support for WMServer.
+
+ * gst/rtsp/rtspconnection.c: (rtsp_connection_create),
+ (rtsp_connection_connect), (rtsp_connection_read), (read_body),
+ (rtsp_connection_receive):
+ * gst/rtsp/rtspconnection.h:
+ Make connection interruptable.
+ Refactor to make it reconnectable.
+ Don't fail on short reads when reading data packets.
+
+ * gst/rtsp/rtspurl.c: (rtsp_url_parse), (rtsp_url_set_port),
+ (rtsp_url_get_port):
+ * gst/rtsp/rtspurl.h:
+ Add methods for getting/setting the port.
+
+ * gst/rtsp/sdpmessage.c: (sdp_message_get_attribute_val_n),
+ (sdp_message_get_attribute_val), (sdp_media_get_attribute),
+ (sdp_media_get_attribute_val_n), (sdp_media_get_attribute_val),
+ (sdp_media_get_format), (sdp_parse_line),
+ (sdp_message_parse_buffer):
+ Fix headers.
+ Add methods for getting multiple attributes with the same name.
+ Increase buffer size when parsing.
+ Fix parsing of a=foo fields.
+
+ * gst/rtsp/test.c: (main):
+ Update to new connection API.
+
+ * gst/rtsp/rtspmessage.c: (rtsp_message_new_response),
+ (rtsp_message_init_response), (rtsp_message_init_data),
+ (rtsp_message_unset), (rtsp_message_free), (rtsp_message_dump):
+ * gst/rtsp/rtspmessage.h:
+ * gst/rtsp/rtsptransport.c: (rtsp_transport_free):
+ * gst/rtsp/rtsptransport.h:
+ * gst/rtsp/sdp.h:
+ * gst/rtsp/sdpmessage.h:
+ * gst/rtsp/gstrtsp.c:
+ * gst/rtsp/gstrtsp.h:
+ * gst/rtsp/gstrtpdec.c:
+ * gst/rtsp/gstrtpdec.h:
+ * gst/rtsp/rtsp.h:
+ * gst/rtsp/rtspdefs.c:
+ * gst/rtsp/rtspdefs.h:
+ Dual licensed under MIT and LGPL now.
+
2006-09-19 Wim Taymans <wim@fluendo.com>
* gst/rtsp/gstrtspsrc.c: (find_stream_by_pt),
--- /dev/null
+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
/* 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
* 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 */
/**
* Last reviewed on 2006-06-20 (0.10.4)
*/
-
#include "gstrtpdec.h"
GST_DEBUG_CATEGORY_STATIC (rtpdec_debug);
/* 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
* 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__
/* 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
* 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"
/* 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
* 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__
/* 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
* 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
*
}
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;
guint size;
GstFlowReturn ret = GST_FLOW_OK;
GstCaps *caps = NULL;
+ GstBuffer *buf;
do {
GST_DEBUG_OBJECT (src, "doing receive");
/* 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;
}
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;
}
{
GST_ELEMENT_WARNING (src, RESOURCE, READ,
("Short message received."), (NULL));
+ rtsp_message_unset (&response);
return;
}
need_pause:
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...");
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;
/* 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)
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));
("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:
/* 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
* 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__
gint numstreams;
GList *streams;
+ GstStructure *props;
gchar *location;
RTSPUrl *url;
/* 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
* 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__
/* 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
* 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>
#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
#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;
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)) {
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:
{
}
}
-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)
{
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;
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;
}
}
/* 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 == '$') {
/* 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 {
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;
&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 */
}
return res;
-error:
- {
- return RTSP_EPARSE;
- }
read_error:
{
- return RTSP_ESYS;
+ return res;
}
}
/* 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
* 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__
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);
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__ */
/* 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
* 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"
/* 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
* 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__
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;
/* 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
* 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"
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;
}
/* 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
* 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__
/* 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
* 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>
rtsp_transport_init (transport);
g_free (transport);
+
return RTSP_OK;
}
/* 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
* 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__
/* 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
* 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>
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;
p = slash + 1;
}
}
+ /* FIXME, this strips the slash from the absolute path */
if (p)
res->abspath = g_strdup (p);
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;
+}
/* 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
* 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__
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__ */
/* 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
* 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__
/* 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
* 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 { \
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); \
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;
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)
{
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;
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
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);
break;
case 'b':
{
- gchar str2[4096];
+ gchar str2[MAX_LINE_LEN];
read_string_del (str, sizeof (str), ':', &p);
read_string (str2, sizeof (str2), &p);
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);
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);
/* 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
* 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__
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);
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
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);