2 This file is part of FreeSDP
3 Copyright (C) 2001,2002,2003 Federico Montesino Pouzols <fedemp@altern.org>
5 FreeSDP is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 Benjamin Zores, (C) 2006
20 added support in parser for the a=control: lines.
21 added support in parser for the a=range: lines.
27 * @short Specific public header for parsing module.
37 * @defgroup parser FreeSDP Parsing Module
39 * SDP descriptions parsing routines.
43 * Parse a SDP description in <code>description</code>, extracting the
44 * session properties into <code>dsc</code>. These properties can be
45 * obtained individually later using the <code>fsdp_get_xxxx<code>
48 * @param description a multimedia session description formatted in
50 * @param dsc pointer that is updated to point to a fsdp_description_t
51 * object. This fsdp_description_t object should have been previously
52 * allocated using <code>fsdp_description_new()</code>; to free it,
53 * <code>fsdp_description_delete()</code> should be used.
55 * @return FSDPE_OK when parsing completes successfully. Otherwise,
56 * another error code is returned.
58 fsdp_error_t
fsdp_parse (const char *description
, fsdp_description_t
* dsc
);
61 * Get the SDP protocol version of the description.
63 * @return SDP protocol version number.
65 unsigned int fsdp_get_version (const fsdp_description_t
* dsc
);
68 * Get the username provided by the originator of the session.
70 * @param dsc SDP description object.
71 * @return username of the session owner
73 const char *fsdp_get_owner_username (const fsdp_description_t
* dsc
);
76 * Get the id for the session described in <code>dsc</code>.
78 * @param dsc SDP description object.
79 * @return id string for this session.
81 const char *fsdp_get_session_id (const fsdp_description_t
* dsc
);
84 * Get the announcement version for the session description in
87 * @param dsc SDP description object.
88 * @return announcement version string for this description.
90 const char *fsdp_get_announcement_version (const fsdp_description_t
* dsc
);
93 * Get the the type of network the owner of the session described in
94 * <code>dsc</code> is based on.
96 * @param dsc SDP description object.
97 * @return network type for the owner of this session.
100 fsdp_get_owner_network_type (const fsdp_description_t
* dsc
);
103 * Get the the type of address the owner of the session described in
104 * <code>dsc</code> is based on.
106 * @param dsc SDP description object.
107 * @return network address type for the owner of this session.
110 fsdp_get_owner_address_type (const fsdp_description_t
* dsc
);
113 * Get the network address of the owner of the session described in
116 * @param dsc SDP description object.
117 * @return network address for the owner this session.
119 const char *fsdp_get_owner_address (const fsdp_description_t
* dsc
);
122 * Get the name of the session described in <code>dsc</code>.
124 * @param dsc SDP description object.
125 * @return name of this session.
127 const char *fsdp_get_name (const fsdp_description_t
* dsc
);
130 * Get the information about the session provided in the description
133 * @param dsc SDP description object.
134 * @return information of this session.
136 const char *fsdp_get_information (const fsdp_description_t
* dsc
);
139 * Get an URI about the session provided in the description
142 * @param dsc SDP description object.
143 * @return string containing an URI about the session. NULL if the
144 * session uri is missing.
146 const char *fsdp_get_uri (const fsdp_description_t
* dsc
);
149 * Get the number of emails specified for the session in the description
152 * @param dsc SDP description object.
153 * @return number of emails.
155 unsigned int fsdp_get_emails_count (const fsdp_description_t
* dsc
);
158 * Get the n-th email specified for the session in the description
161 * @param dsc SDP description object.
162 * @param index number of URI. Note that this index follows the
163 * traditional C convention: from 0 to fsdp_get_emails_count() - 1.
164 * @return string containing an email about the session. NULL if there
167 const char *fsdp_get_email (const fsdp_description_t
* dsc
,
171 * Get the number of phones specified for the session in the description
174 * @param dsc SDP description object.
175 * @return number of emails.
177 unsigned int fsdp_get_phones_count (const fsdp_description_t
* dsc
);
180 * Get the n-th phone specified for the session in the description
183 * @param dsc SDP description object.
184 * @param index number of URI. Note that this index follows the
185 * traditional C convention: from 0 to fsdp_get_phones_count() - 1.
186 * @return string containing a phone about the session. NULL if there
189 const char *fsdp_get_phone (const fsdp_description_t
* dsc
,
193 * Get the the global type of network of the multimedia session
196 * @param dsc SDP description object.
197 * @return global network type for this
198 * connection. FSDP_NETWORK_TYPE_UNDEFINED if no global network
199 * address type is included in the description.
202 fsdp_get_global_conn_network_type (const fsdp_description_t
* dsc
);
205 * Get the the global type of network address of the multimedia
206 * session connection.
208 * @param dsc SDP description object.
209 * @return global network address type for this connection.
210 * FSDP_ADDRESS_TYPE_UNDEFINED if no global network address type is
211 * included in the description.
214 fsdp_get_global_conn_address_type (const fsdp_description_t
* dsc
);
217 * Get the the global address of the multimedia session connection.
219 * @param dsc SDP description object.
220 * @return global address for this connection.
222 const char *fsdp_get_global_conn_address (const fsdp_description_t
* dsc
);
225 fsdp_get_global_conn_address_ttl (const fsdp_description_t
* dsc
);
228 fsdp_get_global_conn_address_count (const fsdp_description_t
* dsc
);
231 * Get the number of bandwidth modifiers specified for this session.
233 * @param dsc SDP description object.
234 * @return number of bandwidth modifiers.
236 unsigned int fsdp_get_bw_modifier_count (const fsdp_description_t
* dsc
);
239 * Get the bandwidth modifier type for the session.
241 * @param dsc SDP description object.
242 * @param index number of bandwidth modifier.
244 * @return global bandwidth modifier type.
245 * @retval FSDP_BW_MOD_TYPE_UNDEFINED if no global bandwith modifier
246 * type is defined or invalid index.
247 * @retval FSDP_BW_MOD_TYPE_UNKNOWN if an unknown bandwith modifier is
248 * specified or an invalid index is provided. In this case
249 * fsdp_get_bw_modifer_type_unknown() can be called to get the
250 * modifier as a character string.
252 fsdp_bw_modifier_type_t
253 fsdp_get_bw_modifier_type (const fsdp_description_t
* dsc
,
257 * Get the textual bandwidth modifier type when it is unknown.
259 * @param dsc SDP description object.
260 * @param index number of bandwidth modifier.
262 * @return global bandwidth modifier type.
263 * @retval empty string if the provided bandwidth type is not unknown,
264 * the provided index is invalid or or there was a parse error.
266 const char *fsdp_get_bw_modifier_type_unknown (const fsdp_description_t
* dsc
,
270 * Get the value for the bandwidth modifier.
272 * @param dsc SDP description object.
273 * @param index number of bandwidth modifier.
274 * @return global bandwidth value.
275 * @retval 0 if no bandwidth is specified for this session or an
276 * invalid index has been provided.
279 fsdp_get_bw_value (const fsdp_description_t
* dsc
, unsigned int index
);
282 * Get the number of time periods specified for this session
284 * @param dsc SDP description object.
285 * @return number of time periods
287 unsigned long int fsdp_get_period_count (const fsdp_description_t
* dsc
);
290 * Get the start time for the period selected by index.
292 * @param dsc SDP description object.
293 * @param index number of time period. Note that this index follows the
294 * traditional C convention: from 0 to fsdp_get_period_count() - 1.
296 * @retval 0 if an invalid index is provided.
299 fsdp_get_period_start (const fsdp_description_t
* dsc
, unsigned int index
);
302 * Get the stop time for the period selected by index.
304 * @param dsc SDP description object.
305 * @param index number of time period. Note that this index follows the
306 * traditional C convention: from 0 to fsdp_get_period_count() - 1.
308 * @retval 0 if an invalid index is provided.
311 fsdp_get_period_stop (const fsdp_description_t
* dsc
, unsigned int index
);
314 * Get the number of repeats for the period selected by index.
316 * @param dsc SDP description object.
317 * @param index number of the period. Note that this index follows the
318 * traditional C convention: from 0 to fsdp_get_period_count() - 1.
319 * @return number of repeats
320 * @retval 0 if an invalid index is provided.
323 fsdp_get_period_repeats_count (const fsdp_description_t
* dsc
,
327 * Get the interval time of the repeat selected by rindex for the
328 * period selected by index.
330 * @param dsc SDP description object.
331 * @param index number of time period. Note that this index follows the
332 * traditional C convention: from 0 to fsdp_get_period_count() - 1.
333 * @param rindex number of repeat
334 * @return interval time
335 * @retval 0 if an invalid index is provided.
338 fsdp_get_period_repeat_interval (const fsdp_description_t
* dsc
,
339 unsigned int index
, unsigned int rindex
);
342 * Get the duration of the repeat selected by rindex for the period
345 * @param dsc SDP description object.
346 * @param index number of time period. Note that this index follows the
347 * traditional C convention: from 0 to fsdp_get_period_count() - 1.
348 * @param rindex number of repeat
350 * @retval 0 if an invalid index is provided.
353 fsdp_get_period_repeat_duration (const fsdp_description_t
* dsc
,
354 unsigned int index
, unsigned int rindex
);
357 * Get the offsets of the repeat selected by rindex for the period
360 * @param dsc SDP description object.
361 * @param index number of time period. Note that this index follows the
362 * traditional C convention: from 0 to fsdp_get_period_count() - 1.
363 * @param rindex number of repeat
364 * @return array of offsets
365 * @retval NULL if an invalid index is provided.
367 const unsigned long int *fsdp_get_period_repeat_offsets (const
371 unsigned int rindex
);
374 * Get the encryption method defined for this session.
376 * @param dsc SDP description object.
377 * @return encryption method. FSDP_ENCRYPTION_METHOD_UNDEFINED if no
378 * encryption method is specified.
380 fsdp_encryption_method_t
381 fsdp_get_encryption_method (const fsdp_description_t
* dsc
);
384 * Get the encryption key or a URI pointing to the encryption key for
387 * @param dsc SDP description object.
388 * @return encryption key unless FSDP_ENCRYPTION_METHOD_URI is
389 * specified, in which case a URI pointing to the key is returned. If
390 * the global encryption method is undefined, NULL is returned.
392 const char *fsdp_get_encryption_content (const fsdp_description_t
* dsc
);
395 * Get timezone adjustments.
397 * @param dsc SDP description object.
398 * @return string with list of timezone adjustments
399 * @retval NULL if no timezone adjustment list was specified or there
402 const char *fsdp_get_timezone_adj (const fsdp_description_t
* dsc
);
408 fsdp_get_unidentified_attribute_count (const fsdp_description_t
* dsc
);
413 const char *fsdp_get_unidentified_attribute (const fsdp_description_t
* dsc
,
420 fsdp_get_media_rtpmap_count (const fsdp_media_description_t
* mdsc
);
425 const char *fsdp_get_media_rtpmap_payload_type (const fsdp_media_description_t
426 * mdsc
, unsigned int index
);
431 const char *fsdp_get_media_rtpmap_encoding_name (const
432 fsdp_media_description_t
*
433 mdsc
, unsigned int index
);
439 fsdp_get_media_rtpmap_clock_rate (const fsdp_media_description_t
* mdsc
,
445 const char *fsdp_get_media_rtpmap_encoding_parameters (const
451 * Get the value of the session attribute specified in
452 * <code>att</code>. This function works for all the session
453 * attributes whose value is a character string. These attributes are
454 * defined in the session_string_attribute_t enumerated type.
456 * @param dsc SDP description object.
457 * @param att attribute to get.
459 * @return value of the attribute <code>att</code>.
460 * @retval NULL if the attribute was not specified or there was a
461 * parse error or an invalid att is given.
463 const char *fsdp_get_str_att (const fsdp_description_t
* dsc
,
464 fsdp_session_str_att_t att
);
469 unsigned int fsdp_get_sdplang_count (const fsdp_description_t
* dsc
);
474 const char *fsdp_get_sdplang (const fsdp_description_t
* dsc
,
478 * Get the mode of the conference, specified with attributes sendrecv,
479 * sendonly, recvonly and inactive.
481 * @param dsc SDP description object.
482 * @return send/rec conference mode.
483 * @retval FSDP_SENDRECV_UNDEFINED if conference mode not provided.
485 fsdp_sendrecv_mode_t
fsdp_get_sendrecv_mode (const fsdp_description_t
* dsc
);
488 * Get the type of conference, such as broadcast, meeting, moderated,
491 * @param dsc SDP description object.
492 * @return conference type.
493 * @retval FSDP_SESSION_TYPE_UNDEFINED if conference type not provided.
495 fsdp_session_type_t
fsdp_get_session_type (const fsdp_description_t
* dsc
);
500 unsigned int fsdp_get_media_count (const fsdp_description_t
* dsc
);
505 const fsdp_media_description_t
*fsdp_get_media (const fsdp_description_t
*
506 dsc
, unsigned int index
);
511 fsdp_media_t
fsdp_get_media_type (const fsdp_media_description_t
* dsc
);
516 unsigned int fsdp_get_media_port (const fsdp_media_description_t
* dsc
);
518 unsigned int fsdp_get_media_port_count (const fsdp_media_description_t
* dsc
);
523 fsdp_transport_protocol_t
524 fsdp_get_media_transport_protocol (const fsdp_media_description_t
* dsc
);
529 const char *fsdp_get_media_formats (const fsdp_media_description_t
* dsc
);
535 fsdp_get_media_formats_count (const fsdp_media_description_t
* dsc
);
540 const char *fsdp_get_media_format (const fsdp_media_description_t
* dsc
,
546 const char *fsdp_get_media_title (const fsdp_media_description_t
* dsc
);
552 fsdp_get_media_network_type (const fsdp_media_description_t
* dsc
);
558 fsdp_get_media_address_type (const fsdp_media_description_t
* dsc
);
563 const char *fsdp_get_media_address (const fsdp_media_description_t
* dsc
);
566 fsdp_get_media_address_ttl (const fsdp_media_description_t
* mdsc
);
569 fsdp_get_media_address_count (const fsdp_media_description_t
* mdsc
);
574 fsdp_bw_modifier_type_t
575 fsdp_get_media_bw_modifier_type (const fsdp_media_description_t
* dsc
,
581 const char *fsdp_get_media_bw_modifier_type_unknown (const
582 fsdp_media_description_t
590 fsdp_get_media_bw_value (const fsdp_media_description_t
* dsc
,
596 fsdp_encryption_method_t
597 fsdp_get_media_encryption_method (const fsdp_media_description_t
* dsc
);
602 const char *fsdp_get_media_encryption_content (const fsdp_media_description_t
608 unsigned int fsdp_get_media_ptime (const fsdp_media_description_t
* dsc
);
613 unsigned int fsdp_get_media_maxptime (const fsdp_media_description_t
* dsc
);
619 fsdp_get_media_fmtp_count (const fsdp_media_description_t
* mdsc
);
624 const char *fsdp_get_media_fmtp (const fsdp_media_description_t
* mdsc
,
631 fsdp_get_media_sdplang_count (const fsdp_media_description_t
* dsc
);
636 const char *fsdp_get_media_sdplang (const fsdp_media_description_t
* dsc
,
642 unsigned int fsdp_get_media_lang_count (const fsdp_media_description_t
* dsc
);
647 const char *fsdp_get_media_lang (const fsdp_media_description_t
* dsc
,
651 unsigned int fsdp_get_control_count (const fsdp_description_t
* dsc
);
653 const char *fsdp_get_control (const fsdp_description_t
* dsc
,
656 const char *fsdp_get_range (const fsdp_description_t
* dsc
);
659 fsdp_get_media_control_count (const fsdp_media_description_t
* mdsc
);
661 char *fsdp_get_media_control (const fsdp_media_description_t
* mdsc
,
664 char *fsdp_get_media_range (const fsdp_media_description_t
* mdsc
);
669 fsdp_orient_t
fsdp_get_media_orient (const fsdp_media_description_t
* dsc
);
675 fsdp_get_media_sendrecv (const fsdp_media_description_t
* dsc
);
680 float fsdp_get_media_framerate (const fsdp_media_description_t
* dsc
);
685 unsigned int fsdp_get_media_quality (const fsdp_media_description_t
* dsc
);
690 unsigned int fsdp_get_media_rtcp_port (const fsdp_media_description_t
* dsc
);
696 fsdp_get_media_rtcp_network_type (const fsdp_media_description_t
* dsc
);
702 fsdp_get_media_rtcp_address_type (const fsdp_media_description_t
* dsc
);
707 const char *fsdp_get_media_rtcp_address (const fsdp_media_description_t
*
714 fsdp_get_media_unidentified_attribute_count (const fsdp_media_description_t
720 const char *fsdp_get_media_unidentified_attribute (const
721 fsdp_media_description_t
*
722 mdsc
, unsigned int index
);
725 /** @} *//* closes parser group */
728 #endif /* FSDP_PARSER_H */