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
;
68 unsigned int index
, j
;
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
*));
256 for (j
= 0; j
< dsc
->time_periods_count
; j
++)
259 if (sscanf (p
, "t=%10lu %10lu", &wuint
[0], &wuint
[1]) != 2)
261 /* not all periods have been successfully parsed */
262 dsc
->time_periods_count
= j
;
263 return FSDPE_INVALID_TIME
;
265 dsc
->time_periods
[j
] = calloc (1, sizeof (fsdp_time_period_t
));
267 /* convert from NTP to time_t time */
269 wuint
[0] -= NTP_EPOCH_OFFSET
;
271 wuint
[1] -= NTP_EPOCH_OFFSET
;
272 dsc
->time_periods
[j
]->start
= wuint
[0];
273 dsc
->time_periods
[j
]->stop
= wuint
[1];
276 /* `r' lines [zero or more repeat times for each t=] */
277 /*r=<repeat interval> <active duration> <list of offsets from
280 while (!strncmp (p2
, "r=", 2))
285 dsc
->time_periods
[j
]->repeats_count
= h
;
288 unsigned int index2
= 0;
289 dsc
->time_periods
[j
]->repeats
=
290 calloc (h
, sizeof (fsdp_repeat_t
*));
291 for (h
= 0; h
< dsc
->time_periods
[j
]->repeats_count
; h
++)
294 get_repeat_values(p,&(dsc->time_periods[index].repeats[index2]));
295 fsdp_error_t get_repeat_values (const char *r, fsdp_repeat_t
298 if (sscanf (p
, "r=%10s %10s %" MLFLENS
"[^\r\n]",
299 fsdp_buf
[0], fsdp_buf
[1], longfsdp_buf
) == 3)
301 fsdp_repeat_t
*repeat
;
302 dsc
->time_periods
[j
]->repeats
[h
] =
303 calloc (1, sizeof (fsdp_repeat_t
));
304 repeat
= dsc
->time_periods
[j
]->repeats
[h
];
305 /* get interval, duration and list of offsets */
307 fsdp_repeat_time_to_uint (fsdp_buf
[0],
308 &(repeat
->interval
));
309 if (result
== FSDPE_OK
)
312 fsdp_repeat_time_to_uint (fsdp_buf
[1],
313 &(repeat
->duration
));
314 if (result
== FSDPE_OK
)
317 const char *i
= longfsdp_buf
;
318 while (NULL
!= (i
= strchr (i
, ' ')))
324 repeat
->offsets_count
= k
;
325 repeat
->offsets
= calloc (k
, sizeof (time_t));
328 (k
< repeat
->offsets_count
)
329 && (result
== FSDPE_OK
); k
++)
332 fsdp_repeat_time_to_uint (i
,
339 if (k
< repeat
->offsets_count
)
341 /* there where invalid repeat offsets */
342 dsc
->time_periods
[j
]->repeats_count
= k
;
343 return FSDPE_INVALID_REPEAT
;
347 if (result
!= FSDPE_OK
)
349 /* not all repeats have been succesfully parsed */
350 dsc
->time_periods
[j
]->repeats_count
= h
;
351 return FSDPE_INVALID_REPEAT
;
357 /* not all repeats have been succesfully parsed */
358 dsc
->time_periods
[j
]->repeats_count
= h
;
359 return FSDPE_INVALID_REPEAT
;
366 /* `z=' line (time zone adjustments) [zero or more] */
367 /* z=<adjustment time> <offset> <adjustment time> <offset> .... */
368 if (!strncmp (p
, "z=", 2))
370 if (sscanf (p
, "z=%" MLFLENS
"[^\r\n]", longfsdp_buf
))
372 /* TODO: guess how many pairs are there and process them */
373 dsc
->timezone_adj
= strdup (longfsdp_buf
);
378 return FSDPE_INVALID_TIMEZONE
;
382 /* `k=' line (encryption key) [optional] */
384 k=<method>:<encryption key> */
385 result
= fsdp_parse_k (&p
, &(dsc
->k_encryption_method
),
386 &(dsc
->k_encryption_content
));
387 if (result
!= FSDPE_OK
)
390 /* A.2) Attributes */
391 /* `a=' lines (session attribute) [0 or more] */
393 a=<attribute>:<value> */
394 while (!strncmp (p
, "a=", 2))
396 /* The "9" length specifier of the first string is subject to
399 (p
, "a=%9[^:\r\n]:%" MSFLENS
"[^\r\n]", fsdp_buf
[0],
402 /* session-level value attributes */
403 if (!strncmp (fsdp_buf
[0], "cat", 3))
404 dsc
->a_category
= strdup (fsdp_buf
[1]);
405 else if (!strncmp (fsdp_buf
[0], "keywds", 6))
406 dsc
->a_keywords
= strdup (fsdp_buf
[1]);
407 else if (!strncmp (fsdp_buf
[0], "tool", 4))
408 dsc
->a_keywords
= strdup (fsdp_buf
[1]);
409 else if (!strncmp (fsdp_buf
[0], "rtpmap", 6))
410 fsdp_parse_rtpmap (&(dsc
->a_rtpmaps
),
411 &(dsc
->a_rtpmaps_count
), fsdp_buf
[1]);
412 else if (!strncmp (fsdp_buf
[0], "type", 4))
414 if (!strncmp (fsdp_buf
[1], "broadcast", 9))
415 dsc
->a_type
= FSDP_SESSION_TYPE_BROADCAST
;
416 else if (!strncmp (fsdp_buf
[1], "meeting", 7))
417 dsc
->a_type
= FSDP_SESSION_TYPE_MEETING
;
418 else if (!strncmp (fsdp_buf
[1], "moderated", 9))
419 dsc
->a_type
= FSDP_SESSION_TYPE_MODERATED
;
420 else if (!strncmp (fsdp_buf
[1], "test", 4))
421 dsc
->a_type
= FSDP_SESSION_TYPE_TEST
;
422 else if (!strncmp (fsdp_buf
[1], "H332", 4))
423 dsc
->a_type
= FSDP_SESSION_TYPE_H332
;
425 return FSDPE_INVALID_SESSION_TYPE
;
427 else if (!strncmp (fsdp_buf
[0], "charset", 7))
428 dsc
->a_charset
= strdup (fsdp_buf
[1]);
429 else if (!strncmp (fsdp_buf
[0], "sdplang", 7))
431 if (NULL
== dsc
->a_sdplangs
)
433 dsc
->a_sdplangs_count
= 0;
435 calloc (SDPLANGS_MAX_COUNT
, sizeof (char *));
437 if (dsc
->a_sdplangs_count
< SDPLANGS_MAX_COUNT
)
439 dsc
->a_sdplangs
[dsc
->a_sdplangs_count
] =
440 strdup (fsdp_buf
[1]);
441 dsc
->a_sdplangs_count
++;
444 else if (!strncmp (fsdp_buf
[0], "lang", 4))
446 if (NULL
== dsc
->a_langs
)
448 dsc
->a_langs_count
= 0;
449 dsc
->a_langs
= calloc (SDPLANGS_MAX_COUNT
, sizeof (char *));
451 if (dsc
->a_langs_count
< SDPLANGS_MAX_COUNT
)
453 dsc
->a_langs
[dsc
->a_langs_count
] = strdup (fsdp_buf
[1]);
454 dsc
->a_langs_count
++;
457 else if (!strncmp (fsdp_buf
[0], "control", 7))
459 if (NULL
== dsc
->a_controls
)
461 dsc
->a_controls_count
= 0;
463 calloc (SDPCONTROLS_MAX_COUNT
, sizeof (char *));
465 if (dsc
->a_controls_count
< SDPCONTROLS_MAX_COUNT
)
467 dsc
->a_controls
[dsc
->a_controls_count
] =
468 strdup (fsdp_buf
[1]);
469 dsc
->a_controls_count
++;
472 else if (!strncmp (fsdp_buf
[0], "range", 5))
475 dsc
->a_range
= strdup (fsdp_buf
[1]);
479 /* ignore unknown attributes, but provide access to them */
480 *longfsdp_buf
= '\0';
481 strncat (longfsdp_buf
, fsdp_buf
[0], MAXLONGFIELDLEN
-1);
482 strncat (longfsdp_buf
, ":", MAXLONGFIELDLEN
-strlen(longfsdp_buf
)-1);
483 strncat (longfsdp_buf
, fsdp_buf
[1], MAXLONGFIELDLEN
-strlen(longfsdp_buf
)-1);
484 if (NULL
== dsc
->unidentified_attributes
)
486 dsc
->unidentified_attributes_count
= 0;
487 dsc
->unidentified_attributes
=
488 calloc (UNIDENTIFIED_ATTRIBUTES_MAX_COUNT
,
491 if (dsc
->unidentified_attributes_count
<
492 UNIDENTIFIED_ATTRIBUTES_MAX_COUNT
)
494 dsc
->unidentified_attributes
495 [dsc
->unidentified_attributes_count
] =
496 strdup (longfsdp_buf
);
497 dsc
->unidentified_attributes_count
++;
502 else if (sscanf (p
, "a=%20s", fsdp_buf
[0]) == 1)
504 /* session-level property attributes */
505 if (!strncmp (fsdp_buf
[0], "recvonly", 8))
506 dsc
->a_sendrecv_mode
= FSDP_SENDRECV_RECVONLY
;
507 else if (!strncmp (fsdp_buf
[0], "sendonly", 8))
508 dsc
->a_sendrecv_mode
= FSDP_SENDRECV_SENDONLY
;
509 else if (!strncmp (fsdp_buf
[0], "inactive", 8))
510 dsc
->a_sendrecv_mode
= FSDP_SENDRECV_INACTIVE
;
511 else if (!strncmp (fsdp_buf
[0], "sendrecv", 8))
512 dsc
->a_sendrecv_mode
= FSDP_SENDRECV_SENDRECV
;
515 /* ignore unknown attributes, but provide access to them */
516 *longfsdp_buf
= '\0';
517 strncat (longfsdp_buf
, fsdp_buf
[0], MAXLONGFIELDLEN
-1);
518 if (NULL
== dsc
->unidentified_attributes
)
520 dsc
->unidentified_attributes_count
= 0;
521 dsc
->unidentified_attributes
=
522 calloc (UNIDENTIFIED_ATTRIBUTES_MAX_COUNT
,
525 if (dsc
->unidentified_attributes_count
<
526 UNIDENTIFIED_ATTRIBUTES_MAX_COUNT
)
528 dsc
->unidentified_attributes
529 [dsc
->unidentified_attributes_count
] =
530 strdup (longfsdp_buf
);
531 dsc
->unidentified_attributes_count
++;
537 return FSDPE_INVALID_ATTRIBUTE
;
540 /***************************************************************************/
541 /* B) parse media-level descriptions */
542 /***************************************************************************/
545 while ((*p2
!= '\0') && !strncmp (p2
, "m=", 2))
550 while (sscanf (p2
, "%c=", &c
) == 1)
552 if (c
== 'i' || c
== 'c' || c
== 'b' || c
== 'k' || c
== 'a')
562 return FSDPE_INVALID_LINE
;
566 dsc
->media_announcements_count
= j
;
567 if (dsc
->media_announcements_count
== 0)
570 /*return FSDPE_MISSING_MEDIA; */
573 { /* dsc->media_announcements_count > 0 */
574 dsc
->media_announcements
=
575 calloc (j
, sizeof (fsdp_media_announcement_t
*));
576 for (j
= 0; j
< dsc
->media_announcements_count
; j
++)
578 fsdp_media_announcement_t
*media
= NULL
;
579 /* `m=' line (media name, transport address and format list) */
580 /* m=<media> <port> <transport> <fmt list> */
581 /* The max. string lengths are subject to change */
582 if (sscanf (p
, "m=%11s %8s %7s %" MLFLENS
"[^\r\n]",
583 fsdp_buf
[0], fsdp_buf
[1], fsdp_buf
[2],
586 return FSDPE_INVALID_MEDIA
;
590 dsc
->media_announcements
[j
] =
591 calloc (1, sizeof (fsdp_media_announcement_t
));
592 media
= dsc
->media_announcements
[j
];
593 if (!strncmp (fsdp_buf
[0], "audio", 5))
594 media
->media_type
= FSDP_MEDIA_AUDIO
;
595 else if (!strncmp (fsdp_buf
[0], "video", 5))
596 media
->media_type
= FSDP_MEDIA_VIDEO
;
597 else if (!strncmp (fsdp_buf
[0], "application", 11))
598 media
->media_type
= FSDP_MEDIA_APPLICATION
;
599 else if (!strncmp (fsdp_buf
[0], "data", 4))
600 media
->media_type
= FSDP_MEDIA_DATA
;
601 else if (!strncmp (fsdp_buf
[0], "control", 7))
602 media
->media_type
= FSDP_MEDIA_CONTROL
;
604 return FSDPE_UNKNOWN_MEDIA_TYPE
;
605 { /* try to get port specification as port/number */
607 if ((slash
= strchr (fsdp_buf
[1], '/')))
611 media
->port
= strtol (fsdp_buf
[1], NULL
, 10);
612 media
->port_count
= strtol (slash
, NULL
, 10);
616 media
->port
= strtol (fsdp_buf
[1], NULL
, 10);
617 media
->port_count
= 0;
620 if (!strncmp (fsdp_buf
[2], "RTP/AVP", 7))
621 media
->transport
= FSDP_TP_RTP_AVP
;
622 else if (!strncmp (fsdp_buf
[2], "udp", 3))
623 media
->transport
= FSDP_TP_UDP
;
624 else if (!strncmp (fsdp_buf
[2], "TCP", 3))
625 media
->transport
= FSDP_TP_TCP
;
626 else if (!strncmp (fsdp_buf
[2], "UDPTL", 5))
627 media
->transport
= FSDP_TP_UDPTL
;
628 else if (!strncmp (fsdp_buf
[2], "vat", 3))
629 media
->transport
= FSDP_TP_VAT
;
630 else if (!strncmp (fsdp_buf
[2], "rtp", 3))
631 media
->transport
= FSDP_TP_OLD_RTP
;
633 return FSDPE_UNKNOWN_MEDIA_TRANSPORT
;
636 char *s
= longfsdp_buf
;
637 while (NULL
!= (s
= strchr (s
, ' ')))
643 k
++; /* when there is no space left, count the last format */
644 media
->formats_count
= k
;
645 media
->formats
= calloc (k
, sizeof (char *));
647 for (k
= 0; k
< media
->formats_count
; k
++)
649 char *space
= strchr (s
, ' ');
652 media
->formats
[k
] = strdup (s
);
659 /* `i=' line (media title) [optional] */
660 /* i=<media title> */
661 if (!strncmp (p
, "i=", 2)
662 && sscanf (p
, "i=%" MLFLENS
"[^\r\n]", longfsdp_buf
))
664 media
->i_title
= strdup (longfsdp_buf
);
669 /* (optional) information absent */
672 /* `c=' line (connection information - overrides session-level
673 line) [optional if provided at session-level] */
674 /* c=<network type> <address type> <connection address> */
675 result
= fsdp_parse_c (&p
, &(media
->c_network_type
),
676 &(media
->c_address_type
),
677 &(media
->c_address
));
678 if (result
!= FSDPE_OK
)
681 /* `b=' lines (bandwidth information) [optional] */
682 /* b=<modifier>:<bandwidth-value> */
683 result
= fsdp_parse_b (&p
, &(media
->bw_modifiers
),
684 &(media
->bw_modifiers_count
));
685 if (FSDPE_OK
!= result
)
688 /* `k=' line (encryption key) [optional] */
690 k=<method>:<encryption key> */
691 result
= fsdp_parse_k (&p
, &(media
->k_encryption_method
),
692 &(media
->k_encryption_content
));
693 if (result
!= FSDPE_OK
)
696 /* B.1) Attributes */
698 /* `a=' lines (zero or more media attribute lines) [optional] */
700 a=<attribute>:<value> */
701 while (!strncmp (p
, "a=", 2))
704 (p
, "a=%9[^:\r\n]:%" MLFLENS
"[^\r\n]", fsdp_buf
[0],
707 /* media-level value attributes */
708 if (!strncmp (fsdp_buf
[0], "ptime", 5))
709 media
->a_ptime
= strtoul (longfsdp_buf
, NULL
, 10);
710 else if (!strncmp (fsdp_buf
[0], "maxptime", 8))
711 media
->a_maxptime
= strtoul (longfsdp_buf
, NULL
, 10);
712 else if (!strncmp (fsdp_buf
[0], "rtpmap", 6))
713 fsdp_parse_rtpmap (&(media
->a_rtpmaps
),
714 &(media
->a_rtpmaps_count
),
716 else if (!strncmp (fsdp_buf
[0], "orient", 6))
718 if (!strncmp (longfsdp_buf
, "portrait", 8))
719 media
->a_orient
= FSDP_ORIENT_PORTRAIT
;
720 else if (!strncmp (longfsdp_buf
, "landscape", 9))
721 media
->a_orient
= FSDP_ORIENT_LANDSCAPE
;
722 else if (!strncmp (longfsdp_buf
, "seascape", 9))
723 media
->a_orient
= FSDP_ORIENT_SEASCAPE
;
725 else if (!strncmp (fsdp_buf
[0], "sdplang", 7))
727 if (NULL
== dsc
->a_sdplangs
)
729 media
->a_sdplangs_count
= 0;
731 calloc (SDPLANGS_MAX_COUNT
, sizeof (char *));
733 if (media
->a_sdplangs_count
< SDPLANGS_MAX_COUNT
)
735 media
->a_sdplangs
[dsc
->a_sdplangs_count
] =
736 strdup (longfsdp_buf
);
737 media
->a_sdplangs_count
++;
740 else if (!strncmp (fsdp_buf
[0], "lang", 4))
742 if (NULL
== dsc
->a_langs
)
744 media
->a_langs_count
= 0;
746 calloc (SDPLANGS_MAX_COUNT
, sizeof (char *));
748 if (media
->a_langs_count
< SDPLANGS_MAX_COUNT
)
750 media
->a_langs
[dsc
->a_langs_count
] =
751 strdup (longfsdp_buf
);
752 media
->a_langs_count
++;
755 else if (!strncmp (fsdp_buf
[0], "control", 7))
757 if (NULL
== media
->a_controls
)
759 media
->a_controls_count
= 0;
761 calloc (SDPCONTROLS_MAX_COUNT
, sizeof (char *));
763 if (media
->a_controls_count
< SDPCONTROLS_MAX_COUNT
)
765 media
->a_controls
[media
->a_controls_count
] =
766 strdup (longfsdp_buf
);
767 media
->a_controls_count
++;
770 else if (!strncmp (fsdp_buf
[0], "range", 5))
772 free (media
->a_range
);
773 media
->a_range
= strdup (fsdp_buf
[1]);
775 else if (!strncmp (fsdp_buf
[0], "framerate", 9))
776 media
->a_framerate
= strtod (longfsdp_buf
, NULL
);
777 else if (!strncmp (fsdp_buf
[0], "fmtp", 4))
779 if (NULL
== media
->a_fmtps
)
781 media
->a_fmtps_count
= 0;
783 calloc (SDPLANGS_MAX_COUNT
, sizeof (char *));
785 if (media
->a_fmtps_count
< SDPLANGS_MAX_COUNT
)
787 media
->a_fmtps
[media
->a_fmtps_count
] =
788 strdup (longfsdp_buf
);
789 media
->a_fmtps_count
++;
792 else if (!strncmp (fsdp_buf
[0], "rtcp", 4))
795 /* rtcp attribute: a=rtcp:<port> <nettype> <addrtype> <address> */
797 sscanf (longfsdp_buf
, "%lu %2s %3s %" MSFLENS
"s",
798 &wuint
[0], fsdp_buf
[0], fsdp_buf
[1],
802 media
->a_rtcp_port
= wuint
[0];
805 if (!strncmp (fsdp_buf
[0], "IN", 2))
807 media
->a_rtcp_network_type
=
808 FSDP_NETWORK_TYPE_INET
;
810 ; TODO: define error code? */
813 if (!strncmp (fsdp_buf
[1], "IP4", 3))
814 media
->a_rtcp_address_type
=
815 FSDP_ADDRESS_TYPE_IPV4
;
816 else if (!strncmp (fsdp_buf
[1], "IP6", 3))
817 media
->a_rtcp_address_type
=
818 FSDP_ADDRESS_TYPE_IPV6
;
820 return FSDPE_INVALID_CONNECTION_NETTYPE
;
821 /*add specific code? */
823 media
->a_rtcp_address
=
824 strdup (fsdp_buf
[2]);
831 /* ignore unknown attributes, but provide access to them */
833 strncat (fsdp_buf
[1], fsdp_buf
[0], MAXSHORTFIELDLEN
-1);
834 strncat (fsdp_buf
[1], ":", MAXSHORTFIELDLEN
-strlen(fsdp_buf
[1])-1);
835 strncat (fsdp_buf
[1], longfsdp_buf
, MAXSHORTFIELDLEN
-strlen(fsdp_buf
[1])-1);
836 if (NULL
== media
->unidentified_attributes
)
838 media
->unidentified_attributes_count
= 0;
839 media
->unidentified_attributes
=
840 calloc (UNIDENTIFIED_ATTRIBUTES_MAX_COUNT
,
843 if (media
->unidentified_attributes_count
<
844 UNIDENTIFIED_ATTRIBUTES_MAX_COUNT
)
846 media
->unidentified_attributes
847 [media
->unidentified_attributes_count
] =
848 strdup (fsdp_buf
[1]);
849 media
->unidentified_attributes_count
++;
854 else if (sscanf (p
, "a=%8s", fsdp_buf
[0]) == 1)
856 /* media-level property attributes */
857 if (!strncmp (fsdp_buf
[0], "recvonly", 8))
858 media
->a_sendrecv_mode
= FSDP_SENDRECV_RECVONLY
;
859 else if (!strncmp (fsdp_buf
[0], "sendonly", 8))
860 media
->a_sendrecv_mode
= FSDP_SENDRECV_SENDONLY
;
861 else if (!strncmp (fsdp_buf
[0], "inactive", 8))
862 media
->a_sendrecv_mode
= FSDP_SENDRECV_INACTIVE
;
863 else if (!strncmp (fsdp_buf
[0], "sendrecv", 8))
864 media
->a_sendrecv_mode
= FSDP_SENDRECV_SENDRECV
;
867 /* ignore unknown attributes, but provide access to them */
868 *longfsdp_buf
= '\0';
869 strncat (longfsdp_buf
, fsdp_buf
[0], MAXLONGFIELDLEN
-1);
870 if (NULL
== media
->unidentified_attributes
)
872 media
->unidentified_attributes_count
= 0;
873 media
->unidentified_attributes
=
874 calloc (UNIDENTIFIED_ATTRIBUTES_MAX_COUNT
,
877 if (media
->unidentified_attributes_count
<
878 UNIDENTIFIED_ATTRIBUTES_MAX_COUNT
)
880 media
->unidentified_attributes
881 [media
->unidentified_attributes_count
] =
882 strdup (longfsdp_buf
);
883 media
->unidentified_attributes_count
++;
889 return FSDPE_INVALID_ATTRIBUTE
;
894 /* Check c= has been given at session level or at media level for
896 if (NULL
== dsc
->c_address
.address
)
899 for (c
= 0; c
< dsc
->media_announcements_count
; c
++)
900 if (NULL
== dsc
->media_announcements
[c
]->c_address
.address
)
901 return FSDPE_MISSING_CONNECTION_INFO
;
908 return FSDPE_OVERFILLED
;
912 fsdp_parse_c (const char **p
, fsdp_network_type_t
* ntype
,
913 fsdp_address_type_t
* atype
,
914 fsdp_connection_address_t
* address
)
916 const unsigned int TEMPCHARS
= 3;
917 char fsdp_buf
[TEMPCHARS
][MAXSHORTFIELDLEN
];
919 if (!strncmp (*p
, "c=", 2))
921 if (sscanf (*p
, "c=%2s %3s %" MSFLENS
"s",
922 fsdp_buf
[0], fsdp_buf
[1], fsdp_buf
[2]))
924 if (!strncmp (fsdp_buf
[0], "IN", 2))
926 *ntype
= FSDP_NETWORK_TYPE_INET
;
927 if (!strncmp (fsdp_buf
[1], "IP4", 3))
928 *atype
= FSDP_ADDRESS_TYPE_IPV4
;
929 else if (!strncmp (fsdp_buf
[1], "IP6", 3))
930 *atype
= FSDP_ADDRESS_TYPE_IPV6
;
932 return FSDPE_INVALID_CONNECTION_NETTYPE
;
936 return FSDPE_INVALID_CONNECTION_ADDRTYPE
;
939 char *slash
= strchr (fsdp_buf
[2], '/');
942 address
->address
= strdup (fsdp_buf
[2]);
943 address
->address_ttl
= 0;
944 address
->address_count
= 0;
948 /* address is IP4 multicast */
952 address
->address
= strdup (fsdp_buf
[2]);
953 slash2
= strchr (slash
+ 1, '/');
956 address
->address_ttl
= strtol (slash
, NULL
, 10);
957 address
->address_count
= 0;
963 address
->address_ttl
= strtol (slash
, NULL
, 10);
964 address
->address_count
= strtol (slash2
, NULL
, 10);
972 return FSDPE_INVALID_CONNECTION
;
979 fsdp_parse_b (const char **p
, fsdp_bw_modifier_t
** bw_modifiers
,
980 unsigned int *bw_modifiers_count
)
982 char fsdp_buf
[MAXSHORTFIELDLEN
];
983 unsigned long int wuint
;
988 while (!strncmp (lp
, "b=", 2))
993 *bw_modifiers
= calloc (i
, sizeof (fsdp_bw_modifier_t
));
994 *bw_modifiers_count
= i
;
998 unsigned int index
= *bw_modifiers_count
- i
;
999 if (2 == sscanf (*p
, "b=%20[^:\r\n]:%lu", fsdp_buf
, &wuint
))
1001 if (!strncmp (fsdp_buf
, "CT", 2))
1002 (*bw_modifiers
)[index
].b_mod_type
=
1003 FSDP_BW_MOD_TYPE_CONFERENCE_TOTAL
;
1004 else if (!strncmp (fsdp_buf
, "AS", 2))
1005 (*bw_modifiers
)[index
].b_mod_type
=
1006 FSDP_BW_MOD_TYPE_APPLICATION_SPECIFIC
;
1007 else if (!strncmp (fsdp_buf
, "RS", 2))
1008 (*bw_modifiers
)[index
].b_mod_type
= FSDP_BW_MOD_TYPE_RTCP_SENDERS
;
1009 else if (!strncmp (fsdp_buf
, "RR", 2))
1010 (*bw_modifiers
)[index
].b_mod_type
=
1011 FSDP_BW_MOD_TYPE_RTCP_RECEIVERS
;
1014 (*bw_modifiers
)[index
].b_mod_type
= FSDP_BW_MOD_TYPE_UNKNOWN
;
1015 (*bw_modifiers
)[index
].b_unknown_bw_modt
=
1016 (char *) strdup (fsdp_buf
);
1018 (*bw_modifiers
)[index
].b_value
= wuint
;
1023 *bw_modifiers_count
-= i
;
1024 return FSDPE_INVALID_BANDWIDTH
;
1032 fsdp_parse_k (const char **p
, fsdp_encryption_method_t
* method
,
1035 char fsdp_buf
[MAXSHORTFIELDLEN
];
1036 char longfsdp_buf
[MAXLONGFIELDLEN
];
1038 if (!strncmp (*p
, "k=", 2))
1040 if (sscanf (*p
, "k=prompt"))
1042 *method
= FSDP_ENCRYPTION_METHOD_PROMPT
;
1049 (*p
, "k=%6[^:\r\n]:%" MLFLENS
"s", fsdp_buf
, longfsdp_buf
))
1051 if (!strncmp (fsdp_buf
, "clear", 5))
1052 *method
= FSDP_ENCRYPTION_METHOD_CLEAR
;
1053 else if (!strncmp (fsdp_buf
, "base64", 6))
1054 *method
= FSDP_ENCRYPTION_METHOD_BASE64
;
1055 else if (!strncmp (fsdp_buf
, "uri", 3))
1056 *method
= FSDP_ENCRYPTION_METHOD_URI
;
1058 return FSDPE_INVALID_ENCRYPTION_METHOD
;
1059 *content
= strdup (longfsdp_buf
);
1068 fsdp_parse_rtpmap (fsdp_rtpmap_t
*** rtpmap
, unsigned int *counter
,
1071 fsdp_error_t result
= FSDPE_OK
;
1076 *rtpmap
= calloc (MEDIA_RTPMAPS_MAX_COUNT
, sizeof (fsdp_rtpmap_t
*));
1078 if (*counter
< MEDIA_RTPMAPS_MAX_COUNT
)
1080 unsigned int c
= *counter
;
1081 fsdp_rtpmap_t
**map
= *rtpmap
;
1082 char fsdp_buf
[MAXSHORTFIELDLEN
];
1083 char longfsdp_buf
[MAXLONGFIELDLEN
];
1084 map
[c
] = calloc (1, sizeof (fsdp_rtpmap_t
));
1086 /* a=rtpmap:<payload type> <encoding name>/<clock rate>[/<encoding
1088 if (2 == sscanf (value
, "%s %s", fsdp_buf
, longfsdp_buf
))
1091 map
[c
]->pt
= strdup (fsdp_buf
);
1092 /* parse <encoding name>/<clock rate>[/<encoding parameters>] */
1093 slash1
= strchr (longfsdp_buf
, '/');
1096 result
= FSDPE_INVALID_ATTRIBUTE_RTPMAP
;
1103 map
[c
]->encoding_name
= strdup (longfsdp_buf
);
1104 slash2
= strchr (slash1
, '/');
1109 map
[c
]->parameters
= strdup (slash2
);
1111 map
[c
]->clock_rate
= strtol (slash1
, NULL
, 10);
1120 fsdp_repeat_time_to_uint (const char *time
, unsigned long int *seconds
)
1122 const unsigned long SECONDS_PER_DAY
= 86400;
1123 const unsigned long SECONDS_PER_HOUR
= 3600;
1124 const unsigned long SECONDS_PER_MINUTE
= 60;
1126 unsigned long int wuint
;
1128 if (sscanf (time
, "%lu%c", &wuint
, &c
) == 2)
1130 /* time with unit specification character */
1134 *seconds
= wuint
* SECONDS_PER_DAY
;
1137 *seconds
= wuint
* SECONDS_PER_HOUR
;
1140 *seconds
= wuint
* SECONDS_PER_MINUTE
;
1146 return FSDPE_INVALID_REPEAT
;
1150 else if (sscanf (time
, "%lu", &wuint
) == 1)
1152 /* time without unit specification character */
1157 return FSDPE_INVALID_REPEAT
;
1163 fsdp_get_version (const fsdp_description_t
* dsc
)
1167 return dsc
->version
;
1171 fsdp_get_owner_username (const fsdp_description_t
* dsc
)
1175 return dsc
->o_username
;
1179 fsdp_get_session_id (const fsdp_description_t
* dsc
)
1183 return dsc
->o_session_id
;
1187 fsdp_get_announcement_version (const fsdp_description_t
* dsc
)
1191 return dsc
->o_announcement_version
;
1195 fsdp_get_owner_network_type (const fsdp_description_t
* dsc
)
1198 return FSDP_NETWORK_TYPE_UNDEFINED
;
1199 return dsc
->o_network_type
;
1203 fsdp_get_owner_address_type (const fsdp_description_t
* dsc
)
1206 return FSDP_ADDRESS_TYPE_UNDEFINED
;
1207 return dsc
->o_address_type
;
1211 fsdp_get_owner_address (const fsdp_description_t
* dsc
)
1215 return dsc
->o_address
;
1219 fsdp_get_name (const fsdp_description_t
* dsc
)
1227 fsdp_get_information (const fsdp_description_t
* dsc
)
1231 return dsc
->i_information
;
1235 fsdp_get_uri (const fsdp_description_t
* dsc
)
1243 fsdp_get_emails_count (const fsdp_description_t
* dsc
)
1247 return dsc
->emails_count
;
1251 fsdp_get_email (const fsdp_description_t
* dsc
, unsigned int index
)
1253 if ((!dsc
) || (index
>= dsc
->emails_count
))
1255 return dsc
->emails
[index
];
1259 fsdp_get_phones_count (const fsdp_description_t
* dsc
)
1263 return dsc
->phones_count
;
1267 fsdp_get_phone (const fsdp_description_t
* dsc
, unsigned int index
)
1269 if ((!dsc
) || (index
>= dsc
->phones_count
))
1271 return dsc
->phones
[index
];
1275 fsdp_get_global_conn_network_type (const fsdp_description_t
* dsc
)
1278 return FSDP_NETWORK_TYPE_UNDEFINED
;
1279 return dsc
->c_network_type
;
1283 fsdp_get_global_conn_address_type (const fsdp_description_t
* dsc
)
1286 return FSDP_ADDRESS_TYPE_UNDEFINED
;
1287 return dsc
->c_address_type
;
1291 fsdp_get_global_conn_address (const fsdp_description_t
* dsc
)
1295 return dsc
->c_address
.address
;
1299 fsdp_get_global_conn_address_ttl (const fsdp_description_t
* dsc
)
1303 return dsc
->c_address
.address_ttl
;
1307 fsdp_get_global_conn_address_count (const fsdp_description_t
* dsc
)
1311 return dsc
->c_address
.address_count
;
1315 fsdp_get_bw_modifier_count (const fsdp_description_t
* dsc
)
1319 return dsc
->bw_modifiers_count
;
1322 fsdp_bw_modifier_type_t
1323 fsdp_get_bw_modifier_type (const fsdp_description_t
* dsc
, unsigned int index
)
1325 if ((!dsc
) || (index
>= dsc
->bw_modifiers_count
))
1326 return FSDP_BW_MOD_TYPE_UNDEFINED
;
1327 return dsc
->bw_modifiers
[index
].b_mod_type
;
1331 fsdp_get_bw_modifier_type_unknown (const fsdp_description_t
* dsc
,
1334 if ((!dsc
) || (index
>= dsc
->bw_modifiers_count
) ||
1335 (dsc
->bw_modifiers
[index
].b_mod_type
!= FSDP_BW_MOD_TYPE_UNKNOWN
))
1337 return dsc
->bw_modifiers
[index
].b_unknown_bw_modt
;
1341 fsdp_get_bw_value (const fsdp_description_t
* dsc
, unsigned int index
)
1343 if ((!dsc
) || (index
>= dsc
->bw_modifiers_count
))
1345 return dsc
->bw_modifiers
[index
].b_value
;
1349 fsdp_get_period_start (const fsdp_description_t
* dsc
, unsigned int index
)
1351 if ((!dsc
) || (index
>= dsc
->time_periods_count
))
1353 return dsc
->time_periods
[index
]->start
;
1357 fsdp_get_period_stop (const fsdp_description_t
* dsc
, unsigned int index
)
1359 if ((!dsc
) || (index
>= dsc
->time_periods_count
))
1361 return dsc
->time_periods
[index
]->stop
;
1365 fsdp_get_period_repeats_count (const fsdp_description_t
* dsc
,
1368 if ((!dsc
) || (index
>= dsc
->time_periods_count
))
1370 return dsc
->time_periods
[index
]->repeats_count
;
1374 fsdp_get_period_repeat_interval (const fsdp_description_t
* dsc
,
1375 unsigned int index
, unsigned int rindex
)
1377 if ((!dsc
) || (index
>= dsc
->time_periods_count
))
1379 return dsc
->time_periods
[index
]->repeats
[rindex
]->interval
;
1383 fsdp_get_period_repeat_duration (const fsdp_description_t
* dsc
,
1384 unsigned int index
, unsigned int rindex
)
1386 if ((!dsc
) || (index
>= dsc
->time_periods_count
))
1388 return dsc
->time_periods
[index
]->repeats
[rindex
]->duration
;
1391 const unsigned long int *
1392 fsdp_get_period_repeat_offsets (const fsdp_description_t
* dsc
,
1393 unsigned int index
, unsigned int rindex
)
1395 if ((!dsc
) || (index
>= dsc
->time_periods_count
))
1397 return dsc
->time_periods
[index
]->repeats
[rindex
]->offsets
;
1401 fsdp_get_timezone_adj (const fsdp_description_t
* dsc
)
1405 return dsc
->timezone_adj
;
1409 fsdp_get_unidentified_attribute_count (const fsdp_description_t
* dsc
)
1413 return dsc
->unidentified_attributes_count
;
1417 fsdp_get_unidentified_attribute (const fsdp_description_t
* dsc
,
1420 if (!dsc
|| (index
< dsc
->unidentified_attributes_count
))
1422 return dsc
->unidentified_attributes
[index
];
1425 fsdp_encryption_method_t
1426 fsdp_get_encryption_method (const fsdp_description_t
* dsc
)
1429 return FSDP_ENCRYPTION_METHOD_UNDEFINED
;
1430 return dsc
->k_encryption_method
;
1434 fsdp_get_encryption_content (const fsdp_description_t
* dsc
)
1436 if (!dsc
|| (dsc
->k_encryption_method
== FSDP_ENCRYPTION_METHOD_UNDEFINED
))
1438 return dsc
->k_encryption_content
;
1442 fsdp_get_str_att (const fsdp_description_t
* dsc
, fsdp_session_str_att_t att
)
1444 /*TODO: change these individual attributes with a table, thus
1445 avoiding this slow switch */
1453 case FSDP_SESSION_STR_ATT_CATEGORY
:
1454 result
= dsc
->a_category
;
1456 case FSDP_SESSION_STR_ATT_KEYWORDS
:
1457 result
= dsc
->a_keywords
;
1459 case FSDP_SESSION_STR_ATT_TOOL
:
1460 result
= dsc
->a_tool
;
1462 case FSDP_SESSION_STR_ATT_CHARSET
:
1463 result
= dsc
->a_charset
;
1472 fsdp_get_sdplang_count (const fsdp_description_t
* dsc
)
1476 return dsc
->a_sdplangs_count
;
1480 fsdp_get_sdplang (const fsdp_description_t
* dsc
, unsigned int index
)
1482 if ((!dsc
) || (index
>= dsc
->a_sdplangs_count
))
1484 return dsc
->a_sdplangs
[index
];
1488 fsdp_get_control_count (const fsdp_description_t
* dsc
)
1492 return dsc
->a_controls_count
;
1496 fsdp_get_control (const fsdp_description_t
* dsc
, unsigned int index
)
1498 if ((!dsc
) || (index
>= dsc
->a_controls_count
))
1500 return dsc
->a_controls
[index
];
1504 fsdp_get_range (const fsdp_description_t
* dsc
)
1506 return dsc
->a_range
;
1509 fsdp_sendrecv_mode_t
1510 fsdp_get_sendrecv_mode (const fsdp_description_t
* dsc
)
1513 return FSDP_SENDRECV_UNDEFINED
;
1514 return dsc
->a_sendrecv_mode
;
1518 fsdp_get_session_type (const fsdp_description_t
* dsc
)
1521 return FSDP_SESSION_TYPE_UNDEFINED
;
1526 fsdp_get_media_count (const fsdp_description_t
* dsc
)
1530 return dsc
->media_announcements_count
;
1533 const fsdp_media_description_t
*
1534 fsdp_get_media (const fsdp_description_t
* dsc
, unsigned int index
)
1536 if ((index
>= dsc
->media_announcements_count
))
1538 return dsc
->media_announcements
[index
];
1542 fsdp_get_media_type (const fsdp_media_description_t
* dsc
)
1545 return FSDP_MEDIA_UNDEFINED
;
1546 return dsc
->media_type
;
1550 fsdp_get_media_port (const fsdp_media_description_t
* dsc
)
1558 fsdp_get_media_port_count (const fsdp_media_description_t
* dsc
)
1562 return dsc
->port_count
;
1565 fsdp_transport_protocol_t
1566 fsdp_get_media_transport_protocol (const fsdp_media_description_t
* dsc
)
1569 return FSDP_TP_UNDEFINED
;
1570 return dsc
->transport
;
1574 fsdp_get_media_formats_count (const fsdp_media_description_t
* dsc
)
1578 return dsc
->formats_count
;
1582 fsdp_get_media_format (const fsdp_media_description_t
* dsc
,
1585 if (!dsc
|| (index
< dsc
->formats_count
- 1))
1587 return dsc
->formats
[index
];
1591 fsdp_get_media_title (const fsdp_media_description_t
* dsc
)
1595 return dsc
->i_title
;
1599 fsdp_get_media_network_type (const fsdp_media_description_t
* dsc
)
1602 return FSDP_NETWORK_TYPE_UNDEFINED
;
1603 return dsc
->c_network_type
;
1607 fsdp_get_media_address_type (const fsdp_media_description_t
* dsc
)
1610 return FSDP_ADDRESS_TYPE_UNDEFINED
;
1611 return dsc
->c_address_type
;
1615 fsdp_get_media_address (const fsdp_media_description_t
* dsc
)
1619 return dsc
->c_address
.address
;
1623 fsdp_get_media_address_ttl (const fsdp_media_description_t
* mdsc
)
1627 return mdsc
->c_address
.address_ttl
;
1631 fsdp_get_media_address_count (const fsdp_media_description_t
* mdsc
)
1635 return mdsc
->c_address
.address_count
;
1638 fsdp_bw_modifier_type_t
1639 fsdp_get_media_bw_modifier_type (const fsdp_media_description_t
* dsc
,
1642 if (!dsc
|| (index
>= dsc
->bw_modifiers_count
))
1643 return FSDP_BW_MOD_TYPE_UNDEFINED
;
1644 return dsc
->bw_modifiers
[index
].b_mod_type
;
1648 fsdp_get_media_bw_modifier_type_unknown (const fsdp_media_description_t
* dsc
,
1651 if (!dsc
|| (index
>= dsc
->bw_modifiers_count
) ||
1652 (FSDP_BW_MOD_TYPE_UNKNOWN
!= dsc
->bw_modifiers
[index
].b_mod_type
))
1654 return dsc
->bw_modifiers
[index
].b_unknown_bw_modt
;
1658 fsdp_get_media_bw_value (const fsdp_media_description_t
* dsc
,
1661 if (!dsc
|| (index
>= dsc
->bw_modifiers_count
))
1663 return dsc
->bw_modifiers
[index
].b_value
;
1666 fsdp_encryption_method_t
1667 fsdp_get_media_encryption_method (const fsdp_media_description_t
* dsc
)
1670 return FSDP_ENCRYPTION_METHOD_UNDEFINED
;
1671 return dsc
->k_encryption_method
;
1675 fsdp_get_media_encryption_content (const fsdp_media_description_t
* dsc
)
1679 return dsc
->k_encryption_content
;
1683 fsdp_get_media_ptime (const fsdp_media_description_t
* dsc
)
1687 return dsc
->a_ptime
;
1691 fsdp_get_media_maxptime (const fsdp_media_description_t
* dsc
)
1695 return dsc
->a_maxptime
;
1699 fsdp_get_media_rtpmap_count (const fsdp_media_description_t
* mdsc
)
1703 return mdsc
->a_rtpmaps_count
;
1707 fsdp_get_media_rtpmap_payload_type (const fsdp_media_description_t
* mdsc
,
1710 if (!mdsc
|| (index
>= mdsc
->a_rtpmaps_count
))
1712 return mdsc
->a_rtpmaps
[index
]->pt
;
1716 fsdp_get_media_rtpmap_encoding_name (const fsdp_media_description_t
* mdsc
,
1719 if (!mdsc
|| (index
>= mdsc
->a_rtpmaps_count
))
1721 return mdsc
->a_rtpmaps
[index
]->encoding_name
;
1725 fsdp_get_media_rtpmap_clock_rate (const fsdp_media_description_t
* mdsc
,
1728 if (!mdsc
|| (index
>= mdsc
->a_rtpmaps_count
))
1730 return mdsc
->a_rtpmaps
[index
]->clock_rate
;
1734 fsdp_get_media_rtpmap_encoding_parameters (const fsdp_description_t
* mdsc
,
1737 if (!mdsc
|| (index
>= mdsc
->a_rtpmaps_count
))
1739 return mdsc
->a_rtpmaps
[index
]->parameters
;
1743 fsdp_get_media_sdplang_count (const fsdp_media_description_t
* mdsc
)
1747 return mdsc
->a_sdplangs_count
;
1751 fsdp_get_media_sdplang (const fsdp_media_description_t
* mdsc
,
1754 if (!mdsc
|| (index
>= mdsc
->a_sdplangs_count
))
1756 return mdsc
->a_sdplangs
[index
];
1760 fsdp_get_media_lang_count (const fsdp_media_description_t
* mdsc
)
1764 return mdsc
->a_langs_count
;
1768 fsdp_get_media_lang (const fsdp_media_description_t
* mdsc
,
1771 if (!mdsc
|| (index
>= mdsc
->a_langs_count
))
1773 return mdsc
->a_langs
[index
];
1777 fsdp_get_media_control_count (const fsdp_media_description_t
* mdsc
)
1781 return mdsc
->a_controls_count
;
1785 fsdp_get_media_control (const fsdp_media_description_t
* mdsc
,
1788 if (!mdsc
|| (index
>= mdsc
->a_controls_count
))
1790 return mdsc
->a_controls
[index
];
1794 fsdp_get_media_range (const fsdp_media_description_t
* mdsc
)
1796 return mdsc
->a_range
;
1800 fsdp_get_media_fmtp_count (const fsdp_media_description_t
* mdsc
)
1804 return mdsc
->a_fmtps_count
;
1808 fsdp_get_media_fmtp (const fsdp_media_description_t
* mdsc
,
1811 if (!mdsc
|| (index
>= mdsc
->a_fmtps_count
))
1813 return mdsc
->a_fmtps
[index
];
1817 fsdp_get_media_orient (const fsdp_media_description_t
* dsc
)
1820 return FSDP_ORIENT_UNDEFINED
;
1821 return dsc
->a_orient
;
1824 fsdp_sendrecv_mode_t
1825 fsdp_get_media_sendrecv (const fsdp_media_description_t
* dsc
)
1828 return FSDP_SENDRECV_UNDEFINED
;
1829 return dsc
->a_sendrecv_mode
;
1833 fsdp_get_media_framerate (const fsdp_media_description_t
* dsc
)
1837 return dsc
->a_framerate
;
1841 fsdp_get_media_quality (const fsdp_media_description_t
* dsc
)
1845 return dsc
->a_quality
;
1849 fsdp_get_media_rtcp_port (const fsdp_media_description_t
* dsc
)
1853 return dsc
->a_rtcp_port
;
1857 fsdp_get_media_rtcp_network_type (const fsdp_media_description_t
* dsc
)
1860 return FSDP_NETWORK_TYPE_UNDEFINED
;
1861 return dsc
->a_rtcp_network_type
;
1865 fsdp_get_media_rtcp_address_type (const fsdp_media_description_t
* dsc
)
1868 return FSDP_ADDRESS_TYPE_UNDEFINED
;
1869 return dsc
->a_rtcp_address_type
;
1873 fsdp_get_media_rtcp_address (const fsdp_media_description_t
* dsc
)
1877 return dsc
->a_rtcp_address
;
1881 fsdp_get_media_unidentified_attribute_count (const fsdp_media_description_t
1886 return mdsc
->unidentified_attributes_count
;
1890 fsdp_get_media_unidentified_attribute (const fsdp_media_description_t
* mdsc
,
1893 if (!mdsc
|| (index
< mdsc
->unidentified_attributes_count
))
1895 return mdsc
->unidentified_attributes
[index
];