From ee42361c89e45089ac5b1fa04d5578c6338b2c6f Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 24 Jul 2007 17:37:03 +0000 Subject: [PATCH] Document the SDP library. Original commit message from CVS: * docs/libs/Makefile.am: * docs/libs/gst-plugins-base-libs-docs.sgml: * docs/libs/gst-plugins-base-libs-sections.txt: * gst-libs/gst/sdp/gstsdp.h: * gst-libs/gst/sdp/gstsdpmessage.c: (gst_sdp_message_set_origin), (gst_sdp_message_set_connection), (gst_sdp_message_add_bandwidth), (gst_sdp_message_add_time), (gst_sdp_message_add_zone), (gst_sdp_message_set_key), (gst_sdp_message_get_attribute_val_n), (gst_sdp_message_get_attribute_val), (gst_sdp_message_add_attribute), (gst_sdp_media_new), (gst_sdp_media_init), (gst_sdp_media_uninit), (gst_sdp_media_free), (gst_sdp_media_get_media), (gst_sdp_media_set_media), (gst_sdp_media_get_port), (gst_sdp_media_get_num_ports), (gst_sdp_media_set_port_info), (gst_sdp_media_get_proto), (gst_sdp_media_set_proto), (gst_sdp_media_formats_len), (gst_sdp_media_get_format), (gst_sdp_media_add_format), (gst_sdp_media_get_information), (gst_sdp_media_set_information), (gst_sdp_media_connections_len), (gst_sdp_media_get_connection), (gst_sdp_media_add_connection), (gst_sdp_media_bandwidths_len), (gst_sdp_media_get_badwidth), (gst_sdp_media_add_bandwidth), (gst_sdp_media_set_key), (gst_sdp_media_get_key), (gst_sdp_media_attributes_len), (gst_sdp_media_add_attribute), (gst_sdp_media_get_attribute_val_n), (gst_sdp_media_get_attribute_val), (gst_sdp_message_parse_buffer), (print_media), (gst_sdp_message_dump): * gst-libs/gst/sdp/gstsdpmessage.h: Document the SDP library. Add some of the missing SDPMedia methods. --- ChangeLog | 31 + docs/libs/Makefile.am | 2 + docs/libs/gst-plugins-base-libs-docs.sgml | 16 +- docs/libs/gst-plugins-base-libs-sections.txt | 97 +++ gst-libs/gst/sdp/gstsdp.h | 7 + gst-libs/gst/sdp/gstsdpmessage.c | 1025 ++++++++++++++++++++++---- gst-libs/gst/sdp/gstsdpmessage.h | 339 ++++++--- 7 files changed, 1286 insertions(+), 231 deletions(-) diff --git a/ChangeLog b/ChangeLog index c756e79..2a094e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,36 @@ 2007-07-24 Wim Taymans + * docs/libs/Makefile.am: + * docs/libs/gst-plugins-base-libs-docs.sgml: + * docs/libs/gst-plugins-base-libs-sections.txt: + * gst-libs/gst/sdp/gstsdp.h: + * gst-libs/gst/sdp/gstsdpmessage.c: (gst_sdp_message_set_origin), + (gst_sdp_message_set_connection), (gst_sdp_message_add_bandwidth), + (gst_sdp_message_add_time), (gst_sdp_message_add_zone), + (gst_sdp_message_set_key), (gst_sdp_message_get_attribute_val_n), + (gst_sdp_message_get_attribute_val), + (gst_sdp_message_add_attribute), (gst_sdp_media_new), + (gst_sdp_media_init), (gst_sdp_media_uninit), (gst_sdp_media_free), + (gst_sdp_media_get_media), (gst_sdp_media_set_media), + (gst_sdp_media_get_port), (gst_sdp_media_get_num_ports), + (gst_sdp_media_set_port_info), (gst_sdp_media_get_proto), + (gst_sdp_media_set_proto), (gst_sdp_media_formats_len), + (gst_sdp_media_get_format), (gst_sdp_media_add_format), + (gst_sdp_media_get_information), (gst_sdp_media_set_information), + (gst_sdp_media_connections_len), (gst_sdp_media_get_connection), + (gst_sdp_media_add_connection), (gst_sdp_media_bandwidths_len), + (gst_sdp_media_get_badwidth), (gst_sdp_media_add_bandwidth), + (gst_sdp_media_set_key), (gst_sdp_media_get_key), + (gst_sdp_media_attributes_len), (gst_sdp_media_add_attribute), + (gst_sdp_media_get_attribute_val_n), + (gst_sdp_media_get_attribute_val), (gst_sdp_message_parse_buffer), + (print_media), (gst_sdp_message_dump): + * gst-libs/gst/sdp/gstsdpmessage.h: + Document the SDP library. + Add some of the missing SDPMedia methods. + +2007-07-24 Wim Taymans + * configure.ac: * gst-libs/gst/Makefile.am: * gst-libs/gst/rtsp/Makefile.am: diff --git a/docs/libs/Makefile.am b/docs/libs/Makefile.am index 42ec27a..85696ba 100644 --- a/docs/libs/Makefile.am +++ b/docs/libs/Makefile.am @@ -70,6 +70,8 @@ SCANOBJ_DEPS = \ $(top_builddir)/gst-libs/gst/audio/libgstaudio-@GST_MAJORMINOR@.la \ $(top_builddir)/gst-libs/gst/cdda/libgstcdda-@GST_MAJORMINOR@.la \ $(top_builddir)/gst-libs/gst/rtp/libgstrtp-@GST_MAJORMINOR@.la \ + $(top_builddir)/gst-libs/gst/rtsp/libgstrtsp-@GST_MAJORMINOR@.la \ + $(top_builddir)/gst-libs/gst/sdp/libgstsdp-@GST_MAJORMINOR@.la \ $(top_builddir)/gst-libs/gst/tag/libgsttag-@GST_MAJORMINOR@.la \ $(top_builddir)/gst-libs/gst/video/libgstvideo-@GST_MAJORMINOR@.la diff --git a/docs/libs/gst-plugins-base-libs-docs.sgml b/docs/libs/gst-plugins-base-libs-docs.sgml index 2e47b18..b2e9170 100644 --- a/docs/libs/gst-plugins-base-libs-docs.sgml +++ b/docs/libs/gst-plugins-base-libs-docs.sgml @@ -42,6 +42,9 @@ + + + @@ -155,7 +158,7 @@ - Rtp Library + RTP Library This library should be linked to by getting cflags and libs from gstreamer-plugins-base-&GST_MAJORMINOR;.pc and adding @@ -168,6 +171,17 @@ &GstRtcpBuffer; + + SDP Library + + This library should be linked to by getting cflags and libs from + gstreamer-plugins-base-&GST_MAJORMINOR;.pc and adding + -lgstsdp-&GST_MAJORMINOR; to the library flags. + + &GstSDP; + &GstSDPMessage; + + Tag Support Library diff --git a/docs/libs/gst-plugins-base-libs-sections.txt b/docs/libs/gst-plugins-base-libs-sections.txt index 52c241d..0733d9d 100644 --- a/docs/libs/gst-plugins-base-libs-sections.txt +++ b/docs/libs/gst-plugins-base-libs-sections.txt @@ -964,6 +964,103 @@ GST_RTP_PAYLOAD_TS41 GST_RTP_PAYLOAD_TS48 +# sdp +
+gstsdp +gst/sdp/sdp.h +GstSDPResult +
+ +
+gstsdpmessage +gst/sdp/sdpmessage.h +GstSDPOrigin +GstSDPConnection +GST_SDP_BWTYPE_CT +GST_SDP_BWTYPE_AS +GST_SDP_BWTYPE_EXT_PREFIX +GstSDPBandwidth +GstSDPTime +GstSDPZone +GstSDPKey +GstSDPAttribute +GstSDPMedia +GstSDPMessage +gst_sdp_message_new +gst_sdp_message_init +gst_sdp_message_uninit +gst_sdp_message_free +gst_sdp_message_parse_buffer +gst_sdp_message_get_version +gst_sdp_message_set_version +gst_sdp_message_get_origin +gst_sdp_message_set_origin +gst_sdp_message_get_session_name +gst_sdp_message_set_session_name +gst_sdp_message_get_information +gst_sdp_message_set_information +gst_sdp_message_get_uri +gst_sdp_message_set_uri +gst_sdp_message_emails_len +gst_sdp_message_get_email +gst_sdp_message_add_email +gst_sdp_message_phones_len +gst_sdp_message_get_phone +gst_sdp_message_add_phone +gst_sdp_message_get_connection +gst_sdp_message_set_connection +gst_sdp_message_bandwidths_len +gst_sdp_message_get_bandwidth +gst_sdp_message_add_bandwidth +gst_sdp_message_times_len +gst_sdp_message_get_time +gst_sdp_message_add_time +gst_sdp_message_zones_len +gst_sdp_message_get_zone +gst_sdp_message_add_zone +gst_sdp_message_get_key +gst_sdp_message_set_key +gst_sdp_message_attributes_len +gst_sdp_message_get_attribute +gst_sdp_message_get_attribute_val +gst_sdp_message_get_attribute_val_n +gst_sdp_message_add_attribute +gst_sdp_message_medias_len +gst_sdp_message_get_media +gst_sdp_message_add_media +gst_sdp_message_dump + +gst_sdp_media_new +gst_sdp_media_init +gst_sdp_media_uninit +gst_sdp_media_free +gst_sdp_media_get_media +gst_sdp_media_set_media +gst_sdp_media_get_port +gst_sdp_media_get_num_ports +gst_sdp_media_set_port_info +gst_sdp_media_get_proto +gst_sdp_media_set_proto +gst_sdp_media_formats_len +gst_sdp_media_get_format +gst_sdp_media_add_format +gst_sdp_media_get_information +gst_sdp_media_set_information +gst_sdp_media_connections_len +gst_sdp_media_get_connection +gst_sdp_media_add_connection +gst_sdp_media_bandwidths_len +gst_sdp_media_get_bandwidth +gst_sdp_media_add_bandwidth +gst_sdp_media_get_key +gst_sdp_media_set_key +gst_sdp_media_attributes_len +gst_sdp_media_get_attribute +gst_sdp_media_get_attribute_val +gst_sdp_media_get_attribute_val_n +gst_sdp_media_add_attribute +
+ # tag
diff --git a/gst-libs/gst/sdp/gstsdp.h b/gst-libs/gst/sdp/gstsdp.h index a16518f..3dbd86d 100644 --- a/gst-libs/gst/sdp/gstsdp.h +++ b/gst-libs/gst/sdp/gstsdp.h @@ -43,6 +43,13 @@ #ifndef __GST_SDP_H__ #define __GST_SDP_H__ +/** + * GstSDPResult: + * @GST_SDP_OK: A successful return value + * @GST_SDP_EINVAL: a function was given invalid parameters + * + * Return values for the SDP functions. + */ typedef enum { GST_SDP_OK = 0, GST_SDP_EINVAL = -1 diff --git a/gst-libs/gst/sdp/gstsdpmessage.c b/gst-libs/gst/sdp/gstsdpmessage.c index 2bf7f8a..18c096c 100644 --- a/gst-libs/gst/sdp/gstsdpmessage.c +++ b/gst-libs/gst/sdp/gstsdpmessage.c @@ -40,6 +40,21 @@ * SOFTWARE. */ +/** + * SECTION:gstsdpmessage + * @short_description: Helper methods for dealing with SDP messages + * + * + * + * The GstSDPMessage helper functions makes it easy to parse and create SDP + * messages. + * + * + * + * Last reviewed on 2007-07-24 (0.10.14) + */ + + #include #include @@ -70,13 +85,13 @@ G_STMT_START { \ } G_STMT_END #define DEFINE_STRING_SETTER(field) \ -GstSDPResult gst_sdp_message_set_##field (GstSDPMessage *msg, gchar *val) { \ +GstSDPResult gst_sdp_message_set_##field (GstSDPMessage *msg, const gchar *val) { \ g_free (msg->field); \ msg->field = g_strdup (val); \ return GST_SDP_OK; \ } #define DEFINE_STRING_GETTER(field) \ -char* gst_sdp_message_get_##field (GstSDPMessage *msg) { \ +const gchar* gst_sdp_message_get_##field (GstSDPMessage *msg) { \ return msg->field; \ } @@ -180,7 +195,7 @@ gst_sdp_message_new (GstSDPMessage ** msg) /** * gst_sdp_message_init: - * @msg: an #GstSDPMessage + * @msg: a #GstSDPMessage * * Initialize @msg so that its contents are as if it was freshly allocated * with gst_sdp_message_new(). This function is mostly used to initialize a message @@ -216,7 +231,7 @@ gst_sdp_message_init (GstSDPMessage * msg) /** * gst_sdp_message_uninit: - * @msg: an #GstSDPMessage + * @msg: a #GstSDPMessage * * Free all resources allocated in @msg. @msg should not be used anymore after * this function. This function should be used when @msg was allocated on the @@ -244,7 +259,7 @@ gst_sdp_message_uninit (GstSDPMessage * msg) /** * gst_sdp_message_free: - * @msg: an #GstSDPMessage + * @msg: a #GstSDPMessage * * Free all resources allocated by @msg. @msg should not be used anymore after * this function. This function should be used when @msg was dynamically @@ -264,111 +279,43 @@ gst_sdp_message_free (GstSDPMessage * msg) } /** - * gst_sdp_media_new: - * @media: pointer to new #GstSDPMedia - * - * Allocate a new GstSDPMedia and store the result in @media. - * - * Returns: a #GstSDPResult. - */ -GstSDPResult -gst_sdp_media_new (GstSDPMedia ** media) -{ - GstSDPMedia *newmedia; - - g_return_val_if_fail (media != NULL, GST_SDP_EINVAL); - - newmedia = g_new0 (GstSDPMedia, 1); - - *media = newmedia; - - return gst_sdp_media_init (newmedia); -} - -/** - * gst_sdp_media_init: - * @media: a #GstSDPMedia - * - * Initialize @media so that its contents are as if it was freshly allocated - * with gst_sdp_media_new(). This function is mostly used to initialize a media - * allocated on the stack. gst_sdp_media_uninit() undoes this operation. + * gst_sdp_message_set_version: + * @msg: a #GstSDPMessage + * @version: the version * - * When this function is invoked on newly allocated data (with malloc or on the - * stack), its contents should be set to 0 before calling this function. + * Set the version in @msg. * * Returns: a #GstSDPResult. */ -GstSDPResult -gst_sdp_media_init (GstSDPMedia * media) -{ - g_return_val_if_fail (media != NULL, GST_SDP_EINVAL); - - FREE_STRING (media->media); - media->port = 0; - media->num_ports = 0; - FREE_STRING (media->proto); - INIT_ARRAY (media->fmts, gchar *, g_free); - FREE_STRING (media->information); - INIT_ARRAY (media->connections, GstSDPConnection, gst_sdp_connection_init); - INIT_ARRAY (media->bandwidths, GstSDPBandwidth, gst_sdp_bandwidth_init); - gst_sdp_key_init (&media->key); - INIT_ARRAY (media->attributes, GstSDPAttribute, gst_sdp_attribute_init); - - return GST_SDP_OK; -} - +DEFINE_STRING_SETTER (version); /** - * gst_sdp_media_uninit: - * @media: an #GstSDPMedia + * gst_sdp_message_get_version: + * @msg: a #GstSDPMessage * - * Free all resources allocated in @media. @media should not be used anymore after - * this function. This function should be used when @media was allocated on the - * stack and initialized with gst_sdp_media_init(). + * Get the version in @msg. * * Returns: a #GstSDPResult. */ -GstSDPResult -gst_sdp_media_uninit (GstSDPMedia * media) -{ - g_return_val_if_fail (media != NULL, GST_SDP_EINVAL); - - gst_sdp_media_init (media); - FREE_ARRAY (media->fmts); - FREE_ARRAY (media->connections); - FREE_ARRAY (media->bandwidths); - FREE_ARRAY (media->attributes); - - return GST_SDP_OK; -} +DEFINE_STRING_GETTER (version); /** - * gst_sdp_media_free: - * @media: an #GstSDPMedia + * gst_sdp_message_set_origin: + * @msg: a #GstSDPMessage + * @username: the user name + * @sess_id: a session id + * @sess_version: a session version + * @nettype: a network type + * @addrtype: an address type + * @addr: an address * - * Free all resources allocated by @media. @media should not be used anymore after - * this function. This function should be used when @media was dynamically - * allocated with gst_sdp_media_new(). + * Configure the SDP origin in @msg with the given parameters. * - * Returns: a #GstSDPResult. + * Returns: #GST_SDP_OK. */ GstSDPResult -gst_sdp_media_free (GstSDPMedia * media) -{ - g_return_val_if_fail (media != NULL, GST_SDP_EINVAL); - - gst_sdp_media_uninit (media); - g_free (media); - - return GST_SDP_OK; -} - -DEFINE_STRING_SETTER (version); -DEFINE_STRING_GETTER (version); - -GstSDPResult -gst_sdp_message_set_origin (GstSDPMessage * msg, gchar * username, - gchar * sess_id, gchar * sess_version, gchar * nettype, gchar * addrtype, - gchar * addr) +gst_sdp_message_set_origin (GstSDPMessage * msg, const gchar * username, + const gchar * sess_id, const gchar * sess_version, const gchar * nettype, + const gchar * addrtype, const gchar * addr) { REPLACE_STRING (msg->origin.username, username); REPLACE_STRING (msg->origin.sess_id, sess_id); @@ -376,53 +323,217 @@ gst_sdp_message_set_origin (GstSDPMessage * msg, gchar * username, REPLACE_STRING (msg->origin.nettype, nettype); REPLACE_STRING (msg->origin.addrtype, addrtype); REPLACE_STRING (msg->origin.addr, addr); + return GST_SDP_OK; } -GstSDPOrigin * +/** + * gst_sdp_message_get_origin: + * @msg: a #GstSDPMessage + * + * Get the origin of @msg. + * + * Returns: a #GstSDPOrigin. The result remains valid as long as @msg is valid. + */ +const GstSDPOrigin * gst_sdp_message_get_origin (GstSDPMessage * msg) { return &msg->origin; } +/** + * gst_sdp_message_set_session_name: + * @msg: a #GstSDPMessage + * @session_name: the session name + * + * Set the session name in @msg. + * + * Returns: a #GstSDPResult. + */ DEFINE_STRING_SETTER (session_name); +/** + * gst_sdp_message_get_session_name: + * @msg: a #GstSDPMessage + * + * Get the session name in @msg. + * + * Returns: a #GstSDPResult. + */ DEFINE_STRING_GETTER (session_name); +/** + * gst_sdp_message_set_information: + * @msg: a #GstSDPMessage + * @information: the information + * + * Set the information in @msg. + * + * Returns: a #GstSDPResult. + */ DEFINE_STRING_SETTER (information); +/** + * gst_sdp_message_get_information: + * @msg: a #GstSDPMessage + * + * Get the information in @msg. + * + * Returns: a #GstSDPResult. + */ DEFINE_STRING_GETTER (information); +/** + * gst_sdp_message_set_uri: + * @msg: a #GstSDPMessage + * @uri: the URI + * + * Set the URI in @msg. + * + * Returns: a #GstSDPResult. + */ DEFINE_STRING_SETTER (uri); +/** + * gst_sdp_message_get_uri: + * @msg: a #GstSDPMessage + * + * Get the URI in @msg. + * + * Returns: a #GstSDPResult. + */ DEFINE_STRING_GETTER (uri); +/** + * gst_sdp_message_emails_len: + * @msg: a #GstSDPMessage + * + * Get the number of emails in @msg. + * + * Returns: the number of emails in @msg. + */ DEFINE_ARRAY_LEN (emails); -DEFINE_ARRAY_GETTER (email, emails, gchar *); -DEFINE_ARRAY_ADDER (email, emails, gchar *, g_strdup); +/** + * gst_sdp_message_get_email: + * @msg: a #GstSDPMessage + * @idx: an email index + * + * Get the email with number @idx from @msg. + * + * Returns: the email at position @idx. + */ +DEFINE_ARRAY_GETTER (email, emails, const gchar *); +/** + * gst_sdp_message_add_email: + * @msg: a #GstSDPMessage + * @email: an email + * + * Add @email to the list of emails in @msg. + * + * Returns: a #GstSDPResult. + */ +DEFINE_ARRAY_ADDER (email, emails, const gchar *, g_strdup); + +/** + * gst_sdp_message_phones_len: + * @msg: a #GstSDPMessage + * + * Get the number of phones in @msg. + * + * Returns: the number of phones in @msg. + */ DEFINE_ARRAY_LEN (phones); -DEFINE_ARRAY_GETTER (phone, phones, gchar *); -DEFINE_ARRAY_ADDER (phone, phones, gchar *, g_strdup); +/** + * gst_sdp_message_get_phone: + * @msg: a #GstSDPMessage + * @idx: a phone index + * + * Get the phone with number @idx from @msg. + * + * Returns: the phone at position @idx. + */ +DEFINE_ARRAY_GETTER (phone, phones, const gchar *); + +/** + * gst_sdp_message_add_phone: + * @msg: a #GstSDPMessage + * @phone: a phone + * + * Add @phone to the list of phones in @msg. + * + * Returns: a #GstSDPResult. + */ +DEFINE_ARRAY_ADDER (phone, phones, const gchar *, g_strdup); +/** + * gst_sdp_message_set_connection: + * @msg: a #GstSDPMessage + * @nettype: the type of network. "IN" is defined to have the meaning + * "Internet". + * @addrtype: the type of address. + * @address: the address + * @ttl: the time to live of the address + * @addr_number: the number of layers + * + * Configure the SDP connection in @msg with the given parameters. + * + * Returns: a #GstSDPResult. + */ GstSDPResult -gst_sdp_message_set_connection (GstSDPMessage * msg, gchar * nettype, - gchar * addrtype, gchar * address, gint ttl, gint addr_number) +gst_sdp_message_set_connection (GstSDPMessage * msg, const gchar * nettype, + const gchar * addrtype, const gchar * address, gint ttl, gint addr_number) { REPLACE_STRING (msg->connection.nettype, nettype); REPLACE_STRING (msg->connection.addrtype, addrtype); REPLACE_STRING (msg->connection.address, address); msg->connection.ttl = ttl; msg->connection.addr_number = addr_number; + return GST_SDP_OK; } -GstSDPConnection * +/** + * gst_sdp_message_get_connection: + * @msg: a #GstSDPMessage + * + * Get the connection of @msg. + * + * Returns: a #GstSDPConnection. The result remains valid as long as @msg is valid. + */ +const GstSDPConnection * gst_sdp_message_get_connection (GstSDPMessage * msg) { return &msg->connection; } +/** + * gst_sdp_message_bandwidths_len: + * @msg: a #GstSDPMessage + * + * Get the number of bandwidth information in @msg. + * + * Returns: the number of bandwidth information in @msg. + */ DEFINE_ARRAY_LEN (bandwidths); -DEFINE_ARRAY_P_GETTER (bandwidth, bandwidths, GstSDPBandwidth); +/** + * gst_sdp_message_get_bandwidth: + * @msg: a #GstSDPMessage + * @idx: the bandwidth index + * + * Get the bandwidth at index @idx from @msg. + * + * Returns: a #GstSDPBandwidth. + */ +DEFINE_ARRAY_P_GETTER (bandwidth, bandwidths, const GstSDPBandwidth); +/** + * gst_sdp_message_add_bandwidth: + * @msg: a #GstSDPMessage + * @bwtype: the bandwidth modifier type + * @bandwidth: the bandwidth in kilobits per second + * + * Add the specified bandwidth information to @msg. + * + * Returns: a #GstSDPResult. + */ GstSDPResult -gst_sdp_message_add_bandwidth (GstSDPMessage * msg, gchar * bwtype, +gst_sdp_message_add_bandwidth (GstSDPMessage * msg, const gchar * bwtype, gint bandwidth) { GstSDPBandwidth bw; @@ -435,19 +546,75 @@ gst_sdp_message_add_bandwidth (GstSDPMessage * msg, gchar * bwtype, return GST_SDP_OK; } +/** + * gst_sdp_message_times_len: + * @msg: a #GstSDPMessage + * + * Get the number of time information entries in @msg. + * + * Returns: the number of time information entries in @msg. + */ DEFINE_ARRAY_LEN (times); -DEFINE_ARRAY_P_GETTER (time, times, GstSDPTime); +/** + * gst_sdp_message_get_time: + * @msg: a #GstSDPMessage + * @idx: the time index + * + * Get time information with index @idx from @msg. + * + * Returns: a #GstSDPTime. + */ +DEFINE_ARRAY_P_GETTER (time, times, const GstSDPTime); + +/** + * gst_sdp_message_add_time: + * @msg: a #GstSDPMessage + * @time: a time information + * + * Add time information @time to @msg. + * + * Returns: a #GstSDPResult. + */ GstSDPResult -gst_sdp_message_add_time (GstSDPMessage * msg, gchar * time) +gst_sdp_message_add_time (GstSDPMessage * msg, const gchar * time) { return GST_SDP_OK; } +/** + * gst_sdp_message_zones_len: + * @msg: a #GstSDPMessage + * + * Get the number of time zone information entries in @msg. + * + * Returns: the number of time zone information entries in @msg. + */ DEFINE_ARRAY_LEN (zones); -DEFINE_ARRAY_P_GETTER (zone, zones, GstSDPZone); +/** + * gst_sdp_message_get_zone: + * @msg: a #GstSDPMessage + * @idx: the zone index + * + * Get time zone information with index @idx from @msg. + * + * Returns: a #GstSDPZone. + */ +DEFINE_ARRAY_P_GETTER (zone, zones, const GstSDPZone); + +/** + * gst_sdp_message_add_zone: + * @msg: a #GstSDPMessage + * @time: the NTP time that a time zone adjustment happens + * @typed_time: the offset from the time when the session was first scheduled + * + * Add time zone information to @msg. + * + * Returns: a #GstSDPResult. + */ GstSDPResult -gst_sdp_message_add_zone (GstSDPMessage * msg, gchar * time, gchar * typed_time) +gst_sdp_message_add_zone (GstSDPMessage * msg, const gchar * time, + const gchar * typed_time) { GstSDPZone zone; @@ -459,25 +626,71 @@ gst_sdp_message_add_zone (GstSDPMessage * msg, gchar * time, gchar * typed_time) return GST_SDP_OK; } +/** + * gst_sdp_message_set_key: + * @msg: a #GstSDPMessage + * @type: the encryption type + * @data: the encryption data + * + * Adds the encryption information to @msg. + * + * Returns: a #GstSDPResult. + */ GstSDPResult -gst_sdp_message_set_key (GstSDPMessage * msg, gchar * type, gchar * data) +gst_sdp_message_set_key (GstSDPMessage * msg, const gchar * type, + const gchar * data) { REPLACE_STRING (msg->key.type, type); REPLACE_STRING (msg->key.data, data); + return GST_SDP_OK; } -GstSDPKey * +/** + * gst_sdp_message_get_key: + * @msg: a #GstSDPMessage + * + * Get the encryption information from @msg. + * + * Returns: a #GstSDPKey. + */ +const GstSDPKey * gst_sdp_message_get_key (GstSDPMessage * msg) { return &msg->key; } - +/** + * gst_sdp_message_attributes_len: + * @msg: a #GstSDPMessage + * + * Get the number of attributes in @msg. + * + * Returns: the number of attributes in @msg. + */ DEFINE_ARRAY_LEN (attributes); -DEFINE_ARRAY_P_GETTER (attribute, attributes, GstSDPAttribute); -gchar * -gst_sdp_message_get_attribute_val_n (GstSDPMessage * msg, gchar * key, +/** + * gst_sdp_message_get_attribute: + * @msg: a #GstSDPMessage + * @idx: the index + * + * Get the attribute at position @idx in @msg. + * + * Returns: the #GstSDPAttribute at position @idx. + */ +DEFINE_ARRAY_P_GETTER (attribute, attributes, const GstSDPAttribute); +/** + * gst_sdp_message_get_attribute_val_n: + * @msg: a #GstSDPMessage + * @key: the key + * @nth: the index + * + * Get the @nth attribute with key @key in @msg. + * + * Returns: the attribute value of the @nth attribute with @key. + */ +const gchar * +gst_sdp_message_get_attribute_val_n (GstSDPMessage * msg, const gchar * key, guint nth) { guint i; @@ -496,14 +709,34 @@ gst_sdp_message_get_attribute_val_n (GstSDPMessage * msg, gchar * key, return NULL; } -gchar * -gst_sdp_message_get_attribute_val (GstSDPMessage * msg, gchar * key) +/** + * gst_sdp_message_get_attribute_val: + * @msg: a #GstSDPMessage + * @key: the key + * + * Get the first attribute with key @key in @msg. + * + * Returns: the attribute value of the first attribute with @key. + */ +const gchar * +gst_sdp_message_get_attribute_val (GstSDPMessage * msg, const gchar * key) { return gst_sdp_message_get_attribute_val_n (msg, key, 0); } +/** + * gst_sdp_message_add_attribute: + * @msg: a #GstSDPMessage + * @key: the key + * @value: the value + * + * Add the attribute with @key and @value to @msg. + * + * Returns: @GST_SDP_OK. + */ GstSDPResult -gst_sdp_message_add_attribute (GstSDPMessage * msg, gchar * key, gchar * value) +gst_sdp_message_add_attribute (GstSDPMessage * msg, const gchar * key, + const gchar * value) { GstSDPAttribute attr; @@ -515,19 +748,36 @@ gst_sdp_message_add_attribute (GstSDPMessage * msg, gchar * key, gchar * value) return GST_SDP_OK; } +/** + * gst_sdp_message_medias_len: + * @msg: a #GstSDPMessage + * + * Get the number of media descriptions in @msg. + * + * Returns: the number of media descriptions in @msg. + */ DEFINE_ARRAY_LEN (medias); -DEFINE_ARRAY_P_GETTER (media, medias, GstSDPMedia); +/** + * gst_sdp_message_get_media: + * @msg: a #GstSDPMessage + * @idx: the index + * + * Get the media description at index @idx in @msg. + * + * Returns: a #GstSDPMedia. + */ +DEFINE_ARRAY_P_GETTER (media, medias, const GstSDPMedia); /** * gst_sdp_message_add_media: - * @msg: an #GstSDPMessage - * @media: an #GstSDPMedia to add + * @msg: a #GstSDPMessage + * @media: a #GstSDPMedia to add * * Adds @media to the array of medias in @msg. This function takes ownership of * the contents of @media so that @media will have to be reinitialized with * gst_media_init() before it can be used again. * - * Returns: an #GstSDPResult. + * Returns: a #GstSDPResult. */ GstSDPResult gst_sdp_message_add_media (GstSDPMessage * msg, GstSDPMedia * media) @@ -547,21 +797,401 @@ gst_sdp_message_add_media (GstSDPMessage * msg, GstSDPMedia * media) /* media access */ +/** + * gst_sdp_media_new: + * @media: pointer to new #GstSDPMedia + * + * Allocate a new GstSDPMedia and store the result in @media. + * + * Returns: a #GstSDPResult. + */ GstSDPResult -gst_sdp_media_add_attribute (GstSDPMedia * media, gchar * key, gchar * value) +gst_sdp_media_new (GstSDPMedia ** media) { - GstSDPAttribute attr; + GstSDPMedia *newmedia; - attr.key = g_strdup (key); - attr.value = g_strdup (value); + g_return_val_if_fail (media != NULL, GST_SDP_EINVAL); - g_array_append_val (media->attributes, attr); + newmedia = g_new0 (GstSDPMedia, 1); + + *media = newmedia; + + return gst_sdp_media_init (newmedia); +} + +/** + * gst_sdp_media_init: + * @media: a #GstSDPMedia + * + * Initialize @media so that its contents are as if it was freshly allocated + * with gst_sdp_media_new(). This function is mostly used to initialize a media + * allocated on the stack. gst_sdp_media_uninit() undoes this operation. + * + * When this function is invoked on newly allocated data (with malloc or on the + * stack), its contents should be set to 0 before calling this function. + * + * Returns: a #GstSDPResult. + */ +GstSDPResult +gst_sdp_media_init (GstSDPMedia * media) +{ + g_return_val_if_fail (media != NULL, GST_SDP_EINVAL); + + FREE_STRING (media->media); + media->port = 0; + media->num_ports = 0; + FREE_STRING (media->proto); + INIT_ARRAY (media->fmts, gchar *, g_free); + FREE_STRING (media->information); + INIT_ARRAY (media->connections, GstSDPConnection, gst_sdp_connection_init); + INIT_ARRAY (media->bandwidths, GstSDPBandwidth, gst_sdp_bandwidth_init); + gst_sdp_key_init (&media->key); + INIT_ARRAY (media->attributes, GstSDPAttribute, gst_sdp_attribute_init); return GST_SDP_OK; } +/** + * gst_sdp_media_uninit: + * @media: a #GstSDPMedia + * + * Free all resources allocated in @media. @media should not be used anymore after + * this function. This function should be used when @media was allocated on the + * stack and initialized with gst_sdp_media_init(). + * + * Returns: a #GstSDPResult. + */ GstSDPResult -gst_sdp_media_add_bandwidth (GstSDPMedia * media, gchar * bwtype, +gst_sdp_media_uninit (GstSDPMedia * media) +{ + g_return_val_if_fail (media != NULL, GST_SDP_EINVAL); + + gst_sdp_media_init (media); + FREE_ARRAY (media->fmts); + FREE_ARRAY (media->connections); + FREE_ARRAY (media->bandwidths); + FREE_ARRAY (media->attributes); + + return GST_SDP_OK; +} + +/** + * gst_sdp_media_free: + * @media: a #GstSDPMedia + * + * Free all resources allocated by @media. @media should not be used anymore after + * this function. This function should be used when @media was dynamically + * allocated with gst_sdp_media_new(). + * + * Returns: a #GstSDPResult. + */ +GstSDPResult +gst_sdp_media_free (GstSDPMedia * media) +{ + g_return_val_if_fail (media != NULL, GST_SDP_EINVAL); + + gst_sdp_media_uninit (media); + g_free (media); + + return GST_SDP_OK; +} + +/** + * gst_sdp_media_get_media: + * @media: a #GstSDPMedia + * + * Get the media description of @media. + * + * Returns: the media description. + */ +const gchar * +gst_sdp_media_get_media (GstSDPMedia * media) +{ + return media->media; +} + +/** + * gst_sdp_media_set_media: + * @media: a #GstSDPMedia + * @med: the media description + * + * Set the media description of @media to @med. + * + * Returns: #GST_SDP_OK. + */ +GstSDPResult +gst_sdp_media_set_media (GstSDPMedia * media, const gchar * med) +{ + g_free (media->media); + media->media = g_strdup (med); + + return GST_SDP_OK; +} + +/** + * gst_sdp_media_get_port: + * @media: a #GstSDPMedia + * + * Get the port number for @media. + * + * Returns: the port number of @media. + */ +gint +gst_sdp_media_get_port (GstSDPMedia * media) +{ + return media->port; +} + +/** + * gst_sdp_media_get_num_ports: + * @media: a #GstSDPMedia + * + * Get the number of ports for @media. + * + * Returns: the number of ports for @media. + */ +gint +gst_sdp_media_get_num_ports (GstSDPMedia * media) +{ + return media->num_ports; +} + +/** + * gst_sdp_media_set_port_info: + * @media: a #GstSDPMedia + * @port: the port number + * @num_ports: the number of ports + * + * Set the port information in @media. + * + * Returns: #GST_SDP_OK. + */ +GstSDPResult +gst_sdp_media_set_port_info (GstSDPMedia * media, gint port, gint num_ports) +{ + media->port = port; + media->num_ports = num_ports; + + return GST_SDP_OK; +} + +/** + * gst_sdp_media_get_proto: + * @media: a #GstSDPMedia + * + * Get the transport protocol of @media + * + * Returns: the transport protocol of @media. + */ +const gchar * +gst_sdp_media_get_proto (GstSDPMedia * media) +{ + return media->proto; +} + +/** + * gst_sdp_media_set_proto: + * @media: a #GstSDPMedia + * @proto: the media transport protocol + * + * Set the media transport protocol of @media to @proto. + * + * Returns: #GST_SDP_OK. + */ +GstSDPResult +gst_sdp_media_set_proto (GstSDPMedia * media, const gchar * proto) +{ + g_free (media->proto); + media->proto = g_strdup (proto); + + return GST_SDP_OK; +} + +/** + * gst_sdp_media_formats_len: + * @media: a #GstSDPMedia + * + * Get the number of formats in @media. + * + * Returns: the number of formats in @media. + */ +gint +gst_sdp_media_formats_len (GstSDPMedia * media) +{ + return media->fmts->len; +} + +/** + * gst_sdp_media_get_format: + * @media: a #GstSDPMedia + * @idx: an index + * + * Get the format information at position @idx in @media. + * + * Returns: the format at position @idx. + */ +const gchar * +gst_sdp_media_get_format (GstSDPMedia * media, guint idx) +{ + if (idx >= media->fmts->len) + return NULL; + return g_array_index (media->fmts, gchar *, idx); +} + +/** + * gst_sdp_media_add_format: + * @media: a #GstSDPMedia + * @format: the format + * + * Add the format information to @media. + * + * Returns: #GST_SDP_OK. + */ +GstSDPResult +gst_sdp_media_add_format (GstSDPMedia * media, const gchar * format) +{ + gchar *fmt; + + fmt = g_strdup (format); + + g_array_append_val (media->fmts, fmt); + + return GST_SDP_OK; +} + +/** + * gst_sdp_media_get_information: + * @media: a #GstSDPMedia + * + * Get the information of @media + * + * Returns: the information of @media. + */ +const gchar * +gst_sdp_media_get_information (GstSDPMedia * media) +{ + return media->information; +} + +/** + * gst_sdp_media_set_information: + * @media: a #GstSDPMedia + * @information: the media information + * + * Set the media information of @media to @information. + * + * Returns: #GST_SDP_OK. + */ +GstSDPResult +gst_sdp_media_set_information (GstSDPMedia * media, const gchar * information) +{ + g_free (media->information); + media->information = g_strdup (information); + + return GST_SDP_OK; +} + +/** + * gst_sdp_media_connections_len: + * @media: a #GstSDPMedia + * + * Get the number of connection fields in @media. + * + * Returns: the number of connections in @media. + */ +gint +gst_sdp_media_connections_len (GstSDPMedia * media) +{ + return (media->connections->len); +} + +/** + * gst_sdp_media_get_connection: + * @media: a #GstSDPMedia + * @idx: an index + * + * Get the connection at position @idx in @media. + * + * Returns: the #GstSDPConnection at position @idx. + */ +const GstSDPConnection * +gst_sdp_media_get_connection (GstSDPMedia * media, guint idx) +{ + return &g_array_index (media->connections, GstSDPConnection, idx); +} + +/** + * gst_sdp_media_add_connection: + * @media: a #GstSDPMedia + * @nettype: the type of network. "IN" is defined to have the meaning + * "Internet". + * @addrtype: the type of address. + * @address: the address + * @ttl: the time to live of the address + * @addr_number: the number of layers + * + * Add the given connection parameters to @media. + * + * Returns: a #GstSDPResult. + */ +GstSDPResult +gst_sdp_media_add_connection (GstSDPMedia * media, const gchar * nettype, + const gchar * addrtype, const gchar * address, gint ttl, gint addr_number) +{ + GstSDPConnection conn; + + conn.nettype = g_strdup (nettype); + conn.addrtype = g_strdup (addrtype); + conn.address = g_strdup (address); + conn.ttl = ttl; + conn.addr_number = addr_number; + + g_array_append_val (media->connections, conn); + + return GST_SDP_OK; +} + +/** + * gst_sdp_media_bandwidths_len: + * @media: a #GstSDPMedia + * + * Get the number of bandwidth fields in @media. + * + * Returns: the number of bandwidths in @media. + */ +gint +gst_sdp_media_bandwidths_len (GstSDPMedia * media) +{ + return (media->bandwidths->len); +} + +/** + * gst_sdp_media_get_bandwidth: + * @media: a #GstSDPMedia + * @idx: an index + * + * Get the bandwidth at position @idx in @media. + * + * Returns: the #GstSDPBandwidth at position @idx. + */ +const GstSDPBandwidth * +gst_sdp_media_get_badwidth (GstSDPMedia * media, guint idx) +{ + return &g_array_index (media->bandwidths, GstSDPBandwidth, idx); +} + +/** + * gst_sdp_media_add_bandwidth: + * @media: a #GstSDPMedia + * @bwtype: the bandwidth modifier type + * @bandwidth: the bandwidth in kilobits per second + * + * Add the bandwidth information with @bwtype and @bandwidth to @media. + * + * Returns: #GST_SDP_OK. + */ +GstSDPResult +gst_sdp_media_add_bandwidth (GstSDPMedia * media, const gchar * bwtype, gint bandwidth) { GstSDPBandwidth bw; @@ -574,26 +1204,108 @@ gst_sdp_media_add_bandwidth (GstSDPMedia * media, gchar * bwtype, return GST_SDP_OK; } +/** + * gst_sdp_media_set_key: + * @media: a #GstSDPMedia + * @type: the encryption type + * @data: the encryption data + * + * Adds the encryption information to @media. + * + * Returns: a #GstSDPResult. + */ GstSDPResult -gst_sdp_media_add_format (GstSDPMedia * media, gchar * format) +gst_sdp_media_set_key (GstSDPMedia * media, const gchar * type, + const gchar * data) { - gchar *fmt; + g_free (media->key.type); + media->key.type = g_strdup (type); + g_free (media->key.data); + media->key.data = g_strdup (data); - fmt = g_strdup (format); + return GST_SDP_OK; +} - g_array_append_val (media->fmts, fmt); +/** + * gst_sdp_media_get_key: + * @media: a #GstSDPMedia + * + * Get the encryption information from @media. + * + * Returns: a #GstSDPKey. + */ +const GstSDPKey * +gst_sdp_media_get_key (GstSDPMedia * media) +{ + return &media->key; +} + +/** + * gst_sdp_media_attributes_len: + * @media: a #GstSDPMedia + * + * Get the number of attribute fields in @media. + * + * Returns: the number of attributes in @media. + */ +gint +gst_sdp_media_attributes_len (GstSDPMedia * media) +{ + return (media->attributes->len); +} + +/** + * gst_sdp_media_add_attribute: + * @media: a #GstSDPMedia + * @key: a key + * @value: a value + * + * Add the attribute with @key and @value to @media. + * + * Returns: #GST_SDP_OK. + */ +GstSDPResult +gst_sdp_media_add_attribute (GstSDPMedia * media, const gchar * key, + const gchar * value) +{ + GstSDPAttribute attr; + + attr.key = g_strdup (key); + attr.value = g_strdup (value); + + g_array_append_val (media->attributes, attr); return GST_SDP_OK; } -GstSDPAttribute * +/** + * gst_sdp_media_get_attribute: + * @media: a #GstSDPMedia + * @idx: an index + * + * Get the attribute at position @idx in @media. + * + * Returns: the #GstSDPAttribute at position @idx. + */ +const GstSDPAttribute * gst_sdp_media_get_attribute (GstSDPMedia * media, guint idx) { return &g_array_index (media->attributes, GstSDPAttribute, idx); } -gchar * -gst_sdp_media_get_attribute_val_n (GstSDPMedia * media, gchar * key, guint nth) +/** + * gst_sdp_media_get_attribute_val_n: + * @media: a #GstSDPMedia + * @key: a key + * @nth: an index + * + * Get the @nth attribute value for @key in @media. + * + * Returns: the @nth attribute value. + */ +const gchar * +gst_sdp_media_get_attribute_val_n (GstSDPMedia * media, const gchar * key, + guint nth) { guint i; @@ -611,20 +1323,21 @@ gst_sdp_media_get_attribute_val_n (GstSDPMedia * media, gchar * key, guint nth) return NULL; } -gchar * -gst_sdp_media_get_attribute_val (GstSDPMedia * media, gchar * key) +/** + * gst_sdp_media_get_attribute_val: + * @media: a #GstSDPMedia + * @key: a key + * + * Get the first attribute value for @key in @media. + * + * Returns: the first attribute value for @key. + */ +const gchar * +gst_sdp_media_get_attribute_val (GstSDPMedia * media, const gchar * key) { return gst_sdp_media_get_attribute_val_n (media, key, 0); } -gchar * -gst_sdp_media_get_format (GstSDPMedia * media, guint idx) -{ - if (idx >= media->fmts->len) - return NULL; - return g_array_index (media->fmts, gchar *, idx); -} - static void read_string (gchar * dest, guint size, gchar ** src) { @@ -788,8 +1501,20 @@ gst_sdp_parse_line (SDPContext * c, gchar type, gchar * buffer) return TRUE; } +/** + * gst_sdp_message_parse_buffer: + * @data: the start of the buffer + * @size: the size of the buffer + * @msg: the result #GstSDPMessage + * + * Parse the contents of @size bytes pointed to by @data and store the result in + * @msg. + * + * Returns: #GST_SDP_OK on success. + */ GstSDPResult -gst_sdp_message_parse_buffer (guint8 * data, guint size, GstSDPMessage * msg) +gst_sdp_message_parse_buffer (const guint8 * data, guint size, + GstSDPMessage * msg) { gchar *p; SDPContext c; @@ -869,6 +1594,14 @@ print_media (GstSDPMedia * media) } } +/** + * gst_sdp_message_dump: + * @msg: a #GstSDPMessage + * + * Dump the parsed contents of @msg to stdout. + * + * Returns: a #GstSDPResult. + */ GstSDPResult gst_sdp_message_dump (GstSDPMessage * msg) { diff --git a/gst-libs/gst/sdp/gstsdpmessage.h b/gst-libs/gst/sdp/gstsdpmessage.h index e381ace..b0cb869 100644 --- a/gst-libs/gst/sdp/gstsdpmessage.h +++ b/gst-libs/gst/sdp/gstsdpmessage.h @@ -49,6 +49,24 @@ G_BEGIN_DECLS +/** + * GstSDPOrigin: + * @username: the user's login on the originating host, or it is "-" + * if the originating host does not support the concept of user ids. + * @sess_id: is a numeric string such that the tuple of @username, @sess_id, + * @nettype, @addrtype and @addr form a globally unique identifier for the + * session. + * @sess_version: a version number for this announcement + * @nettype: the type of network. "IN" is defined to have the meaning + * "Internet". + * @addrtype: the type of @addr. + * @addr: the globally unique address of the machine from which the session was + * created. + * + * The contents of the SDP "o=" field which gives the originator of the session + * (their username and the address of the user's host) plus a session id and + * session version number. + */ typedef struct { gchar *username; gchar *sess_id; @@ -58,6 +76,17 @@ typedef struct { gchar *addr; } GstSDPOrigin; +/** + * GstSDPConnection: + * @nettype: the type of network. "IN" is defined to have the meaning + * "Internet". + * @addrtype: the type of @address. + * @address: the address + * @ttl: the time to live of the address + * @addr_number: the number of layers + * + * The contents of the SDP "c=" field which contains connection data. + */ typedef struct { gchar *nettype; gchar *addrtype; @@ -66,15 +95,50 @@ typedef struct { gint addr_number; } GstSDPConnection; -#define GST_SDP_BWTYPE_CT "CT" /* conference total */ -#define GST_SDP_BWTYPE_AS "AS" /* application specific */ -#define GST_SDP_BWTYPE_EXT_PREFIX "X-" /* extension prefix */ +/** + * GST_SDP_BWTYPE_CT: + * + * The Conference Total bandwidth modifier. + */ +#define GST_SDP_BWTYPE_CT "CT" +/** + * GST_SDP_BWTYPE_AS: + * + * The Application-Specific Maximum bandwidth modifier. + */ +#define GST_SDP_BWTYPE_AS "AS" +/** + * GST_SDP_BWTYPE_EXT_PREFIX: + * + * The extension prefix bandwidth modifier. + */ +#define GST_SDP_BWTYPE_EXT_PREFIX "X-" +/** + * GstSDPBandwidth: + * @bwtype: the bandwidth modifier type + * @bandwidth: the bandwidth in kilobits per second + * + * The contents of the SDP "b=" field which specifies the proposed bandwidth to + * be used by the session or media. + */ typedef struct { gchar *bwtype; gint bandwidth; } GstSDPBandwidth; +/** + * GstSDPTime: + * @start: start time for the conference. The value is the decimal + * representation of Network Time Protocol (NTP) time values in seconds + * @stop: stop time for the conference. The value is the decimal + * representation of Network Time Protocol (NTP) time values in seconds + * @n_repeat: the number of repeat times + * @repeat: repeat times for a session + * + * The contents of the SDP "t=" field which specify the start and stop times for + * a conference session. + */ typedef struct { gchar *start; gchar *stop; @@ -82,118 +146,225 @@ typedef struct { gchar **repeat; } GstSDPTime; +/** + * GstSDPZone: + * @time: the NTP time that a time zone adjustment happens + * @typed_time: the offset from the time when the session was first scheduled + * + * The contents of the SDP "z=" field which allows the sender to + * specify a list of time zone adjustments and offsets from the base + * time. + */ typedef struct { gchar *time; gchar *typed_time; } GstSDPZone; +/** + * GstSDPKey: + * @type: the encryption type + * @data: the encryption data + * + * The contents of the SDP "k=" field which is used to convey encryption + * keys. + */ typedef struct { gchar *type; gchar *data; } GstSDPKey; +/** + * GstSDPAttribute: + * @key: the attribute key + * @value: the attribute value or NULL when it was a property attribute + * + * The contents of the SDP "a=" field which contains a key/value pair. + */ typedef struct { gchar *key; gchar *value; } GstSDPAttribute; +/** + * GstSDPMedia: + * @media: the media type + * @port: the transport port to which the media stream will be sent + * @num_ports: the number of ports or -1 if only one port was specified + * @proto: the transport protocol + * @fmts: an array of #gchar formats + * @information: the media title + * @connections: array of #GstSDPConnection with media connection information + * @bandwidths: array of #GstSDPBandwidth with media bandwidth information + * @key: the encryption key + * @attributes: array of #GstSDPAttribute with the additional media attributes + * + * The contents of the SDP "m=" field with all related fields. + */ typedef struct { - gchar *media; - gint port; - gint num_ports; - gchar *proto; - GArray *fmts; - gchar *information; - GArray *connections; - GArray *bandwidths; + gchar *media; + gint port; + gint num_ports; + gchar *proto; + GArray *fmts; + gchar *information; + GArray *connections; + GArray *bandwidths; GstSDPKey key; - GArray *attributes; + GArray *attributes; } GstSDPMedia; +/** + * GstSDPMessage: + * @version: the protocol version + * @origin: owner/creator and session identifier + * @session_name: session name + * @information: session information + * @uri: URI of description + * @emails: array of #gchar with email addresses + * @phones: array of #gchar with phone numbers + * @connection: connection information for the session + * @bandwidths: array of #GstSDPBandwidth with bandwidth information + * @times: array of #GstSDPTime with time descriptions + * @zones: array of #GstSDPZone with time zone adjustments + * @key: encryption key + * @attributes: array of #GstSDPAttribute with session attributes + * @medias: array of #GstSDPMedia with media descriptions + * + * The contents of the SDP message. + */ typedef struct { - gchar *version; + gchar *version; GstSDPOrigin origin; - gchar *session_name; - gchar *information; - gchar *uri; - GArray *emails; - GArray *phones; + gchar *session_name; + gchar *information; + gchar *uri; + GArray *emails; + GArray *phones; GstSDPConnection connection; - GArray *bandwidths; - GArray *times; - GArray *zones; + GArray *bandwidths; + GArray *times; + GArray *zones; GstSDPKey key; - GArray *attributes; - GArray *medias; + GArray *attributes; + GArray *medias; } GstSDPMessage; /* Session descriptions */ -GstSDPResult gst_sdp_message_new (GstSDPMessage **msg); -GstSDPResult gst_sdp_message_init (GstSDPMessage *msg); -GstSDPResult gst_sdp_message_uninit (GstSDPMessage *msg); -GstSDPResult gst_sdp_message_free (GstSDPMessage *msg); - -GstSDPResult gst_sdp_message_parse_buffer (guint8 *data, guint size, GstSDPMessage *msg); - -GstSDPResult gst_sdp_message_set_version (GstSDPMessage *msg, gchar *version); -gchar* gst_sdp_message_get_version (GstSDPMessage *msg); -GstSDPResult gst_sdp_message_set_origin (GstSDPMessage *msg, gchar *username, gchar *sess_id, - gchar *sess_version, gchar *nettype, - gchar *addrtype, gchar *addr); -GstSDPOrigin* gst_sdp_message_get_origin (GstSDPMessage *msg); -GstSDPResult gst_sdp_message_set_session_name (GstSDPMessage *msg, gchar *session_name); -gchar* gst_sdp_message_get_session_name (GstSDPMessage *msg); -GstSDPResult gst_sdp_message_set_information (GstSDPMessage *msg, gchar *information); -gchar* gst_sdp_message_get_information (GstSDPMessage *msg); -GstSDPResult gst_sdp_message_set_uri (GstSDPMessage *msg, gchar *uri); -gchar* gst_sdp_message_get_uri (GstSDPMessage *msg); -gint gst_sdp_message_emails_len (GstSDPMessage *msg); -gchar* gst_sdp_message_get_email (GstSDPMessage *msg, guint idx); -GstSDPResult gst_sdp_message_add_email (GstSDPMessage *msg, gchar *email); -gint gst_sdp_message_phones_len (GstSDPMessage *msg); -gchar* gst_sdp_message_get_phone (GstSDPMessage *msg, guint idx); -GstSDPResult gst_sdp_message_add_phone (GstSDPMessage *msg, gchar *phone); -GstSDPResult gst_sdp_message_set_connection (GstSDPMessage *msg, gchar *nettype, gchar *addrtype, - gchar *address, gint ttl, gint addr_number); -GstSDPConnection* gst_sdp_message_get_connection (GstSDPMessage *msg); -gint gst_sdp_message_bandwidths_len (GstSDPMessage *msg); -GstSDPBandwidth* gst_sdp_message_get_bandwidth (GstSDPMessage *msg, guint idx); -GstSDPResult gst_sdp_message_add_bandwidth (GstSDPMessage *msg, gchar *bwtype, gint bandwidth); -gint gst_sdp_message_times_len (GstSDPMessage *msg); -GstSDPTime* gst_sdp_message_get_time (GstSDPMessage *msg, guint idx); -GstSDPResult gst_sdp_message_add_time (GstSDPMessage *msg, gchar *time); -gint gst_sdp_message_zones_len (GstSDPMessage *msg); -GstSDPZone* gst_sdp_message_get_zone (GstSDPMessage *msg, guint idx); -GstSDPResult gst_sdp_message_add_zone (GstSDPMessage *msg, gchar *time, gchar *typed_time); -GstSDPResult gst_sdp_message_set_key (GstSDPMessage *msg, gchar *type, gchar *data); -GstSDPKey* gst_sdp_message_get_key (GstSDPMessage *msg); -gint gst_sdp_message_attributes_len (GstSDPMessage *msg); -GstSDPAttribute* gst_sdp_message_get_attribute (GstSDPMessage *msg, guint idx); -gchar* gst_sdp_message_get_attribute_val (GstSDPMessage *msg, gchar *key); -gchar* gst_sdp_message_get_attribute_val_n (GstSDPMessage *msg, gchar *key, guint nth); -GstSDPResult gst_sdp_message_add_attribute (GstSDPMessage *msg, gchar *key, gchar *value); -gint gst_sdp_message_medias_len (GstSDPMessage *msg); -GstSDPMedia* gst_sdp_message_get_media (GstSDPMessage *msg, guint idx); -GstSDPResult gst_sdp_message_add_media (GstSDPMessage *msg, GstSDPMedia *media); - - -GstSDPResult gst_sdp_message_dump (GstSDPMessage *msg); +GstSDPResult gst_sdp_message_new (GstSDPMessage **msg); +GstSDPResult gst_sdp_message_init (GstSDPMessage *msg); +GstSDPResult gst_sdp_message_uninit (GstSDPMessage *msg); +GstSDPResult gst_sdp_message_free (GstSDPMessage *msg); + +GstSDPResult gst_sdp_message_parse_buffer (const guint8 *data, guint size, GstSDPMessage *msg); + +const gchar* gst_sdp_message_get_version (GstSDPMessage *msg); +GstSDPResult gst_sdp_message_set_version (GstSDPMessage *msg, const gchar *version); + +const GstSDPOrigin* gst_sdp_message_get_origin (GstSDPMessage *msg); +GstSDPResult gst_sdp_message_set_origin (GstSDPMessage *msg, const gchar *username, + const gchar *sess_id, const gchar *sess_version, + const gchar *nettype, const gchar *addrtype, + const gchar *addr); + +const gchar* gst_sdp_message_get_session_name (GstSDPMessage *msg); +GstSDPResult gst_sdp_message_set_session_name (GstSDPMessage *msg, const gchar *session_name); + +const gchar* gst_sdp_message_get_information (GstSDPMessage *msg); +GstSDPResult gst_sdp_message_set_information (GstSDPMessage *msg, const gchar *information); + +const gchar* gst_sdp_message_get_uri (GstSDPMessage *msg); +GstSDPResult gst_sdp_message_set_uri (GstSDPMessage *msg, const gchar *uri); + +gint gst_sdp_message_emails_len (GstSDPMessage *msg); +const gchar* gst_sdp_message_get_email (GstSDPMessage *msg, guint idx); +GstSDPResult gst_sdp_message_add_email (GstSDPMessage *msg, const gchar *email); + +gint gst_sdp_message_phones_len (GstSDPMessage *msg); +const gchar* gst_sdp_message_get_phone (GstSDPMessage *msg, guint idx); +GstSDPResult gst_sdp_message_add_phone (GstSDPMessage *msg, const gchar *phone); + +const GstSDPConnection* gst_sdp_message_get_connection (GstSDPMessage *msg); +GstSDPResult gst_sdp_message_set_connection (GstSDPMessage *msg, const gchar *nettype, + const gchar *addrtype, const gchar *address, + gint ttl, gint addr_number); + +gint gst_sdp_message_bandwidths_len (GstSDPMessage *msg); +const GstSDPBandwidth* gst_sdp_message_get_bandwidth (GstSDPMessage *msg, guint idx); +GstSDPResult gst_sdp_message_add_bandwidth (GstSDPMessage *msg, const gchar *bwtype, + gint bandwidth); + +gint gst_sdp_message_times_len (GstSDPMessage *msg); +const GstSDPTime* gst_sdp_message_get_time (GstSDPMessage *msg, guint idx); +GstSDPResult gst_sdp_message_add_time (GstSDPMessage *msg, const gchar *time); + +gint gst_sdp_message_zones_len (GstSDPMessage *msg); +const GstSDPZone* gst_sdp_message_get_zone (GstSDPMessage *msg, guint idx); +GstSDPResult gst_sdp_message_add_zone (GstSDPMessage *msg, const gchar *time, + const gchar *typed_time); + +const GstSDPKey* gst_sdp_message_get_key (GstSDPMessage *msg); +GstSDPResult gst_sdp_message_set_key (GstSDPMessage *msg, const gchar *type, + const gchar *data); + +gint gst_sdp_message_attributes_len (GstSDPMessage *msg); +const GstSDPAttribute* gst_sdp_message_get_attribute (GstSDPMessage *msg, guint idx); +const gchar* gst_sdp_message_get_attribute_val (GstSDPMessage *msg, const gchar *key); +const gchar* gst_sdp_message_get_attribute_val_n (GstSDPMessage *msg, const gchar *key, + guint nth); +GstSDPResult gst_sdp_message_add_attribute (GstSDPMessage *msg, const gchar *key, + const gchar *value); + +gint gst_sdp_message_medias_len (GstSDPMessage *msg); +const GstSDPMedia* gst_sdp_message_get_media (GstSDPMessage *msg, guint idx); +GstSDPResult gst_sdp_message_add_media (GstSDPMessage *msg, GstSDPMedia *media); + +GstSDPResult gst_sdp_message_dump (GstSDPMessage *msg); /* Media descriptions */ -GstSDPResult gst_sdp_media_new (GstSDPMedia **media); -GstSDPResult gst_sdp_media_init (GstSDPMedia *media); -GstSDPResult gst_sdp_media_uninit (GstSDPMedia *media); -GstSDPResult gst_sdp_media_free (GstSDPMedia *media); +GstSDPResult gst_sdp_media_new (GstSDPMedia **media); +GstSDPResult gst_sdp_media_init (GstSDPMedia *media); +GstSDPResult gst_sdp_media_uninit (GstSDPMedia *media); +GstSDPResult gst_sdp_media_free (GstSDPMedia *media); + +const gchar* gst_sdp_media_get_media (GstSDPMedia *media); +GstSDPResult gst_sdp_media_set_media (GstSDPMedia *media, const gchar *med); + +gint gst_sdp_media_get_port (GstSDPMedia *media); +gint gst_sdp_media_get_num_ports (GstSDPMedia *media); +GstSDPResult gst_sdp_media_set_port_info (GstSDPMedia *media, gint port, + gint num_ports); + +const gchar* gst_sdp_media_get_proto (GstSDPMedia *media); +GstSDPResult gst_sdp_media_set_proto (GstSDPMedia *media, const gchar *proto); + +gint gst_sdp_media_formats_len (GstSDPMedia *media); +const gchar* gst_sdp_media_get_format (GstSDPMedia *media, guint idx); +GstSDPResult gst_sdp_media_add_format (GstSDPMedia *media, const gchar *format); + +const gchar* gst_sdp_media_get_information (GstSDPMedia *media); +GstSDPResult gst_sdp_media_set_information (GstSDPMedia *media, const gchar *information); + +gint gst_sdp_media_connections_len (GstSDPMedia *media); +const GstSDPConnection* gst_sdp_media_get_connection (GstSDPMedia *media, guint idx); +GstSDPResult gst_sdp_media_add_connection (GstSDPMedia *media, const gchar *nettype, + const gchar *addrtype, const gchar *address, + gint ttl, gint addr_number); -GstSDPResult gst_sdp_media_add_bandwidth (GstSDPMedia * media, gchar * bwtype, gint bandwidth); +gint gst_sdp_media_bandwidths_len (GstSDPMedia *media); +const GstSDPBandwidth* gst_sdp_media_get_bandwidth (GstSDPMedia *media, guint idx); +GstSDPResult gst_sdp_media_add_bandwidth (GstSDPMedia *media, const gchar *bwtype, + gint bandwidth); -GstSDPResult gst_sdp_media_add_attribute (GstSDPMedia *media, gchar * key, gchar * value); -GstSDPAttribute * gst_sdp_media_get_attribute (GstSDPMedia *media, guint idx); -gchar* gst_sdp_media_get_attribute_val (GstSDPMedia *media, gchar *key); -gchar* gst_sdp_media_get_attribute_val_n (GstSDPMedia *media, gchar *key, guint nth); +const GstSDPKey* gst_sdp_media_get_key (GstSDPMedia *media); +GstSDPResult gst_sdp_media_set_key (GstSDPMedia *media, const gchar *type, + const gchar *data); -GstSDPResult gst_sdp_media_add_format (GstSDPMedia * media, gchar * format); -gchar* gst_sdp_media_get_format (GstSDPMedia *media, guint idx); +gint gst_sdp_media_attributes_len (GstSDPMedia *media); +const GstSDPAttribute * gst_sdp_media_get_attribute (GstSDPMedia *media, guint idx); +const gchar* gst_sdp_media_get_attribute_val (GstSDPMedia *media, const gchar *key); +const gchar* gst_sdp_media_get_attribute_val_n (GstSDPMedia *media, const gchar *key, guint nth); +GstSDPResult gst_sdp_media_add_attribute (GstSDPMedia *media, const gchar *key, + const gchar *value); G_END_DECLS -- 2.7.4