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 Parsing module implementation.
29 * This file implements the parsing routine <code>fsdp_parse</code>
30 * and the <code>fsdp_get_xxxx</code> routines that allow to get the
31 * session properties from a session description object build through
32 * the application of <code>fsdp_parse</code> to a textual SDP session
36 #include "parserpriv.h"
39 * \brief find the start of the next line
40 * \param c pointer to current position in string
41 * \return pointer to start of next line or NULL if illegal (i.e.
42 * a '\r' is not followed by a '\n'
44 static const char *next_line(const char *c
) {
45 c
+= strcspn(c
, "\n\r");
46 if (*c
== 0) return c
;
54 * Moves the <code>c<code> pointer up to the beginning of the next
57 * @param c char pointer to pointer
58 * @retval FSDPE_ILLEGAL_CHARACTER, when an illegal '\r' character
59 * (not followed by a '\n') is found, returns
61 #define NEXT_LINE(c) do { if (!(c = next_line(c))) return FSDPE_ILLEGAL_CHARACTER; } while (0);
64 fsdp_parse (const char *text_description
, fsdp_description_t
* dsc
)
67 const char *p
= text_description
, *p2
;
69 /* temps for sscanf */
70 const unsigned int TEMPCHARS
= 6;
71 char fsdp_buf
[TEMPCHARS
][MAXSHORTFIELDLEN
];
72 char longfsdp_buf
[MAXLONGFIELDLEN
];
73 const unsigned int TEMPINTS
= 2;
74 unsigned long int wuint
[TEMPINTS
];
76 if ((NULL
== text_description
) || (NULL
== dsc
))
77 return FSDPE_INVALID_PARAMETER
;
79 /***************************************************************************/
80 /* A) parse session-level description */
81 /***************************************************************************/
83 /* `v=' line (protocol version) */
84 /* according to the RFC, only `v=0' is valid */
85 if (sscanf (p
, "v=%1lu", &wuint
[0]))
88 return FSDPE_INVALID_VERSION
;
92 return FSDPE_MISSING_VERSION
;
96 /* `o=' line (owner/creator and session identifier) */
97 /* o=<username> <session id> <version> <network type> <address type>
99 if (!strncmp (p
, "o=", 2))
102 /* note that the following max lengths may vary in the future and
103 are quite arbitary */
106 "%" MSFLENS
"[\x21-\xFF] %" MSFLENS
"[0-9] %" MSFLENS
107 "[0-9] %2s %3s %" MSFLENS
"s", fsdp_buf
[0], fsdp_buf
[1],
108 fsdp_buf
[2], fsdp_buf
[3], fsdp_buf
[4], fsdp_buf
[5]) != 6)
109 return FSDPE_INVALID_OWNER
;
110 dsc
->o_username
= strdup (fsdp_buf
[0]);
111 dsc
->o_session_id
= strdup (fsdp_buf
[1]);
112 dsc
->o_announcement_version
= strdup (fsdp_buf
[2]);
113 if (!strncmp (fsdp_buf
[3], "IN", 2))
115 dsc
->o_network_type
= FSDP_NETWORK_TYPE_INET
;
116 if (!strncmp (fsdp_buf
[4], "IP4", 3))
117 dsc
->o_address_type
= FSDP_ADDRESS_TYPE_IPV4
;
118 else if (!strncmp (fsdp_buf
[4], "IP6", 3))
119 dsc
->o_address_type
= FSDP_ADDRESS_TYPE_IPV6
;
121 return FSDPE_INVALID_OWNER
;
125 return FSDPE_INVALID_OWNER
;
127 /* TODO? check valid unicast address/FQDN */
128 dsc
->o_address
= strdup (fsdp_buf
[5]);
132 return FSDPE_MISSING_OWNER
;
136 /* `s=' line (session name) -note that the name string cannot be empty */
137 /* s=<session name> */
138 if (!strncmp (p
, "s=", 2))
140 if (sscanf (p
, "s=%" MLFLENS
"[^\r\n]", longfsdp_buf
) < 1)
141 return FSDPE_EMPTY_NAME
;
142 dsc
->s_name
= strdup (longfsdp_buf
);
146 return FSDPE_MISSING_NAME
;
150 /* `i=' line (session information) [optional] */
151 /* i=<session description> */
152 if (!strncmp (p
, "i=", 2)
153 && sscanf (p
, "i=%" MLFLENS
"[^\r\n]", longfsdp_buf
))
155 dsc
->i_information
= strdup (longfsdp_buf
);
160 /* (optional) information absent */
163 /* `u=' line (URI of description) [optional] */
165 if (!strncmp (p
, "u=", 2)
166 && sscanf (p
, "u=%" MLFLENS
"[^\r\n]", longfsdp_buf
))
168 /* TODO? check valid uri */
169 dsc
->u_uri
= strdup (longfsdp_buf
);
174 /* (optional) uri absent */
177 /* `e=' lines (email address) [zero or more] */
178 /* e=<email address> */
181 while (!strncmp (p2
, "e=", 2))
183 /* First, count how many emails are there */
187 dsc
->emails_count
= j
;
188 if (dsc
->emails_count
> 0)
190 /* Then, build the array of emails */
191 dsc
->emails
= calloc (j
, sizeof (const char *));
192 for (j
= 0; j
< dsc
->emails_count
; j
++)
194 sscanf (p
, "e=%" MLFLENS
"[^\r\n]", longfsdp_buf
);
195 /* TODO? check valid email-address. */
196 dsc
->emails
[j
] = strdup (longfsdp_buf
);
201 /* `p=' lines (phone number) [zero or more] */
202 /* p=<phone number> */
204 /* assert ( p2 == p ); */
205 while (!strncmp (p2
, "p=", 2))
210 dsc
->phones_count
= j
;
211 if (dsc
->phones_count
> 0)
213 dsc
->phones
= calloc (j
, sizeof (const char *));
214 for (j
= 0; j
< dsc
->phones_count
; j
++)
216 sscanf (p
, "p=%" MLFLENS
"[^\r\n]", longfsdp_buf
);
217 /* TODO? check valid phone-number. */
218 dsc
->phones
[j
] = strdup (longfsdp_buf
);
223 /* `c=' line (connection information - not required if included in all media) [optional] */
224 /* c=<network type> <address type> <connection address> */
225 result
= fsdp_parse_c (&p
, &(dsc
->c_network_type
), &(dsc
->c_address_type
),
227 if (FSDPE_OK
!= result
)
230 /* `b=' lines (bandwidth information) [optional] */
231 /* b=<modifier>:<bandwidth-value> */
233 fsdp_parse_b (&p
, &(dsc
->bw_modifiers
), &(dsc
->bw_modifiers_count
));
234 if (FSDPE_OK
!= result
)
237 /* A.1) Time descriptions: */
239 /* `t=' lines (time the session is active) [1 or more] */
240 /* t=<start time> <stop time> */
243 while (!strncmp (p2
, "t=", 2))
247 while (!strncmp (p2
, "r=", 2))
250 dsc
->time_periods_count
= j
;
251 if (dsc
->time_periods_count
== 0)
252 return FSDPE_MISSING_TIME
;
253 dsc
->time_periods
= calloc (dsc
->time_periods_count
,
254 sizeof (fsdp_time_period_t
*));
255 for (j
= 0; j
< dsc
->time_periods_count
; j
++)
258 if (sscanf (p
, "t=%10lu %10lu", &wuint
[0], &wuint
[1]) != 2)
260 /* not all periods have been successfully parsed */
261 dsc
->time_periods_count
= j
;
262 return FSDPE_INVALID_TIME
;
264 dsc
->time_periods
[j
] = calloc (1, sizeof (fsdp_time_period_t
));
266 /* convert from NTP to time_t time */
268 wuint
[0] -= NTP_EPOCH_OFFSET
;
270 wuint
[1] -= NTP_EPOCH_OFFSET
;
271 dsc
->time_periods
[j
]->start
= wuint
[0];
272 dsc
->time_periods
[j
]->stop
= wuint
[1];
275 /* `r' lines [zero or more repeat times for each t=] */
276 /*r=<repeat interval> <active duration> <list of offsets from
279 while (!strncmp (p2
, "r=", 2))
284 dsc
->time_periods
[j
]->repeats_count
= h
;
287 unsigned int index2
= 0;
288 dsc
->time_periods
[j
]->repeats
=
289 calloc (h
, sizeof (fsdp_repeat_t
*));
290 for (h
= 0; h
< dsc
->time_periods
[j
]->repeats_count
; h
++)
292 if (sscanf (p
, "r=%10s %10s %" MLFLENS
"[^\r\n]",
293 fsdp_buf
[0], fsdp_buf
[1], longfsdp_buf
) == 3)
295 fsdp_repeat_t
*repeat
;
296 dsc
->time_periods
[j
]->repeats
[h
] =
297 calloc (1, sizeof (fsdp_repeat_t
));
298 repeat
= dsc
->time_periods
[j
]->repeats
[h
];
299 /* get interval, duration and list of offsets */
301 fsdp_repeat_time_to_uint (fsdp_buf
[0],
302 &(repeat
->interval
));
303 if (result
== FSDPE_OK
)
306 fsdp_repeat_time_to_uint (fsdp_buf
[1],
307 &(repeat
->duration
));
308 if (result
== FSDPE_OK
)
311 const char *i
= longfsdp_buf
;
312 while (NULL
!= (i
= strchr (i
, ' ')))
318 repeat
->offsets_count
= k
;
319 repeat
->offsets
= calloc (k
, sizeof (time_t));
322 (k
< repeat
->offsets_count
)
323 && (result
== FSDPE_OK
); k
++)
326 fsdp_repeat_time_to_uint (i
,
333 if (k
< repeat
->offsets_count
)
335 /* there where invalid repeat offsets */
336 dsc
->time_periods
[j
]->repeats_count
= k
;
337 return FSDPE_INVALID_REPEAT
;
341 if (result
!= FSDPE_OK
)
343 /* not all repeats have been succesfully parsed */
344 dsc
->time_periods
[j
]->repeats_count
= h
;
345 return FSDPE_INVALID_REPEAT
;
351 /* not all repeats have been succesfully parsed */
352 dsc
->time_periods
[j
]->repeats_count
= h
;
353 return FSDPE_INVALID_REPEAT
;
360 /* `z=' line (time zone adjustments) [zero or more] */
361 /* z=<adjustment time> <offset> <adjustment time> <offset> .... */
362 if (!strncmp (p
, "z=", 2))
364 if (sscanf (p
, "z=%" MLFLENS
"[^\r\n]", longfsdp_buf
))
366 /* TODO: guess how many pairs are there and process them */
367 dsc
->timezone_adj
= strdup (longfsdp_buf
);
372 return FSDPE_INVALID_TIMEZONE
;
376 /* `k=' line (encryption key) [optional] */
378 k=<method>:<encryption key> */
379 result
= fsdp_parse_k (&p
, &(dsc
->k_encryption_method
),
380 &(dsc
->k_encryption_content
));
381 if (result
!= FSDPE_OK
)
384 /* A.2) Attributes */
385 /* `a=' lines (session attribute) [0 or more] */
387 a=<attribute>:<value> */
388 while (!strncmp (p
, "a=", 2))
390 /* The "9" length specifier of the first string is subject to
393 (p
, "a=%9[^:\r\n]:%" MSFLENS
"[^\r\n]", fsdp_buf
[0],
396 /* session-level value attributes */
397 if (!strncmp (fsdp_buf
[0], "cat", 3))
398 dsc
->a_category
= strdup (fsdp_buf
[1]);
399 else if (!strncmp (fsdp_buf
[0], "keywds", 6))
400 dsc
->a_keywords
= strdup (fsdp_buf
[1]);
401 else if (!strncmp (fsdp_buf
[0], "tool", 4))
402 dsc
->a_keywords
= strdup (fsdp_buf
[1]);
403 else if (!strncmp (fsdp_buf
[0], "rtpmap", 6))
404 fsdp_parse_rtpmap (&(dsc
->a_rtpmaps
),
405 &(dsc
->a_rtpmaps_count
), fsdp_buf
[1]);
406 else if (!strncmp (fsdp_buf
[0], "type", 4))
408 if (!strncmp (fsdp_buf
[1], "broadcast", 9))
409 dsc
->a_type
= FSDP_SESSION_TYPE_BROADCAST
;
410 else if (!strncmp (fsdp_buf
[1], "meeting", 7))
411 dsc
->a_type
= FSDP_SESSION_TYPE_MEETING
;
412 else if (!strncmp (fsdp_buf
[1], "moderated", 9))
413 dsc
->a_type
= FSDP_SESSION_TYPE_MODERATED
;
414 else if (!strncmp (fsdp_buf
[1], "test", 4))
415 dsc
->a_type
= FSDP_SESSION_TYPE_TEST
;
416 else if (!strncmp (fsdp_buf
[1], "H332", 4))
417 dsc
->a_type
= FSDP_SESSION_TYPE_H332
;
419 return FSDPE_INVALID_SESSION_TYPE
;
421 else if (!strncmp (fsdp_buf
[0], "charset", 7))
422 dsc
->a_charset
= strdup (fsdp_buf
[1]);
423 else if (!strncmp (fsdp_buf
[0], "sdplang", 7))
425 if (NULL
== dsc
->a_sdplangs
)
427 dsc
->a_sdplangs_count
= 0;
429 calloc (SDPLANGS_MAX_COUNT
, sizeof (char *));
431 if (dsc
->a_sdplangs_count
< SDPLANGS_MAX_COUNT
)
433 dsc
->a_sdplangs
[dsc
->a_sdplangs_count
] =
434 strdup (fsdp_buf
[1]);
435 dsc
->a_sdplangs_count
++;
438 else if (!strncmp (fsdp_buf
[0], "lang", 4))
440 if (NULL
== dsc
->a_langs
)
442 dsc
->a_langs_count
= 0;
443 dsc
->a_langs
= calloc (SDPLANGS_MAX_COUNT
, sizeof (char *));
445 if (dsc
->a_langs_count
< SDPLANGS_MAX_COUNT
)
447 dsc
->a_langs
[dsc
->a_langs_count
] = strdup (fsdp_buf
[1]);
448 dsc
->a_langs_count
++;
451 else if (!strncmp (fsdp_buf
[0], "control", 7))
453 if (NULL
== dsc
->a_controls
)
455 dsc
->a_controls_count
= 0;
457 calloc (SDPCONTROLS_MAX_COUNT
, sizeof (char *));
459 if (dsc
->a_controls_count
< SDPCONTROLS_MAX_COUNT
)
461 dsc
->a_controls
[dsc
->a_controls_count
] =
462 strdup (fsdp_buf
[1]);
463 dsc
->a_controls_count
++;
466 else if (!strncmp (fsdp_buf
[0], "range", 5))
469 dsc
->a_range
= strdup (fsdp_buf
[1]);
473 /* ignore unknown attributes, but provide access to them */
474 *longfsdp_buf
= '\0';
475 strncat (longfsdp_buf
, fsdp_buf
[0], MAXLONGFIELDLEN
-1);
476 strncat (longfsdp_buf
, ":", MAXLONGFIELDLEN
-strlen(longfsdp_buf
)-1);
477 strncat (longfsdp_buf
, fsdp_buf
[1], MAXLONGFIELDLEN
-strlen(longfsdp_buf
)-1);
478 if (NULL
== dsc
->unidentified_attributes
)
480 dsc
->unidentified_attributes_count
= 0;
481 dsc
->unidentified_attributes
=
482 calloc (UNIDENTIFIED_ATTRIBUTES_MAX_COUNT
,
485 if (dsc
->unidentified_attributes_count
<
486 UNIDENTIFIED_ATTRIBUTES_MAX_COUNT
)
488 dsc
->unidentified_attributes
489 [dsc
->unidentified_attributes_count
] =
490 strdup (longfsdp_buf
);
491 dsc
->unidentified_attributes_count
++;
496 else if (sscanf (p
, "a=%20s", fsdp_buf
[0]) == 1)
498 /* session-level property attributes */
499 if (!strncmp (fsdp_buf
[0], "recvonly", 8))
500 dsc
->a_sendrecv_mode
= FSDP_SENDRECV_RECVONLY
;
501 else if (!strncmp (fsdp_buf
[0], "sendonly", 8))
502 dsc
->a_sendrecv_mode
= FSDP_SENDRECV_SENDONLY
;
503 else if (!strncmp (fsdp_buf
[0], "inactive", 8))
504 dsc
->a_sendrecv_mode
= FSDP_SENDRECV_INACTIVE
;
505 else if (!strncmp (fsdp_buf
[0], "sendrecv", 8))
506 dsc
->a_sendrecv_mode
= FSDP_SENDRECV_SENDRECV
;
509 /* ignore unknown attributes, but provide access to them */
510 *longfsdp_buf
= '\0';
511 strncat (longfsdp_buf
, fsdp_buf
[0], MAXLONGFIELDLEN
-1);
512 if (NULL
== dsc
->unidentified_attributes
)
514 dsc
->unidentified_attributes_count
= 0;
515 dsc
->unidentified_attributes
=
516 calloc (UNIDENTIFIED_ATTRIBUTES_MAX_COUNT
,
519 if (dsc
->unidentified_attributes_count
<
520 UNIDENTIFIED_ATTRIBUTES_MAX_COUNT
)
522 dsc
->unidentified_attributes
523 [dsc
->unidentified_attributes_count
] =
524 strdup (longfsdp_buf
);
525 dsc
->unidentified_attributes_count
++;
531 return FSDPE_INVALID_ATTRIBUTE
;
534 /***************************************************************************/
535 /* B) parse media-level descriptions */
536 /***************************************************************************/
539 while ((*p2
!= '\0') && !strncmp (p2
, "m=", 2))
544 while (sscanf (p2
, "%c=", &c
) == 1)
546 if (c
== 'i' || c
== 'c' || c
== 'b' || c
== 'k' || c
== 'a')
556 return FSDPE_INVALID_LINE
;
560 dsc
->media_announcements_count
= j
;
561 if (dsc
->media_announcements_count
== 0)
564 /*return FSDPE_MISSING_MEDIA; */
567 { /* dsc->media_announcements_count > 0 */
568 dsc
->media_announcements
=
569 calloc (j
, sizeof (fsdp_media_announcement_t
*));
570 for (j
= 0; j
< dsc
->media_announcements_count
; j
++)
572 fsdp_media_announcement_t
*media
= NULL
;
573 /* `m=' line (media name, transport address and format list) */
574 /* m=<media> <port> <transport> <fmt list> */
575 /* The max. string lengths are subject to change */
576 if (sscanf (p
, "m=%11s %8s %7s %" MLFLENS
"[^\r\n]",
577 fsdp_buf
[0], fsdp_buf
[1], fsdp_buf
[2],
580 return FSDPE_INVALID_MEDIA
;
584 dsc
->media_announcements
[j
] =
585 calloc (1, sizeof (fsdp_media_announcement_t
));
586 media
= dsc
->media_announcements
[j
];
587 if (!strncmp (fsdp_buf
[0], "audio", 5))
588 media
->media_type
= FSDP_MEDIA_AUDIO
;
589 else if (!strncmp (fsdp_buf
[0], "video", 5))
590 media
->media_type
= FSDP_MEDIA_VIDEO
;
591 else if (!strncmp (fsdp_buf
[0], "application", 11))
592 media
->media_type
= FSDP_MEDIA_APPLICATION
;
593 else if (!strncmp (fsdp_buf
[0], "data", 4))
594 media
->media_type
= FSDP_MEDIA_DATA
;
595 else if (!strncmp (fsdp_buf
[0], "control", 7))
596 media
->media_type
= FSDP_MEDIA_CONTROL
;
598 return FSDPE_UNKNOWN_MEDIA_TYPE
;
599 { /* try to get port specification as port/number */
601 if ((slash
= strchr (fsdp_buf
[1], '/')))
605 media
->port
= strtol (fsdp_buf
[1], NULL
, 10);
606 media
->port_count
= strtol (slash
, NULL
, 10);
610 media
->port
= strtol (fsdp_buf
[1], NULL
, 10);
611 media
->port_count
= 0;
614 if (!strncmp (fsdp_buf
[2], "RTP/AVP", 7))
615 media
->transport
= FSDP_TP_RTP_AVP
;
616 else if (!strncmp (fsdp_buf
[2], "udp", 3))
617 media
->transport
= FSDP_TP_UDP
;
618 else if (!strncmp (fsdp_buf
[2], "TCP", 3))
619 media
->transport
= FSDP_TP_TCP
;
620 else if (!strncmp (fsdp_buf
[2], "UDPTL", 5))
621 media
->transport
= FSDP_TP_UDPTL
;
622 else if (!strncmp (fsdp_buf
[2], "vat", 3))
623 media
->transport
= FSDP_TP_VAT
;
624 else if (!strncmp (fsdp_buf
[2], "rtp", 3))
625 media
->transport
= FSDP_TP_OLD_RTP
;
627 return FSDPE_UNKNOWN_MEDIA_TRANSPORT
;
630 char *s
= longfsdp_buf
;
631 while (NULL
!= (s
= strchr (s
, ' ')))
637 k
++; /* when there is no space left, count the last format */
638 media
->formats_count
= k
;
639 media
->formats
= calloc (k
, sizeof (char *));
641 for (k
= 0; k
< media
->formats_count
; k
++)
643 char *space
= strchr (s
, ' ');
646 media
->formats
[k
] = strdup (s
);
653 /* `i=' line (media title) [optional] */
654 /* i=<media title> */
655 if (!strncmp (p
, "i=", 2)
656 && sscanf (p
, "i=%" MLFLENS
"[^\r\n]", longfsdp_buf
))
658 media
->i_title
= strdup (longfsdp_buf
);
663 /* (optional) information absent */
666 /* `c=' line (connection information - overrides session-level
667 line) [optional if provided at session-level] */
668 /* c=<network type> <address type> <connection address> */
669 result
= fsdp_parse_c (&p
, &(media
->c_network_type
),
670 &(media
->c_address_type
),
671 &(media
->c_address
));
672 if (result
!= FSDPE_OK
)
675 /* `b=' lines (bandwidth information) [optional] */
676 /* b=<modifier>:<bandwidth-value> */
677 result
= fsdp_parse_b (&p
, &(media
->bw_modifiers
),
678 &(media
->bw_modifiers_count
));
679 if (FSDPE_OK
!= result
)
682 /* `k=' line (encryption key) [optional] */
684 k=<method>:<encryption key> */
685 result
= fsdp_parse_k (&p
, &(media
->k_encryption_method
),
686 &(media
->k_encryption_content
));
687 if (result
!= FSDPE_OK
)
690 /* B.1) Attributes */
692 /* `a=' lines (zero or more media attribute lines) [optional] */
694 a=<attribute>:<value> */
695 while (!strncmp (p
, "a=", 2))
698 (p
, "a=%9[^:\r\n]:%" MLFLENS
"[^\r\n]", fsdp_buf
[0],
701 /* media-level value attributes */
702 if (!strncmp (fsdp_buf
[0], "ptime", 5))
703 media
->a_ptime
= strtoul (longfsdp_buf
, NULL
, 10);
704 else if (!strncmp (fsdp_buf
[0], "maxptime", 8))
705 media
->a_maxptime
= strtoul (longfsdp_buf
, NULL
, 10);
706 else if (!strncmp (fsdp_buf
[0], "rtpmap", 6))
707 fsdp_parse_rtpmap (&(media
->a_rtpmaps
),
708 &(media
->a_rtpmaps_count
),
710 else if (!strncmp (fsdp_buf
[0], "orient", 6))
712 if (!strncmp (longfsdp_buf
, "portrait", 8))
713 media
->a_orient
= FSDP_ORIENT_PORTRAIT
;
714 else if (!strncmp (longfsdp_buf
, "landscape", 9))
715 media
->a_orient
= FSDP_ORIENT_LANDSCAPE
;
716 else if (!strncmp (longfsdp_buf
, "seascape", 9))
717 media
->a_orient
= FSDP_ORIENT_SEASCAPE
;
719 else if (!strncmp (fsdp_buf
[0], "sdplang", 7))
721 if (NULL
== dsc
->a_sdplangs
)
723 media
->a_sdplangs_count
= 0;
725 calloc (SDPLANGS_MAX_COUNT
, sizeof (char *));
727 if (media
->a_sdplangs_count
< SDPLANGS_MAX_COUNT
)
729 media
->a_sdplangs
[dsc
->a_sdplangs_count
] =
730 strdup (longfsdp_buf
);
731 media
->a_sdplangs_count
++;
734 else if (!strncmp (fsdp_buf
[0], "lang", 4))
736 if (NULL
== dsc
->a_langs
)
738 media
->a_langs_count
= 0;
740 calloc (SDPLANGS_MAX_COUNT
, sizeof (char *));
742 if (media
->a_langs_count
< SDPLANGS_MAX_COUNT
)
744 media
->a_langs
[dsc
->a_langs_count
] =
745 strdup (longfsdp_buf
);
746 media
->a_langs_count
++;
749 else if (!strncmp (fsdp_buf
[0], "control", 7))
751 if (NULL
== media
->a_controls
)
753 media
->a_controls_count
= 0;
755 calloc (SDPCONTROLS_MAX_COUNT
, sizeof (char *));
757 if (media
->a_controls_count
< SDPCONTROLS_MAX_COUNT
)
759 media
->a_controls
[media
->a_controls_count
] =
760 strdup (longfsdp_buf
);
761 media
->a_controls_count
++;
764 else if (!strncmp (fsdp_buf
[0], "range", 5))
766 free (media
->a_range
);
767 media
->a_range
= strdup (fsdp_buf
[1]);
769 else if (!strncmp (fsdp_buf
[0], "framerate", 9))
770 media
->a_framerate
= strtod (longfsdp_buf
, NULL
);
771 else if (!strncmp (fsdp_buf
[0], "fmtp", 4))
773 if (NULL
== media
->a_fmtps
)
775 media
->a_fmtps_count
= 0;
777 calloc (SDPLANGS_MAX_COUNT
, sizeof (char *));
779 if (media
->a_fmtps_count
< SDPLANGS_MAX_COUNT
)
781 media
->a_fmtps
[media
->a_fmtps_count
] =
782 strdup (longfsdp_buf
);
783 media
->a_fmtps_count
++;
786 else if (!strncmp (fsdp_buf
[0], "rtcp", 4))
789 /* rtcp attribute: a=rtcp:<port> <nettype> <addrtype> <address> */
791 sscanf (longfsdp_buf
, "%lu %2s %3s %" MSFLENS
"s",
792 &wuint
[0], fsdp_buf
[0], fsdp_buf
[1],
796 media
->a_rtcp_port
= wuint
[0];
799 if (!strncmp (fsdp_buf
[0], "IN", 2))
801 media
->a_rtcp_network_type
=
802 FSDP_NETWORK_TYPE_INET
;
804 ; TODO: define error code? */
807 if (!strncmp (fsdp_buf
[1], "IP4", 3))
808 media
->a_rtcp_address_type
=
809 FSDP_ADDRESS_TYPE_IPV4
;
810 else if (!strncmp (fsdp_buf
[1], "IP6", 3))
811 media
->a_rtcp_address_type
=
812 FSDP_ADDRESS_TYPE_IPV6
;
814 return FSDPE_INVALID_CONNECTION_NETTYPE
;
815 /*add specific code? */
817 media
->a_rtcp_address
=
818 strdup (fsdp_buf
[2]);
825 /* ignore unknown attributes, but provide access to them */
827 strncat (fsdp_buf
[1], fsdp_buf
[0], MAXSHORTFIELDLEN
-1);
828 strncat (fsdp_buf
[1], ":", MAXSHORTFIELDLEN
-strlen(fsdp_buf
[1])-1);
829 strncat (fsdp_buf
[1], longfsdp_buf
, MAXSHORTFIELDLEN
-strlen(fsdp_buf
[1])-1);
830 if (NULL
== media
->unidentified_attributes
)
832 media
->unidentified_attributes_count
= 0;
833 media
->unidentified_attributes
=
834 calloc (UNIDENTIFIED_ATTRIBUTES_MAX_COUNT
,
837 if (media
->unidentified_attributes_count
<
838 UNIDENTIFIED_ATTRIBUTES_MAX_COUNT
)
840 media
->unidentified_attributes
841 [media
->unidentified_attributes_count
] =
842 strdup (fsdp_buf
[1]);
843 media
->unidentified_attributes_count
++;
848 else if (sscanf (p
, "a=%8s", fsdp_buf
[0]) == 1)
850 /* media-level property attributes */
851 if (!strncmp (fsdp_buf
[0], "recvonly", 8))
852 media
->a_sendrecv_mode
= FSDP_SENDRECV_RECVONLY
;
853 else if (!strncmp (fsdp_buf
[0], "sendonly", 8))
854 media
->a_sendrecv_mode
= FSDP_SENDRECV_SENDONLY
;
855 else if (!strncmp (fsdp_buf
[0], "inactive", 8))
856 media
->a_sendrecv_mode
= FSDP_SENDRECV_INACTIVE
;
857 else if (!strncmp (fsdp_buf
[0], "sendrecv", 8))
858 media
->a_sendrecv_mode
= FSDP_SENDRECV_SENDRECV
;
861 /* ignore unknown attributes, but provide access to them */
862 *longfsdp_buf
= '\0';
863 strncat (longfsdp_buf
, fsdp_buf
[0], MAXLONGFIELDLEN
-1);
864 if (NULL
== media
->unidentified_attributes
)
866 media
->unidentified_attributes_count
= 0;
867 media
->unidentified_attributes
=
868 calloc (UNIDENTIFIED_ATTRIBUTES_MAX_COUNT
,
871 if (media
->unidentified_attributes_count
<
872 UNIDENTIFIED_ATTRIBUTES_MAX_COUNT
)
874 media
->unidentified_attributes
875 [media
->unidentified_attributes_count
] =
876 strdup (longfsdp_buf
);
877 media
->unidentified_attributes_count
++;
883 return FSDPE_INVALID_ATTRIBUTE
;
888 /* Check c= has been given at session level or at media level for
890 if (NULL
== dsc
->c_address
.address
)
893 for (c
= 0; c
< dsc
->media_announcements_count
; c
++)
894 if (NULL
== dsc
->media_announcements
[c
]->c_address
.address
)
895 return FSDPE_MISSING_CONNECTION_INFO
;
902 return FSDPE_OVERFILLED
;
906 fsdp_parse_c (const char **p
, fsdp_network_type_t
* ntype
,
907 fsdp_address_type_t
* atype
,
908 fsdp_connection_address_t
* address
)
910 const unsigned int TEMPCHARS
= 3;
911 char fsdp_buf
[TEMPCHARS
][MAXSHORTFIELDLEN
];
913 if (!strncmp (*p
, "c=", 2))
915 if (sscanf (*p
, "c=%2s %3s %" MSFLENS
"s",
916 fsdp_buf
[0], fsdp_buf
[1], fsdp_buf
[2]))
918 if (!strncmp (fsdp_buf
[0], "IN", 2))
920 *ntype
= FSDP_NETWORK_TYPE_INET
;
921 if (!strncmp (fsdp_buf
[1], "IP4", 3))
922 *atype
= FSDP_ADDRESS_TYPE_IPV4
;
923 else if (!strncmp (fsdp_buf
[1], "IP6", 3))
924 *atype
= FSDP_ADDRESS_TYPE_IPV6
;
926 return FSDPE_INVALID_CONNECTION_NETTYPE
;
930 return FSDPE_INVALID_CONNECTION_ADDRTYPE
;
933 char *slash
= strchr (fsdp_buf
[2], '/');
936 address
->address
= strdup (fsdp_buf
[2]);
937 address
->address_ttl
= 0;
938 address
->address_count
= 0;
942 /* address is IP4 multicast */
946 address
->address
= strdup (fsdp_buf
[2]);
947 slash2
= strchr (slash
+ 1, '/');
950 address
->address_ttl
= strtol (slash
, NULL
, 10);
951 address
->address_count
= 0;
957 address
->address_ttl
= strtol (slash
, NULL
, 10);
958 address
->address_count
= strtol (slash2
, NULL
, 10);
966 return FSDPE_INVALID_CONNECTION
;
973 fsdp_parse_b (const char **p
, fsdp_bw_modifier_t
** bw_modifiers
,
974 unsigned int *bw_modifiers_count
)
976 char fsdp_buf
[MAXSHORTFIELDLEN
];
977 unsigned long int wuint
;
982 while (!strncmp (lp
, "b=", 2))
987 *bw_modifiers
= calloc (i
, sizeof (fsdp_bw_modifier_t
));
988 *bw_modifiers_count
= i
;
992 unsigned int index
= *bw_modifiers_count
- i
;
993 if (2 == sscanf (*p
, "b=%20[^:\r\n]:%lu", fsdp_buf
, &wuint
))
995 if (!strncmp (fsdp_buf
, "CT", 2))
996 (*bw_modifiers
)[index
].b_mod_type
=
997 FSDP_BW_MOD_TYPE_CONFERENCE_TOTAL
;
998 else if (!strncmp (fsdp_buf
, "AS", 2))
999 (*bw_modifiers
)[index
].b_mod_type
=
1000 FSDP_BW_MOD_TYPE_APPLICATION_SPECIFIC
;
1001 else if (!strncmp (fsdp_buf
, "RS", 2))
1002 (*bw_modifiers
)[index
].b_mod_type
= FSDP_BW_MOD_TYPE_RTCP_SENDERS
;
1003 else if (!strncmp (fsdp_buf
, "RR", 2))
1004 (*bw_modifiers
)[index
].b_mod_type
=
1005 FSDP_BW_MOD_TYPE_RTCP_RECEIVERS
;
1008 (*bw_modifiers
)[index
].b_mod_type
= FSDP_BW_MOD_TYPE_UNKNOWN
;
1009 (*bw_modifiers
)[index
].b_unknown_bw_modt
=
1010 (char *) strdup (fsdp_buf
);
1012 (*bw_modifiers
)[index
].b_value
= wuint
;
1017 *bw_modifiers_count
-= i
;
1018 return FSDPE_INVALID_BANDWIDTH
;
1026 fsdp_parse_k (const char **p
, fsdp_encryption_method_t
* method
,
1029 char fsdp_buf
[MAXSHORTFIELDLEN
];
1030 char longfsdp_buf
[MAXLONGFIELDLEN
];
1032 if (!strncmp (*p
, "k=", 2))
1034 if (sscanf (*p
, "k=prompt"))
1036 *method
= FSDP_ENCRYPTION_METHOD_PROMPT
;
1043 (*p
, "k=%6[^:\r\n]:%" MLFLENS
"s", fsdp_buf
, longfsdp_buf
))
1045 if (!strncmp (fsdp_buf
, "clear", 5))
1046 *method
= FSDP_ENCRYPTION_METHOD_CLEAR
;
1047 else if (!strncmp (fsdp_buf
, "base64", 6))
1048 *method
= FSDP_ENCRYPTION_METHOD_BASE64
;
1049 else if (!strncmp (fsdp_buf
, "uri", 3))
1050 *method
= FSDP_ENCRYPTION_METHOD_URI
;
1052 return FSDPE_INVALID_ENCRYPTION_METHOD
;
1053 *content
= strdup (longfsdp_buf
);
1062 fsdp_parse_rtpmap (fsdp_rtpmap_t
*** rtpmap
, unsigned int *counter
,
1065 fsdp_error_t result
= FSDPE_OK
;
1070 *rtpmap
= calloc (MEDIA_RTPMAPS_MAX_COUNT
, sizeof (fsdp_rtpmap_t
*));
1072 if (*counter
< MEDIA_RTPMAPS_MAX_COUNT
)
1074 unsigned int c
= *counter
;
1075 fsdp_rtpmap_t
**map
= *rtpmap
;
1076 char fsdp_buf
[MAXSHORTFIELDLEN
];
1077 char longfsdp_buf
[MAXLONGFIELDLEN
];
1078 map
[c
] = calloc (1, sizeof (fsdp_rtpmap_t
));
1080 /* a=rtpmap:<payload type> <encoding name>/<clock rate>[/<encoding
1082 if (2 == sscanf (value
, "%s %s", fsdp_buf
, longfsdp_buf
))
1085 map
[c
]->pt
= strdup (fsdp_buf
);
1086 /* parse <encoding name>/<clock rate>[/<encoding parameters>] */
1087 slash1
= strchr (longfsdp_buf
, '/');
1090 result
= FSDPE_INVALID_ATTRIBUTE_RTPMAP
;
1097 map
[c
]->encoding_name
= strdup (longfsdp_buf
);
1098 slash2
= strchr (slash1
, '/');
1103 map
[c
]->parameters
= strdup (slash2
);
1105 map
[c
]->clock_rate
= strtol (slash1
, NULL
, 10);
1114 fsdp_repeat_time_to_uint (const char *time
, unsigned long int *seconds
)
1116 const unsigned long SECONDS_PER_DAY
= 86400;
1117 const unsigned long SECONDS_PER_HOUR
= 3600;
1118 const unsigned long SECONDS_PER_MINUTE
= 60;
1120 unsigned long int wuint
;
1122 if (sscanf (time
, "%lu%c", &wuint
, &c
) == 2)
1124 /* time with unit specification character */
1128 *seconds
= wuint
* SECONDS_PER_DAY
;
1131 *seconds
= wuint
* SECONDS_PER_HOUR
;
1134 *seconds
= wuint
* SECONDS_PER_MINUTE
;
1140 return FSDPE_INVALID_REPEAT
;
1144 else if (sscanf (time
, "%lu", &wuint
) == 1)
1146 /* time without unit specification character */
1151 return FSDPE_INVALID_REPEAT
;
1157 fsdp_get_version (const fsdp_description_t
* dsc
)
1161 return dsc
->version
;
1165 fsdp_get_owner_username (const fsdp_description_t
* dsc
)
1169 return dsc
->o_username
;
1173 fsdp_get_session_id (const fsdp_description_t
* dsc
)
1177 return dsc
->o_session_id
;
1181 fsdp_get_announcement_version (const fsdp_description_t
* dsc
)
1185 return dsc
->o_announcement_version
;
1189 fsdp_get_owner_network_type (const fsdp_description_t
* dsc
)
1192 return FSDP_NETWORK_TYPE_UNDEFINED
;
1193 return dsc
->o_network_type
;
1197 fsdp_get_owner_address_type (const fsdp_description_t
* dsc
)
1200 return FSDP_ADDRESS_TYPE_UNDEFINED
;
1201 return dsc
->o_address_type
;
1205 fsdp_get_owner_address (const fsdp_description_t
* dsc
)
1209 return dsc
->o_address
;
1213 fsdp_get_name (const fsdp_description_t
* dsc
)
1221 fsdp_get_information (const fsdp_description_t
* dsc
)
1225 return dsc
->i_information
;
1229 fsdp_get_uri (const fsdp_description_t
* dsc
)
1237 fsdp_get_emails_count (const fsdp_description_t
* dsc
)
1241 return dsc
->emails_count
;
1245 fsdp_get_email (const fsdp_description_t
* dsc
, unsigned int index
)
1247 if ((!dsc
) || (index
>= dsc
->emails_count
))
1249 return dsc
->emails
[index
];
1253 fsdp_get_phones_count (const fsdp_description_t
* dsc
)
1257 return dsc
->phones_count
;
1261 fsdp_get_phone (const fsdp_description_t
* dsc
, unsigned int index
)
1263 if ((!dsc
) || (index
>= dsc
->phones_count
))
1265 return dsc
->phones
[index
];
1269 fsdp_get_global_conn_network_type (const fsdp_description_t
* dsc
)
1272 return FSDP_NETWORK_TYPE_UNDEFINED
;
1273 return dsc
->c_network_type
;
1277 fsdp_get_global_conn_address_type (const fsdp_description_t
* dsc
)
1280 return FSDP_ADDRESS_TYPE_UNDEFINED
;
1281 return dsc
->c_address_type
;
1285 fsdp_get_global_conn_address (const fsdp_description_t
* dsc
)
1289 return dsc
->c_address
.address
;
1293 fsdp_get_global_conn_address_ttl (const fsdp_description_t
* dsc
)
1297 return dsc
->c_address
.address_ttl
;
1301 fsdp_get_global_conn_address_count (const fsdp_description_t
* dsc
)
1305 return dsc
->c_address
.address_count
;
1309 fsdp_get_bw_modifier_count (const fsdp_description_t
* dsc
)
1313 return dsc
->bw_modifiers_count
;
1316 fsdp_bw_modifier_type_t
1317 fsdp_get_bw_modifier_type (const fsdp_description_t
* dsc
, unsigned int index
)
1319 if ((!dsc
) || (index
>= dsc
->bw_modifiers_count
))
1320 return FSDP_BW_MOD_TYPE_UNDEFINED
;
1321 return dsc
->bw_modifiers
[index
].b_mod_type
;
1325 fsdp_get_bw_modifier_type_unknown (const fsdp_description_t
* dsc
,
1328 if ((!dsc
) || (index
>= dsc
->bw_modifiers_count
) ||
1329 (dsc
->bw_modifiers
[index
].b_mod_type
!= FSDP_BW_MOD_TYPE_UNKNOWN
))
1331 return dsc
->bw_modifiers
[index
].b_unknown_bw_modt
;
1335 fsdp_get_bw_value (const fsdp_description_t
* dsc
, unsigned int index
)
1337 if ((!dsc
) || (index
>= dsc
->bw_modifiers_count
))
1339 return dsc
->bw_modifiers
[index
].b_value
;
1343 fsdp_get_period_start (const fsdp_description_t
* dsc
, unsigned int index
)
1345 if ((!dsc
) || (index
>= dsc
->time_periods_count
))
1347 return dsc
->time_periods
[index
]->start
;
1351 fsdp_get_period_stop (const fsdp_description_t
* dsc
, unsigned int index
)
1353 if ((!dsc
) || (index
>= dsc
->time_periods_count
))
1355 return dsc
->time_periods
[index
]->stop
;
1359 fsdp_get_period_repeats_count (const fsdp_description_t
* dsc
,
1362 if ((!dsc
) || (index
>= dsc
->time_periods_count
))
1364 return dsc
->time_periods
[index
]->repeats_count
;
1368 fsdp_get_period_repeat_interval (const fsdp_description_t
* dsc
,
1369 unsigned int index
, unsigned int rindex
)
1371 if ((!dsc
) || (index
>= dsc
->time_periods_count
))
1373 return dsc
->time_periods
[index
]->repeats
[rindex
]->interval
;
1377 fsdp_get_period_repeat_duration (const fsdp_description_t
* dsc
,
1378 unsigned int index
, unsigned int rindex
)
1380 if ((!dsc
) || (index
>= dsc
->time_periods_count
))
1382 return dsc
->time_periods
[index
]->repeats
[rindex
]->duration
;
1385 const unsigned long int *
1386 fsdp_get_period_repeat_offsets (const fsdp_description_t
* dsc
,
1387 unsigned int index
, unsigned int rindex
)
1389 if ((!dsc
) || (index
>= dsc
->time_periods_count
))
1391 return dsc
->time_periods
[index
]->repeats
[rindex
]->offsets
;
1395 fsdp_get_timezone_adj (const fsdp_description_t
* dsc
)
1399 return dsc
->timezone_adj
;
1403 fsdp_get_unidentified_attribute_count (const fsdp_description_t
* dsc
)
1407 return dsc
->unidentified_attributes_count
;
1411 fsdp_get_unidentified_attribute (const fsdp_description_t
* dsc
,
1414 if (!dsc
|| (index
< dsc
->unidentified_attributes_count
))
1416 return dsc
->unidentified_attributes
[index
];
1419 fsdp_encryption_method_t
1420 fsdp_get_encryption_method (const fsdp_description_t
* dsc
)
1423 return FSDP_ENCRYPTION_METHOD_UNDEFINED
;
1424 return dsc
->k_encryption_method
;
1428 fsdp_get_encryption_content (const fsdp_description_t
* dsc
)
1430 if (!dsc
|| (dsc
->k_encryption_method
== FSDP_ENCRYPTION_METHOD_UNDEFINED
))
1432 return dsc
->k_encryption_content
;
1436 fsdp_get_str_att (const fsdp_description_t
* dsc
, fsdp_session_str_att_t att
)
1438 /*TODO: change these individual attributes with a table, thus
1439 avoiding this slow switch */
1447 case FSDP_SESSION_STR_ATT_CATEGORY
:
1448 result
= dsc
->a_category
;
1450 case FSDP_SESSION_STR_ATT_KEYWORDS
:
1451 result
= dsc
->a_keywords
;
1453 case FSDP_SESSION_STR_ATT_TOOL
:
1454 result
= dsc
->a_tool
;
1456 case FSDP_SESSION_STR_ATT_CHARSET
:
1457 result
= dsc
->a_charset
;
1466 fsdp_get_sdplang_count (const fsdp_description_t
* dsc
)
1470 return dsc
->a_sdplangs_count
;
1474 fsdp_get_sdplang (const fsdp_description_t
* dsc
, unsigned int index
)
1476 if ((!dsc
) || (index
>= dsc
->a_sdplangs_count
))
1478 return dsc
->a_sdplangs
[index
];
1482 fsdp_get_control_count (const fsdp_description_t
* dsc
)
1486 return dsc
->a_controls_count
;
1490 fsdp_get_control (const fsdp_description_t
* dsc
, unsigned int index
)
1492 if ((!dsc
) || (index
>= dsc
->a_controls_count
))
1494 return dsc
->a_controls
[index
];
1498 fsdp_get_range (const fsdp_description_t
* dsc
)
1500 return dsc
->a_range
;
1503 fsdp_sendrecv_mode_t
1504 fsdp_get_sendrecv_mode (const fsdp_description_t
* dsc
)
1507 return FSDP_SENDRECV_UNDEFINED
;
1508 return dsc
->a_sendrecv_mode
;
1512 fsdp_get_session_type (const fsdp_description_t
* dsc
)
1515 return FSDP_SESSION_TYPE_UNDEFINED
;
1520 fsdp_get_media_count (const fsdp_description_t
* dsc
)
1524 return dsc
->media_announcements_count
;
1527 const fsdp_media_description_t
*
1528 fsdp_get_media (const fsdp_description_t
* dsc
, unsigned int index
)
1530 if ((index
>= dsc
->media_announcements_count
))
1532 return dsc
->media_announcements
[index
];
1536 fsdp_get_media_type (const fsdp_media_description_t
* dsc
)
1539 return FSDP_MEDIA_UNDEFINED
;
1540 return dsc
->media_type
;
1544 fsdp_get_media_port (const fsdp_media_description_t
* dsc
)
1552 fsdp_get_media_port_count (const fsdp_media_description_t
* dsc
)
1556 return dsc
->port_count
;
1559 fsdp_transport_protocol_t
1560 fsdp_get_media_transport_protocol (const fsdp_media_description_t
* dsc
)
1563 return FSDP_TP_UNDEFINED
;
1564 return dsc
->transport
;
1568 fsdp_get_media_formats_count (const fsdp_media_description_t
* dsc
)
1572 return dsc
->formats_count
;
1576 fsdp_get_media_format (const fsdp_media_description_t
* dsc
,
1579 if (!dsc
|| (index
< dsc
->formats_count
- 1))
1581 return dsc
->formats
[index
];
1585 fsdp_get_media_title (const fsdp_media_description_t
* dsc
)
1589 return dsc
->i_title
;
1593 fsdp_get_media_network_type (const fsdp_media_description_t
* dsc
)
1596 return FSDP_NETWORK_TYPE_UNDEFINED
;
1597 return dsc
->c_network_type
;
1601 fsdp_get_media_address_type (const fsdp_media_description_t
* dsc
)
1604 return FSDP_ADDRESS_TYPE_UNDEFINED
;
1605 return dsc
->c_address_type
;
1609 fsdp_get_media_address (const fsdp_media_description_t
* dsc
)
1613 return dsc
->c_address
.address
;
1617 fsdp_get_media_address_ttl (const fsdp_media_description_t
* mdsc
)
1621 return mdsc
->c_address
.address_ttl
;
1625 fsdp_get_media_address_count (const fsdp_media_description_t
* mdsc
)
1629 return mdsc
->c_address
.address_count
;
1632 fsdp_bw_modifier_type_t
1633 fsdp_get_media_bw_modifier_type (const fsdp_media_description_t
* dsc
,
1636 if (!dsc
|| (index
>= dsc
->bw_modifiers_count
))
1637 return FSDP_BW_MOD_TYPE_UNDEFINED
;
1638 return dsc
->bw_modifiers
[index
].b_mod_type
;
1642 fsdp_get_media_bw_modifier_type_unknown (const fsdp_media_description_t
* dsc
,
1645 if (!dsc
|| (index
>= dsc
->bw_modifiers_count
) ||
1646 (FSDP_BW_MOD_TYPE_UNKNOWN
!= dsc
->bw_modifiers
[index
].b_mod_type
))
1648 return dsc
->bw_modifiers
[index
].b_unknown_bw_modt
;
1652 fsdp_get_media_bw_value (const fsdp_media_description_t
* dsc
,
1655 if (!dsc
|| (index
>= dsc
->bw_modifiers_count
))
1657 return dsc
->bw_modifiers
[index
].b_value
;
1660 fsdp_encryption_method_t
1661 fsdp_get_media_encryption_method (const fsdp_media_description_t
* dsc
)
1664 return FSDP_ENCRYPTION_METHOD_UNDEFINED
;
1665 return dsc
->k_encryption_method
;
1669 fsdp_get_media_encryption_content (const fsdp_media_description_t
* dsc
)
1673 return dsc
->k_encryption_content
;
1677 fsdp_get_media_ptime (const fsdp_media_description_t
* dsc
)
1681 return dsc
->a_ptime
;
1685 fsdp_get_media_maxptime (const fsdp_media_description_t
* dsc
)
1689 return dsc
->a_maxptime
;
1693 fsdp_get_media_rtpmap_count (const fsdp_media_description_t
* mdsc
)
1697 return mdsc
->a_rtpmaps_count
;
1701 fsdp_get_media_rtpmap_payload_type (const fsdp_media_description_t
* mdsc
,
1704 if (!mdsc
|| (index
>= mdsc
->a_rtpmaps_count
))
1706 return mdsc
->a_rtpmaps
[index
]->pt
;
1710 fsdp_get_media_rtpmap_encoding_name (const fsdp_media_description_t
* mdsc
,
1713 if (!mdsc
|| (index
>= mdsc
->a_rtpmaps_count
))
1715 return mdsc
->a_rtpmaps
[index
]->encoding_name
;
1719 fsdp_get_media_rtpmap_clock_rate (const fsdp_media_description_t
* mdsc
,
1722 if (!mdsc
|| (index
>= mdsc
->a_rtpmaps_count
))
1724 return mdsc
->a_rtpmaps
[index
]->clock_rate
;
1728 fsdp_get_media_rtpmap_encoding_parameters (const fsdp_description_t
* mdsc
,
1731 if (!mdsc
|| (index
>= mdsc
->a_rtpmaps_count
))
1733 return mdsc
->a_rtpmaps
[index
]->parameters
;
1737 fsdp_get_media_sdplang_count (const fsdp_media_description_t
* mdsc
)
1741 return mdsc
->a_sdplangs_count
;
1745 fsdp_get_media_sdplang (const fsdp_media_description_t
* mdsc
,
1748 if (!mdsc
|| (index
>= mdsc
->a_sdplangs_count
))
1750 return mdsc
->a_sdplangs
[index
];
1754 fsdp_get_media_lang_count (const fsdp_media_description_t
* mdsc
)
1758 return mdsc
->a_langs_count
;
1762 fsdp_get_media_lang (const fsdp_media_description_t
* mdsc
,
1765 if (!mdsc
|| (index
>= mdsc
->a_langs_count
))
1767 return mdsc
->a_langs
[index
];
1771 fsdp_get_media_control_count (const fsdp_media_description_t
* mdsc
)
1775 return mdsc
->a_controls_count
;
1779 fsdp_get_media_control (const fsdp_media_description_t
* mdsc
,
1782 if (!mdsc
|| (index
>= mdsc
->a_controls_count
))
1784 return mdsc
->a_controls
[index
];
1788 fsdp_get_media_range (const fsdp_media_description_t
* mdsc
)
1790 return mdsc
->a_range
;
1794 fsdp_get_media_fmtp_count (const fsdp_media_description_t
* mdsc
)
1798 return mdsc
->a_fmtps_count
;
1802 fsdp_get_media_fmtp (const fsdp_media_description_t
* mdsc
,
1805 if (!mdsc
|| (index
>= mdsc
->a_fmtps_count
))
1807 return mdsc
->a_fmtps
[index
];
1811 fsdp_get_media_orient (const fsdp_media_description_t
* dsc
)
1814 return FSDP_ORIENT_UNDEFINED
;
1815 return dsc
->a_orient
;
1818 fsdp_sendrecv_mode_t
1819 fsdp_get_media_sendrecv (const fsdp_media_description_t
* dsc
)
1822 return FSDP_SENDRECV_UNDEFINED
;
1823 return dsc
->a_sendrecv_mode
;
1827 fsdp_get_media_framerate (const fsdp_media_description_t
* dsc
)
1831 return dsc
->a_framerate
;
1835 fsdp_get_media_quality (const fsdp_media_description_t
* dsc
)
1839 return dsc
->a_quality
;
1843 fsdp_get_media_rtcp_port (const fsdp_media_description_t
* dsc
)
1847 return dsc
->a_rtcp_port
;
1851 fsdp_get_media_rtcp_network_type (const fsdp_media_description_t
* dsc
)
1854 return FSDP_NETWORK_TYPE_UNDEFINED
;
1855 return dsc
->a_rtcp_network_type
;
1859 fsdp_get_media_rtcp_address_type (const fsdp_media_description_t
* dsc
)
1862 return FSDP_ADDRESS_TYPE_UNDEFINED
;
1863 return dsc
->a_rtcp_address_type
;
1867 fsdp_get_media_rtcp_address (const fsdp_media_description_t
* dsc
)
1871 return dsc
->a_rtcp_address
;
1875 fsdp_get_media_unidentified_attribute_count (const fsdp_media_description_t
1880 return mdsc
->unidentified_attributes_count
;
1884 fsdp_get_media_unidentified_attribute (const fsdp_media_description_t
* mdsc
,
1887 if (!mdsc
|| (index
< mdsc
->unidentified_attributes_count
))
1889 return mdsc
->unidentified_attributes
[index
];