diff options
author | Wim Taymans <wim.taymans@gmail.com> | 2006-09-20 16:06:27 +0000 |
---|---|---|
committer | Wim Taymans <wim.taymans@gmail.com> | 2006-09-20 16:06:27 +0000 |
commit | a365a29c77d2ca41fcd3e15f22d24e7fe8f05e02 (patch) | |
tree | bcb6509cd572d4e74269f9de7afebd1220de55fc /gst/rtsp/sdpmessage.c | |
parent | a7d7309e18dca433661058e54651c2d1b78edc6a (diff) |
gst/rtsp/URLS: Added some test URLS.
Original commit message from CVS:
* 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.
Diffstat (limited to 'gst/rtsp/sdpmessage.c')
-rw-r--r-- | gst/rtsp/sdpmessage.c | 94 |
1 files changed, 73 insertions, 21 deletions
diff --git a/gst/rtsp/sdpmessage.c b/gst/rtsp/sdpmessage.c index 23aab927..a9430cf0 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); |