no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / third_party / sipcc / sdp_attr_access.c
blobb3efa3e6b69e2e1546c4179f09d434d565b75a26
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "sdp_os_defs.h"
6 #include "sipcc_sdp.h"
7 #include "sdp_private.h"
9 #include "sdp_log.h"
11 static const char* logTag = "sdp_attr_access";
13 /* Attribute access routines are all defined by the following parameters.
15 * sdp_p The SDP handle returned by sdp_init_description.
16 * level The level the attribute is defined. Can be either
17 * SDP_SESSION_LEVEL or 0-n specifying a media line level.
18 * inst_num The instance number of the attribute. Multiple instances
19 * of a particular attribute may exist at each level and so
20 * the inst_num determines the particular attribute at that
21 * level that should be accessed. Note that this is the
22 * instance number of the specified type of attribute, not the
23 * overall attribute number at the level. Also note that the
24 * instance number is 1-based. For example:
25 * v=0
26 * o=mhandley 2890844526 2890842807 IN IP4 126.16.64.4
27 * s=SDP Seminar
28 * c=IN IP4 10.1.0.2
29 * t=0 0
30 * m=audio 1234 RTP/AVP 0 101 102
31 * a=foo 1
32 * a=foo 2
33 * a=bar 1 # This is instance 1 of attribute bar.
34 * a=foo 3 # This is instance 3 of attribute foo.
35 * cap_num Almost all of the attributes may be defined as X-cpar
36 * parameters (with the exception of X-sqn, X-cap, and X-cpar).
37 * If the cap_num is set to zero, then the attribute is not
38 * an X-cpar parameter attribute. If the cap_num is any other
39 * value, it specifies the capability number that the X-cpar
40 * attribute is specified for.
43 /* Attribute handling:
45 * There are two basic types of attributes handled by the SDP library,
46 * those defined by a= token lines, and those embedded with a=X-cpar lines.
47 * The handling for each of these is described here.
49 * Simple (non X-cpar attributes):
51 * Attributes not embedded in a=X-cpar lines are referenced by level and
52 * instance number. For these attributes the capability number is always
53 * set to zero.
55 * An application will typically process these attributes in one of two ways.
56 * With the first method, the application can determine the total number
57 * of attributes defined at a given level and process them one at a time.
58 * For each attribute, the application will query the library to find out
59 * what type of attribute it is and which instance within that type. The
60 * application can then process this particular attribute referencing it
61 * by level and instance number.
63 * A second method of processing attributes is for applications to determine
64 * each type of attribute they are interested in, query the SDP library to
65 * find out how many of that type of attribute exist at a given level, and
66 * process each one at a time.
68 * X-cpar attribute processing:
70 * X-cpar attributes can contain embedded attributes. They are associated
71 * with X-cap attribute lines. An example of X-cap and X-cpar attributes
72 * found in an SDP is as follows:
74 * v=0
75 * o=- 25678 753849 IN IP4 128.96.41.1
76 * s=-
77 * t=0 0
78 * c=IN IP4 10.1.0.2
79 * m=audio 3456 RTP/AVP 18 96
80 * a=rtpmap:96 telephone-event/8000
81 * a=fmtp:96 0-15,32-35
82 * a=X-sqn: 0
83 * a=X-cap: 1 audio RTP/AVP 0 18 96 97
84 * a=X-cpar: a=fmtp:96 0-16,32-35
85 * a=X-cpar: a=rtpmap:97 X-NSE/8000
86 * a=X-cpar: a=fmtp:97 195-197
87 * a=X-cap: 5 image udptl t38
88 * a=X-cap: 6 application udp X-tmr
89 * a=X-cap: 7 audio RTP/AVP 100 101
90 * a=X-cpar: a=rtpmap:100 g.711/8000
91 * a=X-cpar: a=rtpmap:101 g.729/8000
93 * X-cap attributes can be defined at the SESSION_LEVEL or any media level.
94 * An X-cap attr is defined by the level and instance number just like
95 * other attributes. In the example above, X-cap attrs are defined at
96 * media level 1 and there are four instances at that level.
98 * The X-cpar attributes can also be referenced by level and instance number.
99 * However, the embedded attribute within an X-cpar attribute must be
100 * referenced by level, instance number, and capability number. This is
101 * because the X-cpar attribute is associated with a particular X-cap/
102 * capability.
103 * For all attributes that are not embedded within an X-cpar attribute, the
104 * cap_num should be referenced as zero. But for X-cpar attributes, the
105 * cap_num is specified to be one of the capability numbers of the previous
106 * X-cap line. The number of capabilities specified in an X-cap line is
107 * equal to the number of payloads. Thus, in this example, the first X-cap
108 * attr instance specifies capabilities 1-4, the second specifies capability
109 * 5, the third capability 6, and the fourth capabilities 7-8.
111 * X-cpar attributes can be processed with methods similar to the two
112 * previously mentioned. For each X-cap attribute, the application can
113 * use one of two methods to process the X-cpar attributes. First, it
114 * can query the total number of X-cpar attributes associated with a
115 * given X-cap attribute. The X-cap attribute is here defined by a level
116 * and a capability number. In the example above, the total number of
117 * attributes defined is as follows:
118 * level 1, cap_num 1 - total attrs: 3
119 * level 1, cap_num 5 - total attrs: 0
120 * level 1, cap_num 6 - total attrs: 0
121 * level 1, cap_num 7 - total attrs: 2
123 * Note that if the application queried the number of attributes for
124 * cap_num 2, 3, or 4, it would also return 3 attrs, and for cap_num
125 * 8 the library would return 2.
127 * Once the application determines the total number of attributes for
128 * that capability, it can again query the embedded attribute type and
129 * instance. For example, sdp_get_attr_type would return the following:
130 * level 1, cap_num 1, attr 1 -> attr type fmtp, instance 1
131 * level 1, cap_num 1, attr 2 -> attr type rtpmap, instance 1
132 * level 1, cap_num 1, attr 3 -> attr type fmtp, instance 2
133 * level 1, cap_num 7, attr 1 -> attr type rtpmap, instance 1
134 * level 1, cap_num 7, attr 2 -> attr type rtpmap, instance 2
136 * The individual embedded attributes can then be accessed by level,
137 * cap_num, and instance number.
139 * With the second method for handling X-cpar attributes, the application
140 * determines the types of attributes it is interested in. It can then
141 * query the SDP library to determine the number of attributes of that
142 * type found for that level and cap_num, and then process each one at
143 * a time. e.g., calling sdp_attr_num_instances would give:
144 * level 1, cap_num 1, attr_type fmtp -> two instances
145 * level 1, cap_num 1, attr_type rtpmap -> one instance
146 * level 1, cap_num 7, attr_type fmtp -> zero instances
147 * level 1, cap_num 7, attr_type rtpmap -> two instances
151 /* Function: sdp_add_new_attr
152 * Description: Add a new attribute of the specified type at the given
153 * level and capability level or base attribute if cap_num
154 * is zero.
155 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
156 * level The level to check for the attribute.
157 * cap_num The capability number associated with the
158 * attribute if any. If none, should be zero.
159 * attr_type The type of attribute to add.
160 * inst_num Pointer to a uint16_t in which to return the instance
161 * number of the newly added attribute.
162 * Returns: SDP_SUCCESS Attribute was added successfully.
163 * SDP_NO_RESOURCE No memory avail for new attribute.
164 * SDP_INVALID_PARAMETER Specified media line is not defined.
166 sdp_result_e sdp_add_new_attr (sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
167 sdp_attr_e attr_type, uint16_t *inst_num)
169 uint16_t i;
170 sdp_mca_t *mca_p;
171 sdp_mca_t *cap_p;
172 sdp_attr_t *attr_p;
173 sdp_attr_t *new_attr_p;
174 sdp_attr_t *prev_attr_p=NULL;
175 sdp_fmtp_t *fmtp_p;
176 sdp_comediadir_t *comediadir_p;
178 *inst_num = 0;
180 if ((cap_num != 0) &&
181 ((attr_type == SDP_ATTR_X_CAP) || (attr_type == SDP_ATTR_X_CPAR) ||
182 (attr_type == SDP_ATTR_X_SQN) || (attr_type == SDP_ATTR_CDSC) ||
183 (attr_type == SDP_ATTR_CPAR) || (attr_type == SDP_ATTR_SQN))) {
184 if (sdp_p->debug_flag[SDP_DEBUG_WARNINGS]) {
185 SDPLogDebug(logTag, "%s Warning: Invalid attribute type for X-cpar/cdsc "
186 "parameter.", sdp_p->debug_str);
188 sdp_p->conf_p->num_invalid_param++;
189 return (SDP_INVALID_PARAMETER);
192 /* Some attributes are valid only under media level */
193 if (level == SDP_SESSION_LEVEL) {
194 switch (attr_type) {
195 case SDP_ATTR_RTCP:
196 case SDP_ATTR_LABEL:
197 return (SDP_INVALID_MEDIA_LEVEL);
199 default:
200 break;
204 new_attr_p = (sdp_attr_t *)SDP_MALLOC(sizeof(sdp_attr_t));
205 if (new_attr_p == NULL) {
206 sdp_p->conf_p->num_no_resource++;
207 return (SDP_NO_RESOURCE);
210 new_attr_p->type = attr_type;
211 new_attr_p->next_p = NULL;
213 /* Initialize the new attribute structure */
214 if ((new_attr_p->type == SDP_ATTR_X_CAP) ||
215 (new_attr_p->type == SDP_ATTR_CDSC)) {
216 new_attr_p->attr.cap_p = (sdp_mca_t *)SDP_MALLOC(sizeof(sdp_mca_t));
217 if (new_attr_p->attr.cap_p == NULL) {
218 sdp_free_attr(new_attr_p);
219 sdp_p->conf_p->num_no_resource++;
220 return (SDP_NO_RESOURCE);
222 } else if (new_attr_p->type == SDP_ATTR_FMTP) {
223 fmtp_p = &(new_attr_p->attr.fmtp);
224 fmtp_p->fmtp_format = SDP_FMTP_UNKNOWN_TYPE;
225 // set to invalid value
226 fmtp_p->packetization_mode = SDP_INVALID_PACKETIZATION_MODE_VALUE;
227 fmtp_p->level_asymmetry_allowed = SDP_INVALID_LEVEL_ASYMMETRY_ALLOWED_VALUE;
228 fmtp_p->annexb_required = FALSE;
229 fmtp_p->annexa_required = FALSE;
230 fmtp_p->maxval = 0;
231 fmtp_p->bitrate = 0;
232 fmtp_p->cif = 0;
233 fmtp_p->qcif = 0;
234 fmtp_p->profile = SDP_INVALID_VALUE;
235 fmtp_p->level = SDP_INVALID_VALUE;
236 fmtp_p->parameter_add = SDP_FMTP_UNUSED;
237 fmtp_p->usedtx = SDP_FMTP_UNUSED;
238 fmtp_p->stereo = SDP_FMTP_UNUSED;
239 fmtp_p->useinbandfec = SDP_FMTP_UNUSED;
240 fmtp_p->cbr = SDP_FMTP_UNUSED;
241 for (i=0; i < SDP_NE_NUM_BMAP_WORDS; i++) {
242 fmtp_p->bmap[i] = 0;
244 } else if ((new_attr_p->type == SDP_ATTR_RTPMAP) ||
245 (new_attr_p->type == SDP_ATTR_SPRTMAP)) {
246 new_attr_p->attr.transport_map.num_chan = 1;
247 } else if (new_attr_p->type == SDP_ATTR_DIRECTION) {
248 comediadir_p = &(new_attr_p->attr.comediadir);
249 comediadir_p->role = SDP_MEDIADIR_ROLE_PASSIVE;
250 comediadir_p->conn_info_present = FALSE;
251 } else if (new_attr_p->type == SDP_ATTR_MPTIME) {
252 sdp_mptime_t *mptime = &(new_attr_p->attr.mptime);
253 mptime->num_intervals = 0;
256 if (cap_num == 0) {
257 /* Add a new attribute. */
258 if (level == SDP_SESSION_LEVEL) {
259 if (sdp_p->sess_attrs_p == NULL) {
260 sdp_p->sess_attrs_p = new_attr_p;
261 } else {
262 for (attr_p = sdp_p->sess_attrs_p;
263 attr_p != NULL;
264 prev_attr_p = attr_p, attr_p = attr_p->next_p) {
265 /* Count the num instances of this type. */
266 if (attr_p->type == attr_type) {
267 (*inst_num)++;
270 prev_attr_p->next_p = new_attr_p;
272 } else {
273 mca_p = sdp_find_media_level(sdp_p, level);
274 if (mca_p == NULL) {
275 sdp_free_attr(new_attr_p);
276 sdp_p->conf_p->num_invalid_param++;
277 return (SDP_INVALID_PARAMETER);
279 if (mca_p->media_attrs_p == NULL) {
280 mca_p->media_attrs_p = new_attr_p;
281 } else {
282 for (attr_p = mca_p->media_attrs_p;
283 attr_p != NULL;
284 prev_attr_p = attr_p, attr_p = attr_p->next_p) {
285 /* Count the num instances of this type. */
286 if (attr_p->type == attr_type) {
287 (*inst_num)++;
290 prev_attr_p->next_p = new_attr_p;
293 } else {
294 /* Add a new capability attribute - find the capability attr. */
295 attr_p = sdp_find_capability(sdp_p, level, cap_num);
296 if (attr_p == NULL) {
297 sdp_free_attr(new_attr_p);
298 sdp_p->conf_p->num_invalid_param++;
299 return (SDP_INVALID_PARAMETER);
301 cap_p = attr_p->attr.cap_p;
302 if (cap_p->media_attrs_p == NULL) {
303 cap_p->media_attrs_p = new_attr_p;
304 } else {
305 for (attr_p = cap_p->media_attrs_p;
306 attr_p != NULL;
307 prev_attr_p = attr_p, attr_p = attr_p->next_p) {
308 /* Count the num instances of this type. */
309 if (attr_p->type == attr_type) {
310 (*inst_num)++;
313 prev_attr_p->next_p = new_attr_p;
317 /* Increment the instance num for the attr just added. */
318 (*inst_num)++;
319 return (SDP_SUCCESS);
322 /* Function: sdp_attr_num_instances
323 * Description: Get the number of attributes of the specified type at
324 * the given level and capability level.
325 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
326 * level The level to check for the attribute.
327 * cap_num The capability number associated with the
328 * attribute if any. If none, should be zero.
329 * attr_type The type of attribute to add.
330 * num_attr_inst Pointer to a uint16_t in which to return the
331 * number of attributes.
332 * Returns: SDP_SUCCESS Attribute was added successfully.
333 * SDP_INVALID_PARAMETER Specified media line is not defined.
335 sdp_result_e sdp_attr_num_instances (sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
336 sdp_attr_e attr_type, uint16_t *num_attr_inst)
338 sdp_attr_t *attr_p;
339 sdp_result_e rc;
340 static char fname[] = "attr_num_instances";
342 *num_attr_inst = 0;
344 rc = sdp_find_attr_list(sdp_p, level, cap_num, &attr_p, fname);
345 if (rc == SDP_SUCCESS) {
346 /* Found the attr list. Count the number of attrs of the given
347 * type at this level. */
348 for (; attr_p != NULL; attr_p = attr_p->next_p) {
349 if (attr_p->type == attr_type) {
350 (*num_attr_inst)++;
356 return (rc);
359 /* Forward declaration for use in sdp_free_attr */
360 static boolean sdp_attr_is_long_string(sdp_attr_e attr_type);
363 /* Internal routine to free the memory associated with an attribute.
364 * Certain attributes allocate additional memory. Free this and then
365 * free the attribute itself.
366 * Note that this routine may be called at any point (i.e., may be
367 * called due to a failure case) and so the additional memory
368 * associated with an attribute may or may not have been already
369 * allocated. This routine should check this carefully.
371 void sdp_free_attr (sdp_attr_t *attr_p)
373 sdp_mca_t *cap_p;
374 sdp_attr_t *cpar_p;
375 sdp_attr_t *next_cpar_p;
376 int i;
378 /* If this is an X-cap/cdsc attr, free the cap_p structure and
379 * all X-cpar/cpar attributes. */
380 if ((attr_p->type == SDP_ATTR_X_CAP) ||
381 (attr_p->type == SDP_ATTR_CDSC)) {
382 cap_p = attr_p->attr.cap_p;
383 if (cap_p != NULL) {
384 for (cpar_p = cap_p->media_attrs_p; cpar_p != NULL;) {
385 next_cpar_p = cpar_p->next_p;
386 sdp_free_attr(cpar_p);
387 cpar_p = next_cpar_p;
389 SDP_FREE(cap_p);
391 } else if ((attr_p->type == SDP_ATTR_SDESCRIPTIONS) ||
392 (attr_p->type == SDP_ATTR_SRTP_CONTEXT)) {
393 SDP_FREE(attr_p->attr.srtp_context.session_parameters);
394 } else if (sdp_attr_is_long_string(attr_p->type)) {
395 SDP_FREE(attr_p->attr.stringp);
398 if (attr_p->type == SDP_ATTR_GROUP) {
399 for (i = 0; i < attr_p->attr.stream_data.num_group_id; i++) {
400 SDP_FREE(attr_p->attr.stream_data.group_ids[i]);
402 } else if (attr_p->type == SDP_ATTR_MSID_SEMANTIC) {
403 for (i = 0; i < SDP_MAX_MEDIA_STREAMS; ++i) {
404 SDP_FREE(attr_p->attr.msid_semantic.msids[i]);
408 /* Now free the actual attribute memory. */
409 SDP_FREE(attr_p);
414 /* Function: sdp_find_attr_list
415 * Description: Find the attribute list for the specified level and cap_num.
416 * Note: This is not an API for the application but an internal
417 * routine used by the SDP library.
418 * Parameters: sdp_p Pointer to the SDP to search.
419 * level The level to check for the attribute list.
420 * cap_num The capability number associated with the
421 * attribute list. If none, should be zero.
422 * attr_p Pointer to the attr list pointer. Will be
423 * filled in on return if successful.
424 * fname String function name calling this routine.
425 * Use for printing debug.
426 * Returns: SDP_SUCCESS
427 * SDP_INVALID_MEDIA_LEVEL
428 * SDP_INVALID_CAPABILITY
429 * SDP_FAILURE
431 sdp_result_e sdp_find_attr_list (sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
432 sdp_attr_t **attr_p, char *fname)
434 sdp_mca_t *mca_p;
435 sdp_mca_t *cap_p;
436 sdp_attr_t *cap_attr_p;
438 /* Initialize the attr pointer. */
439 *attr_p = NULL;
441 if (cap_num == 0) {
442 /* Find attribute list at the specified level. */
443 if (level == SDP_SESSION_LEVEL) {
444 *attr_p = sdp_p->sess_attrs_p;
445 } else {
446 mca_p = sdp_find_media_level(sdp_p, level);
447 if (mca_p == NULL) {
448 sdp_p->conf_p->num_invalid_param++;
449 return (SDP_INVALID_PARAMETER);
451 *attr_p = mca_p->media_attrs_p;
453 } else {
454 /* Find the attr list for the capability specified. */
455 cap_attr_p = sdp_find_capability(sdp_p, level, cap_num);
456 if (cap_attr_p == NULL) {
457 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
458 SDPLogError(logTag, "%s %s, invalid capability %u at "
459 "level %u specified.", sdp_p->debug_str, fname,
460 (unsigned)cap_num, (unsigned)level);
462 sdp_p->conf_p->num_invalid_param++;
463 return (SDP_INVALID_CAPABILITY);
465 cap_p = cap_attr_p->attr.cap_p;
466 *attr_p = cap_p->media_attrs_p;
469 return (SDP_SUCCESS);
472 /* Find fmtp inst_num with correct payload value or -1 for failure */
473 int sdp_find_fmtp_inst (sdp_t *sdp_p, uint16_t level, uint16_t payload_num)
475 uint16_t attr_count=0;
476 sdp_mca_t *mca_p;
477 sdp_attr_t *attr_p;
479 /* Attr is at a media level */
480 mca_p = sdp_find_media_level(sdp_p, level);
481 if (mca_p == NULL) {
482 return (-1);
484 for (attr_p = mca_p->media_attrs_p; attr_p != NULL;
485 attr_p = attr_p->next_p) {
486 if (attr_p->type == SDP_ATTR_FMTP) {
487 attr_count++;
488 if (attr_p->attr.fmtp.payload_num == payload_num) {
489 return (attr_count);
494 return (-1);
498 /* Function: sdp_find_attr
499 * Description: Find the specified attribute in an SDP structure.
500 * Note: This is not an API for the application but an internal
501 * routine used by the SDP library.
502 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
503 * level The level to check for the attribute.
504 * cap_num The capability number associated with the
505 * attribute if any. If none, should be zero.
506 * attr_type The type of attribute to find.
507 * inst_num The instance num of the attribute to find.
508 * Range should be (1 - max num insts of this
509 * particular type of attribute at this level).
510 * Returns: Pointer to the attribute or NULL if not found.
512 sdp_attr_t *sdp_find_attr (sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
513 sdp_attr_e attr_type, uint16_t inst_num)
515 uint16_t attr_count=0;
516 sdp_mca_t *mca_p;
517 sdp_mca_t *cap_p;
518 sdp_attr_t *attr_p;
520 if (inst_num < 1) {
521 return (NULL);
524 if (cap_num == 0) {
525 if (level == SDP_SESSION_LEVEL) {
526 for (attr_p = sdp_p->sess_attrs_p; attr_p != NULL;
527 attr_p = attr_p->next_p) {
528 if (attr_p->type == attr_type) {
529 attr_count++;
530 if (attr_count == inst_num) {
531 return (attr_p);
535 } else { /* Attr is at a media level */
536 mca_p = sdp_find_media_level(sdp_p, level);
537 if (mca_p == NULL) {
538 return (NULL);
540 for (attr_p = mca_p->media_attrs_p; attr_p != NULL;
541 attr_p = attr_p->next_p) {
542 if (attr_p->type == attr_type) {
543 attr_count++;
544 if (attr_count == inst_num) {
545 return (attr_p);
549 } /* Attr is at a media level */
550 } else {
551 /* Attr is a capability X-cpar/cpar attribute. */
552 attr_p = sdp_find_capability(sdp_p, level, cap_num);
553 if (attr_p == NULL) {
554 return (NULL);
556 cap_p = attr_p->attr.cap_p;
557 /* Now find the specific attribute. */
558 for (attr_p = cap_p->media_attrs_p; attr_p != NULL;
559 attr_p = attr_p->next_p) {
560 if (attr_p->type == attr_type) {
561 attr_count++;
562 if (attr_count == inst_num) {
563 return (attr_p);
569 return (NULL);
572 /* Function: sdp_find_capability
573 * Description: Find the specified capability attribute in an SDP structure.
574 * Note: This is not an API for the application but an internal
575 * routine used by the SDP library.
576 * Parameters: sdp_p The SDP handle.
577 * level The level to check for the capability.
578 * cap_num The capability number to locate.
579 * Returns: Pointer to the capability attribute or NULL if not found.
581 sdp_attr_t *sdp_find_capability (sdp_t *sdp_p, uint16_t level, uint8_t cap_num)
583 uint8_t cur_cap_num=0;
584 sdp_mca_t *mca_p;
585 sdp_mca_t *cap_p;
586 sdp_attr_t *attr_p;
588 if (level == SDP_SESSION_LEVEL) {
589 for (attr_p = sdp_p->sess_attrs_p; attr_p != NULL;
590 attr_p = attr_p->next_p) {
591 if ((attr_p->type == SDP_ATTR_X_CAP) ||
592 (attr_p->type == SDP_ATTR_CDSC)) {
593 cap_p = attr_p->attr.cap_p;
594 cur_cap_num += cap_p->num_payloads;
595 if (cap_num <= cur_cap_num) {
596 /* This is the right capability */
597 return (attr_p);
601 } else { /* Capability is at a media level */
602 mca_p = sdp_find_media_level(sdp_p, level);
603 if (mca_p == NULL) {
604 return (NULL);
606 for (attr_p = mca_p->media_attrs_p; attr_p != NULL;
607 attr_p = attr_p->next_p) {
608 if ((attr_p->type == SDP_ATTR_X_CAP) ||
609 (attr_p->type == SDP_ATTR_CDSC)) {
610 cap_p = attr_p->attr.cap_p;
611 cur_cap_num += cap_p->num_payloads;
612 if (cap_num <= cur_cap_num) {
613 /* This is the right capability */
614 return (attr_p);
620 /* We didn't find the specified capability. */
621 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
622 SDPLogError(logTag, "%s Unable to find specified capability (level %u, "
623 "cap_num %u).", sdp_p->debug_str, (unsigned)level, (unsigned)cap_num);
625 sdp_p->conf_p->num_invalid_param++;
626 return (NULL);
629 /* Function: sdp_attr_valid(sdp_t *sdp_p)
630 * Description: Returns true or false depending on whether the specified
631 * instance of the given attribute has been defined at the
632 * given level.
633 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
634 * attr_type The attribute type to validate.
635 * level The level to check for the attribute.
636 * cap_num The capability number associated with the
637 * attribute if any. If none, should be zero.
638 * inst_num The attribute instance number to check.
639 * Returns: TRUE or FALSE.
641 tinybool sdp_attr_valid (sdp_t *sdp_p, sdp_attr_e attr_type, uint16_t level,
642 uint8_t cap_num, uint16_t inst_num)
644 if (sdp_find_attr(sdp_p, level, cap_num, attr_type, inst_num) == NULL) {
645 return (FALSE);
646 } else {
647 return (TRUE);
651 /* Function: sdp_attr_line_number(sdp_t *sdp_p)
652 * Description: Returns the line number this attribute appears on.
653 * Only works if the SDP was parsed rather than created
654 * locally.
655 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
656 * attr_type The attribute type to validate.
657 * level The level to check for the attribute.
658 * cap_num The capability number associated with the
659 * attribute if any. If none, should be zero.
660 * inst_num The attribute instance number to check.
661 * Returns: line number, or 0 if an error
663 uint32_t sdp_attr_line_number (sdp_t *sdp_p, sdp_attr_e attr_type, uint16_t level,
664 uint8_t cap_num, uint16_t inst_num)
666 sdp_attr_t *attr_p;
668 attr_p = sdp_find_attr(sdp_p, level, cap_num, attr_type, inst_num);
669 if (attr_p == NULL) {
670 return 0;
671 } else {
672 return attr_p->line_number;
676 static boolean sdp_attr_is_simple_string(sdp_attr_e attr_type) {
677 if ((attr_type != SDP_ATTR_BEARER) &&
678 (attr_type != SDP_ATTR_CALLED) &&
679 (attr_type != SDP_ATTR_CONN_TYPE) &&
680 (attr_type != SDP_ATTR_DIALED) &&
681 (attr_type != SDP_ATTR_DIALING) &&
682 (attr_type != SDP_ATTR_FRAMING) &&
683 (attr_type != SDP_ATTR_MID) &&
684 (attr_type != SDP_ATTR_X_SIDIN) &&
685 (attr_type != SDP_ATTR_X_SIDOUT)&&
686 (attr_type != SDP_ATTR_X_CONFID) &&
687 (attr_type != SDP_ATTR_LABEL) &&
688 (attr_type != SDP_ATTR_ICE_OPTIONS) &&
689 (attr_type != SDP_ATTR_IMAGEATTR) &&
690 (attr_type != SDP_ATTR_SIMULCAST) &&
691 (attr_type != SDP_ATTR_RID)) {
692 return FALSE;
694 return TRUE;
697 /* Function: sdp_attr_get_simple_string
698 * Description: Returns a pointer to a string attribute parameter. This
699 * routine can only be called for attributes that have just
700 * one string parameter. The value is returned as a const
701 * ptr and so cannot be modified by the application. If the
702 * given attribute is not defined, NULL will be returned.
703 * Attributes with a simple string parameter currently include:
704 * bearer, called, connection_type, dialed, dialing, direction
705 * and framing.
706 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
707 * attr_type The simple string attribute type.
708 * level The level to check for the attribute.
709 * cap_num The capability number associated with the
710 * attribute if any. If none, should be zero.
711 * inst_num The attribute instance number to check.
712 * Returns: Pointer to the parameter value.
714 const char *sdp_attr_get_simple_string (sdp_t *sdp_p, sdp_attr_e attr_type,
715 uint16_t level, uint8_t cap_num, uint16_t inst_num)
717 sdp_attr_t *attr_p;
719 if (!sdp_attr_is_simple_string(attr_type)) {
720 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
721 SDPLogError(logTag, "%s Attribute type is not a simple string (%s)",
722 sdp_p->debug_str, sdp_get_attr_name(attr_type));
724 sdp_p->conf_p->num_invalid_param++;
725 return (NULL);
728 attr_p = sdp_find_attr(sdp_p, level, cap_num, attr_type, inst_num);
729 if (attr_p == NULL) {
730 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
731 SDPLogError(logTag, "%s Attribute %s, level %u instance %u not found.",
732 sdp_p->debug_str, sdp_get_attr_name(attr_type),
733 (unsigned)level, (unsigned)inst_num);
735 sdp_p->conf_p->num_invalid_param++;
736 return (NULL);
737 } else {
738 return (attr_p->attr.string_val);
742 static boolean sdp_attr_is_long_string(sdp_attr_e attr_type) {
743 return (attr_type == SDP_ATTR_IDENTITY || attr_type == SDP_ATTR_DTLS_MESSAGE);
746 /* Identical in usage to sdp_attr_get_simple_string() */
747 const char *sdp_attr_get_long_string (sdp_t *sdp_p, sdp_attr_e attr_type,
748 uint16_t level, uint8_t cap_num, uint16_t inst_num)
750 sdp_attr_t *attr_p;
752 if (!sdp_attr_is_long_string(attr_type)) {
753 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
754 SDPLogError(logTag, "%s Attribute type is not a long string (%s)",
755 sdp_p->debug_str, sdp_get_attr_name(attr_type));
757 sdp_p->conf_p->num_invalid_param++;
758 return (NULL);
761 attr_p = sdp_find_attr(sdp_p, level, cap_num, attr_type, inst_num);
762 if (attr_p == NULL) {
763 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
764 SDPLogError(logTag, "%s Attribute %s, level %u instance %u not found.",
765 sdp_p->debug_str, sdp_get_attr_name(attr_type),
766 (unsigned)level, (unsigned)inst_num);
768 sdp_p->conf_p->num_invalid_param++;
769 return (NULL);
770 } else {
771 return (attr_p->attr.stringp);
775 static boolean sdp_attr_is_simple_u32(sdp_attr_e attr_type) {
776 if ((attr_type != SDP_ATTR_EECID) &&
777 (attr_type != SDP_ATTR_PTIME) &&
778 (attr_type != SDP_ATTR_MAXPTIME) &&
779 (attr_type != SDP_ATTR_SCTPPORT) &&
780 (attr_type != SDP_ATTR_MAXMESSAGESIZE) &&
781 (attr_type != SDP_ATTR_T38_VERSION) &&
782 (attr_type != SDP_ATTR_T38_MAXBITRATE) &&
783 (attr_type != SDP_ATTR_T38_MAXBUFFER) &&
784 (attr_type != SDP_ATTR_T38_MAXDGRAM) &&
785 (attr_type != SDP_ATTR_X_SQN) &&
786 (attr_type != SDP_ATTR_TC1_PAYLOAD_BYTES) &&
787 (attr_type != SDP_ATTR_TC1_WINDOW_SIZE) &&
788 (attr_type != SDP_ATTR_TC2_PAYLOAD_BYTES) &&
789 (attr_type != SDP_ATTR_TC2_WINDOW_SIZE) &&
790 (attr_type != SDP_ATTR_FRAMERATE)) {
791 return FALSE;
794 return TRUE;
797 /* Function: sdp_attr_get_simple_u32
798 * Description: Returns an unsigned 32-bit attribute parameter. This
799 * routine can only be called for attributes that have just
800 * one uint32_t parameter. If the given attribute is not defined,
801 * zero will be returned. There is no way for the application
802 * to determine if zero is the actual value or the attribute
803 * wasn't defined, so the application must use the
804 * sdp_attr_valid function to determine this.
805 * Attributes with a simple uint32_t parameter currently include:
806 * eecid, ptime, T38FaxVersion, T38maxBitRate, T38FaxMaxBuffer,
807 * T38FaxMaxDatagram, X-sqn, TC1PayloadBytes, TC1WindowSize,
808 * TC2PayloadBytes, TC2WindowSize, rtcp.
809 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
810 * attr_type The simple uint32_t attribute type.
811 * level The level to check for the attribute.
812 * cap_num The capability number associated with the
813 * attribute if any. If none, should be zero.
814 * inst_num The attribute instance number to check.
815 * Returns: uint32_t parameter value.
817 uint32_t sdp_attr_get_simple_u32 (sdp_t *sdp_p, sdp_attr_e attr_type, uint16_t level,
818 uint8_t cap_num, uint16_t inst_num)
820 sdp_attr_t *attr_p;
822 if (!sdp_attr_is_simple_u32(attr_type)) {
823 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
824 SDPLogError(logTag, "%s Attribute type is not a simple uint32_t (%s)",
825 sdp_p->debug_str, sdp_get_attr_name(attr_type));
827 sdp_p->conf_p->num_invalid_param++;
828 return (0);
831 attr_p = sdp_find_attr(sdp_p, level, cap_num, attr_type, inst_num);
832 if (attr_p == NULL) {
833 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
834 SDPLogError(logTag, "%s Attribute %s, level %u instance %u not found.",
835 sdp_p->debug_str, sdp_get_attr_name(attr_type),
836 (unsigned)level, (unsigned)inst_num);
838 sdp_p->conf_p->num_invalid_param++;
839 return (0);
840 } else {
841 return (attr_p->attr.u32_val);
845 /* Function: sdp_attr_get_simple_boolean
846 * Description: Returns a boolean attribute parameter. This
847 * routine can only be called for attributes that have just
848 * one boolean parameter. If the given attribute is not defined,
849 * FALSE will be returned. There is no way for the application
850 * to determine if FALSE is the actual value or the attribute
851 * wasn't defined, so the application must use the
852 * sdp_attr_valid function to determine this.
853 * Attributes with a simple boolean parameter currently include:
854 * T38FaxFillBitRemoval, T38FaxTranscodingMMR,
855 * T38FaxTranscodingJBIG, and TMRGwXid.
856 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
857 * attr_type The simple boolean attribute type.
858 * level The level to check for the attribute.
859 * cap_num The capability number associated with the
860 * attribute if any. If none, should be zero.
861 * inst_num The attribute instance number to check.
862 * Returns: Boolean value.
864 tinybool sdp_attr_get_simple_boolean (sdp_t *sdp_p, sdp_attr_e attr_type,
865 uint16_t level, uint8_t cap_num, uint16_t inst_num)
867 sdp_attr_t *attr_p;
869 if ((attr_type != SDP_ATTR_T38_FILLBITREMOVAL) &&
870 (attr_type != SDP_ATTR_T38_TRANSCODINGMMR) &&
871 (attr_type != SDP_ATTR_T38_TRANSCODINGJBIG) &&
872 (attr_type != SDP_ATTR_TMRGWXID)) {
873 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
874 SDPLogError(logTag, "%s Attribute type is not a simple boolean (%s)",
875 sdp_p->debug_str, sdp_get_attr_name(attr_type));
877 sdp_p->conf_p->num_invalid_param++;
878 return (FALSE);
881 attr_p = sdp_find_attr(sdp_p, level, cap_num, attr_type, inst_num);
882 if (attr_p == NULL) {
883 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
884 SDPLogError(logTag, "%s Attribute %s, level %u instance %u not found.",
885 sdp_p->debug_str, sdp_get_attr_name(attr_type),
886 (unsigned)level, (unsigned)inst_num);
888 sdp_p->conf_p->num_invalid_param++;
889 return (FALSE);
890 } else {
891 return (attr_p->attr.boolean_val);
896 * sdp_attr_get_maxprate
898 * This function is used by the application layer to get the packet-rate
899 * within the maxprate attribute.
901 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
902 * level The level to check for the attribute.
903 * inst_num The attribute instance number to set.
905 * Returns a pointer to a constant char array that stores the packet-rate,
906 * OR null if the attribute does not exist.
908 const char*
909 sdp_attr_get_maxprate (sdp_t *sdp_p, uint16_t level, uint16_t inst_num)
911 sdp_attr_t *attr_p;
913 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_MAXPRATE, inst_num);
914 if (attr_p == NULL) {
915 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
916 SDPLogError(logTag, "%s Attribute %s, level %u instance %u not found.",
917 sdp_p->debug_str, sdp_get_attr_name(SDP_ATTR_MAXPRATE),
918 (unsigned)level, (unsigned)inst_num);
920 sdp_p->conf_p->num_invalid_param++;
921 return (NULL);
922 } else {
923 return (attr_p->attr.string_val);
927 /* Function: sdp_attr_get_t38ratemgmt
928 * Description: Returns the value of the t38ratemgmt attribute
929 * parameter specified for the given attribute. If the given
930 * attribute is not defined, SDP_T38_UNKNOWN_RATE is returned.
931 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
932 * level The level to check for the attribute.
933 * cap_num The capability number associated with the
934 * attribute if any. If none, should be zero.
935 * inst_num The attribute instance number to check.
936 * Returns: Ratemgmt value.
938 sdp_t38_ratemgmt_e sdp_attr_get_t38ratemgmt (sdp_t *sdp_p, uint16_t level,
939 uint8_t cap_num, uint16_t inst_num)
941 sdp_attr_t *attr_p;
943 attr_p = sdp_find_attr(sdp_p, level, cap_num,
944 SDP_ATTR_T38_RATEMGMT, inst_num);
945 if (attr_p == NULL) {
946 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
947 SDPLogError(logTag, "%s t38ratemgmt attribute, level %u instance %u "
948 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
950 sdp_p->conf_p->num_invalid_param++;
951 return (SDP_T38_UNKNOWN_RATE);
952 } else {
953 return (attr_p->attr.t38ratemgmt);
957 /* Function: sdp_attr_get_t38udpec
958 * Description: Returns the value of the t38udpec attribute
959 * parameter specified for the given attribute. If the given
960 * attribute is not defined, SDP_T38_UDPEC_UNKNOWN is returned.
961 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
962 * level The level to check for the attribute.
963 * cap_num The capability number associated with the
964 * attribute if any. If none, should be zero.
965 * inst_num The attribute instance number to check.
966 * Returns: UDP EC value.
968 sdp_t38_udpec_e sdp_attr_get_t38udpec (sdp_t *sdp_p, uint16_t level,
969 uint8_t cap_num, uint16_t inst_num)
971 sdp_attr_t *attr_p;
973 attr_p = sdp_find_attr(sdp_p, level, cap_num,
974 SDP_ATTR_T38_UDPEC, inst_num);
975 if (attr_p == NULL) {
976 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
977 SDPLogError(logTag, "%s t38udpec attribute, level %u instance %u "
978 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
980 sdp_p->conf_p->num_invalid_param++;
981 return (SDP_T38_UDPEC_UNKNOWN);
982 } else {
983 return (attr_p->attr.t38udpec);
987 /* Function: sdp_get_media_direction
988 * Description: Determines the direction defined for a given level. The
989 * direction will be inactive, sendonly, recvonly, or sendrecv
990 * as determined by the last of these attributes specified at
991 * the given level. If none of these attributes are specified,
992 * the direction will be sendrecv by default.
993 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
994 * level The level to check for the attribute.
995 * cap_num The capability number associated with the
996 * attribute if any. If none, should be zero.
997 * Returns: An SDP direction enum value.
999 sdp_direction_e sdp_get_media_direction (sdp_t *sdp_p, uint16_t level,
1000 uint8_t cap_num)
1002 sdp_mca_t *mca_p;
1003 sdp_attr_t *attr_p;
1004 sdp_direction_e direction = SDP_DIRECTION_SENDRECV;
1006 if (cap_num == 0) {
1007 /* Find the pointer to the attr list for this level. */
1008 if (level == SDP_SESSION_LEVEL) {
1009 attr_p = sdp_p->sess_attrs_p;
1010 } else { /* Attr is at a media level */
1011 mca_p = sdp_find_media_level(sdp_p, level);
1012 if (mca_p == NULL) {
1013 return (direction);
1015 attr_p = mca_p->media_attrs_p;
1018 /* Scan for direction oriented attributes. Last one wins. */
1019 for (; attr_p != NULL; attr_p = attr_p->next_p) {
1020 if (attr_p->type == SDP_ATTR_INACTIVE) {
1021 direction = SDP_DIRECTION_INACTIVE;
1022 } else if (attr_p->type == SDP_ATTR_SENDONLY) {
1023 direction = SDP_DIRECTION_SENDONLY;
1024 } else if (attr_p->type == SDP_ATTR_RECVONLY) {
1025 direction = SDP_DIRECTION_RECVONLY;
1026 } else if (attr_p->type == SDP_ATTR_SENDRECV) {
1027 direction = SDP_DIRECTION_SENDRECV;
1030 } else {
1031 if (sdp_p->debug_flag[SDP_DEBUG_WARNINGS]) {
1032 SDPLogDebug(logTag, "%s Warning: Invalid cap_num for media direction.",
1033 sdp_p->debug_str);
1037 return (direction);
1040 /* Since there are four different attribute names which all have the same
1041 * qos parameters, all of these attributes are accessed through this same
1042 * set of APIs. To distinguish between specific attributes, the application
1043 * must also pass the attribute type. The attribute must be one of:
1044 * SDP_ATTR_QOS, SDP_ATTR_SECURE, SDP_ATTR_X_PC_QOS, and SDP_ATTR_X_QOS.
1046 tinybool sdp_validate_qos_attr (sdp_attr_e qos_attr)
1048 if ((qos_attr == SDP_ATTR_QOS) ||
1049 (qos_attr == SDP_ATTR_SECURE) ||
1050 (qos_attr == SDP_ATTR_X_PC_QOS) ||
1051 (qos_attr == SDP_ATTR_X_QOS) ||
1052 (qos_attr == SDP_ATTR_CURR) ||
1053 (qos_attr == SDP_ATTR_DES) ||
1054 (qos_attr == SDP_ATTR_CONF)){
1055 return (TRUE);
1056 } else {
1057 return (FALSE);
1061 /* Function: sdp_attr_get_qos_strength
1062 * Description: Returns the value of the qos attribute strength
1063 * parameter specified for the given attribute. If the given
1064 * attribute is not defined, SDP_QOS_STRENGTH_UNKNOWN is
1065 * returned.
1066 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1067 * level The level to check for the attribute.
1068 * cap_num The capability number associated with the
1069 * attribute if any. If none, should be zero.
1070 * qos_attr The specific type of qos attribute. May be
1071 * qos, secure, X-pc-qos, or X-qos.
1072 * inst_num The attribute instance number to check.
1073 * Returns: Qos strength value.
1075 sdp_qos_strength_e sdp_attr_get_qos_strength (sdp_t *sdp_p, uint16_t level,
1076 uint8_t cap_num, sdp_attr_e qos_attr, uint16_t inst_num)
1078 sdp_attr_t *attr_p;
1080 if (sdp_validate_qos_attr(qos_attr) == FALSE) {
1081 if (sdp_p->debug_flag[SDP_DEBUG_WARNINGS]) {
1082 SDPLogDebug(logTag, "%s Warning: Invalid QOS attribute specified for"
1083 "get qos strength.", sdp_p->debug_str);
1085 return (SDP_QOS_STRENGTH_UNKNOWN);
1087 attr_p = sdp_find_attr(sdp_p, level, cap_num, qos_attr, inst_num);
1088 if (attr_p == NULL) {
1089 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1090 SDPLogError(logTag, "%s %s attribute, level %u instance %u "
1091 "not found.", sdp_p->debug_str,
1092 sdp_get_attr_name(qos_attr), (unsigned)level, (unsigned)inst_num);
1094 sdp_p->conf_p->num_invalid_param++;
1095 return (SDP_QOS_STRENGTH_UNKNOWN);
1096 } else {
1097 switch (qos_attr) {
1098 case SDP_ATTR_QOS:
1099 return (attr_p->attr.qos.strength);
1100 case SDP_ATTR_DES:
1101 return (attr_p->attr.des.strength);
1102 default:
1103 return SDP_QOS_STRENGTH_UNKNOWN;
1109 /* Function: sdp_attr_get_qos_direction
1110 * Description: Returns the value of the qos attribute direction
1111 * parameter specified for the given attribute. If the given
1112 * attribute is not defined, SDP_QOS_DIR_UNKNOWN is
1113 * returned.
1114 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1115 * level The level to check for the attribute.
1116 * cap_num The capability number associated with the
1117 * attribute if any. If none, should be zero.
1118 * qos_attr The specific type of qos attribute. May be
1119 * qos, secure, X-pc-qos, or X-qos.
1120 * inst_num The attribute instance number to check.
1121 * Returns: Qos direction value.
1123 sdp_qos_dir_e sdp_attr_get_qos_direction (sdp_t *sdp_p, uint16_t level,
1124 uint8_t cap_num, sdp_attr_e qos_attr, uint16_t inst_num)
1126 sdp_attr_t *attr_p;
1128 if (sdp_validate_qos_attr(qos_attr) == FALSE) {
1129 if (sdp_p->debug_flag[SDP_DEBUG_WARNINGS]) {
1130 SDPLogDebug(logTag, "%s Warning: Invalid QOS attribute specified "
1131 "for get qos direction.", sdp_p->debug_str);
1133 return (SDP_QOS_DIR_UNKNOWN);
1135 attr_p = sdp_find_attr(sdp_p, level, cap_num, qos_attr, inst_num);
1136 if (attr_p == NULL) {
1137 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1138 SDPLogError(logTag, "%s %s attribute, level %u instance %u "
1139 "not found.", sdp_p->debug_str,
1140 sdp_get_attr_name(qos_attr), (unsigned)level, (unsigned)inst_num);
1142 sdp_p->conf_p->num_invalid_param++;
1143 return (SDP_QOS_DIR_UNKNOWN);
1144 } else {
1145 switch (qos_attr) {
1146 case SDP_ATTR_QOS:
1147 return (attr_p->attr.qos.direction);
1148 case SDP_ATTR_CURR:
1149 return (attr_p->attr.curr.direction);
1150 case SDP_ATTR_DES:
1151 return (attr_p->attr.des.direction);
1152 case SDP_ATTR_CONF:
1153 return (attr_p->attr.conf.direction);
1154 default:
1155 return SDP_QOS_DIR_UNKNOWN;
1161 /* Function: sdp_attr_get_qos_status_type
1162 * Description: Returns the value of the qos attribute status_type
1163 * parameter specified for the given attribute. If the given
1164 * attribute is not defined, SDP_QOS_STATUS_TYPE_UNKNOWN is
1165 * returned.
1166 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1167 * level The level to check for the attribute.
1168 * cap_num The capability number associated with the
1169 * attribute if any. If none, should be zero.
1170 * qos_attr The specific type of qos attribute. May be
1171 * qos, secure, X-pc-qos, or X-qos.
1172 * inst_num The attribute instance number to check.
1173 * Returns: Qos direction value.
1175 sdp_qos_status_types_e sdp_attr_get_qos_status_type (sdp_t *sdp_p, uint16_t level,
1176 uint8_t cap_num, sdp_attr_e qos_attr, uint16_t inst_num)
1178 sdp_attr_t *attr_p;
1180 if (sdp_validate_qos_attr(qos_attr) == FALSE) {
1181 if (sdp_p->debug_flag[SDP_DEBUG_WARNINGS]) {
1182 SDPLogDebug(logTag, "%s Warning: Invalid QOS attribute specified "
1183 "for get qos status_type.", sdp_p->debug_str);
1185 return (SDP_QOS_STATUS_TYPE_UNKNOWN);
1187 attr_p = sdp_find_attr(sdp_p, level, cap_num, qos_attr, inst_num);
1188 if (attr_p == NULL) {
1189 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1190 SDPLogError(logTag, "%s %s attribute, level %u instance %u "
1191 "not found.", sdp_p->debug_str,
1192 sdp_get_attr_name(qos_attr), (unsigned)level, (unsigned)inst_num);
1194 sdp_p->conf_p->num_invalid_param++;
1195 return (SDP_QOS_STATUS_TYPE_UNKNOWN);
1196 } else {
1197 switch (qos_attr) {
1198 case SDP_ATTR_CURR:
1199 return (attr_p->attr.curr.status_type);
1200 case SDP_ATTR_DES:
1201 return (attr_p->attr.des.status_type);
1202 case SDP_ATTR_CONF:
1203 return (attr_p->attr.conf.status_type);
1204 default:
1205 return SDP_QOS_STATUS_TYPE_UNKNOWN;
1211 /* Function: sdp_attr_get_qos_confirm
1212 * Description: Returns the value of the qos attribute confirm
1213 * parameter specified for the given attribute. Returns TRUE if
1214 * the confirm parameter is specified.
1215 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1216 * level The level to check for the attribute.
1217 * cap_num The capability number associated with the
1218 * attribute if any. If none, should be zero.
1219 * qos_attr The specific type of qos attribute. May be
1220 * qos, secure, X-pc-qos, or X-qos.
1221 * inst_num The attribute instance number to check.
1222 * Returns: Boolean value.
1224 tinybool sdp_attr_get_qos_confirm (sdp_t *sdp_p, uint16_t level,
1225 uint8_t cap_num, sdp_attr_e qos_attr, uint16_t inst_num)
1227 sdp_attr_t *attr_p;
1229 if (sdp_validate_qos_attr(qos_attr) == FALSE) {
1230 if (sdp_p->debug_flag[SDP_DEBUG_WARNINGS]) {
1231 SDPLogDebug(logTag, "%s Warning: Invalid QOS attribute specified "
1232 "for get qos confirm.", sdp_p->debug_str);
1234 return (FALSE);
1236 attr_p = sdp_find_attr(sdp_p, level, cap_num, qos_attr, inst_num);
1237 if (attr_p == NULL) {
1238 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1239 SDPLogError(logTag, "%s %s attribute, level %u instance %u "
1240 "not found.", sdp_p->debug_str,
1241 sdp_get_attr_name(qos_attr), (unsigned)level, (unsigned)inst_num);
1243 sdp_p->conf_p->num_invalid_param++;
1244 return (FALSE);
1245 } else {
1246 return (attr_p->attr.qos.confirm);
1250 /* Function: sdp_attr_get_curr_type
1251 * Description: Returns the value of the curr attribute status_type
1252 * parameter specified for the given attribute. If the given
1253 * attribute is not defined, SDP_CURR_UNKNOWN_TYPE is
1254 * returned.
1255 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1256 * level The level to check for the attribute.
1257 * cap_num The capability number associated with the
1258 * attribute if any. If none, should be zero.
1259 * qos_attr The specific type of qos attribute. May be
1260 * qos, secure, X-pc-qos, or X-qos.
1261 * inst_num The attribute instance number to check.
1262 * Returns: Curr type value.
1264 sdp_curr_type_e sdp_attr_get_curr_type (sdp_t *sdp_p, uint16_t level,
1265 uint8_t cap_num, sdp_attr_e qos_attr, uint16_t inst_num)
1267 sdp_attr_t *attr_p;
1269 attr_p = sdp_find_attr(sdp_p, level, cap_num, qos_attr, inst_num);
1270 if (attr_p == NULL) {
1271 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1272 SDPLogError(logTag, "%s %s attribute, level %u instance %u "
1273 "not found.", sdp_p->debug_str,
1274 sdp_get_attr_name(qos_attr), (unsigned)level, (unsigned)inst_num);
1276 sdp_p->conf_p->num_invalid_param++;
1277 return (SDP_CURR_UNKNOWN_TYPE);
1278 } else {
1279 return (attr_p->attr.curr.type);
1283 /* Function: sdp_attr_get_des_type
1284 * Description: Returns the value of the des attribute status_type
1285 * parameter specified for the given attribute. If the given
1286 * attribute is not defined, SDP_DES_UNKNOWN_TYPE is
1287 * returned.
1288 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1289 * level The level to check for the attribute.
1290 * cap_num The capability number associated with the
1291 * attribute if any. If none, should be zero.
1292 * qos_attr The specific type of qos attribute. May be
1293 * qos, secure, X-pc-qos, or X-qos.
1294 * inst_num The attribute instance number to check.
1295 * Returns: DES type value.
1297 sdp_des_type_e sdp_attr_get_des_type (sdp_t *sdp_p, uint16_t level,
1298 uint8_t cap_num, sdp_attr_e qos_attr, uint16_t inst_num)
1300 sdp_attr_t *attr_p;
1302 attr_p = sdp_find_attr(sdp_p, level, cap_num, qos_attr, inst_num);
1303 if (attr_p == NULL) {
1304 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1305 SDPLogError(logTag, "%s %s attribute, level %u instance %u "
1306 "not found.", sdp_p->debug_str,
1307 sdp_get_attr_name(qos_attr), (unsigned)level, (unsigned)inst_num);
1309 sdp_p->conf_p->num_invalid_param++;
1310 return (SDP_DES_UNKNOWN_TYPE);
1311 } else {
1312 return (attr_p->attr.des.type);
1316 /* Function: sdp_attr_get_conf_type
1317 * Description: Returns the value of the des attribute status_type
1318 * parameter specified for the given attribute. If the given
1319 * attribute is not defined, SDP_CONF_UNKNOWN_TYPE is
1320 * returned.
1321 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1322 * level The level to check for the attribute.
1323 * cap_num The capability number associated with the
1324 * attribute if any. If none, should be zero.
1325 * qos_attr The specific type of qos attribute. May be
1326 * qos, secure, X-pc-qos, or X-qos.
1327 * inst_num The attribute instance number to check.
1328 * Returns: CONF type value.
1330 sdp_conf_type_e sdp_attr_get_conf_type (sdp_t *sdp_p, uint16_t level,
1331 uint8_t cap_num, sdp_attr_e qos_attr, uint16_t inst_num)
1333 sdp_attr_t *attr_p;
1335 attr_p = sdp_find_attr(sdp_p, level, cap_num, qos_attr, inst_num);
1336 if (attr_p == NULL) {
1337 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1338 SDPLogError(logTag, "%s %s attribute, level %u instance %u "
1339 "not found.", sdp_p->debug_str,
1340 sdp_get_attr_name(qos_attr), (unsigned)level, (unsigned)inst_num);
1342 sdp_p->conf_p->num_invalid_param++;
1343 return (SDP_CONF_UNKNOWN_TYPE);
1344 } else {
1345 return (attr_p->attr.conf.type);
1349 /* Function: sdp_attr_get_subnet_nettype
1350 * Description: Returns the value of the subnet attribute network type
1351 * parameter specified for the given attribute. If the given
1352 * attribute is not defined, SDP_NT_INVALID is returned.
1353 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1354 * level The level to check for the attribute.
1355 * cap_num The capability number associated with the
1356 * attribute if any. If none, should be zero.
1357 * inst_num The attribute instance number to check.
1358 * Returns: Nettype value.
1360 sdp_nettype_e sdp_attr_get_subnet_nettype (sdp_t *sdp_p, uint16_t level,
1361 uint8_t cap_num, uint16_t inst_num)
1363 sdp_attr_t *attr_p;
1365 attr_p = sdp_find_attr(sdp_p, level, cap_num,
1366 SDP_ATTR_SUBNET, inst_num);
1367 if (attr_p == NULL) {
1368 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1369 SDPLogError(logTag, "%s Subnet attribute, level %u instance %u "
1370 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
1372 sdp_p->conf_p->num_invalid_param++;
1373 return (SDP_NT_INVALID);
1374 } else {
1375 return (attr_p->attr.subnet.nettype);
1379 /* Function: sdp_attr_get_subnet_addrtype
1380 * Description: Returns the value of the subnet attribute address type
1381 * parameter specified for the given attribute. If the given
1382 * attribute is not defined, SDP_AT_INVALID is returned.
1383 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1384 * level The level to check for the attribute.
1385 * cap_num The capability number associated with the
1386 * attribute if any. If none, should be zero.
1387 * inst_num The attribute instance number to check.
1388 * Returns: Addrtype value.
1390 sdp_addrtype_e sdp_attr_get_subnet_addrtype (sdp_t *sdp_p, uint16_t level,
1391 uint8_t cap_num, uint16_t inst_num)
1393 sdp_attr_t *attr_p;
1395 attr_p = sdp_find_attr(sdp_p, level, cap_num,
1396 SDP_ATTR_SUBNET, inst_num);
1397 if (attr_p == NULL) {
1398 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1399 SDPLogError(logTag, "%s Subnet attribute, level %u instance %u "
1400 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
1402 sdp_p->conf_p->num_invalid_param++;
1403 return (SDP_AT_INVALID);
1404 } else {
1405 return (attr_p->attr.subnet.addrtype);
1409 /* Function: sdp_attr_get_subnet_addr
1410 * Description: Returns the value of the subnet attribute address
1411 * parameter specified for the given attribute. If the given
1412 * attribute is not defined, NULL is returned. Value is
1413 * returned as a const ptr and so cannot be modified by the
1414 * application.
1415 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1416 * level The level to check for the attribute.
1417 * cap_num The capability number associated with the
1418 * attribute if any. If none, should be zero.
1419 * inst_num The attribute instance number to check.
1420 * Returns: Pointer to address or NULL.
1422 const char *sdp_attr_get_subnet_addr (sdp_t *sdp_p, uint16_t level,
1423 uint8_t cap_num, uint16_t inst_num)
1425 sdp_attr_t *attr_p;
1427 attr_p = sdp_find_attr(sdp_p, level, cap_num,
1428 SDP_ATTR_SUBNET, inst_num);
1429 if (attr_p == NULL) {
1430 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1431 SDPLogError(logTag, "%s Subnet attribute, level %u instance %u "
1432 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
1434 sdp_p->conf_p->num_invalid_param++;
1435 return (NULL);
1436 } else {
1437 return (attr_p->attr.subnet.addr);
1441 /* Function: sdp_attr_get_subnet_prefix
1442 * Description: Returns the value of the subnet attribute prefix
1443 * parameter specified for the given attribute. If the given
1444 * attribute is not defined, SDP_INVALID_PARAM is returned.
1445 * Note that this is value is defined to be (-2) and is
1446 * different from the return code SDP_INVALID_PARAMETER.
1447 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1448 * level The level to check for the attribute.
1449 * cap_num The capability number associated with the
1450 * attribute if any. If none, should be zero.
1451 * inst_num The attribute instance number to check.
1452 * Returns: Prefix value or SDP_INVALID_PARAM.
1454 int32_t sdp_attr_get_subnet_prefix (sdp_t *sdp_p, uint16_t level,
1455 uint8_t cap_num, uint16_t inst_num)
1457 sdp_attr_t *attr_p;
1459 attr_p = sdp_find_attr(sdp_p, level, cap_num,
1460 SDP_ATTR_SUBNET, inst_num);
1461 if (attr_p == NULL) {
1462 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1463 SDPLogError(logTag, "%s Subnet attribute, level %u instance %u "
1464 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
1466 sdp_p->conf_p->num_invalid_param++;
1467 return (SDP_INVALID_VALUE);
1468 } else {
1469 return (attr_p->attr.subnet.prefix);
1473 /* Function: sdp_attr_rtpmap_payload_valid
1474 * Description: Returns true or false depending on whether an rtpmap
1475 * attribute was specified with the given payload value
1476 * at the given level. If it was, the instance number of
1477 * that attribute is returned.
1478 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1479 * level The level to check for the attribute.
1480 * cap_num The capability number associated with the
1481 * attribute if any. If none, should be zero.
1482 * inst_num The attribute instance number of the attribute
1483 * found is returned via this param.
1484 * Returns: TRUE or FALSE.
1486 tinybool sdp_attr_rtpmap_payload_valid (sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
1487 uint16_t *inst_num, uint16_t payload_type)
1489 uint16_t i;
1490 sdp_attr_t *attr_p;
1491 uint16_t num_instances;
1493 *inst_num = 0;
1495 if (sdp_attr_num_instances(sdp_p, level, cap_num,
1496 SDP_ATTR_RTPMAP, &num_instances) != SDP_SUCCESS) {
1497 return (FALSE);
1500 for (i=1; i <= num_instances; i++) {
1501 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_RTPMAP, i);
1502 if ((attr_p != NULL) &&
1503 (attr_p->attr.transport_map.payload_num == payload_type)) {
1504 *inst_num = i;
1505 return (TRUE);
1509 return (FALSE);
1512 /* Function: sdp_attr_get_rtpmap_payload_type
1513 * Description: Returns the value of the rtpmap attribute payload type
1514 * parameter specified for the given attribute. If the given
1515 * attribute is not defined, zero is returned.
1516 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1517 * level The level to check for the attribute.
1518 * cap_num The capability number associated with the
1519 * attribute if any. If none, should be zero.
1520 * inst_num The attribute instance number to check.
1521 * Returns: Payload type value.
1523 uint16_t sdp_attr_get_rtpmap_payload_type (sdp_t *sdp_p, uint16_t level,
1524 uint8_t cap_num, uint16_t inst_num)
1526 sdp_attr_t *attr_p;
1528 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_RTPMAP, inst_num);
1529 if (attr_p == NULL) {
1530 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1531 SDPLogError(logTag, "%s rtpmap attribute, level %u instance %u "
1532 "not found.",
1533 sdp_p->debug_str,
1534 (unsigned)level,
1535 (unsigned)inst_num);
1537 sdp_p->conf_p->num_invalid_param++;
1538 return (0);
1539 } else {
1540 return (attr_p->attr.transport_map.payload_num);
1544 /* Function: sdp_attr_get_rtpmap_encname
1545 * Description: Returns a pointer to the value of the encoding name
1546 * parameter specified for the given attribute. Value is
1547 * returned as a const ptr and so cannot be modified by the
1548 * application. If the given attribute is not defined, NULL
1549 * will be returned.
1550 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1551 * level The level to check for the attribute.
1552 * cap_num The capability number associated with the
1553 * attribute if any. If none, should be zero.
1554 * inst_num The attribute instance number to check.
1555 * Returns: Codec value or SDP_CODEC_INVALID.
1557 const char *sdp_attr_get_rtpmap_encname (sdp_t *sdp_p, uint16_t level,
1558 uint8_t cap_num, uint16_t inst_num)
1560 sdp_attr_t *attr_p;
1562 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_RTPMAP, inst_num);
1563 if (attr_p == NULL) {
1564 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1565 SDPLogError(logTag, "%s rtpmap attribute, level %u instance %u "
1566 "not found.",
1567 sdp_p->debug_str,
1568 (unsigned)level,
1569 (unsigned)inst_num);
1571 sdp_p->conf_p->num_invalid_param++;
1572 return (NULL);
1573 } else {
1574 return (attr_p->attr.transport_map.encname);
1578 /* Function: sdp_attr_get_rtpmap_clockrate
1579 * Description: Returns the value of the rtpmap attribute clockrate
1580 * parameter specified for the given attribute. If the given
1581 * attribute is not defined, zero is returned.
1582 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1583 * level The level to check for the attribute.
1584 * cap_num The capability number associated with the
1585 * attribute if any. If none, should be zero.
1586 * inst_num The attribute instance number to check.
1587 * Returns: Clockrate value.
1589 uint32_t sdp_attr_get_rtpmap_clockrate (sdp_t *sdp_p, uint16_t level,
1590 uint8_t cap_num, uint16_t inst_num)
1592 sdp_attr_t *attr_p;
1594 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_RTPMAP, inst_num);
1595 if (attr_p == NULL) {
1596 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1597 SDPLogError(logTag, "%s rtpmap attribute, level %u instance %u "
1598 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
1600 sdp_p->conf_p->num_invalid_param++;
1601 return (0);
1602 } else {
1603 return (attr_p->attr.transport_map.clockrate);
1607 /* Function: sdp_attr_get_rtpmap_num_chan
1608 * Description: Returns the value of the rtpmap attribute num_chan
1609 * parameter specified for the given attribute. If the given
1610 * attribute is not defined, zero is returned.
1611 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1612 * level The level to check for the attribute.
1613 * cap_num The capability number associated with the
1614 * attribute if any. If none, should be zero.
1615 * inst_num The attribute instance number to check.
1616 * Returns: Number of channels param or zero.
1618 uint16_t sdp_attr_get_rtpmap_num_chan (sdp_t *sdp_p, uint16_t level,
1619 uint8_t cap_num, uint16_t inst_num)
1621 sdp_attr_t *attr_p;
1623 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_RTPMAP, inst_num);
1624 if (attr_p == NULL) {
1625 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1626 SDPLogError(logTag, "%s rtpmap attribute, level %u instance %u "
1627 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
1629 sdp_p->conf_p->num_invalid_param++;
1630 return (0);
1631 } else {
1632 return (attr_p->attr.transport_map.num_chan);
1636 /* Function: sdp_attr_get_ice_attribute
1637 * Description: Returns the value of an ice attribute at a given level
1639 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1640 * level The level to check for the attribute.
1641 * cap_num The capability number associated with the
1642 * attribute if any. If none, should be zero.
1643 * inst_num The attribute instance number to check.
1644 * ice_attrib Returns an ice attrib string
1645 * Returns:
1646 * SDP_SUCCESS Attribute param was set successfully.
1647 * SDP_INVALID_SDP_PTR SDP pointer invalid
1648 * SDP_INVALID_PARAMETER Specified attribute is not defined.
1651 sdp_result_e sdp_attr_get_ice_attribute (sdp_t *sdp_p, uint16_t level,
1652 uint8_t cap_num, sdp_attr_e sdp_attr, uint16_t inst_num,
1653 char **out)
1655 sdp_attr_t *attr_p;
1657 attr_p = sdp_find_attr(sdp_p, level, cap_num, sdp_attr, inst_num);
1658 if (attr_p != NULL) {
1659 *out = attr_p->attr.ice_attr;
1660 return (SDP_SUCCESS);
1661 } else {
1662 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1663 SDPLogError(logTag, "%s ice attribute, level %u instance %u "
1664 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
1666 sdp_p->conf_p->num_invalid_param++;
1667 return (SDP_INVALID_PARAMETER);
1671 /* Function: sdp_attr_is_present
1672 * Description: Returns a boolean value based on attribute being present or
1673 * not
1675 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1676 * attr_type The attribute type.
1677 * level The level to check for the attribute.
1678 * cap_num The capability number associated with the
1679 * attribute if any. If none, should be zero.
1680 * Returns:
1681 * Boolean value.
1684 tinybool sdp_attr_is_present (sdp_t *sdp_p, sdp_attr_e attr_type, uint16_t level,
1685 uint8_t cap_num)
1687 sdp_attr_t *attr_p;
1689 attr_p = sdp_find_attr(sdp_p, level, cap_num, attr_type, 1);
1690 if (attr_p != NULL) {
1691 return (TRUE);
1693 if (sdp_p->debug_flag[SDP_DEBUG_WARNINGS]) {
1694 SDPLogDebug(logTag, "%s Attribute %s, level %u not found.",
1695 sdp_p->debug_str, sdp_get_attr_name(attr_type), level);
1698 return (FALSE);
1703 /* Function: sdp_attr_get_rtcp_mux_attribute
1704 * Description: Returns the value of an rtcp-mux attribute at a given level
1706 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1707 * level The level to check for the attribute.
1708 * cap_num The capability number associated with the
1709 * attribute if any. If none, should be zero.
1710 * inst_num The attribute instance number to check.
1711 * rtcp_mux Returns an rtcp-mux attrib bool
1712 * Returns:
1713 * SDP_SUCCESS Attribute param was set successfully.
1714 * SDP_INVALID_SDP_PTR SDP pointer invalid
1715 * SDP_INVALID_PARAMETER Specified attribute is not defined.
1717 sdp_result_e sdp_attr_get_rtcp_mux_attribute (sdp_t *sdp_p, uint16_t level,
1718 uint8_t cap_num, sdp_attr_e sdp_attr, uint16_t inst_num,
1719 tinybool *rtcp_mux)
1721 sdp_attr_t *attr_p;
1723 attr_p = sdp_find_attr(sdp_p, level, cap_num, sdp_attr, inst_num);
1724 if (attr_p != NULL) {
1725 *rtcp_mux = attr_p->attr.boolean_val;
1726 return (SDP_SUCCESS);
1727 } else {
1728 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1729 SDPLogError(logTag, "%s rtcp-mux attribute, level %u instance %u "
1730 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
1732 sdp_p->conf_p->num_invalid_param++;
1733 return (SDP_INVALID_PARAMETER);
1737 /* Function: sdp_attr_get_setup_attribute
1738 * Description: Returns the value of a setup attribute at a given level
1740 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1741 * level The level to check for the attribute.
1742 * cap_num The capability number associated with the
1743 * attribute if any. If none, should be zero.
1744 * inst_num The attribute instance number to check.
1745 * setup_type Returns sdp_setup_type_e enum
1746 * Returns:
1747 * SDP_SUCCESS Attribute param was set successfully.
1748 * SDP_INVALID_SDP_PTR SDP pointer invalid
1749 * SDP_INVALID_PARAMETER Specified attribute is not defined.
1751 sdp_result_e sdp_attr_get_setup_attribute (sdp_t *sdp_p, uint16_t level,
1752 uint8_t cap_num, uint16_t inst_num, sdp_setup_type_e *setup_type)
1754 sdp_attr_t *attr_p;
1756 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_SETUP, inst_num);
1757 if (!attr_p) {
1758 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1759 SDPLogError(logTag,
1760 "%s setup attribute, level %u instance %u not found.",
1761 sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
1763 sdp_p->conf_p->num_invalid_param++;
1764 return SDP_INVALID_PARAMETER;
1767 *setup_type = attr_p->attr.setup;
1768 return SDP_SUCCESS;
1771 /* Function: sdp_attr_get_connection_attribute
1772 * Description: Returns the value of a connection attribute at a given level
1774 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1775 * level The level to check for the attribute.
1776 * cap_num The capability number associated with the
1777 * attribute if any. If none, should be zero.
1778 * inst_num The attribute instance number to check.
1779 * connection_type Returns sdp_connection_type_e enum
1780 * Returns:
1781 * SDP_SUCCESS Attribute param was set successfully.
1782 * SDP_INVALID_SDP_PTR SDP pointer invalid
1783 * SDP_INVALID_PARAMETER Specified attribute is not defined.
1785 sdp_result_e sdp_attr_get_connection_attribute (sdp_t *sdp_p, uint16_t level,
1786 uint8_t cap_num, uint16_t inst_num, sdp_connection_type_e *connection_type)
1788 sdp_attr_t *attr_p;
1790 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_CONNECTION,
1791 inst_num);
1792 if (!attr_p) {
1793 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1794 SDPLogError(logTag,
1795 "%s setup attribute, level %u instance %u not found.",
1796 sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
1798 sdp_p->conf_p->num_invalid_param++;
1799 return SDP_INVALID_PARAMETER;
1802 *connection_type = attr_p->attr.connection;
1803 return SDP_SUCCESS;
1806 /* Function: sdp_attr_get_dtls_fingerprint_attribute
1807 * Description: Returns the value of dtls fingerprint attribute at a given level
1809 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1810 * level The level to check for the attribute.
1811 * cap_num The capability number associated with the
1812 * attribute if any. If none, should be zero.
1813 * inst_num The attribute instance number to check.
1814 * dtls_fingerprint Returns an dtls fingerprint attrib string
1815 * Returns:
1816 * SDP_SUCCESS Attribute param was set successfully.
1817 * SDP_INVALID_SDP_PTR SDP pointer invalid
1818 * SDP_INVALID_PARAMETER Specified attribute is not defined.
1820 sdp_result_e sdp_attr_get_dtls_fingerprint_attribute (sdp_t *sdp_p, uint16_t level,
1821 uint8_t cap_num, sdp_attr_e sdp_attr, uint16_t inst_num,
1822 char **out)
1824 sdp_attr_t *attr_p;
1826 attr_p = sdp_find_attr(sdp_p, level, cap_num, sdp_attr, inst_num);
1827 if (attr_p != NULL) {
1828 *out = attr_p->attr.string_val;
1829 return (SDP_SUCCESS);
1830 } else {
1831 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1832 SDPLogError(logTag, "%s dtls fingerprint attribute, level %u instance %u "
1833 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
1835 sdp_p->conf_p->num_invalid_param++;
1836 return (SDP_INVALID_PARAMETER);
1840 /* Function: sdp_attr_sprtmap_payload_valid
1841 * Description: Returns true or false depending on whether an sprtmap
1842 * attribute was specified with the given payload value
1843 * at the given level. If it was, the instance number of
1844 * that attribute is returned.
1845 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1846 * level The level to check for the attribute.
1847 * cap_num The capability number associated with the
1848 * attribute if any. If none, should be zero.
1849 * inst_num The attribute instance number of the attribute
1850 * found is returned via this param.
1851 * Returns: TRUE or FALSE.
1853 tinybool sdp_attr_sprtmap_payload_valid (sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
1854 uint16_t *inst_num, uint16_t payload_type)
1856 uint16_t i;
1857 sdp_attr_t *attr_p;
1858 uint16_t num_instances;
1860 *inst_num = 0;
1862 if (sdp_attr_num_instances(sdp_p, level, cap_num,
1863 SDP_ATTR_SPRTMAP, &num_instances) != SDP_SUCCESS) {
1864 return (FALSE);
1867 for (i=1; i <= num_instances; i++) {
1868 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_SPRTMAP, i);
1869 if ((attr_p != NULL) &&
1870 (attr_p->attr.transport_map.payload_num == payload_type)) {
1871 *inst_num = i;
1872 return (TRUE);
1876 return (FALSE);
1879 /* Function: sdp_attr_get_sprtmap_payload_type
1880 * Description: Returns the value of the sprtmap attribute payload type
1881 * parameter specified for the given attribute. If the given
1882 * attribute is not defined, zero is returned.
1883 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1884 * level The level to check for the attribute.
1885 * cap_num The capability number associated with the
1886 * attribute if any. If none, should be zero.
1887 * inst_num The attribute instance number to check.
1888 * Returns: Payload type value.
1890 uint16_t sdp_attr_get_sprtmap_payload_type (sdp_t *sdp_p, uint16_t level,
1891 uint8_t cap_num, uint16_t inst_num)
1893 sdp_attr_t *attr_p;
1895 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_SPRTMAP, inst_num);
1896 if (attr_p == NULL) {
1897 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1898 SDPLogError(logTag, "%s sprtmap attribute, level %u instance %u "
1899 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
1901 sdp_p->conf_p->num_invalid_param++;
1902 return (0);
1903 } else {
1904 return (attr_p->attr.transport_map.payload_num);
1908 /* Function: sdp_attr_get_sprtmap_encname
1909 * Description: Returns a pointer to the value of the encoding name
1910 * parameter specified for the given attribute. Value is
1911 * returned as a const ptr and so cannot be modified by the
1912 * application. If the given attribute is not defined, NULL
1913 * will be returned.
1914 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1915 * level The level to check for the attribute.
1916 * cap_num The capability number associated with the
1917 * attribute if any. If none, should be zero.
1918 * inst_num The attribute instance number to check.
1919 * Returns: Codec value or SDP_CODEC_INVALID.
1921 const char *sdp_attr_get_sprtmap_encname (sdp_t *sdp_p, uint16_t level,
1922 uint8_t cap_num, uint16_t inst_num)
1924 sdp_attr_t *attr_p;
1926 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_SPRTMAP, inst_num);
1927 if (attr_p == NULL) {
1928 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1929 SDPLogError(logTag, "%s sprtmap attribute, level %u instance %u "
1930 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
1932 sdp_p->conf_p->num_invalid_param++;
1933 return (NULL);
1934 } else {
1935 return (attr_p->attr.transport_map.encname);
1939 /* Function: sdp_attr_get_sprtmap_clockrate
1940 * Description: Returns the value of the sprtmap attribute clockrate
1941 * parameter specified for the given attribute. If the given
1942 * attribute is not defined, zero is returned.
1943 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1944 * level The level to check for the attribute.
1945 * cap_num The capability number associated with the
1946 * attribute if any. If none, should be zero.
1947 * inst_num The attribute instance number to check.
1948 * Returns: Clockrate value.
1950 uint32_t sdp_attr_get_sprtmap_clockrate (sdp_t *sdp_p, uint16_t level,
1951 uint8_t cap_num, uint16_t inst_num)
1953 sdp_attr_t *attr_p;
1955 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_SPRTMAP, inst_num);
1956 if (attr_p == NULL) {
1957 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1958 SDPLogError(logTag, "%s sprtmap attribute, level %u instance %u "
1959 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
1961 sdp_p->conf_p->num_invalid_param++;
1962 return (0);
1963 } else {
1964 return (attr_p->attr.transport_map.clockrate);
1968 /* Function: sdp_attr_get_sprtmap_num_chan
1969 * Description: Returns the value of the sprtmap attribute num_chan
1970 * parameter specified for the given attribute. If the given
1971 * attribute is not defined, zero is returned.
1972 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
1973 * level The level to check for the attribute.
1974 * cap_num The capability number associated with the
1975 * attribute if any. If none, should be zero.
1976 * inst_num The attribute instance number to check.
1977 * Returns: Number of channels param or zero.
1979 uint16_t sdp_attr_get_sprtmap_num_chan (sdp_t *sdp_p, uint16_t level,
1980 uint8_t cap_num, uint16_t inst_num)
1982 sdp_attr_t *attr_p;
1984 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_SPRTMAP, inst_num);
1985 if (attr_p == NULL) {
1986 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
1987 SDPLogError(logTag, "%s sprtmap attribute, level %u instance %u "
1988 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
1990 sdp_p->conf_p->num_invalid_param++;
1991 return (0);
1992 } else {
1993 return (attr_p->attr.transport_map.num_chan);
1997 /* Note: The fmtp attribute formats currently handled are:
1998 * fmtp:<payload type> <event>,<event>...
1999 * fmtp:<payload_type> [annexa=yes/no] [annexb=yes/no] [bitrate=<value>]
2000 * where "value" is a numeric value > 0
2001 * where each event is a single number or a range separated
2002 * by a '-'.
2003 * Example: fmtp:101 1,3-15,20
2006 /* Function: tinybool sdp_attr_fmtp_valid(sdp_t *sdp_p)
2007 * Description: Returns true or false depending on whether an fmtp
2008 * attribute was specified with the given payload value
2009 * at the given level. If it was, the instance number of
2010 * that attribute is returned.
2011 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2012 * level The level to check for the attribute.
2013 * cap_num The capability number associated with the
2014 * attribute if any. If none, should be zero.
2015 * inst_num The attribute instance number to check.
2016 * Returns: TRUE or FALSE.
2018 tinybool sdp_attr_fmtp_payload_valid (sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
2019 uint16_t *inst_num, uint16_t payload_type)
2021 uint16_t i;
2022 sdp_attr_t *attr_p;
2023 uint16_t num_instances;
2025 if (sdp_attr_num_instances(sdp_p, level, cap_num,
2026 SDP_ATTR_FMTP, &num_instances) != SDP_SUCCESS) {
2027 return (FALSE);
2030 for (i=1; i <= num_instances; i++) {
2031 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, i);
2032 if ((attr_p != NULL) &&
2033 (attr_p->attr.fmtp.payload_num == payload_type)) {
2034 *inst_num = i;
2035 return (TRUE);
2039 return (FALSE);
2042 /* Function: sdp_attr_get_fmtp_payload_type
2043 * Description: Returns the value of the fmtp attribute payload type
2044 * parameter specified for the given attribute. If the given
2045 * attribute is not defined, zero is returned.
2046 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2047 * level The level to check for the attribute.
2048 * cap_num The capability number associated with the
2049 * attribute if any. If none, should be zero.
2050 * inst_num The attribute instance number to check.
2051 * Returns: Payload type value.
2053 uint16_t sdp_attr_get_fmtp_payload_type (sdp_t *sdp_p, uint16_t level,
2054 uint8_t cap_num, uint16_t inst_num)
2056 sdp_attr_t *attr_p;
2058 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, inst_num);
2059 if (attr_p == NULL) {
2060 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2061 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2062 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2064 sdp_p->conf_p->num_invalid_param++;
2065 return (0);
2066 } else {
2067 return (attr_p->attr.fmtp.payload_num);
2072 /* Function: sdp_attr_fmtp_is_range_set
2073 * Description: Determines if a range of events is set in an fmtp attribute.
2074 * The overall range for events is 0-255.
2075 * This will return either FULL_MATCH, PARTIAL_MATCH, or NO_MATCH
2076 * depending on whether all, some, or none of the specified
2077 * events are defined. If the given attribute is not defined,
2078 * NO_MATCH will be returned. It is up to the appl to verify
2079 * the validity of the attribute before calling this routine.
2080 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2081 * level The level to check for the attribute.
2082 * cap_num The capability number associated with the
2083 * attribute if any. If none, should be zero.
2084 * inst_num The attribute instance number to check.
2085 * low_val Low value of the range. Range is 0-255.
2086 * high_val High value of the range.
2087 * Returns: SDP_FULL_MATCH, SDP_PARTIAL_MATCH, SDP_NO_MATCH
2089 sdp_ne_res_e sdp_attr_fmtp_is_range_set (sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
2090 uint16_t inst_num, uint8_t low_val, uint8_t high_val)
2092 uint16_t i;
2093 uint32_t mapword;
2094 uint32_t bmap;
2095 uint32_t num_vals = 0;
2096 uint32_t num_vals_set = 0;
2097 sdp_attr_t *attr_p;
2098 sdp_fmtp_t *fmtp_p;
2100 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, inst_num);
2101 if (attr_p == NULL) {
2102 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2103 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2104 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2106 sdp_p->conf_p->num_invalid_param++;
2107 return (SDP_NO_MATCH);
2110 fmtp_p = &(attr_p->attr.fmtp);
2111 for (i = low_val; i <= high_val; i++) {
2112 num_vals++;
2113 mapword = i/SDP_NE_BITS_PER_WORD;
2114 bmap = SDP_NE_BIT_0 << (i%32);
2115 if (fmtp_p->bmap[ mapword ] & bmap) {
2116 num_vals_set++;
2120 if (num_vals == num_vals_set) {
2121 return (SDP_FULL_MATCH);
2122 } else if (num_vals_set == 0) {
2123 return (SDP_NO_MATCH);
2124 } else {
2125 return (SDP_PARTIAL_MATCH);
2129 /* Function: sdp_attr_fmtp_valid
2130 * Description: Determines the validity of the events in the fmtp.
2131 * The overall range for events is 0-255.
2132 * The user passes an event list with valid events supported by Appl.
2133 * This routine will do a simple AND comparison and report the result.
2135 * This will return TRUE if ftmp events are valid, and FALSE otherwise.
2136 * It is up to the appl to verify the validity of the attribute
2137 * before calling this routine.
2138 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2139 * level The level to check for the attribute.
2140 * cap_num The capability number associated with the
2141 * attribute if any. If none, should be zero.
2142 * inst_num The attribute instance number to check.
2143 * appl_maxval Max event value supported by Appl. Range is 0-255.
2144 * evt_array Bitmap containing events supported by application.
2145 * Returns: TRUE, FALSE
2147 tinybool
2148 sdp_attr_fmtp_valid(sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
2149 uint16_t inst_num, uint16_t appl_maxval, uint32_t* evt_array)
2151 uint16_t i;
2152 uint32_t mapword;
2153 sdp_attr_t *attr_p;
2154 sdp_fmtp_t *fmtp_p;
2156 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, inst_num);
2157 if (attr_p == NULL) {
2158 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2159 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2160 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2162 sdp_p->conf_p->num_invalid_param++;
2163 return FALSE;
2166 fmtp_p = &(attr_p->attr.fmtp);
2168 /* Do quick test. If application max value is lower than fmtp's then error */
2169 if (fmtp_p->maxval > appl_maxval)
2170 return FALSE;
2172 /* Ok, events are within range. Now check that only
2173 * allowed events have been received
2175 mapword = appl_maxval/SDP_NE_BITS_PER_WORD;
2176 for (i=0; i<mapword; i++) {
2177 if (fmtp_p->bmap[i] & ~(evt_array[i])) {
2178 /* Remote SDP is requesting events not supported by Application */
2179 return FALSE;
2182 return TRUE;
2185 /* Function: sdp_attr_set_fmtp_payload_type
2186 * Description: Sets the value of the fmtp attribute payload type parameter
2187 * for the given attribute.
2188 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2189 * level The level to check for the attribute.
2190 * cap_num The capability number associated with the
2191 * attribute if any. If none, should be zero.
2192 * inst_num The attribute instance number to check.
2193 * payload_type New payload type value.
2194 * Returns: SDP_SUCCESS Attribute param was set successfully.
2195 * SDP_INVALID_PARAMETER Specified attribute is not defined.
2197 sdp_result_e sdp_attr_set_fmtp_payload_type (sdp_t *sdp_p, uint16_t level,
2198 uint8_t cap_num, uint16_t inst_num,
2199 uint16_t payload_num)
2201 sdp_attr_t *attr_p;
2203 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, inst_num);
2204 if (attr_p == NULL) {
2205 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2206 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2207 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2209 sdp_p->conf_p->num_invalid_param++;
2210 return (SDP_INVALID_PARAMETER);
2211 } else {
2212 attr_p->attr.fmtp.payload_num = payload_num;
2213 return (SDP_SUCCESS);
2217 /* Function: sdp_attr_get_fmtp_range
2218 * Description: Get a range of named events for an fmtp attribute.
2219 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2220 * level The level to check for the attribute.
2221 * cap_num The capability number associated with the
2222 * attribute if any. If none, should be zero.
2223 * inst_num The attribute instance number to check.
2224 * bmap The 8 word data array holding the bitmap
2225 * Returns: SDP_SUCCESS
2227 sdp_result_e sdp_attr_get_fmtp_range (sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
2228 uint16_t inst_num, uint32_t *bmap)
2230 sdp_attr_t *attr_p;
2231 sdp_fmtp_t *fmtp_p;
2233 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, inst_num);
2234 if (attr_p == NULL) {
2235 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2236 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2237 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2239 sdp_p->conf_p->num_invalid_param++;
2240 return (SDP_INVALID_PARAMETER);
2243 fmtp_p = &(attr_p->attr.fmtp);
2244 memcpy(bmap, fmtp_p->bmap, SDP_NE_NUM_BMAP_WORDS * sizeof(uint32_t) );
2246 return (SDP_SUCCESS);
2249 /* Function: sdp_attr_clear_fmtp_range
2250 * Description: Clear a range of named events for an fmtp attribute. The low
2251 * value specified must be <= the high value.
2252 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2253 * level The level to check for the attribute.
2254 * cap_num The capability number associated with the
2255 * attribute if any. If none, should be zero.
2256 * inst_num The attribute instance number to check.
2257 * low_val The low value of the range. Range is 0-255
2258 * high_val The high value of the range. May be == low.
2259 * Returns: SDP_SUCCESS
2261 sdp_result_e sdp_attr_clear_fmtp_range (sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
2262 uint16_t inst_num, uint8_t low_val, uint8_t high_val)
2264 uint16_t i;
2265 uint32_t mapword;
2266 uint32_t bmap;
2267 sdp_attr_t *attr_p;
2268 sdp_fmtp_t *fmtp_p;
2270 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, inst_num);
2271 if (attr_p == NULL) {
2272 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2273 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2274 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2276 sdp_p->conf_p->num_invalid_param++;
2277 return (SDP_INVALID_PARAMETER);
2280 fmtp_p = &(attr_p->attr.fmtp);
2281 for (i = low_val; i <= high_val; i++) {
2282 mapword = i/SDP_NE_BITS_PER_WORD;
2283 bmap = SDP_NE_BIT_0 << (i%32);
2284 fmtp_p->bmap[ mapword ] &= ~bmap;
2286 if (high_val > fmtp_p->maxval) {
2287 fmtp_p->maxval = high_val;
2289 return (SDP_SUCCESS);
2292 /* Function: sdp_attr_compare_fmtp_ranges
2293 * Description: Compare the named events set of two fmtp attributes. If all
2294 * events are the same (either set or not), FULL_MATCH will be
2295 * returned. If no events match, NO_MATCH will be returned.
2296 * Otherwise PARTIAL_MATCH will be returned. If either attr is
2297 * invalid, NO_MATCH will be returned.
2298 * Parameters: src_sdp_p The SDP handle returned by sdp_init_description.
2299 * dst_sdp_p The SDP handle returned by sdp_init_description.
2300 * src_level The level of the src fmtp attribute.
2301 * dst_level The level to the dst fmtp attribute.
2302 * src_cap_num The capability number of the src attr.
2303 * dst_cap_num The capability number of the dst attr.
2304 * src_inst_numh The attribute instance of the src attr.
2305 * dst_inst_numh The attribute instance of the dst attr.
2306 * Returns: SDP_FULL_MATCH, SDP_PARTIAL_MATCH, SDP_NO_MATCH.
2308 sdp_ne_res_e sdp_attr_compare_fmtp_ranges (sdp_t *src_sdp_p,sdp_t *dst_sdp_p,
2309 uint16_t src_level, uint16_t dst_level,
2310 uint8_t src_cap_num, uint8_t dst_cap_num,
2311 uint16_t src_inst_num, uint16_t dst_inst_num)
2313 uint16_t i,j;
2314 uint32_t bmap;
2315 uint32_t num_vals_match = 0;
2316 sdp_attr_t *src_attr_p;
2317 sdp_attr_t *dst_attr_p;
2318 sdp_fmtp_t *src_fmtp_p;
2319 sdp_fmtp_t *dst_fmtp_p;
2321 src_attr_p = sdp_find_attr(src_sdp_p, src_level, src_cap_num,
2322 SDP_ATTR_FMTP, src_inst_num);
2323 dst_attr_p = sdp_find_attr(dst_sdp_p, dst_level, dst_cap_num,
2324 SDP_ATTR_FMTP, dst_inst_num);
2325 if ((src_attr_p == NULL) || (dst_attr_p == NULL)) {
2326 if (src_sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2327 SDPLogError(logTag, "%s source or destination fmtp attribute for "
2328 "compare not found.", src_sdp_p->debug_str);
2330 src_sdp_p->conf_p->num_invalid_param++;
2331 return (SDP_NO_MATCH);
2334 src_fmtp_p = &(src_attr_p->attr.fmtp);
2335 dst_fmtp_p = &(dst_attr_p->attr.fmtp);
2336 for (i = 0; i < SDP_NE_NUM_BMAP_WORDS; i++) {
2337 for (j = 0; j < SDP_NE_BITS_PER_WORD; j++) {
2338 bmap = SDP_NE_BIT_0 << j;
2339 if ((src_fmtp_p->bmap[i] & bmap) && (dst_fmtp_p->bmap[i] & bmap)) {
2340 num_vals_match++;
2341 } else if ((!(src_fmtp_p->bmap[i] & bmap)) &&
2342 (!(dst_fmtp_p->bmap[i] & bmap))) {
2343 num_vals_match++;
2348 if (num_vals_match == (SDP_NE_NUM_BMAP_WORDS * SDP_NE_BITS_PER_WORD)) {
2349 return (SDP_FULL_MATCH);
2350 } else if (num_vals_match == 0) {
2351 return (SDP_NO_MATCH);
2352 } else {
2353 return (SDP_PARTIAL_MATCH);
2357 /* Function: sdp_attr_copy_fmtp_ranges
2358 * Description: Copy the named events set for one fmtp attribute to another.
2359 * Parameters: src_sdp_p The SDP handle returned by sdp_init_description.
2360 * dst_sdp_p The SDP handle returned by sdp_init_description.
2361 * src_level The level of the src fmtp attribute.
2362 * dst_level The level to the dst fmtp attribute.
2363 * src_cap_num The capability number of the src attr.
2364 * dst_cap_num The capability number of the dst attr.
2365 * src_inst_numh The attribute instance of the src attr.
2366 * dst_inst_numh The attribute instance of the dst attr.
2367 * Returns: SDP_SUCCESS
2369 sdp_result_e sdp_attr_copy_fmtp_ranges (sdp_t *src_sdp_p, sdp_t *dst_sdp_p,
2370 uint16_t src_level, uint16_t dst_level,
2371 uint8_t src_cap_num, uint8_t dst_cap_num,
2372 uint16_t src_inst_num, uint16_t dst_inst_num)
2374 uint16_t i;
2375 sdp_attr_t *src_attr_p;
2376 sdp_attr_t *dst_attr_p;
2377 sdp_fmtp_t *src_fmtp_p;
2378 sdp_fmtp_t *dst_fmtp_p;
2380 if (!src_sdp_p || !dst_sdp_p) {
2381 return (SDP_INVALID_SDP_PTR);
2384 src_attr_p = sdp_find_attr(src_sdp_p, src_level, src_cap_num,
2385 SDP_ATTR_FMTP, src_inst_num);
2386 dst_attr_p = sdp_find_attr(dst_sdp_p, dst_level, dst_cap_num,
2387 SDP_ATTR_FMTP, dst_inst_num);
2388 if ((src_attr_p == NULL) || (dst_attr_p == NULL)) {
2389 if (src_sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2390 SDPLogError(logTag, "%s source or destination fmtp attribute for "
2391 "copy not found.", src_sdp_p->debug_str);
2393 src_sdp_p->conf_p->num_invalid_param++;
2394 return (SDP_INVALID_PARAMETER);
2397 src_fmtp_p = &(src_attr_p->attr.fmtp);
2398 dst_fmtp_p = &(dst_attr_p->attr.fmtp);
2399 dst_fmtp_p->maxval = src_fmtp_p->maxval;
2400 for (i = 0; i < SDP_NE_NUM_BMAP_WORDS; i++) {
2401 dst_fmtp_p->bmap[i] = src_fmtp_p->bmap[i];
2403 return (SDP_SUCCESS);
2406 /* Function: sdp_attr_get_fmtp_mode
2407 * Description: Gets the value of the fmtp attribute mode parameter
2408 * for the given attribute.
2409 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2410 * level The level to check for the attribute.
2411 * cap_num The capability number associated with the
2412 * attribute if any. If none, should be zero.
2413 * payload_type payload type.
2414 * Returns: mode value or zero if mode attribute not found
2416 uint32_t sdp_attr_get_fmtp_mode_for_payload_type (sdp_t *sdp_p, uint16_t level,
2417 uint8_t cap_num, uint32_t payload_type)
2419 uint16_t num_a_lines = 0;
2420 int i;
2421 sdp_attr_t *attr_p;
2424 * Get number of FMTP attributes for the AUDIO line
2426 (void) sdp_attr_num_instances(sdp_p, level, cap_num, SDP_ATTR_FMTP,
2427 &num_a_lines);
2428 for (i = 0; i < num_a_lines; i++) {
2429 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, (uint16_t) (i + 1));
2430 if ((attr_p != NULL) &&
2431 (attr_p->attr.fmtp.payload_num == (uint16_t)payload_type)) {
2432 if (attr_p->attr.fmtp.fmtp_format == SDP_FMTP_MODE) {
2433 return attr_p->attr.fmtp.mode;
2437 return 0;
2440 sdp_result_e sdp_attr_set_fmtp_max_fs (sdp_t *sdp_p, uint16_t level,
2441 uint8_t cap_num, uint16_t inst_num,
2442 uint32_t max_fs)
2444 sdp_attr_t *attr_p;
2445 sdp_fmtp_t *fmtp_p;
2447 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, inst_num);
2448 if (attr_p == NULL) {
2449 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2450 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2451 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2453 sdp_p->conf_p->num_invalid_param++;
2454 return (SDP_INVALID_PARAMETER);
2457 fmtp_p = &(attr_p->attr.fmtp);
2458 fmtp_p->fmtp_format = SDP_FMTP_CODEC_INFO;
2460 if (max_fs > 0) {
2461 fmtp_p->max_fs = max_fs;
2462 return (SDP_SUCCESS);
2463 } else {
2464 return (SDP_FAILURE);
2468 sdp_result_e sdp_attr_set_fmtp_max_fr (sdp_t *sdp_p, uint16_t level,
2469 uint8_t cap_num, uint16_t inst_num,
2470 uint32_t max_fr)
2472 sdp_attr_t *attr_p;
2473 sdp_fmtp_t *fmtp_p;
2475 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, inst_num);
2476 if (attr_p == NULL) {
2477 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2478 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2479 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2481 sdp_p->conf_p->num_invalid_param++;
2482 return (SDP_INVALID_PARAMETER);
2485 fmtp_p = &(attr_p->attr.fmtp);
2486 fmtp_p->fmtp_format = SDP_FMTP_CODEC_INFO;
2488 if (max_fr > 0) {
2489 fmtp_p->max_fr = max_fr;
2490 return (SDP_SUCCESS);
2491 } else {
2492 return (SDP_FAILURE);
2496 /* Function: sdp_attr_get_fmtp_max_average_bitrate
2497 * Description: Gets the value of the fmtp attribute- maxaveragebitrate parameter for the OPUS codec
2498 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2499 * level The level to check for the attribute.
2500 * cap_num The capability number associated with the
2501 * attribute if any. If none, should be zero.
2502 * inst_num The attribute instance number to check.
2503 * Returns: max-br value.
2506 sdp_result_e sdp_attr_get_fmtp_max_average_bitrate (sdp_t *sdp_p, uint16_t level,
2507 uint8_t cap_num, uint16_t inst_num, uint32_t* val)
2509 sdp_attr_t *attr_p;
2511 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, 1);
2512 if (attr_p == NULL) {
2513 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2514 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2515 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2517 sdp_p->conf_p->num_invalid_param++;
2518 return (SDP_INVALID_PARAMETER);
2519 } else {
2520 *val = attr_p->attr.fmtp.maxaveragebitrate;
2521 return (SDP_SUCCESS);
2526 /* Function: sdp_attr_get_fmtp_usedtx
2527 * Description: Gets the value of the fmtp attribute- usedtx parameter for the OPUS codec
2528 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2529 * level The level to check for the attribute.
2530 * cap_num The capability number associated with the
2531 * attribute if any. If none, should be zero.
2532 * inst_num The attribute instance number to check.
2533 * Returns: usedtx value.
2536 sdp_result_e sdp_attr_get_fmtp_usedtx (sdp_t *sdp_p, uint16_t level,
2537 uint8_t cap_num, uint16_t inst_num, tinybool* val)
2539 sdp_attr_t *attr_p;
2541 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
2542 inst_num);
2543 if (attr_p == NULL) {
2544 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2545 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2546 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2548 sdp_p->conf_p->num_invalid_param++;
2549 return (SDP_INVALID_PARAMETER);
2550 } else {
2551 *val = (tinybool)attr_p->attr.fmtp.usedtx;
2552 return (SDP_SUCCESS);
2556 /* Function: sdp_attr_get_fmtp_usedtx
2557 * Description: Gets the value of the fmtp attribute- usedtx parameter for the OPUS codec
2558 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2559 * level The level to check for the attribute.
2560 * cap_num The capability number associated with the
2561 * attribute if any. If none, should be zero.
2562 * inst_num The attribute instance number to check.
2563 * Returns: stereo value.
2566 sdp_result_e sdp_attr_get_fmtp_stereo (sdp_t *sdp_p, uint16_t level,
2567 uint8_t cap_num, uint16_t inst_num, tinybool* val)
2569 sdp_attr_t *attr_p;
2571 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
2572 inst_num);
2573 if (attr_p == NULL) {
2574 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2575 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2576 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2578 sdp_p->conf_p->num_invalid_param++;
2579 return (SDP_INVALID_PARAMETER);
2580 } else {
2581 *val = (tinybool)attr_p->attr.fmtp.stereo;
2582 return (SDP_SUCCESS);
2586 /* Function: sdp_attr_get_fmtp_useinbandfec
2587 * Description: Gets the value of the fmtp attribute useinbandfec parameter for the OPUS codec
2588 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2589 * level The level to check for the attribute.
2590 * cap_num The capability number associated with the
2591 * attribute if any. If none, should be zero.
2592 * inst_num The attribute instance number to check.
2593 * Returns: useinbandfec value.
2596 sdp_result_e sdp_attr_get_fmtp_useinbandfec (sdp_t *sdp_p, uint16_t level,
2597 uint8_t cap_num, uint16_t inst_num, tinybool* val)
2599 sdp_attr_t *attr_p;
2601 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
2602 inst_num);
2603 if (attr_p == NULL) {
2604 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2605 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2606 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2608 sdp_p->conf_p->num_invalid_param++;
2609 return (SDP_INVALID_PARAMETER);
2610 } else {
2611 *val = (tinybool)attr_p->attr.fmtp.useinbandfec;
2612 return (SDP_SUCCESS);
2616 /* Function: sdp_attr_get_fmtp_maxcodedaudiobandwidth
2617 * Description: Gets the value of the fmtp attribute maxcodedaudiobandwidth parameter for OPUS codec
2618 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2619 * level The level to check for the attribute.
2620 * cap_num The capability number associated with the
2621 * attribute if any. If none, should be zero.
2622 * inst_num The attribute instance number to check.
2623 * Returns: maxcodedaudiobandwidth value.
2625 char* sdp_attr_get_fmtp_maxcodedaudiobandwidth (sdp_t *sdp_p, uint16_t level,
2626 uint8_t cap_num, uint16_t inst_num)
2629 sdp_attr_t *attr_p;
2631 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
2632 inst_num);
2633 if (attr_p == NULL) {
2634 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2635 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2636 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2638 sdp_p->conf_p->num_invalid_param++;
2639 return (0);
2640 } else {
2641 return (attr_p->attr.fmtp.maxcodedaudiobandwidth);
2645 /* Function: sdp_attr_get_fmtp_cbr
2646 * Description: Gets the value of the fmtp attribute cbr parameter for the OPUS codec
2647 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2648 * level The level to check for the attribute.
2649 * cap_num The capability number associated with the
2650 * attribute if any. If none, should be zero.
2651 * inst_num The attribute instance number to check.
2652 * Returns: cbr value.
2655 sdp_result_e sdp_attr_get_fmtp_cbr (sdp_t *sdp_p, uint16_t level,
2656 uint8_t cap_num, uint16_t inst_num, tinybool* val)
2658 sdp_attr_t *attr_p;
2660 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
2661 inst_num);
2662 if (attr_p == NULL) {
2663 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2664 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2665 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2667 sdp_p->conf_p->num_invalid_param++;
2668 return (SDP_INVALID_PARAMETER);
2669 } else {
2670 *val = (tinybool)attr_p->attr.fmtp.cbr;
2671 return (SDP_SUCCESS);
2675 uint16_t sdp_attr_get_sctpmap_port(sdp_t *sdp_p, uint16_t level,
2676 uint8_t cap_num, uint16_t inst_num)
2678 sdp_attr_t *attr_p;
2680 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_SCTPMAP, inst_num);
2681 if (!attr_p) {
2682 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2683 SDPLogError(logTag, "%s sctpmap port, level %u instance %u "
2684 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2686 sdp_p->conf_p->num_invalid_param++;
2687 return 0;
2688 } else {
2689 return attr_p->attr.sctpmap.port;
2693 sdp_result_e sdp_attr_get_sctpmap_streams (sdp_t *sdp_p, uint16_t level,
2694 uint8_t cap_num, uint16_t inst_num, uint32_t* val)
2696 sdp_attr_t *attr_p;
2698 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_SCTPMAP, inst_num);
2699 if (!attr_p) {
2700 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2701 SDPLogError(logTag, "%s sctpmap streams, level %u instance %u "
2702 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2704 sdp_p->conf_p->num_invalid_param++;
2705 return (SDP_INVALID_PARAMETER);
2706 } else {
2707 *val = attr_p->attr.sctpmap.streams;
2708 return (SDP_SUCCESS);
2712 sdp_result_e sdp_attr_get_sctpmap_protocol (sdp_t *sdp_p, uint16_t level,
2713 uint8_t cap_num, uint16_t inst_num,
2714 char* protocol)
2717 sdp_attr_t *attr_p;
2719 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_SCTPMAP,
2720 inst_num);
2721 if (!attr_p) {
2722 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2723 SDPLogError(logTag, "%s sctpmap, level %u instance %u "
2724 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2726 sdp_p->conf_p->num_invalid_param++;
2727 return (SDP_INVALID_PARAMETER);
2728 } else {
2729 sstrncpy(protocol, attr_p->attr.sctpmap.protocol, SDP_MAX_STRING_LEN+1);
2731 return (SDP_SUCCESS);
2734 /* Function: sdp_attr_fmtp_is_annexb_set
2735 * Description: Gives the value of the fmtp attribute annexb type parameter
2736 * for the given attribute.
2737 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2738 * level The level to check for the attribute.
2739 * cap_num The capability number associated with the
2740 * attribute if any. If none, should be zero.
2741 * inst_num The attribute instance number to check.
2744 * Returns: TRUE or FALSE.
2746 tinybool sdp_attr_fmtp_is_annexb_set (sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
2747 uint16_t inst_num)
2750 sdp_attr_t *attr_p;
2752 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
2753 inst_num);
2754 if (attr_p == NULL) {
2755 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2756 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2757 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2759 sdp_p->conf_p->num_invalid_param++;
2760 return (FALSE);
2761 } else {
2762 return (attr_p->attr.fmtp.annexb);
2766 /* Function: sdp_attr_fmtp_is_annexa_set
2767 * Description: Gives the value of the fmtp attribute annexa type parameter
2768 * for the given attribute.
2769 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2770 * level The level to check for the attribute.
2771 * cap_num The capability number associated with the
2772 * attribute if any. If none, should be zero.
2773 * inst_num The attribute instance number to check.
2776 * Returns: TRUE or FALSE.
2778 tinybool sdp_attr_fmtp_is_annexa_set (sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
2779 uint16_t inst_num)
2781 sdp_attr_t *attr_p;
2783 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
2784 inst_num);
2785 if (attr_p == NULL) {
2786 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2787 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2788 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2790 sdp_p->conf_p->num_invalid_param++;
2791 return (FALSE);
2792 } else {
2793 return (attr_p->attr.fmtp.annexa);
2797 /* Function: sdp_attr_get_fmtp_bitrate_type
2798 * Description: Gets the value of the fmtp attribute bitrate type parameter
2799 * for the given attribute.
2800 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2801 * level The level to check for the attribute.
2802 * cap_num The capability number associated with the
2803 * attribute if any. If none, should be zero.
2804 * inst_num The attribute instance number to check.
2805 * Returns: Bitrate type value.
2807 int32_t sdp_attr_get_fmtp_bitrate_type (sdp_t *sdp_p, uint16_t level,
2808 uint8_t cap_num, uint16_t inst_num)
2811 sdp_attr_t *attr_p;
2813 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
2814 inst_num);
2815 if (attr_p == NULL) {
2816 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2817 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2818 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2820 sdp_p->conf_p->num_invalid_param++;
2821 return (SDP_INVALID_VALUE);
2822 } else {
2823 return (attr_p->attr.fmtp.bitrate);
2827 /* Function: sdp_attr_get_fmtp_qcif
2828 * Description: Gets the value of the fmtp attribute QCIF type parameter
2829 * for a given Video codec.
2830 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2831 * level The level to check for the attribute.
2832 * cap_num The capability number associated with the
2833 * attribute if any. If none, should be zero.
2834 * inst_num The attribute instance number to check.
2835 * Returns: QCIF value.
2837 int32_t sdp_attr_get_fmtp_qcif (sdp_t *sdp_p, uint16_t level,
2838 uint8_t cap_num, uint16_t inst_num)
2841 sdp_attr_t *attr_p;
2843 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
2844 inst_num);
2845 if (attr_p == NULL) {
2846 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2847 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2848 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2850 sdp_p->conf_p->num_invalid_param++;
2851 return (SDP_INVALID_VALUE);
2852 } else {
2853 return (attr_p->attr.fmtp.qcif);
2856 /* Function: sdp_attr_get_fmtp_cif
2857 * Description: Gets the value of the fmtp attribute CIF type parameter
2858 * for a given Video codec.
2859 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2860 * level The level to check for the attribute.
2861 * cap_num The capability number associated with the
2862 * attribute if any. If none, should be zero.
2863 * inst_num The attribute instance number to check.
2864 * Returns: CIF value.
2866 int32_t sdp_attr_get_fmtp_cif (sdp_t *sdp_p, uint16_t level,
2867 uint8_t cap_num, uint16_t inst_num)
2870 sdp_attr_t *attr_p;
2872 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
2873 inst_num);
2874 if (attr_p == NULL) {
2875 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2876 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2877 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2879 sdp_p->conf_p->num_invalid_param++;
2880 return (SDP_INVALID_VALUE);
2881 } else {
2882 return (attr_p->attr.fmtp.cif);
2887 /* Function: sdp_attr_get_fmtp_sqcif
2888 * Description: Gets the value of the fmtp attribute sqcif type parameter
2889 * for a given Video codec.
2890 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2891 * level The level to check for the attribute.
2892 * cap_num The capability number associated with the
2893 * attribute if any. If none, should be zero.
2894 * inst_num The attribute instance number to check.
2895 * Returns: sqcif value.
2897 int32_t sdp_attr_get_fmtp_sqcif (sdp_t *sdp_p, uint16_t level,
2898 uint8_t cap_num, uint16_t inst_num)
2901 sdp_attr_t *attr_p;
2903 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
2904 inst_num);
2905 if (attr_p == NULL) {
2906 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2907 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2908 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2910 sdp_p->conf_p->num_invalid_param++;
2911 return (SDP_INVALID_VALUE);
2912 } else {
2913 return (attr_p->attr.fmtp.sqcif);
2917 /* Function: sdp_attr_get_fmtp_cif4
2918 * Description: Gets the value of the fmtp attribute CIF4 type parameter
2919 * for a given Video codec.
2920 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2921 * level The level to check for the attribute.
2922 * cap_num The capability number associated with the
2923 * attribute if any. If none, should be zero.
2924 * inst_num The attribute instance number to check.
2925 * Returns: CIF4 value.
2927 int32_t sdp_attr_get_fmtp_cif4 (sdp_t *sdp_p, uint16_t level,
2928 uint8_t cap_num, uint16_t inst_num)
2931 sdp_attr_t *attr_p;
2933 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
2934 inst_num);
2935 if (attr_p == NULL) {
2936 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2937 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2938 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2940 sdp_p->conf_p->num_invalid_param++;
2941 return (SDP_INVALID_VALUE);
2942 } else {
2943 return (attr_p->attr.fmtp.cif4);
2947 /* Function: sdp_attr_get_fmtp_cif16
2948 * Description: Gets the value of the fmtp attribute CIF16 type parameter
2949 * for a given Video codec.
2950 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2951 * level The level to check for the attribute.
2952 * cap_num The capability number associated with the
2953 * attribute if any. If none, should be zero.
2954 * inst_num The attribute instance number to check.
2955 * Returns: CIF16 value.
2958 int32_t sdp_attr_get_fmtp_cif16 (sdp_t *sdp_p, uint16_t level,
2959 uint8_t cap_num, uint16_t inst_num)
2962 sdp_attr_t *attr_p;
2964 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
2965 inst_num);
2966 if (attr_p == NULL) {
2967 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2968 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
2969 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
2971 sdp_p->conf_p->num_invalid_param++;
2972 return (SDP_INVALID_VALUE);
2973 } else {
2974 return (attr_p->attr.fmtp.cif16);
2979 /* Function: sdp_attr_get_fmtp_maxbr
2980 * Description: Gets the value of the fmtp attribute MAXBR type parameter
2981 * for a given Video codec.
2982 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
2983 * level The level to check for the attribute.
2984 * cap_num The capability number associated with the
2985 * attribute if any. If none, should be zero.
2986 * inst_num The attribute instance number to check.
2987 * Returns: MAXBR value.
2989 int32_t sdp_attr_get_fmtp_maxbr (sdp_t *sdp_p, uint16_t level,
2990 uint8_t cap_num, uint16_t inst_num)
2993 sdp_attr_t *attr_p;
2995 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
2996 inst_num);
2997 if (attr_p == NULL) {
2998 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
2999 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3000 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3002 sdp_p->conf_p->num_invalid_param++;
3003 return (SDP_INVALID_VALUE);
3004 } else {
3005 return (attr_p->attr.fmtp.maxbr);
3009 /* Function: sdp_attr_get_fmtp_custom_x
3010 * Description: Gets the value of the fmtp attribute CUSTOM type parameter
3011 * for a given Video codec.
3012 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3013 * level The level to check for the attribute.
3014 * cap_num The capability number associated with the
3015 * attribute if any. If none, should be zero.
3016 * inst_num The attribute instance number to check.
3017 * Returns: CUSTOM x value.
3020 int32_t sdp_attr_get_fmtp_custom_x (sdp_t *sdp_p, uint16_t level,
3021 uint8_t cap_num, uint16_t inst_num)
3024 sdp_attr_t *attr_p;
3026 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3027 inst_num);
3028 if (attr_p == NULL) {
3029 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3030 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3031 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3033 sdp_p->conf_p->num_invalid_param++;
3034 return (SDP_INVALID_VALUE);
3035 } else {
3036 return (attr_p->attr.fmtp.custom_x);
3039 /* Function: sdp_attr_get_fmtp_custom_y
3040 * Description: Gets the value of the fmtp attribute custom_y type parameter
3041 * for a given Video codec.
3042 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3043 * level The level to check for the attribute.
3044 * cap_num The capability number associated with the
3045 * attribute if any. If none, should be zero.
3046 * inst_num The attribute instance number to check.
3047 * Returns: CUSTOM Y-AXIS value.
3050 int32_t sdp_attr_get_fmtp_custom_y (sdp_t *sdp_p, uint16_t level,
3051 uint8_t cap_num, uint16_t inst_num)
3054 sdp_attr_t *attr_p;
3056 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3057 inst_num);
3058 if (attr_p == NULL) {
3059 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3060 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3061 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3063 sdp_p->conf_p->num_invalid_param++;
3064 return (SDP_INVALID_VALUE);
3065 } else {
3066 return (attr_p->attr.fmtp.custom_y);
3070 /* Function: sdp_attr_get_fmtp_custom_mpi
3071 * Description: Gets the value of the fmtp attribute CUSTOM type parameter
3072 * for a given Video codec.
3073 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3074 * level The level to check for the attribute.
3075 * cap_num The capability number associated with the
3076 * attribute if any. If none, should be zero.
3077 * inst_num The attribute instance number to check.
3078 * Returns: CUSTOM MPI value.
3081 int32_t sdp_attr_get_fmtp_custom_mpi (sdp_t *sdp_p, uint16_t level,
3082 uint8_t cap_num, uint16_t inst_num)
3085 sdp_attr_t *attr_p;
3087 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3088 inst_num);
3089 if (attr_p == NULL) {
3090 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3091 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3092 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3094 sdp_p->conf_p->num_invalid_param++;
3095 return (SDP_INVALID_VALUE);
3096 } else {
3097 return (attr_p->attr.fmtp.custom_mpi);
3101 /* Function: sdp_attr_get_fmtp_par_width
3102 * Description: Gets the value of the fmtp attribute PAR (width) parameter
3103 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3104 * level The level to check for the attribute.
3105 * cap_num The capability number associated with the
3106 * attribute if any. If none, should be zero.
3107 * inst_num The attribute instance number to check.
3108 * Returns: PAR - width value.
3110 int32_t sdp_attr_get_fmtp_par_width (sdp_t *sdp_p, uint16_t level,
3111 uint8_t cap_num, uint16_t inst_num)
3114 sdp_attr_t *attr_p;
3116 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3117 inst_num);
3118 if (attr_p == NULL) {
3119 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3120 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3121 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3123 sdp_p->conf_p->num_invalid_param++;
3124 return (SDP_INVALID_VALUE);
3125 } else {
3126 return (attr_p->attr.fmtp.par_width);
3130 /* Function: sdp_attr_get_fmtp_par_height
3131 * Description: Gets the value of the fmtp attribute PAR (height) parameter
3132 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3133 * level The level to check for the attribute.
3134 * cap_num The capability number associated with the
3135 * attribute if any. If none, should be zero.
3136 * inst_num The attribute instance number to check.
3137 * Returns: PAR - height value.
3139 int32_t sdp_attr_get_fmtp_par_height (sdp_t *sdp_p, uint16_t level,
3140 uint8_t cap_num, uint16_t inst_num)
3143 sdp_attr_t *attr_p;
3145 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3146 inst_num);
3147 if (attr_p == NULL) {
3148 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3149 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3150 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3152 sdp_p->conf_p->num_invalid_param++;
3153 return (SDP_INVALID_VALUE);
3154 } else {
3155 return (attr_p->attr.fmtp.par_height);
3159 /* Function: sdp_attr_get_fmtp_cpcf
3160 * Description: Gets the value of the fmtp attribute- CPCF parameter
3161 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3162 * level The level to check for the attribute.
3163 * cap_num The capability number associated with the
3164 * attribute if any. If none, should be zero.
3165 * inst_num The attribute instance number to check.
3166 * Returns: CPCF value.
3168 int32_t sdp_attr_get_fmtp_cpcf (sdp_t *sdp_p, uint16_t level,
3169 uint8_t cap_num, uint16_t inst_num)
3172 sdp_attr_t *attr_p;
3174 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3175 inst_num);
3176 if (attr_p == NULL) {
3177 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3178 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3179 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3181 sdp_p->conf_p->num_invalid_param++;
3182 return (SDP_INVALID_VALUE);
3183 } else {
3184 return (attr_p->attr.fmtp.cpcf);
3188 /* Function: sdp_attr_get_fmtp_bpp
3189 * Description: Gets the value of the fmtp attribute- BPP parameter
3190 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3191 * level The level to check for the attribute.
3192 * cap_num The capability number associated with the
3193 * attribute if any. If none, should be zero.
3194 * inst_num The attribute instance number to check.
3195 * Returns: BPP value.
3197 int32_t sdp_attr_get_fmtp_bpp (sdp_t *sdp_p, uint16_t level,
3198 uint8_t cap_num, uint16_t inst_num)
3201 sdp_attr_t *attr_p;
3203 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3204 inst_num);
3205 if (attr_p == NULL) {
3206 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3207 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3208 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3210 sdp_p->conf_p->num_invalid_param++;
3211 return (SDP_INVALID_VALUE);
3212 } else {
3213 return (attr_p->attr.fmtp.bpp);
3217 /* Function: sdp_attr_get_fmtp_hrd
3218 * Description: Gets the value of the fmtp attribute- HRD parameter
3219 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3220 * level The level to check for the attribute.
3221 * cap_num The capability number associated with the
3222 * attribute if any. If none, should be zero.
3223 * inst_num The attribute instance number to check.
3224 * Returns: HRD value.
3226 int32_t sdp_attr_get_fmtp_hrd (sdp_t *sdp_p, uint16_t level,
3227 uint8_t cap_num, uint16_t inst_num)
3230 sdp_attr_t *attr_p;
3232 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3233 inst_num);
3234 if (attr_p == NULL) {
3235 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3236 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3237 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3239 sdp_p->conf_p->num_invalid_param++;
3240 return (SDP_INVALID_VALUE);
3241 } else {
3242 return (attr_p->attr.fmtp.hrd);
3246 /* Function: sdp_attr_get_fmtp_profile
3247 * Description: Gets the value of the fmtp attribute- PROFILE parameter
3248 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3249 * level The level to check for the attribute.
3250 * cap_num The capability number associated with the
3251 * attribute if any. If none, should be zero.
3252 * inst_num The attribute instance number to check.
3253 * Returns: PROFILE value.
3255 int32_t sdp_attr_get_fmtp_profile (sdp_t *sdp_p, uint16_t level,
3256 uint8_t cap_num, uint16_t inst_num)
3259 sdp_attr_t *attr_p;
3261 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3262 inst_num);
3263 if (attr_p == NULL) {
3264 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3265 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3266 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3268 sdp_p->conf_p->num_invalid_param++;
3269 return (SDP_INVALID_VALUE);
3270 } else {
3271 return (attr_p->attr.fmtp.profile);
3275 /* Function: sdp_attr_get_fmtp_level
3276 * Description: Gets the value of the fmtp attribute- LEVEL parameter
3277 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3278 * level The level to check for the attribute.
3279 * cap_num The capability number associated with the
3280 * attribute if any. If none, should be zero.
3281 * inst_num The attribute instance number to check.
3282 * Returns: LEVEL value.
3284 int32_t sdp_attr_get_fmtp_level (sdp_t *sdp_p, uint16_t level,
3285 uint8_t cap_num, uint16_t inst_num)
3288 sdp_attr_t *attr_p;
3290 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3291 inst_num);
3292 if (attr_p == NULL) {
3293 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3294 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3295 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3297 sdp_p->conf_p->num_invalid_param++;
3298 return (SDP_INVALID_VALUE);
3299 } else {
3300 return (attr_p->attr.fmtp.level);
3304 /* Function: sdp_attr_get_fmtp_interlace
3305 * Description: Checks if INTERLACE parameter is set.
3306 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3307 * level The level to check for the attribute.
3308 * cap_num The capability number associated with the
3309 * attribute if any. If none, should be zero.
3310 * inst_num The attribute instance number to check.
3311 * Returns: TRUE if INTERLACE is present and FALSE if INTERLACE is absent.
3313 tinybool sdp_attr_get_fmtp_interlace (sdp_t *sdp_p, uint16_t level,
3314 uint8_t cap_num, uint16_t inst_num)
3317 sdp_attr_t *attr_p;
3319 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3320 inst_num);
3321 if (attr_p == NULL) {
3322 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3323 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3324 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3326 sdp_p->conf_p->num_invalid_param++;
3327 return FALSE;
3328 } else {
3329 return (attr_p->attr.fmtp.is_interlace);
3333 /* Function: sdp_attr_get_fmtp_pack_mode
3334 * Description: Gets the value of the fmtp attribute- packetization-mode parameter for H.264 codec
3335 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3336 * level The level to check for the attribute.
3337 * cap_num The capability number associated with the
3338 * attribute if any. If none, should be zero.
3339 * inst_num The attribute instance number to check.
3340 * Returns: packetization-mode value in the range 0 - 2.
3343 sdp_result_e sdp_attr_get_fmtp_pack_mode (sdp_t *sdp_p, uint16_t level,
3344 uint8_t cap_num, uint16_t inst_num, uint16_t *val)
3347 sdp_attr_t *attr_p;
3349 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3350 inst_num);
3351 if (attr_p == NULL) {
3352 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3353 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3354 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3356 sdp_p->conf_p->num_invalid_param++;
3357 return (SDP_INVALID_PARAMETER);
3358 } else {
3359 if (SDP_INVALID_PACKETIZATION_MODE_VALUE == attr_p->attr.fmtp.packetization_mode) {
3360 /* packetization mode unspecified (optional) */
3361 *val = SDP_DEFAULT_PACKETIZATION_MODE_VALUE;
3362 } else {
3363 *val = attr_p->attr.fmtp.packetization_mode;
3365 return (SDP_SUCCESS);
3369 /* Function: sdp_attr_get_fmtp_level_asymmetry_allowed
3370 * Description: Gets the value of the fmtp attribute- level-asymmetry-allowed parameter for H.264 codec
3371 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3372 * level The level to check for the attribute.
3373 * cap_num The capability number associated with the
3374 * attribute if any. If none, should be zero.
3375 * inst_num The attribute instance number to check.
3376 * Returns: level asymmetry allowed value (0 or 1).
3379 sdp_result_e sdp_attr_get_fmtp_level_asymmetry_allowed (sdp_t *sdp_p, uint16_t level,
3380 uint8_t cap_num, uint16_t inst_num, uint16_t *val)
3383 sdp_attr_t *attr_p;
3385 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3386 inst_num);
3387 if (attr_p == NULL) {
3388 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3389 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3390 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3392 sdp_p->conf_p->num_invalid_param++;
3393 return (SDP_INVALID_PARAMETER);
3394 } else {
3395 *val = attr_p->attr.fmtp.level_asymmetry_allowed;
3396 return (SDP_SUCCESS);
3400 /* Function: sdp_attr_get_fmtp_profile_id
3401 * Description: Gets the value of the fmtp attribute- profile-level-id parameter for H.264 codec
3402 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3403 * level The level to check for the attribute.
3404 * cap_num The capability number associated with the
3405 * attribute if any. If none, should be zero.
3406 * inst_num The attribute instance number to check.
3407 * Returns: profile-level-id value.
3409 const char* sdp_attr_get_fmtp_profile_id (sdp_t *sdp_p, uint16_t level,
3410 uint8_t cap_num, uint16_t inst_num)
3413 sdp_attr_t *attr_p;
3415 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3416 inst_num);
3417 if (attr_p == NULL) {
3418 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3419 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3420 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3422 sdp_p->conf_p->num_invalid_param++;
3423 return (0);
3424 } else {
3425 return (attr_p->attr.fmtp.profile_level_id);
3429 /* Function: sdp_attr_get_fmtp_param_sets
3430 * Description: Gets the value of the fmtp attribute- parameter-sets parameter for H.264 codec
3431 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3432 * level The level to check for the attribute.
3433 * cap_num The capability number associated with the
3434 * attribute if any. If none, should be zero.
3435 * inst_num The attribute instance number to check.
3436 * Returns: parameter-sets value.
3438 const char* sdp_attr_get_fmtp_param_sets (sdp_t *sdp_p, uint16_t level,
3439 uint8_t cap_num, uint16_t inst_num)
3442 sdp_attr_t *attr_p;
3444 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3445 inst_num);
3446 if (attr_p == NULL) {
3447 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3448 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3449 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3451 sdp_p->conf_p->num_invalid_param++;
3452 return (0);
3453 } else {
3454 return (attr_p->attr.fmtp.parameter_sets);
3458 /* Function: sdp_attr_get_fmtp_interleaving_depth
3459 * Description: Gets the value of the fmtp attribute- interleaving_depth parameter for H.264 codec
3460 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3461 * level The level to check for the attribute.
3462 * cap_num The capability number associated with the
3463 * attribute if any. If none, should be zero.
3464 * inst_num The attribute instance number to check.
3465 * Returns: interleaving_depth value
3468 sdp_result_e sdp_attr_get_fmtp_interleaving_depth (sdp_t *sdp_p, uint16_t level,
3469 uint8_t cap_num, uint16_t inst_num, uint16_t* val)
3471 sdp_attr_t *attr_p;
3473 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3474 inst_num);
3475 if (attr_p == NULL) {
3476 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3477 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3478 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3480 sdp_p->conf_p->num_invalid_param++;
3481 return (SDP_INVALID_PARAMETER);
3482 } else {
3483 *val = attr_p->attr.fmtp.interleaving_depth;
3484 return (SDP_SUCCESS);
3488 /* Function: sdp_attr_get_fmtp_deint_buf_req
3489 * Description: Gets the value of the fmtp attribute- deint-buf-req parameter for H.264 codec
3490 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3491 * level The level to check for the attribute.
3492 * cap_num The capability number associated with the
3493 * attribute if any. If none, should be zero.
3494 * inst_num The attribute instance number to check.
3495 * Returns: deint-buf-req value.
3498 sdp_result_e sdp_attr_get_fmtp_deint_buf_req (sdp_t *sdp_p, uint16_t level,
3499 uint8_t cap_num, uint16_t inst_num,
3500 uint32_t *val)
3502 sdp_attr_t *attr_p;
3504 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3505 inst_num);
3506 if (attr_p == NULL) {
3507 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3508 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3509 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3511 sdp_p->conf_p->num_invalid_param++;
3512 return (SDP_INVALID_PARAMETER);
3513 } else {
3514 if (attr_p->attr.fmtp.flag & SDP_DEINT_BUF_REQ_FLAG) {
3515 *val = attr_p->attr.fmtp.deint_buf_req;
3516 return (SDP_SUCCESS);
3517 } else {
3518 return (SDP_FAILURE);
3523 /* Function: sdp_attr_get_fmtp_max_don_diff
3524 * Description: Gets the value of the fmtp attribute- max-don-diff parameter for H.264 codec
3525 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3526 * level The level to check for the attribute.
3527 * cap_num The capability number associated with the
3528 * attribute if any. If none, should be zero.
3529 * inst_num The attribute instance number to check.
3530 * Returns: max-don-diff value.
3532 sdp_result_e sdp_attr_get_fmtp_max_don_diff (sdp_t *sdp_p, uint16_t level,
3533 uint8_t cap_num, uint16_t inst_num,
3534 uint32_t *val)
3536 sdp_attr_t *attr_p;
3538 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3539 inst_num);
3540 if (attr_p == NULL) {
3541 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3542 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3543 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3545 sdp_p->conf_p->num_invalid_param++;
3546 return (SDP_INVALID_PARAMETER);
3547 } else {
3548 *val = attr_p->attr.fmtp.max_don_diff;
3549 return (SDP_SUCCESS);
3553 /* Function: sdp_attr_get_fmtp_init_buf_time
3554 * Description: Gets the value of the fmtp attribute- init-buf-time parameter for H.264 codec
3555 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3556 * level The level to check for the attribute.
3557 * cap_num The capability number associated with the
3558 * attribute if any. If none, should be zero.
3559 * inst_num The attribute instance number to check.
3560 * Returns: init-buf-time value.
3562 sdp_result_e sdp_attr_get_fmtp_init_buf_time (sdp_t *sdp_p, uint16_t level,
3563 uint8_t cap_num, uint16_t inst_num,
3564 uint32_t *val)
3566 sdp_attr_t *attr_p;
3568 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3569 inst_num);
3570 if (attr_p == NULL) {
3571 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3572 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3573 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3575 sdp_p->conf_p->num_invalid_param++;
3576 return (SDP_INVALID_PARAMETER);
3577 } else {
3578 if (attr_p->attr.fmtp.flag & SDP_INIT_BUF_TIME_FLAG) {
3579 *val = attr_p->attr.fmtp.init_buf_time;
3580 return (SDP_SUCCESS);
3581 } else {
3582 return (SDP_FAILURE);
3587 /* Function: sdp_attr_get_fmtp_max_mbps
3588 * Description: Gets the value of the fmtp attribute- max-mbps parameter for H.264 codec
3589 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3590 * level The level to check for the attribute.
3591 * cap_num The capability number associated with the
3592 * attribute if any. If none, should be zero.
3593 * inst_num The attribute instance number to check.
3594 * Returns: max-mbps value.
3597 sdp_result_e sdp_attr_get_fmtp_max_mbps (sdp_t *sdp_p, uint16_t level,
3598 uint8_t cap_num, uint16_t inst_num,
3599 uint32_t *val)
3601 sdp_attr_t *attr_p;
3603 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3604 inst_num);
3605 if (attr_p == NULL) {
3606 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3607 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3608 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3610 sdp_p->conf_p->num_invalid_param++;
3611 return (SDP_INVALID_PARAMETER);
3612 } else {
3613 *val = attr_p->attr.fmtp.max_mbps;
3614 return (SDP_SUCCESS);
3618 /* Function: sdp_attr_get_fmtp_max_fs
3619 * Description: Gets the value of the fmtp attribute- max-fs parameter for H.264 codec
3620 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3621 * level The level to check for the attribute.
3622 * cap_num The capability number associated with the
3623 * attribute if any. If none, should be zero.
3624 * inst_num The attribute instance number to check.
3625 * Returns: max-fs value.
3628 sdp_result_e sdp_attr_get_fmtp_max_fs (sdp_t *sdp_p, uint16_t level,
3629 uint8_t cap_num, uint16_t inst_num, uint32_t *val)
3631 sdp_attr_t *attr_p;
3633 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3634 inst_num);
3635 if (attr_p == NULL) {
3636 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3637 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3638 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3640 sdp_p->conf_p->num_invalid_param++;
3641 return (SDP_INVALID_PARAMETER);
3642 } else {
3643 *val = attr_p->attr.fmtp.max_fs;
3644 return (SDP_SUCCESS);
3648 /* Function: sdp_attr_get_fmtp_max_fr
3649 * Description: Gets the value of the fmtp attribute- max-fr parameter
3650 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3651 * level The level to check for the attribute.
3652 * cap_num The capability number associated with the
3653 * attribute if any. If none, should be zero.
3654 * inst_num The attribute instance number to check.
3655 * Returns: max-fr value.
3658 sdp_result_e sdp_attr_get_fmtp_max_fr (sdp_t *sdp_p, uint16_t level,
3659 uint8_t cap_num, uint16_t inst_num, uint32_t *val)
3661 sdp_attr_t *attr_p;
3663 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3664 inst_num);
3665 if (attr_p == NULL) {
3666 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3667 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3668 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3670 sdp_p->conf_p->num_invalid_param++;
3671 return (SDP_INVALID_PARAMETER);
3672 } else {
3673 *val = attr_p->attr.fmtp.max_fr;
3674 return (SDP_SUCCESS);
3678 /* Function: sdp_attr_get_fmtp_max_cpb
3679 * Description: Gets the value of the fmtp attribute- max-cpb parameter for H.264 codec
3680 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3681 * level The level to check for the attribute.
3682 * cap_num The capability number associated with the
3683 * attribute if any. If none, should be zero.
3684 * inst_num The attribute instance number to check.
3685 * Returns: max-cpb value.
3688 sdp_result_e sdp_attr_get_fmtp_max_cpb (sdp_t *sdp_p, uint16_t level,
3689 uint8_t cap_num, uint16_t inst_num, uint32_t *val)
3691 sdp_attr_t *attr_p;
3693 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3694 inst_num);
3695 if (attr_p == NULL) {
3696 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3697 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3698 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3700 sdp_p->conf_p->num_invalid_param++;
3701 return (SDP_INVALID_PARAMETER);
3702 } else {
3703 *val = attr_p->attr.fmtp.max_cpb;
3704 return (SDP_SUCCESS);
3708 /* Function: sdp_attr_get_fmtp_max_dpb
3709 * Description: Gets the value of the fmtp attribute- max-dpb parameter for H.264 codec
3710 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3711 * level The level to check for the attribute.
3712 * cap_num The capability number associated with the
3713 * attribute if any. If none, should be zero.
3714 * inst_num The attribute instance number to check.
3715 * Returns: max-dpb value.
3718 sdp_result_e sdp_attr_get_fmtp_max_dpb (sdp_t *sdp_p, uint16_t level,
3719 uint8_t cap_num, uint16_t inst_num, uint32_t *val)
3721 sdp_attr_t *attr_p;
3723 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3724 inst_num);
3725 if (attr_p == NULL) {
3726 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3727 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3728 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3730 sdp_p->conf_p->num_invalid_param++;
3731 return (SDP_INVALID_PARAMETER);
3732 } else {
3733 *val = attr_p->attr.fmtp.max_dpb;
3734 return (SDP_SUCCESS);
3739 /* Function: sdp_attr_get_fmtp_max_br
3740 * Description: Gets the value of the fmtp attribute- max-br parameter for H.264 codec
3741 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3742 * level The level to check for the attribute.
3743 * cap_num The capability number associated with the
3744 * attribute if any. If none, should be zero.
3745 * inst_num The attribute instance number to check.
3746 * Returns: max-br value.
3749 sdp_result_e sdp_attr_get_fmtp_max_br (sdp_t *sdp_p, uint16_t level,
3750 uint8_t cap_num, uint16_t inst_num, uint32_t* val)
3752 sdp_attr_t *attr_p;
3754 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3755 inst_num);
3756 if (attr_p == NULL) {
3757 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3758 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3759 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3761 sdp_p->conf_p->num_invalid_param++;
3762 return (SDP_INVALID_PARAMETER);
3763 } else {
3764 *val = attr_p->attr.fmtp.max_br;
3765 return (SDP_SUCCESS);
3769 /* Function: sdp_attr_fmtp_is_redundant_pic_cap
3770 * Description: Gets the value of the fmtp attribute- redundant_pic_cap parameter for H.264 codec
3771 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3772 * level The level to check for the attribute.
3773 * cap_num The capability number associated with the
3774 * attribute if any. If none, should be zero.
3775 * inst_num The attribute instance number to check.
3776 * Returns: redundant-pic-cap value.
3778 tinybool sdp_attr_fmtp_is_redundant_pic_cap (sdp_t *sdp_p, uint16_t level,
3779 uint8_t cap_num, uint16_t inst_num)
3782 sdp_attr_t *attr_p;
3784 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3785 inst_num);
3786 if (attr_p == NULL) {
3787 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3788 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3789 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3791 sdp_p->conf_p->num_invalid_param++;
3792 return (FALSE);
3793 } else {
3794 return (attr_p->attr.fmtp.redundant_pic_cap);
3798 /* Function: sdp_attr_get_fmtp_deint_buf_cap
3799 * Description: Gets the value of the fmtp attribute- deint-buf-cap parameter for H.264 codec
3800 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3801 * level The level to check for the attribute.
3802 * cap_num The capability number associated with the
3803 * attribute if any. If none, should be zero.
3804 * inst_num The attribute instance number to check.
3805 * Returns: deint-buf-cap value.
3808 sdp_result_e sdp_attr_get_fmtp_deint_buf_cap (sdp_t *sdp_p, uint16_t level,
3809 uint8_t cap_num, uint16_t inst_num,
3810 uint32_t *val)
3813 sdp_attr_t *attr_p;
3815 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3816 inst_num);
3817 if (attr_p == NULL) {
3818 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3819 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3820 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3822 sdp_p->conf_p->num_invalid_param++;
3823 return (SDP_INVALID_PARAMETER);
3824 } else {
3825 if (attr_p->attr.fmtp.flag & SDP_DEINT_BUF_CAP_FLAG) {
3826 *val = attr_p->attr.fmtp.deint_buf_cap;
3827 return (SDP_SUCCESS);
3828 } else {
3829 return (SDP_FAILURE);
3834 /* Function: sdp_attr_get_fmtp_max_rcmd_nalu_size
3835 * Description: Gets the value of the fmtp attribute- max-rcmd-nalu-size parameter for H.264 codec
3836 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3837 * level The level to check for the attribute.
3838 * cap_num The capability number associated with the
3839 * attribute if any. If none, should be zero.
3840 * inst_num The attribute instance number to check.
3841 * Returns: max-rcmd-nalu-size value.
3843 sdp_result_e sdp_attr_get_fmtp_max_rcmd_nalu_size (sdp_t *sdp_p, uint16_t level,
3844 uint8_t cap_num, uint16_t inst_num,
3845 uint32_t *val)
3848 sdp_attr_t *attr_p;
3850 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3851 inst_num);
3852 if (attr_p == NULL) {
3853 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3854 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3855 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3857 sdp_p->conf_p->num_invalid_param++;
3858 return (SDP_INVALID_PARAMETER);
3859 } else {
3860 if (attr_p->attr.fmtp.flag & SDP_MAX_RCMD_NALU_SIZE_FLAG) {
3861 *val = attr_p->attr.fmtp.max_rcmd_nalu_size;
3862 return (SDP_SUCCESS);
3863 } else {
3864 return (SDP_FAILURE);
3869 /* Function: sdp_attr_fmtp_is_parameter_add
3870 * Description: Gets the value of the fmtp attribute- parameter-add for H.264 codec
3871 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3872 * level The level to check for the attribute.
3873 * cap_num The capability number associated with the
3874 * attribute if any. If none, should be zero.
3875 * inst_num The attribute instance number to check.
3876 * Returns: TRUE/FALSE ( parameter-add is boolean)
3878 tinybool sdp_attr_fmtp_is_parameter_add (sdp_t *sdp_p, uint16_t level,
3879 uint8_t cap_num, uint16_t inst_num)
3882 sdp_attr_t *attr_p;
3884 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3885 inst_num);
3886 if (attr_p == NULL) {
3887 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3888 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3889 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3891 sdp_p->conf_p->num_invalid_param++;
3892 return (FALSE);
3893 } else {
3894 /* Both 1 and SDP_FMTP_UNUSED (parameter not present) should be
3895 * treated as TRUE, per RFC 3984, page 45 */
3896 return (attr_p->attr.fmtp.parameter_add != 0);
3900 /****** Following functions are get routines for Annex values
3901 * For each Annex support, the get routine will return the boolean TRUE/FALSE
3902 * Some Annexures for Video codecs have values defined . In those cases,
3903 * (e.g Annex K, P ) , the return values are not boolean.
3905 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
3906 * level The level to check for the attribute.
3907 * cap_num The capability number associated with the
3908 * attribute if any. If none, should be zero.
3909 * inst_num The attribute instance number to check.
3910 * Returns: Annex value
3913 tinybool sdp_attr_get_fmtp_annex_d (sdp_t *sdp_p, uint16_t level,
3914 uint8_t cap_num, uint16_t inst_num)
3917 sdp_attr_t *attr_p;
3919 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3920 inst_num);
3921 if (attr_p == NULL) {
3922 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3923 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3924 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3926 sdp_p->conf_p->num_invalid_param++;
3927 return (FALSE);
3928 } else {
3929 return (attr_p->attr.fmtp.annex_d);
3933 tinybool sdp_attr_get_fmtp_annex_f (sdp_t *sdp_p, uint16_t level,
3934 uint8_t cap_num, uint16_t inst_num)
3937 sdp_attr_t *attr_p;
3939 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3940 inst_num);
3941 if (attr_p == NULL) {
3942 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3943 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3944 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3946 sdp_p->conf_p->num_invalid_param++;
3947 return (FALSE);
3948 } else {
3949 return (attr_p->attr.fmtp.annex_f);
3953 tinybool sdp_attr_get_fmtp_annex_i (sdp_t *sdp_p, uint16_t level,
3954 uint8_t cap_num, uint16_t inst_num)
3957 sdp_attr_t *attr_p;
3959 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3960 inst_num);
3961 if (attr_p == NULL) {
3962 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3963 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3964 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3966 sdp_p->conf_p->num_invalid_param++;
3967 return (FALSE);
3968 } else {
3969 return (attr_p->attr.fmtp.annex_i);
3973 tinybool sdp_attr_get_fmtp_annex_j (sdp_t *sdp_p, uint16_t level,
3974 uint8_t cap_num, uint16_t inst_num)
3977 sdp_attr_t *attr_p;
3979 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
3980 inst_num);
3981 if (attr_p == NULL) {
3982 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
3983 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
3984 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
3986 sdp_p->conf_p->num_invalid_param++;
3987 return (FALSE);
3988 } else {
3989 return (attr_p->attr.fmtp.annex_j);
3993 tinybool sdp_attr_get_fmtp_annex_t (sdp_t *sdp_p, uint16_t level,
3994 uint8_t cap_num, uint16_t inst_num)
3997 sdp_attr_t *attr_p;
3999 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
4000 inst_num);
4001 if (attr_p == NULL) {
4002 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4003 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
4004 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4006 sdp_p->conf_p->num_invalid_param++;
4007 return (FALSE);
4008 } else {
4009 return (attr_p->attr.fmtp.annex_t);
4013 int32_t sdp_attr_get_fmtp_annex_k_val (sdp_t *sdp_p, uint16_t level,
4014 uint8_t cap_num, uint16_t inst_num)
4017 sdp_attr_t *attr_p;
4019 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
4020 inst_num);
4021 if (attr_p == NULL) {
4022 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4023 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
4024 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4026 sdp_p->conf_p->num_invalid_param++;
4027 return (SDP_INVALID_VALUE);
4028 } else {
4029 return (attr_p->attr.fmtp.annex_k_val);
4033 int32_t sdp_attr_get_fmtp_annex_n_val (sdp_t *sdp_p, uint16_t level,
4034 uint8_t cap_num, uint16_t inst_num)
4037 sdp_attr_t *attr_p;
4039 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
4040 inst_num);
4041 if (attr_p == NULL) {
4042 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4043 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
4044 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4046 sdp_p->conf_p->num_invalid_param++;
4047 return (SDP_INVALID_VALUE);
4048 } else {
4049 return (attr_p->attr.fmtp.annex_n_val);
4053 int32_t sdp_attr_get_fmtp_annex_p_picture_resize (sdp_t *sdp_p, uint16_t level,
4054 uint8_t cap_num, uint16_t inst_num)
4058 sdp_attr_t *attr_p;
4060 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
4061 inst_num);
4062 if (attr_p == NULL) {
4063 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4064 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
4065 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4067 sdp_p->conf_p->num_invalid_param++;
4068 return (SDP_INVALID_VALUE);
4069 } else {
4070 return (attr_p->attr.fmtp.annex_p_val_picture_resize);
4074 int32_t sdp_attr_get_fmtp_annex_p_warp (sdp_t *sdp_p, uint16_t level,
4075 uint8_t cap_num, uint16_t inst_num)
4078 sdp_attr_t *attr_p;
4080 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
4081 inst_num);
4082 if (attr_p == NULL) {
4083 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4084 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
4085 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4087 sdp_p->conf_p->num_invalid_param++;
4088 return (SDP_INVALID_VALUE);
4089 } else {
4090 return (attr_p->attr.fmtp.annex_p_val_warp);
4094 /* Function: sdp_attr_fmtp_get_fmtp_format
4095 * Description: Gives the value of the fmtp attribute fmtp_format
4096 * type parameter
4097 * for the given attribute.
4098 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4099 * level The level to check for the attribute.
4100 * cap_num The capability number associated with the
4101 * attribute if any. If none, should be zero.
4102 * inst_num The attribute instance number to check.
4105 * Returns: Enum type sdp_fmtp_format_type_e
4107 sdp_fmtp_format_type_e sdp_attr_fmtp_get_fmtp_format (sdp_t *sdp_p,
4108 uint16_t level, uint8_t cap_num,
4109 uint16_t inst_num)
4111 sdp_attr_t *attr_p;
4113 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
4114 inst_num);
4115 if (attr_p == NULL) {
4116 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4117 SDPLogError(logTag, "%s fmtp attribute, level %u instance %u "
4118 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4120 sdp_p->conf_p->num_invalid_param++;
4121 return (SDP_FMTP_UNKNOWN_TYPE);
4122 } else {
4123 return (attr_p->attr.fmtp.fmtp_format);
4127 /* Function: sdp_attr_get_pccodec_num_payload_types
4128 * Description: Returns the number of payload types specified for the
4129 * given X-pc-codec attribute. If the given attribute is not
4130 * defined, zero is returned.
4131 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4132 * level The level to check for the attribute.
4133 * cap_num The capability number associated with the
4134 * attribute if any. If none, should be zero.
4135 * inst_num The attribute instance number to check.
4136 * Returns: Number of payload types.
4138 uint16_t sdp_attr_get_pccodec_num_payload_types (sdp_t *sdp_p, uint16_t level,
4139 uint8_t cap_num, uint16_t inst_num)
4141 sdp_attr_t *attr_p;
4143 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_X_PC_CODEC,
4144 inst_num);
4145 if (attr_p == NULL) {
4146 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4147 SDPLogError(logTag, "%s X-pc-codec attribute, level %u instance %u "
4148 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4150 sdp_p->conf_p->num_invalid_param++;
4151 return (0);
4152 } else {
4153 return (attr_p->attr.pccodec.num_payloads);
4157 /* Function: sdp_attr_get_pccodec_payload_type
4158 * Description: Returns the value of the specified payload type for the
4159 * given X-pc-codec attribute. If the given attribute is not
4160 * defined, zero is returned.
4161 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4162 * level The level to check for the attribute.
4163 * cap_num The capability number associated with the
4164 * attribute if any. If none, should be zero.
4165 * inst_num The attribute instance number to check.
4166 * payload_num The payload number to get. Range is (1 -
4167 * max num payloads).
4168 * Returns: Payload type.
4170 uint16_t sdp_attr_get_pccodec_payload_type (sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
4171 uint16_t inst_num, uint16_t payload_num)
4173 sdp_attr_t *attr_p;
4175 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_X_PC_CODEC,
4176 inst_num);
4177 if (attr_p == NULL) {
4178 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4179 SDPLogError(logTag, "%s X-pc-codec attribute, level %u instance %u "
4180 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4182 sdp_p->conf_p->num_invalid_param++;
4183 return (0);
4184 } else {
4185 if ((payload_num < 1) ||
4186 (payload_num > attr_p->attr.pccodec.num_payloads)) {
4187 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4188 SDPLogError(logTag, "%s X-pc-codec attribute, level %u instance %u, "
4189 "invalid payload number %u requested.",
4190 sdp_p->debug_str, (unsigned)level, (unsigned)inst_num, (unsigned)payload_num);
4192 sdp_p->conf_p->num_invalid_param++;
4193 return (0);
4194 } else {
4195 return (attr_p->attr.pccodec.payload_type[payload_num-1]);
4200 /* Function: sdp_attr_add_pccodec_payload_type
4201 * Description: Add a new value to the list of payload types specified for
4202 * the given X-pc-codec attribute. The payload type will be
4203 * added to the end of the list so these values should be added
4204 * in the order they will be displayed within the attribute.
4205 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4206 * level The level to check for the attribute.
4207 * cap_num The capability number associated with the
4208 * attribute if any. If none, should be zero.
4209 * inst_num The attribute instance number to check.
4210 * payload_type The payload type to add.
4211 * Returns: SDP_SUCCESS Payload type was added successfully.
4212 * SDP_INVALID_PARAMETER Specified attribute is not defined.
4214 sdp_result_e sdp_attr_add_pccodec_payload_type (sdp_t *sdp_p, uint16_t level,
4215 uint8_t cap_num, uint16_t inst_num,
4216 uint16_t payload_type)
4218 uint16_t payload_num;
4219 sdp_attr_t *attr_p;
4221 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_X_PC_CODEC,
4222 inst_num);
4223 if (attr_p == NULL) {
4224 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4225 SDPLogError(logTag, "%s X-pc-codec attribute, level %u instance %u "
4226 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4228 sdp_p->conf_p->num_invalid_param++;
4229 return (SDP_INVALID_PARAMETER);
4230 } else {
4231 payload_num = attr_p->attr.pccodec.num_payloads++;
4232 attr_p->attr.pccodec.payload_type[payload_num] = payload_type;
4233 return (SDP_SUCCESS);
4237 /* Function: sdp_attr_get_xcap_first_cap_num
4238 * Description: Gets the first capability number valid for the specified
4239 * X-cap attribute instance. If the capability is not
4240 * defined, zero is returned.
4241 * Note: cap_num is not specified. It must be zero.
4242 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4243 * level The level to check for the capability.
4244 * inst_num The X-cap instance number to check.
4245 * Returns: Capability number or zero.
4247 uint16_t sdp_attr_get_xcap_first_cap_num (sdp_t *sdp_p, uint16_t level, uint16_t inst_num)
4249 uint16_t cap_num=1;
4250 uint16_t attr_count=0;
4251 sdp_attr_t *attr_p;
4252 sdp_mca_t *mca_p;
4254 if (level == SDP_SESSION_LEVEL) {
4255 for (attr_p = sdp_p->sess_attrs_p; attr_p != NULL;
4256 attr_p = attr_p->next_p) {
4257 if (attr_p->type == SDP_ATTR_X_CAP) {
4258 attr_count++;
4259 if (attr_count == inst_num) {
4260 return (cap_num);
4261 } else {
4262 cap_num += attr_p->attr.cap_p->num_payloads;
4266 } else { /* Capability is at a media level */
4267 mca_p = sdp_find_media_level(sdp_p, level);
4268 if (mca_p == NULL) {
4269 sdp_p->conf_p->num_invalid_param++;
4270 return (0);
4272 for (attr_p = mca_p->media_attrs_p; attr_p != NULL;
4273 attr_p = attr_p->next_p) {
4274 if (attr_p->type == SDP_ATTR_X_CAP) {
4275 attr_count++;
4276 if (attr_count == inst_num) {
4277 return (cap_num);
4278 } else {
4279 cap_num += attr_p->attr.cap_p->num_payloads;
4283 } /* Attr is at a media level */
4285 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4286 SDPLogError(logTag, "%s X-cap attribute, level %u instance %u "
4287 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4289 sdp_p->conf_p->num_invalid_param++;
4290 return (0);
4293 /* Function: sdp_attr_get_xcap_media_type
4294 * Description: Returns the media type specified for the given X-cap
4295 * attribute. If the given attribute is not defined,
4296 * SDP_MEDIA_INVALID is returned.
4297 * Note: cap_num is not specified. It must be zero.
4298 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4299 * level The level to check for the attribute.
4300 * inst_num The attribute instance number to check.
4301 * Returns: Media type or SDP_MEDIA_INVALID.
4303 sdp_media_e sdp_attr_get_xcap_media_type (sdp_t *sdp_p, uint16_t level,
4304 uint16_t inst_num)
4306 sdp_attr_t *attr_p;
4307 sdp_mca_t *cap_p;
4309 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_X_CAP, inst_num);
4310 if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
4311 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4312 SDPLogError(logTag, "%s X-cap attribute, level %u instance %u "
4313 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4315 sdp_p->conf_p->num_invalid_param++;
4316 return (SDP_MEDIA_INVALID);
4317 } else {
4318 cap_p = attr_p->attr.cap_p;
4319 return (cap_p->media);
4323 /* Function: sdp_attr_get_xcap_transport_type
4324 * Description: Returns the transport type specified for the given X-cap
4325 * attribute. If the given attribute is not defined,
4326 * SDP_TRANSPORT_INVALID is returned.
4327 * Note: cap_num is not specified. It must be zero.
4328 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4329 * level The level to check for the attribute.
4330 * inst_num The attribute instance number to check.
4331 * Returns: Media type or SDP_TRANSPORT_INVALID.
4333 sdp_transport_e sdp_attr_get_xcap_transport_type (sdp_t *sdp_p, uint16_t level,
4334 uint16_t inst_num)
4336 sdp_attr_t *attr_p;
4337 sdp_mca_t *cap_p;
4339 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_X_CAP,
4340 inst_num);
4341 if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
4342 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4343 SDPLogError(logTag, "%s X-cap attribute, level %u instance %u "
4344 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4346 sdp_p->conf_p->num_invalid_param++;
4347 return (SDP_TRANSPORT_INVALID);
4348 } else {
4349 cap_p = attr_p->attr.cap_p;
4350 return (cap_p->transport);
4354 /* Function: sdp_attr_get_xcap_num_payload_types
4355 * Description: Returns the number of payload types associated with the
4356 * specified X-cap attribute. If the attribute is invalid,
4357 * zero will be returned. Application must validate the
4358 * attribute line before using this routine.
4359 * Note: cap_num is not specified. It must be zero.
4360 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4361 * level The level to check for the attribute.
4362 * cap_num The capability number associated with the
4363 * attribute if any. If none, should be zero.
4364 * inst_num The attribute instance number to check.
4365 * Returns: Number of payload types or zero.
4367 uint16_t sdp_attr_get_xcap_num_payload_types (sdp_t *sdp_p, uint16_t level,
4368 uint16_t inst_num)
4370 sdp_attr_t *attr_p;
4371 sdp_mca_t *cap_p;
4373 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_X_CAP, inst_num);
4374 if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
4375 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4376 SDPLogError(logTag, "%s X-cap attribute, level %u instance %u "
4377 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4379 sdp_p->conf_p->num_invalid_param++;
4380 return (0);
4381 } else {
4382 cap_p = attr_p->attr.cap_p;
4383 return (cap_p->num_payloads);
4387 /* Function: sdp_attr_get_xcap_payload_type
4388 * Description: Returns the payload type of the specified payload for the
4389 * X-cap attribute line. If the attr line or payload number is
4390 * invalid, zero will be returned. Application must validate
4391 * the X-cap attr before using this routine.
4392 * Note: cap_num is not specified. It must be zero.
4393 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4394 * level The level to check for the attribute.
4395 * inst_num The attribute instance number to check.
4396 * payload_num The payload number to retrieve. Range is
4397 * (1 - max num payloads).
4398 * Returns: Payload type or zero.
4400 uint16_t sdp_attr_get_xcap_payload_type (sdp_t *sdp_p, uint16_t level,
4401 uint16_t inst_num, uint16_t payload_num,
4402 sdp_payload_ind_e *indicator)
4404 sdp_attr_t *attr_p;
4405 sdp_mca_t *cap_p;
4407 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_X_CAP, inst_num);
4408 if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
4409 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4410 SDPLogError(logTag, "%s X-cap attribute, level %u instance %u "
4411 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4413 sdp_p->conf_p->num_invalid_param++;
4414 return (0);
4415 } else {
4416 cap_p = attr_p->attr.cap_p;
4417 if ((payload_num < 1) ||
4418 (payload_num > cap_p->num_payloads)) {
4419 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4420 SDPLogError(logTag, "%s X-cap attribute, level %u instance %u, "
4421 "payload num %u invalid.", sdp_p->debug_str,
4422 (unsigned)level, (unsigned)inst_num, (unsigned)payload_num);
4424 sdp_p->conf_p->num_invalid_param++;
4425 return (0);
4426 } else {
4427 *indicator = cap_p->payload_indicator[payload_num-1];
4428 return (cap_p->payload_type[payload_num-1]);
4434 /* Function: sdp_attr_add_xcap_payload_type
4435 * Description: Add a new payload type for the X-cap attribute line
4436 * specified. The new payload type will be added at the end
4437 * of the payload type list.
4438 * Note: cap_num is not specified. It must be zero.
4439 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4440 * level The level to check for the attribute.
4441 * inst_num The attribute instance number to check.
4442 * payload_type The new payload type.
4443 * Returns: SDP_SUCCESS or SDP_INVALID_PARAMETER
4445 sdp_result_e sdp_attr_add_xcap_payload_type(sdp_t *sdp_p, uint16_t level,
4446 uint16_t inst_num, uint16_t payload_type,
4447 sdp_payload_ind_e indicator)
4449 sdp_attr_t *attr_p;
4450 sdp_mca_t *cap_p;
4452 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_X_CAP, inst_num);
4453 if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
4454 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4455 SDPLogError(logTag, "%s X-cap attribute, level %u instance %u "
4456 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4458 sdp_p->conf_p->num_invalid_param++;
4459 return (SDP_INVALID_PARAMETER);
4462 cap_p = attr_p->attr.cap_p;
4463 cap_p->payload_indicator[cap_p->num_payloads] = indicator;
4464 cap_p->payload_type[cap_p->num_payloads++] = payload_type;
4465 return (SDP_SUCCESS);
4468 /* Function: sdp_attr_get_cdsc_first_cap_num
4469 * Description: Gets the first capability number valid for the specified
4470 * CDSC attribute instance. If the capability is not
4471 * defined, zero is returned.
4472 * Note: cap_num is not specified. It must be zero.
4473 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4474 * level The level to check for the capability.
4475 * inst_num The CDSC instance number to check.
4476 * Returns: Capability number or zero.
4478 uint16_t sdp_attr_get_cdsc_first_cap_num(sdp_t *sdp_p, uint16_t level, uint16_t inst_num)
4480 uint16_t cap_num=1;
4481 uint16_t attr_count=0;
4482 sdp_attr_t *attr_p;
4483 sdp_mca_t *mca_p;
4485 if (level == SDP_SESSION_LEVEL) {
4486 for (attr_p = sdp_p->sess_attrs_p; attr_p != NULL;
4487 attr_p = attr_p->next_p) {
4488 if (attr_p->type == SDP_ATTR_CDSC) {
4489 attr_count++;
4490 if (attr_count == inst_num) {
4491 return (cap_num);
4492 } else {
4493 cap_num += attr_p->attr.cap_p->num_payloads;
4497 } else { /* Capability is at a media level */
4498 mca_p = sdp_find_media_level(sdp_p, level);
4499 if (mca_p == NULL) {
4500 sdp_p->conf_p->num_invalid_param++;
4501 return (0);
4503 for (attr_p = mca_p->media_attrs_p; attr_p != NULL;
4504 attr_p = attr_p->next_p) {
4505 if (attr_p->type == SDP_ATTR_CDSC) {
4506 attr_count++;
4507 if (attr_count == inst_num) {
4508 return (cap_num);
4509 } else {
4510 cap_num += attr_p->attr.cap_p->num_payloads;
4514 } /* Attr is at a media level */
4516 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4517 SDPLogError(logTag, "%s CDSC attribute, level %u instance %u "
4518 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4520 sdp_p->conf_p->num_invalid_param++;
4521 return (0);
4524 /* Function: sdp_attr_get_cdsc_media_type
4525 * Description: Returns the media type specified for the given CDSC
4526 * attribute. If the given attribute is not defined,
4527 * SDP_MEDIA_INVALID is returned.
4528 * Note: cap_num is not specified. It must be zero.
4529 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4530 * level The level to check for the attribute.
4531 * inst_num The attribute instance number to check.
4532 * Returns: Media type or SDP_MEDIA_INVALID.
4534 sdp_media_e sdp_attr_get_cdsc_media_type(sdp_t *sdp_p, uint16_t level,
4535 uint16_t inst_num)
4537 sdp_attr_t *attr_p;
4538 sdp_mca_t *cdsc_p;
4540 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_CDSC, inst_num);
4541 if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
4542 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4543 SDPLogError(logTag, "%s CDSC attribute, level %u instance %u "
4544 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4546 sdp_p->conf_p->num_invalid_param++;
4547 return (SDP_MEDIA_INVALID);
4548 } else {
4549 cdsc_p = attr_p->attr.cap_p;
4550 return (cdsc_p->media);
4554 /* Function: sdp_attr_get_cdsc_transport_type
4555 * Description: Returns the transport type specified for the given CDSC
4556 * attribute. If the given attribute is not defined,
4557 * SDP_TRANSPORT_INVALID is returned.
4558 * Note: cap_num is not specified. It must be zero.
4559 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4560 * level The level to check for the attribute.
4561 * inst_num The attribute instance number to check.
4562 * Returns: Media type or SDP_TRANSPORT_INVALID.
4564 sdp_transport_e sdp_attr_get_cdsc_transport_type(sdp_t *sdp_p, uint16_t level,
4565 uint16_t inst_num)
4567 sdp_attr_t *attr_p;
4568 sdp_mca_t *cdsc_p;
4570 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_CDSC,
4571 inst_num);
4572 if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
4573 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4574 SDPLogError(logTag, "%s CDSC attribute, level %u instance %u "
4575 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4577 sdp_p->conf_p->num_invalid_param++;
4578 return (SDP_TRANSPORT_INVALID);
4579 } else {
4580 cdsc_p = attr_p->attr.cap_p;
4581 return (cdsc_p->transport);
4585 /* Function: sdp_attr_get_cdsc_num_payload_types
4586 * Description: Returns the number of payload types associated with the
4587 * specified CDSC attribute. If the attribute is invalid,
4588 * zero will be returned. Application must validate the
4589 * attribute line before using this routine.
4590 * Note: cap_num is not specified. It must be zero.
4591 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4592 * level The level to check for the attribute.
4593 * cap_num The capability number associated with the
4594 * attribute if any. If none, should be zero.
4595 * inst_num The attribute instance number to check.
4596 * Returns: Number of payload types or zero.
4598 uint16_t sdp_attr_get_cdsc_num_payload_types (sdp_t *sdp_p, uint16_t level,
4599 uint16_t inst_num)
4601 sdp_attr_t *attr_p;
4602 sdp_mca_t *cdsc_p;
4604 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_CDSC, inst_num);
4605 if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
4606 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4607 SDPLogError(logTag, "%s CDSC attribute, level %u instance %u "
4608 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4610 sdp_p->conf_p->num_invalid_param++;
4611 return (0);
4612 } else {
4613 cdsc_p = attr_p->attr.cap_p;
4614 return (cdsc_p->num_payloads);
4618 /* Function: sdp_attr_get_cdsc_payload_type
4619 * Description: Returns the payload type of the specified payload for the
4620 * CDSC attribute line. If the attr line or payload number is
4621 * invalid, zero will be returned. Application must validate
4622 * the CDSC attr before using this routine.
4623 * Note: cap_num is not specified. It must be zero.
4624 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4625 * level The level to check for the attribute.
4626 * inst_num The attribute instance number to check.
4627 * payload_num The payload number to retrieve. Range is
4628 * (1 - max num payloads).
4629 * Returns: Payload type or zero.
4631 uint16_t sdp_attr_get_cdsc_payload_type (sdp_t *sdp_p, uint16_t level,
4632 uint16_t inst_num, uint16_t payload_num,
4633 sdp_payload_ind_e *indicator)
4635 sdp_attr_t *attr_p;
4636 sdp_mca_t *cdsc_p;
4638 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_CDSC, inst_num);
4639 if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
4640 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4641 SDPLogError(logTag, "%s CDSC attribute, level %u instance %u "
4642 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4644 sdp_p->conf_p->num_invalid_param++;
4645 return (0);
4646 } else {
4647 cdsc_p = attr_p->attr.cap_p;
4648 if ((payload_num < 1) ||
4649 (payload_num > cdsc_p->num_payloads)) {
4650 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4651 SDPLogError(logTag, "%s CDSC attribute, level %u instance %u, "
4652 "payload num %u invalid.", sdp_p->debug_str,
4653 (unsigned)level, (unsigned)inst_num, (unsigned)payload_num);
4655 sdp_p->conf_p->num_invalid_param++;
4656 return (0);
4657 } else {
4658 *indicator = cdsc_p->payload_indicator[payload_num-1];
4659 return (cdsc_p->payload_type[payload_num-1]);
4664 /* Function: sdp_attr_add_cdsc_payload_type
4665 * Description: Add a new payload type for the CDSC attribute line
4666 * specified. The new payload type will be added at the end
4667 * of the payload type list.
4668 * Note: cap_num is not specified. It must be zero.
4669 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4670 * level The level to check for the attribute.
4671 * inst_num The attribute instance number to check.
4672 * payload_type The new payload type.
4673 * Returns: SDP_SUCCESS or SDP_INVALID_PARAMETER
4675 sdp_result_e sdp_attr_add_cdsc_payload_type (sdp_t *sdp_p, uint16_t level,
4676 uint16_t inst_num, uint16_t payload_type,
4677 sdp_payload_ind_e indicator)
4679 sdp_attr_t *attr_p;
4680 sdp_mca_t *cdsc_p;
4682 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_CDSC, inst_num);
4683 if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
4684 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4685 SDPLogError(logTag, "%s CDSC attribute, level %u instance %u "
4686 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4688 sdp_p->conf_p->num_invalid_param++;
4689 return (SDP_INVALID_PARAMETER);
4692 cdsc_p = attr_p->attr.cap_p;
4693 cdsc_p->payload_indicator[cdsc_p->num_payloads] = indicator;
4694 cdsc_p->payload_type[cdsc_p->num_payloads++] = payload_type;
4695 return (SDP_SUCCESS);
4698 /* Function: sdp_media_dynamic_payload_valid
4699 * Description: Checks if the dynamic payload type passed in is defined
4700 * on the media line m_line
4701 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4702 * payload_type Payload type to be checked
4704 * Returns: TRUE or FALSE. Returns TRUE if payload type is defined on the
4705 * media line, else returns FALSE
4708 tinybool sdp_media_dynamic_payload_valid (sdp_t *sdp_p, uint16_t payload_type,
4709 uint16_t m_line)
4711 uint16_t p_type,m_ptype;
4712 ushort num_payload_types;
4713 sdp_payload_ind_e ind;
4714 tinybool payload_matches = FALSE;
4715 tinybool result = TRUE;
4717 if ((payload_type < SDP_MIN_DYNAMIC_PAYLOAD) ||
4718 (payload_type > SDP_MAX_DYNAMIC_PAYLOAD)) {
4719 return FALSE;
4722 num_payload_types =
4723 sdp_get_media_num_payload_types(sdp_p, m_line);
4725 for(p_type=1; p_type <=num_payload_types;p_type++){
4727 m_ptype = (uint16_t)sdp_get_media_payload_type(sdp_p,
4728 m_line, p_type, &ind);
4729 if (payload_type == m_ptype) {
4730 payload_matches = TRUE;
4731 break;
4736 if (!payload_matches) {
4737 return FALSE;
4740 return (result);
4744 /* Function: sdp_attr_get_rtr_confirm
4745 * Description: Returns the value of the rtr attribute confirm
4746 * parameter specified for the given attribute. Returns TRUE if
4747 * the confirm parameter is specified.
4748 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4749 * level The level to check for the attribute.
4750 * cap_num The capability number associated with the
4751 * attribute if any. If none, should be zero.
4752 * inst_num The attribute instance number to check.
4753 * Returns: Boolean value.
4755 tinybool sdp_attr_get_rtr_confirm (sdp_t *sdp_p, uint16_t level,
4756 uint8_t cap_num, uint16_t inst_num)
4758 sdp_attr_t *attr_p;
4760 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_RTR, inst_num);
4761 if (attr_p == NULL) {
4762 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4763 SDPLogError(logTag, "%s %s attribute, level %u instance %u "
4764 "not found.", sdp_p->debug_str,
4765 sdp_get_attr_name(SDP_ATTR_RTR), (unsigned)level, (unsigned)inst_num);
4767 sdp_p->conf_p->num_invalid_param++;
4768 return (FALSE);
4769 } else {
4770 return (attr_p->attr.rtr.confirm);
4776 sdp_mediadir_role_e sdp_attr_get_comediadir_role (sdp_t *sdp_p, uint16_t level,
4777 uint8_t cap_num, uint16_t inst_num)
4779 sdp_attr_t *attr_p;
4781 attr_p = sdp_find_attr(sdp_p, level, cap_num,
4782 SDP_ATTR_DIRECTION, inst_num);
4783 if (attr_p == NULL) {
4784 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4785 SDPLogError(logTag, "%s Comediadir role attribute, level %u instance %u "
4786 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4788 sdp_p->conf_p->num_invalid_param++;
4789 return (SDP_MEDIADIR_ROLE_UNKNOWN);
4790 } else {
4791 return (attr_p->attr.comediadir.role);
4795 /* Function: sdp_attr_get_silencesupp_enabled
4796 * Description: Returns the value of the silencesupp attribute enable
4797 * parameter specified for the given attribute. Returns TRUE if
4798 * the confirm parameter is specified.
4799 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4800 * level The level to check for the attribute.
4801 * cap_num The capability number associated with the
4802 * attribute if any. If none, should be zero.
4803 * inst_num The attribute instance number to check.
4804 * Returns: Boolean value.
4806 tinybool sdp_attr_get_silencesupp_enabled (sdp_t *sdp_p, uint16_t level,
4807 uint8_t cap_num, uint16_t inst_num)
4809 sdp_attr_t *attr_p;
4811 attr_p = sdp_find_attr(sdp_p, level, cap_num,
4812 SDP_ATTR_SILENCESUPP, inst_num);
4813 if (attr_p == NULL) {
4814 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4815 SDPLogError(logTag, "%s silenceSuppEnable attribute, level %u instance %u "
4816 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4818 sdp_p->conf_p->num_invalid_param++;
4819 return (FALSE);
4820 } else {
4821 return (attr_p->attr.silencesupp.enabled);
4825 /* Function: sdp_attr_get_silencesupp_timer
4826 * Description: Returns the value of the silencesupp attribute timer
4827 * parameter specified for the given attribute. null_ind
4828 * is set to TRUE if no value was specified, but instead the
4829 * null "-" value was specified.
4830 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4831 * level The level to check for the attribute.
4832 * cap_num The capability number associated with the
4833 * attribute if any. If none, should be zero.
4834 * inst_num The attribute instance number to check.
4835 * Returns: 16-bit timer value
4836 * boolean null_ind
4838 uint16_t sdp_attr_get_silencesupp_timer (sdp_t *sdp_p, uint16_t level,
4839 uint8_t cap_num, uint16_t inst_num,
4840 tinybool *null_ind)
4842 sdp_attr_t *attr_p;
4844 attr_p = sdp_find_attr(sdp_p, level, cap_num,
4845 SDP_ATTR_SILENCESUPP, inst_num);
4846 if (attr_p == NULL) {
4847 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4848 SDPLogError(logTag, "%s silenceTimer attribute, level %u instance %u "
4849 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4851 sdp_p->conf_p->num_invalid_param++;
4852 return (0);
4853 } else {
4854 *null_ind = attr_p->attr.silencesupp.timer_null;
4855 return (attr_p->attr.silencesupp.timer);
4859 /* Function: sdp_attr_get_silencesupp_pref
4860 * Description: Sets the silencesupp supppref value
4861 * If this parameter is TRUE, the confirm parameter will be
4862 * specified when the SDP description is built.
4863 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4864 * level The level to check for the attribute.
4865 * cap_num The capability number associated with the
4866 * attribute if any. If none, should be zero.
4867 * inst_num The attribute instance number to check.
4868 * confirm New qos confirm parameter.
4869 * Returns: SDP_SUCCESS Attribute param was set successfully.
4870 * SDP_INVALID_PARAMETER Specified attribute is not defined.
4872 sdp_silencesupp_pref_e sdp_attr_get_silencesupp_pref (sdp_t *sdp_p,
4873 uint16_t level, uint8_t cap_num,
4874 uint16_t inst_num)
4876 sdp_attr_t *attr_p;
4878 attr_p = sdp_find_attr(sdp_p, level, cap_num,
4879 SDP_ATTR_SILENCESUPP, inst_num);
4880 if (attr_p == NULL) {
4881 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4882 SDPLogError(logTag, "%s silence suppPref attribute, level %u instance %u "
4883 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4885 sdp_p->conf_p->num_invalid_param++;
4886 return (SDP_SILENCESUPP_PREF_UNKNOWN);
4887 } else {
4888 return (attr_p->attr.silencesupp.pref);
4892 /* Function: sdp_attr_get_silencesupp_siduse
4893 * Description: Returns the value of the silencesupp attribute siduse
4894 * parameter specified for the given attribute. If the given
4895 * attribute is not defined, SDP_QOS_STRENGTH_UNKNOWN is
4896 * returned.
4897 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4898 * level The level to check for the attribute.
4899 * cap_num The capability number associated with the
4900 * attribute if any. If none, should be zero.
4901 * inst_num The attribute instance number to check.
4902 * Returns: silencesupp siduse enum.
4904 sdp_silencesupp_siduse_e sdp_attr_get_silencesupp_siduse (sdp_t *sdp_p,
4905 uint16_t level,
4906 uint8_t cap_num,
4907 uint16_t inst_num)
4909 sdp_attr_t *attr_p;
4911 attr_p = sdp_find_attr(sdp_p, level, cap_num,
4912 SDP_ATTR_SILENCESUPP, inst_num);
4913 if (attr_p == NULL) {
4914 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4915 SDPLogError(logTag, "%s silence sidUse attribute, level %u instance %u "
4916 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4918 sdp_p->conf_p->num_invalid_param++;
4919 return (SDP_SILENCESUPP_SIDUSE_UNKNOWN);
4920 } else {
4921 return (attr_p->attr.silencesupp.siduse);
4925 /* Function: sdp_attr_get_silencesupp_fxnslevel
4926 * Description: Returns the value of the silencesupp attribute fxns
4927 * (fixed noise) parameter specified for the given attribute.
4928 * null_ind is set to TRUE if no value was specified,
4929 * but instead the null "-" value was specified.
4930 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4931 * level The level to check for the attribute.
4932 * cap_num The capability number associated with the
4933 * attribute if any. If none, should be zero.
4934 * inst_num The attribute instance number to check.
4935 * Returns: 7-bit fxns value
4936 * boolean null_ind
4938 uint8_t sdp_attr_get_silencesupp_fxnslevel (sdp_t *sdp_p, uint16_t level,
4939 uint8_t cap_num, uint16_t inst_num,
4940 tinybool *null_ind)
4942 sdp_attr_t *attr_p;
4944 attr_p = sdp_find_attr(sdp_p, level, cap_num,
4945 SDP_ATTR_SILENCESUPP, inst_num);
4946 if (attr_p == NULL) {
4947 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4948 SDPLogError(logTag, "%s silence fxnslevel attribute, level %u instance %u "
4949 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4951 sdp_p->conf_p->num_invalid_param++;
4952 return (0);
4953 } else {
4954 *null_ind = attr_p->attr.silencesupp.fxnslevel_null;
4955 return (attr_p->attr.silencesupp.fxnslevel);
4959 /* Function: sdp_attr_get_mptime_num_intervals
4960 * Description: Returns the number of intervals specified for the
4961 * given mptime attribute. If the given attribute is not
4962 * defined, zero is returned.
4963 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4964 * level The level to check for the attribute.
4965 * cap_num The capability number associated with the
4966 * attribute if any. If none, should be zero.
4967 * inst_num The attribute instance number to check.
4968 * Returns: Number of intervals.
4970 uint16_t sdp_attr_get_mptime_num_intervals (
4971 sdp_t *sdp_p,
4972 uint16_t level,
4973 uint8_t cap_num,
4974 uint16_t inst_num) {
4976 sdp_attr_t *attr_p;
4978 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_MPTIME, inst_num);
4979 if (attr_p != NULL) {
4980 return attr_p->attr.mptime.num_intervals;
4983 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
4984 SDPLogError(logTag, "%s mptime attribute, level %u instance %u not found.",
4985 sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
4987 sdp_p->conf_p->num_invalid_param++;
4988 return 0;
4991 /* Function: sdp_attr_get_mptime_interval
4992 * Description: Returns the value of the specified interval for the
4993 * given mptime attribute. If the given attribute is not
4994 * defined, zero is returned.
4995 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
4996 * level The level to check for the attribute.
4997 * cap_num The capability number associated with the
4998 * attribute if any. If none, should be zero.
4999 * inst_num The attribute instance number to check.
5000 * interval_num The interval number to get. Range is (1 -
5001 * max num payloads).
5002 * Returns: Interval.
5004 uint16_t sdp_attr_get_mptime_interval (
5005 sdp_t *sdp_p,
5006 uint16_t level,
5007 uint8_t cap_num,
5008 uint16_t inst_num,
5009 uint16_t interval_num) {
5011 sdp_attr_t *attr_p;
5013 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_MPTIME, inst_num);
5014 if (attr_p == NULL) {
5015 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5016 SDPLogError(logTag, "%s mptime attribute, level %u instance %u "
5017 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5019 sdp_p->conf_p->num_invalid_param++;
5020 return 0;
5023 if ((interval_num<1) || (interval_num>attr_p->attr.mptime.num_intervals)) {
5024 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5025 SDPLogError(logTag, "%s mptime attribute, level %u instance %u, "
5026 "invalid interval number %u requested.",
5027 sdp_p->debug_str, (unsigned)level, (unsigned)inst_num, (unsigned)interval_num);
5029 sdp_p->conf_p->num_invalid_param++;
5030 return 0;
5033 return attr_p->attr.mptime.intervals[interval_num-1];
5036 /* Function: sdp_attr_add_mptime_interval
5037 * Description: Add a new value to the list of intervals specified for
5038 * the given mptime attribute. The interval will be
5039 * added to the end of the list so these values should be added
5040 * in the order they will be displayed within the attribute.
5041 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5042 * level The level to check for the attribute.
5043 * cap_num The capability number associated with the
5044 * attribute if any. If none, should be zero.
5045 * inst_num The attribute instance number to check.
5046 * mp_interval The interval to add.
5047 * Returns: SDP_SUCCESS Interval was added successfully.
5048 * SDP_INVALID_PARAMETER Specified attribute is not defined.
5049 * SDP_INVALID_SDP_PTR Supplied SDP pointer is invalid
5051 sdp_result_e sdp_attr_add_mptime_interval (
5052 sdp_t *sdp_p,
5053 uint16_t level,
5054 uint8_t cap_num,
5055 uint16_t inst_num,
5056 uint16_t mp_interval) {
5058 uint16_t interval_num;
5059 sdp_attr_t *attr_p;
5061 attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_MPTIME, inst_num);
5062 if (attr_p == NULL) {
5063 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5064 SDPLogError(logTag, "%s mptime attribute, level %u instance %u "
5065 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5067 sdp_p->conf_p->num_invalid_param++;
5068 return SDP_INVALID_PARAMETER;
5071 interval_num = attr_p->attr.mptime.num_intervals;
5072 if (interval_num>=SDP_MAX_PAYLOAD_TYPES) {
5073 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5074 SDPLogError(logTag, "%s mptime attribute, level %u instance %u "
5075 "exceeds maximum length.",
5076 sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5078 sdp_p->conf_p->num_invalid_param++;
5079 return SDP_INVALID_PARAMETER;
5082 attr_p->attr.mptime.intervals[interval_num] = mp_interval;
5083 ++attr_p->attr.mptime.num_intervals;
5084 return SDP_SUCCESS;
5089 /* Function: sdp_get_group_attr
5090 * Description: Returns the attribute parameter from the a=group:<>
5091 * line. If no attrib has been set ,
5092 * SDP_GROUP_ATTR_UNSUPPORTED will be returned.
5093 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5094 * level SDP_SESSION_LEVEL
5095 * Returns: Valid attrib value or SDP_GROUP_ATTR_UNSUPPORTED.
5097 sdp_group_attr_e sdp_get_group_attr (sdp_t *sdp_p, uint16_t level,
5098 uint8_t cap_num, uint16_t inst_num)
5100 sdp_attr_t *attr_p;
5102 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5103 SDP_ATTR_GROUP, inst_num);
5104 if (attr_p == NULL) {
5105 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5106 SDPLogError(logTag, "%s Group (a= group line) attribute, level %u instance %u "
5107 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5109 sdp_p->conf_p->num_invalid_param++;
5110 return (SDP_GROUP_ATTR_UNSUPPORTED);
5111 } else {
5112 if (sdp_p->debug_flag[SDP_DEBUG_TRACE]) {
5113 SDP_PRINT("%s Stream data group attr field is :%s ",
5114 sdp_p->debug_str,
5115 sdp_get_group_attr_name(attr_p->attr.stream_data.group_attr) );
5117 return (attr_p->attr.stream_data.group_attr);
5121 /* Function: sdp_get_group_num_id
5122 * Description: Returns the number of ids from the a=group:<> line.
5123 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5124 * level SDP_SESSION_LEVEL
5125 * Returns: Num of group ids present or 0 if there is an error.
5127 uint16_t sdp_get_group_num_id (sdp_t *sdp_p, uint16_t level,
5128 uint8_t cap_num, uint16_t inst_num)
5130 sdp_attr_t *attr_p;
5132 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5133 SDP_ATTR_GROUP, inst_num);
5134 if (attr_p == NULL) {
5135 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5136 SDPLogError(logTag, "%s a=group level attribute, level %u instance %u "
5137 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5139 sdp_p->conf_p->num_invalid_param++;
5140 return (0);
5141 } else {
5142 if (sdp_p->debug_flag[SDP_DEBUG_TRACE]) {
5143 SDP_PRINT("%s Stream data group attr - num of ids is :%u ",
5144 sdp_p->debug_str,
5145 (unsigned)attr_p->attr.stream_data.num_group_id);
5148 return (attr_p->attr.stream_data.num_group_id);
5151 /* Function: sdp_get_group_id
5152 * Description: Returns the group id from the a=group:<> line.
5153 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5154 * level SDP_SESSION_LEVEL
5155 * id_num Number of the id to retrieve. The range is (1 -
5156 * SDP_MAX_GROUP_STREAM_ID)
5157 * Returns: Value of the group id at the index specified or
5158 * NULL if an error
5160 const char* sdp_get_group_id (sdp_t *sdp_p, uint16_t level,
5161 uint8_t cap_num, uint16_t inst_num, uint16_t id_num)
5163 sdp_attr_t *attr_p;
5165 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5166 SDP_ATTR_GROUP, inst_num);
5167 if (attr_p == NULL) {
5168 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5169 SDPLogError(logTag, "%s a=group level attribute, level %u instance %u "
5170 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5172 sdp_p->conf_p->num_invalid_param++;
5173 return (NULL);
5174 } else {
5175 if (sdp_p->debug_flag[SDP_DEBUG_TRACE]) {
5176 SDP_PRINT("%s Stream data group attr - num of ids is :%u ",
5177 sdp_p->debug_str,
5178 (unsigned)attr_p->attr.stream_data.num_group_id);
5180 if ((id_num < 1) || (id_num > attr_p->attr.stream_data.num_group_id)) {
5181 return (NULL);
5184 return (attr_p->attr.stream_data.group_ids[id_num-1]);
5187 /* Function: sdp_attr_get_x_sidin
5188 * Description: Returns the attribute parameter from the a=X-sidin:<>
5189 * line. If no attrib has been set NULL will be returned.
5190 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5191 * level media level index
5192 * cap_num The capability number associated with the
5193 * attribute if any. If none, should be zero.
5194 * inst_num The attribute instance number to check.
5195 * Returns: Pointer to sidin or NULL.
5197 const char* sdp_attr_get_x_sidin (sdp_t *sdp_p, uint16_t level,
5198 uint8_t cap_num, uint16_t inst_num)
5200 sdp_attr_t *attr_p;
5202 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5203 SDP_ATTR_X_SIDIN, inst_num);
5204 if (attr_p == NULL) {
5205 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5206 SDPLogError(logTag, "%s X-sidin attribute, level %u instance %u "
5207 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5209 sdp_p->conf_p->num_invalid_param++;
5210 return (NULL);
5211 } else {
5212 if (sdp_p->debug_flag[SDP_DEBUG_TRACE]) {
5213 SDP_PRINT("%s Stream X-sidin attr field is :%s ",
5214 sdp_p->debug_str,
5215 attr_p->attr.stream_data.x_sidin);
5217 return (attr_p->attr.stream_data.x_sidin);
5221 /* Function: sdp_attr_get_x_sidout
5222 * Description: Returns the attribute parameter from the a=X-sidout:<>
5223 * line. If no attrib has been set NULL will be returned.
5224 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5225 * level media level index
5226 * cap_num The capability number associated with the
5227 * attribute if any. If none, should be zero.
5228 * inst_num The attribute instance number to check.
5229 * Returns: Pointer to sidout or NULL.
5231 const char* sdp_attr_get_x_sidout (sdp_t *sdp_p, uint16_t level,
5232 uint8_t cap_num, uint16_t inst_num)
5234 sdp_attr_t *attr_p;
5236 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5237 SDP_ATTR_X_SIDOUT, inst_num);
5238 if (attr_p == NULL) {
5239 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5240 SDPLogError(logTag, "%s X-sidout attribute, level %u instance %u "
5241 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5243 sdp_p->conf_p->num_invalid_param++;
5244 return (NULL);
5245 } else {
5246 if (sdp_p->debug_flag[SDP_DEBUG_TRACE]) {
5247 SDP_PRINT("%s Stream X-sidout attr field is :%s ",
5248 sdp_p->debug_str,
5249 attr_p->attr.stream_data.x_sidout);
5251 return (attr_p->attr.stream_data.x_sidout);
5255 /* Function: sdp_attr_get_x_confid
5256 * Description: Returns the attribute parameter from the a=X-confid:<>
5257 * line. If no attrib has been set NULL will be returned.
5258 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5259 * level media level index
5260 * cap_num The capability number associated with the
5261 * attribute if any. If none, should be zero.
5262 * inst_num The attribute instance number to check.
5263 * Returns: Pointer to confid or NULL.
5265 const char* sdp_attr_get_x_confid (sdp_t *sdp_p, uint16_t level,
5266 uint8_t cap_num, uint16_t inst_num)
5268 sdp_attr_t *attr_p;
5270 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5271 SDP_ATTR_X_CONFID, inst_num);
5272 if (attr_p == NULL) {
5273 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5274 SDPLogError(logTag, "%s X-confid attribute, level %u instance %u "
5275 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5277 sdp_p->conf_p->num_invalid_param++;
5278 return (NULL);
5279 } else {
5280 if (sdp_p->debug_flag[SDP_DEBUG_TRACE]) {
5281 SDP_PRINT("%s Stream X-confid attr field is :%s ",
5282 sdp_p->debug_str,
5283 attr_p->attr.stream_data.x_confid);
5285 return (attr_p->attr.stream_data.x_confid);
5289 /* Function: sdp_get_source_filter_mode
5290 * Description: Gets the filter mode in internal representation
5291 * Parameters: sdp_p The SDP handle which contains the attributes
5292 * level SDP_SESSION_LEVEL/m-line number
5293 * inst_num The attribute instance number
5294 * Returns: Filter mode (incl/excl/not present)
5296 sdp_src_filter_mode_e
5297 sdp_get_source_filter_mode (sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
5298 uint16_t inst_num)
5300 sdp_attr_t *attr_p;
5302 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5303 SDP_ATTR_SOURCE_FILTER, inst_num);
5304 if (attr_p == NULL) {
5305 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5306 SDPLogError(logTag, "%s Source filter attribute, level %u, "
5307 "instance %u not found", sdp_p->debug_str,
5308 (unsigned)level, (unsigned)inst_num);
5310 sdp_p->conf_p->num_invalid_param++;
5311 return (SDP_FILTER_MODE_NOT_PRESENT);
5313 return (attr_p->attr.source_filter.mode);
5316 /* Function: sdp_get_filter_destination_attributes
5317 * Description: Gets the destination address parameters
5318 * Parameters: Network type (optional), destination address type
5319 * (optional), and destination address (mandatory) variables
5320 * which gets updated.
5321 * Returns: SDP_SUCCESS or SDP_INVALID_PARAMETER/SDP_INVALID_SDP_PTR
5323 sdp_result_e
5324 sdp_get_filter_destination_attributes (sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
5325 uint16_t inst_num, sdp_nettype_e *nettype,
5326 sdp_addrtype_e *addrtype,
5327 char *dest_addr)
5329 sdp_attr_t *attr_p;
5331 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5332 SDP_ATTR_SOURCE_FILTER, inst_num);
5333 if (attr_p == NULL) {
5334 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5335 SDPLogError(logTag, "%s Source filter attribute, level %u instance %u "
5336 "not found", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5338 sdp_p->conf_p->num_invalid_param++;
5339 return (SDP_INVALID_PARAMETER);
5341 if (nettype) {
5342 *nettype = attr_p->attr.source_filter.nettype;
5344 if (addrtype) {
5345 *addrtype = attr_p->attr.source_filter.addrtype;
5347 sstrncpy(dest_addr, attr_p->attr.source_filter.dest_addr,
5348 SDP_MAX_STRING_LEN+1);
5350 return (SDP_SUCCESS);
5353 /* Function: sdp_get_filter_source_address_count
5354 * Description: Gets the number of source addresses in the list
5355 * Parameters: sdp_p The SDP handle which contains the attributes
5356 * level SDP_SESSION_LEVEL/m-line number
5357 * inst_num The attribute instance number
5358 * Returns: Source-list count
5361 int32_t
5362 sdp_get_filter_source_address_count (sdp_t *sdp_p, uint16_t level,
5363 uint8_t cap_num, uint16_t inst_num)
5365 sdp_attr_t *attr_p;
5367 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5368 SDP_ATTR_SOURCE_FILTER, inst_num);
5369 if (attr_p == NULL) {
5370 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5371 SDPLogError(logTag, "%s Source filter attribute, level %u instance %u "
5372 "not found", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5374 sdp_p->conf_p->num_invalid_param++;
5375 return (SDP_INVALID_VALUE);
5377 return (attr_p->attr.source_filter.num_src_addr);
5380 /* Function: sdp_get_filter_source_address
5381 * Description: Gets one of the source address that is indexed by the user
5382 * Parameters: sdp_p The SDP handle which contains the attributes
5383 * level SDP_SESSION_LEVEL/m-line number
5384 * inst_num The attribute instance number
5385 * src_addr_id User provided index (value in range between
5386 * 0 to (SDP_MAX_SRC_ADDR_LIST-1) which obtains
5387 * the source addr corresponding to it.
5388 * src_addr The user provided variable which gets updated
5389 * with source address corresponding to the index
5391 sdp_result_e
5392 sdp_get_filter_source_address (sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
5393 uint16_t inst_num, uint16_t src_addr_id,
5394 char *src_addr)
5396 sdp_attr_t *attr_p;
5398 src_addr[0] = '\0';
5400 if (src_addr_id >= SDP_MAX_SRC_ADDR_LIST) {
5401 return (SDP_INVALID_PARAMETER);
5403 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5404 SDP_ATTR_SOURCE_FILTER, inst_num);
5405 if (attr_p == NULL) {
5406 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5407 SDPLogError(logTag, "%s Source filter attribute, level %u instance %u "
5408 "not found", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5410 sdp_p->conf_p->num_invalid_param++;
5411 return (SDP_INVALID_PARAMETER);
5413 if (src_addr_id >= attr_p->attr.source_filter.num_src_addr) {
5414 return (SDP_INVALID_PARAMETER);
5416 sstrncpy(src_addr, attr_p->attr.source_filter.src_list[src_addr_id],
5417 SDP_MAX_STRING_LEN+1);
5419 return (SDP_SUCCESS);
5422 sdp_rtcp_unicast_mode_e
5423 sdp_get_rtcp_unicast_mode(sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
5424 uint16_t inst_num)
5426 sdp_attr_t *attr_p;
5428 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5429 SDP_ATTR_RTCP_UNICAST, inst_num);
5430 if (attr_p == NULL) {
5431 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5432 SDPLogError(logTag, "%s RTCP Unicast attribute, level %u, "
5433 "instance %u not found", sdp_p->debug_str,
5434 (unsigned)level, (unsigned)inst_num);
5436 sdp_p->conf_p->num_invalid_param++;
5437 return (SDP_RTCP_UNICAST_MODE_NOT_PRESENT);
5439 return ((sdp_rtcp_unicast_mode_e)attr_p->attr.u32_val);
5443 /* Function: sdp_attr_get_sdescriptions_tag
5444 * Description: Returns the value of the sdescriptions tag
5445 * parameter specified for the given attribute.
5446 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5447 * level The level to check for the attribute.
5448 * cap_num The capability number associated with the
5449 * attribute if any. If none, should be zero.
5450 * inst_num The attribute instance number to check.
5451 * Returns: Tag value or SDP_INVALID_VALUE (-2) if error encountered.
5454 int32_t
5455 sdp_attr_get_sdescriptions_tag (sdp_t *sdp_p, uint16_t level,
5456 uint8_t cap_num, uint16_t inst_num)
5458 sdp_attr_t *attr_p;
5460 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5461 SDP_ATTR_SDESCRIPTIONS, inst_num);
5463 if (attr_p == NULL) {
5464 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5465 SDPLogError(logTag, "%s srtp attribute tag, level %u instance %u "
5466 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5468 sdp_p->conf_p->num_invalid_param++;
5469 return SDP_INVALID_VALUE;
5470 } else {
5471 return attr_p->attr.srtp_context.tag;
5475 /* Function: sdp_attr_get_sdescriptions_crypto_suite
5476 * Description: Returns the value of the sdescriptions crypto suite
5477 * parameter specified for the given attribute. Note that
5478 * this is a common api for both version 2 and version 9
5479 * sdescriptions. It has no knowledge which version is being
5480 * used so it will first try to find if a version 2 sdescriptions
5481 * attribute is present. If it is, return the suite. If it's not,
5482 * try to find the version 9. This assumes you cannot have both
5483 * versions in the same SDP.
5485 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5486 * level The level to check for the attribute.
5487 * cap_num The capability number associated with the
5488 * attribute if any. If none, should be zero.
5489 * inst_num The attribute instance number to check.
5490 * Returns: SDP_SRTP_UNKNOWN_CRYPTO_SUITE is returned if an error was
5491 * encountered otherwise the crypto suite is returned.
5494 sdp_srtp_crypto_suite_t
5495 sdp_attr_get_sdescriptions_crypto_suite (sdp_t *sdp_p, uint16_t level,
5496 uint8_t cap_num, uint16_t inst_num)
5498 sdp_attr_t *attr_p;
5501 /* Try version 2 first */
5502 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5503 SDP_ATTR_SRTP_CONTEXT, inst_num);
5505 if (attr_p == NULL) {
5506 /* There's no version 2 so now try version 9 */
5507 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5508 SDP_ATTR_SDESCRIPTIONS, inst_num);
5509 if (attr_p == NULL) {
5510 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5511 SDPLogError(logTag, "%s srtp attribute suite, level %u instance %u "
5512 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5514 sdp_p->conf_p->num_invalid_param++;
5515 return SDP_SRTP_UNKNOWN_CRYPTO_SUITE;
5519 return attr_p->attr.srtp_context.suite;
5523 /* Function: sdp_attr_get_sdescriptions_key
5524 * Description: Returns the value of the sdescriptions master key
5525 * parameter specified for the given attribute. Note that
5526 * this is a common api for both version 2 and version 9
5527 * sdescriptions. It has no knowledge which version is being
5528 * used so it will first try to find if a version 2 sdescriptions
5529 * attribute is present. If it is, return the key. If it's not,
5530 * try to find the version 9. This assumes you cannot have both
5531 * versions in the same SDP.
5533 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5534 * level The level to check for the attribute.
5535 * cap_num The capability number associated with the
5536 * attribute if any. If none, should be zero.
5537 * inst_num The attribute instance number to check.
5538 * Returns: NULL if error encountered or master key salt string
5541 const char*
5542 sdp_attr_get_sdescriptions_key (sdp_t *sdp_p, uint16_t level,
5543 uint8_t cap_num, uint16_t inst_num)
5545 sdp_attr_t *attr_p;
5547 /* Try version 2 first */
5548 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5549 SDP_ATTR_SRTP_CONTEXT, inst_num);
5551 if (attr_p == NULL) {
5552 /* Couldn't find version 2 now try version 9 */
5553 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5554 SDP_ATTR_SDESCRIPTIONS, inst_num);
5556 if (attr_p == NULL) {
5557 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5558 SDPLogError(logTag, "%s srtp attribute key, level %u instance %u "
5559 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5561 sdp_p->conf_p->num_invalid_param++;
5562 return NULL;
5566 return (char*)attr_p->attr.srtp_context.master_key;
5570 /* Function: sdp_attr_get_sdescriptions_salt
5571 * Description: Returns the value of the sdescriptions master salt
5572 * parameter specified for the given attribute. Note that
5573 * this is a common api for both version 2 and version 9
5574 * sdescriptions. It has no knowledge which version is being
5575 * used so it will first try to find if a version 2 sdescriptions
5576 * attribute is present. If it is, return the salt. If it's not,
5577 * try to find the version 9. This assumes you cannot have both
5578 * versions in the same SDP.
5580 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5581 * level The level to check for the attribute.
5582 * cap_num The capability number associated with the
5583 * attribute if any. If none, should be zero.
5584 * inst_num The attribute instance number to check.
5585 * Returns: NULL if error encountered or master key salt string
5588 const char*
5589 sdp_attr_get_sdescriptions_salt (sdp_t *sdp_p, uint16_t level,
5590 uint8_t cap_num, uint16_t inst_num)
5592 sdp_attr_t *attr_p;
5594 /* Try version 2 first */
5595 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5596 SDP_ATTR_SRTP_CONTEXT, inst_num);
5598 if (attr_p == NULL) {
5599 /* Couldn't find version 2 now try version 9 */
5600 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5601 SDP_ATTR_SDESCRIPTIONS, inst_num);
5603 if (attr_p == NULL) {
5604 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5605 SDPLogError(logTag, "%s srtp attribute salt, level %u instance %u "
5606 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5608 sdp_p->conf_p->num_invalid_param++;
5609 return NULL;
5613 return (char*) attr_p->attr.srtp_context.master_salt;
5619 /* Function: sdp_attr_get_sdescriptions_lifetime
5620 * Description: Returns the value of the sdescriptions lifetime
5621 * parameter specified for the given attribute.Note that
5622 * this is a common api for both version 2 and version 9
5623 * sdescriptions. It has no knowledge which version is being
5624 * used so it will first try to find if a version 2 sdescriptions
5625 * attribute is present. If it is, return the lifetime. If it's
5626 * not, try to find the version 9. This assumes you cannot have
5627 * both versions in the same SDP.
5629 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5630 * level The level to check for the attribute.
5631 * cap_num The capability number associated with the
5632 * attribute if any. If none, should be zero.
5633 * inst_num The attribute instance number to check.
5634 * Returns: NULL if error encountered or lifetime string
5637 const char*
5638 sdp_attr_get_sdescriptions_lifetime (sdp_t *sdp_p, uint16_t level,
5639 uint8_t cap_num, uint16_t inst_num)
5641 sdp_attr_t *attr_p;
5643 /* Try version 2 first. */
5644 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5645 SDP_ATTR_SRTP_CONTEXT, inst_num);
5647 if (attr_p == NULL) {
5648 /* Couldn't find version 2 now try version 9 */
5649 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5650 SDP_ATTR_SDESCRIPTIONS, inst_num);
5652 if (attr_p == NULL) {
5653 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5654 SDPLogError(logTag, "%s srtp attribute lifetime, level %u instance %u "
5655 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5657 sdp_p->conf_p->num_invalid_param++;
5658 return NULL;
5662 return (char*)attr_p->attr.srtp_context.master_key_lifetime;
5666 /* Function: sdp_attr_get_sdescriptions_mki
5667 * Description: Returns the value of the sdescriptions MKI value and length
5668 * parameter of the specified attribute instance. Note that
5669 * this is a common api for both version 2 and version 9
5670 * sdescriptions. It has no knowledge which version is being
5671 * used so it will first try to find if a version 2 sdescriptions
5672 * attribute is present. If it is, return the MKI. If it's
5673 * not, try to find version 9. This assumes you cannot have
5674 * both versions in the same SDP.
5676 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5677 * level The level to check for the attribute.
5678 * cap_num The capability number associated with the
5679 * attribute if any. If none, should be zero.
5680 * inst_num The attribute instance number to check.
5681 * mki_value application provided pointer that on exit
5682 * is set to the MKI value string if one exists.
5683 * mki_length application provided pointer that on exit
5684 * is set to the MKI length if one exists.
5685 * Returns: SDP_SUCCESS no errors encountered otherwise sdp error
5686 * based upon the specific error.
5689 sdp_result_e
5690 sdp_attr_get_sdescriptions_mki (sdp_t *sdp_p, uint16_t level,
5691 uint8_t cap_num, uint16_t inst_num,
5692 const char **mki_value,
5693 uint16_t *mki_length)
5695 sdp_attr_t *attr_p;
5697 *mki_value = NULL;
5698 *mki_length = 0;
5700 /* Try version 2 first */
5701 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5702 SDP_ATTR_SRTP_CONTEXT, inst_num);
5704 if (attr_p == NULL) {
5705 /* Couldn't find version 2 now try version 9 */
5706 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5707 SDP_ATTR_SDESCRIPTIONS, inst_num);
5708 if (attr_p == NULL) {
5709 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5710 SDPLogError(logTag, "%s srtp attribute MKI, level %u instance %u "
5711 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5713 sdp_p->conf_p->num_invalid_param++;
5714 return SDP_INVALID_PARAMETER;
5718 *mki_value = (char*)attr_p->attr.srtp_context.mki;
5719 *mki_length = attr_p->attr.srtp_context.mki_size_bytes;
5720 return SDP_SUCCESS;
5725 /* Function: sdp_attr_get_sdescriptions_session_params
5726 * Description: Returns the unparsed session parameters string. Note that
5727 * this is a common api for both version 2 and version 9
5728 * sdescriptions. It has no knowledge which version is being
5729 * used so it will first try to find if a version 2 sdescriptions
5730 * attribute is present. If it is, return session parameters. If
5731 * it's not, try to find version 9. This assumes you cannot have
5732 * both versions in the same SDP.
5734 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5735 * level The level to check for the attribute.
5736 * cap_num The capability number associated with the
5737 * attribute if any. If none, should be zero.
5738 * inst_num The attribute instance number to check.
5739 * Returns: NULL if no session parameters were received in the sdp,
5740 * otherwise returns a pointer to the start of the session
5741 * parameters string. Note that the calling function should
5742 * not free the returned pointer.
5745 const char*
5746 sdp_attr_get_sdescriptions_session_params (sdp_t *sdp_p, uint16_t level,
5747 uint8_t cap_num, uint16_t inst_num)
5749 sdp_attr_t *attr_p;
5751 /* Try version 2 first */
5752 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5753 SDP_ATTR_SRTP_CONTEXT, inst_num);
5755 if (attr_p == NULL) {
5756 /* Couldn't find version 2 try version 9 */
5757 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5758 SDP_ATTR_SDESCRIPTIONS, inst_num);
5759 if (attr_p == NULL) {
5760 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5761 SDPLogError(logTag, "%s srtp attribute session params, level %u instance %u "
5762 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5764 sdp_p->conf_p->num_invalid_param++;
5765 return NULL;
5769 return attr_p->attr.srtp_context.session_parameters;
5773 /* Function: sdp_attr_get_sdescriptions_key_size
5774 * Description: Returns the master key size. Note that
5775 * this is a common api for both version 2 and version 9
5776 * sdescriptions. It has no knowledge which version is being
5777 * used so it will first try to find if a version 2 sdescriptions
5778 * attribute is present. If it is, return key size. If
5779 * it's not, try to find version 9. This assumes you cannot have
5780 * both versions in the same SDP.
5782 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5783 * level The level to check for the attribute.
5784 * cap_num The capability number associated with the
5785 * attribute if any. If none, should be zero.
5786 * inst_num The attribute instance number to check.
5787 * Returns: 0 (SDP_SDESCRIPTIONS_KEY_SIZE_UNKNOWN) if error was
5788 * encountered, otherwise key size.
5791 unsigned char
5792 sdp_attr_get_sdescriptions_key_size (sdp_t *sdp_p,
5793 uint16_t level,
5794 uint8_t cap_num,
5795 uint16_t inst_num)
5798 sdp_attr_t *attr_p;
5800 /* Try version 2 first */
5801 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5802 SDP_ATTR_SRTP_CONTEXT, inst_num);
5804 if (attr_p == NULL) {
5805 /* Couldn't find version 2 now try version 9 */
5806 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5807 SDP_ATTR_SDESCRIPTIONS, inst_num);
5808 if (attr_p == NULL) {
5809 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5810 SDPLogError(logTag, "%s srtp attribute MKI, level %u instance %u "
5811 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5813 sdp_p->conf_p->num_invalid_param++;
5814 return SDP_SDESCRIPTIONS_KEY_SIZE_UNKNOWN;
5818 return attr_p->attr.srtp_context.master_key_size_bytes;
5823 /* Function: sdp_attr_get_sdescriptions_salt_size
5824 * Description: Returns the salt key size. Note that
5825 * this is a common api for both version 2 and version 9
5826 * sdescriptions. It has no knowledge which version is being
5827 * used so it will first try to find if a version 2 sdescriptions
5828 * attribute is present. If it is, return salt size. If
5829 * it's not, try to find version 9. This assumes you cannot have
5830 * both versions in the same SDP.
5832 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5833 * level The level to check for the attribute.
5834 * cap_num The capability number associated with the
5835 * attribute if any. If none, should be zero.
5836 * inst_num The attribute instance number to check.
5837 * Returns: 0 (SDP_SDESCRIPTIONS_KEY_SIZE_UNKNOWN) if error was
5838 * encountered, otherwise salt size.
5841 unsigned char
5842 sdp_attr_get_sdescriptions_salt_size (sdp_t *sdp_p,
5843 uint16_t level,
5844 uint8_t cap_num,
5845 uint16_t inst_num)
5848 sdp_attr_t *attr_p;
5850 /* Try version 2 first */
5851 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5852 SDP_ATTR_SRTP_CONTEXT, inst_num);
5854 if (attr_p == NULL) {
5855 /* Couldn't find version 2 now try version 9 */
5856 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5857 SDP_ATTR_SDESCRIPTIONS, inst_num);
5858 if (attr_p == NULL) {
5859 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5860 SDPLogError(logTag, "%s srtp attribute MKI, level %u instance %u "
5861 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5863 sdp_p->conf_p->num_invalid_param++;
5864 return SDP_SDESCRIPTIONS_KEY_SIZE_UNKNOWN;
5868 return attr_p->attr.srtp_context.master_salt_size_bytes;
5873 /* Function: sdp_attr_get_srtp_crypto_selection_flags
5874 * Description: Returns the selection flags. Note that
5875 * this is a common api for both version 2 and version 9
5876 * sdescriptions. It has no knowledge which version is being
5877 * used so it will first try to find if a version 2 sdescriptions
5878 * attribute is present. If it is, return selection flags. If
5879 * it's not, try to find version 9. This assumes you cannot have
5880 * both versions in the same SDP.
5881 * Currently only necessary for MGCP.
5883 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5884 * level The level to check for the attribute.
5885 * cap_num The capability number associated with the
5886 * attribute if any. If none, should be zero.
5887 * inst_num The attribute instance number to check.
5888 * Returns: 0 (SDP_SRTP_CRYPTO_SELECTION_FLAGS_UNKNOWN) if error was
5889 * encountered, otherwise selection flags.
5892 unsigned long
5893 sdp_attr_get_srtp_crypto_selection_flags (sdp_t *sdp_p,
5894 uint16_t level,
5895 uint8_t cap_num,
5896 uint16_t inst_num)
5900 sdp_attr_t *attr_p;
5902 /* Try version 2 first */
5903 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5904 SDP_ATTR_SRTP_CONTEXT, inst_num);
5906 if (attr_p == NULL) {
5907 /* Couldn't find version 2 now try version 9 */
5908 attr_p = sdp_find_attr(sdp_p, level, cap_num,
5909 SDP_ATTR_SDESCRIPTIONS, inst_num);
5910 if (attr_p == NULL) {
5911 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5912 SDPLogError(logTag, "%s srtp attribute MKI, level %u instance %u "
5913 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
5915 sdp_p->conf_p->num_invalid_param++;
5916 return SDP_SRTP_CRYPTO_SELECTION_FLAGS_UNKNOWN;
5920 return attr_p->attr.srtp_context.selection_flags;
5926 /* Function: sdp_find_rtcp_fb_attr
5927 * Description: Helper to find the nth instance of a rtcp-fb attribute of
5928 * the specified feedback type.
5929 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5930 * level The level to check for the attribute.
5931 * payload_type The payload to get the attribute for
5932 * fb_type The feedback type to look for.
5933 * inst_num The attribute instance number to check.
5934 * Returns: Pointer to the attribute, or NULL if not found.
5937 sdp_attr_t *
5938 sdp_find_rtcp_fb_attr (sdp_t *sdp_p,
5939 uint16_t level,
5940 uint16_t payload_type,
5941 sdp_rtcp_fb_type_e fb_type,
5942 uint16_t inst_num)
5944 uint16_t attr_count=0;
5945 sdp_mca_t *mca_p;
5946 sdp_attr_t *attr_p;
5948 mca_p = sdp_find_media_level(sdp_p, level);
5949 if (!mca_p) {
5950 return (NULL);
5952 for (attr_p = mca_p->media_attrs_p; attr_p; attr_p = attr_p->next_p) {
5953 if (attr_p->type == SDP_ATTR_RTCP_FB &&
5954 (attr_p->attr.rtcp_fb.payload_num == payload_type ||
5955 attr_p->attr.rtcp_fb.payload_num == SDP_ALL_PAYLOADS) &&
5956 attr_p->attr.rtcp_fb.feedback_type == fb_type) {
5957 attr_count++;
5958 if (attr_count == inst_num) {
5959 return (attr_p);
5963 return NULL;
5966 /* Function: sdp_attr_get_rtcp_fb_ack
5967 * Description: Returns the value of the rtcp-fb:...ack attribute
5968 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5969 * level The level to check for the attribute.
5970 * payload_type The payload to get the attribute for
5971 * inst_num The attribute instance number to check.
5972 * Returns: ACK type (SDP_RTCP_FB_ACK_NOT_FOUND if not present)
5974 sdp_rtcp_fb_ack_type_e
5975 sdp_attr_get_rtcp_fb_ack(sdp_t *sdp_p, uint16_t level, uint16_t payload_type, uint16_t inst)
5977 sdp_attr_t *attr_p;
5979 attr_p = sdp_find_rtcp_fb_attr(sdp_p, level, payload_type,
5980 SDP_RTCP_FB_ACK, inst);
5981 if (!attr_p) {
5982 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
5983 SDPLogError(logTag, "%s rtcp-fb attribute, level %u, pt %u, "
5984 "instance %u not found.", sdp_p->debug_str, (unsigned)level,
5985 (unsigned)payload_type, (unsigned)inst);
5987 sdp_p->conf_p->num_invalid_param++;
5988 return SDP_RTCP_FB_ACK_NOT_FOUND;
5990 return (attr_p->attr.rtcp_fb.param.ack);
5993 /* Function: sdp_attr_get_rtcp_fb_nack
5994 * Description: Returns the value of the rtcp-fb:...nack attribute
5995 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
5996 * level The level to check for the attribute.
5997 * payload_type The payload to get the attribute for
5998 * inst_num The attribute instance number to check.
5999 * Returns: NACK type (SDP_RTCP_FB_NACK_NOT_FOUND if not present)
6001 sdp_rtcp_fb_nack_type_e
6002 sdp_attr_get_rtcp_fb_nack(sdp_t *sdp_p, uint16_t level, uint16_t payload_type, uint16_t inst)
6004 sdp_attr_t *attr_p;
6006 attr_p = sdp_find_rtcp_fb_attr(sdp_p, level, payload_type,
6007 SDP_RTCP_FB_NACK, inst);
6008 if (!attr_p) {
6009 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
6010 SDPLogError(logTag, "%s rtcp-fb attribute, level %u, pt %u, "
6011 "instance %u not found.", sdp_p->debug_str, (unsigned)level,
6012 (unsigned)payload_type, (unsigned)inst);
6014 sdp_p->conf_p->num_invalid_param++;
6015 return SDP_RTCP_FB_NACK_NOT_FOUND;
6017 return (attr_p->attr.rtcp_fb.param.nack);
6020 /* Function: sdp_attr_get_rtcp_fb_trr_int
6021 * Description: Returns the value of the rtcp-fb:...trr-int attribute
6022 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
6023 * level The level to check for the attribute.
6024 * payload_type The payload to get the attribute for
6025 * inst_num The attribute instance number to check.
6026 * Returns: trr-int interval (0xFFFFFFFF if not found)
6028 uint32_t
6029 sdp_attr_get_rtcp_fb_trr_int(sdp_t *sdp_p, uint16_t level,
6030 uint16_t payload_type, uint16_t inst)
6032 sdp_attr_t *attr_p;
6034 attr_p = sdp_find_rtcp_fb_attr(sdp_p, level, payload_type,
6035 SDP_RTCP_FB_TRR_INT, inst);
6036 if (!attr_p) {
6037 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
6038 SDPLogError(logTag, "%s rtcp-fb attribute, level %u, pt %u, "
6039 "instance %u not found.", sdp_p->debug_str, (unsigned)level,
6040 (unsigned)payload_type, (unsigned)inst);
6042 sdp_p->conf_p->num_invalid_param++;
6043 return 0xFFFFFFFF;
6045 return (attr_p->attr.rtcp_fb.param.trr_int);
6048 /* Function: sdp_attr_get_rtcp_fb_remb_enabled
6049 * Description: Returns true if rtcp-fb:...goog-remb attribute exists
6050 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
6051 * level The level to check for the attribute.
6052 * payload_type The payload to get the attribute for
6053 * Returns: true if rtcp-fb:...goog-remb exists
6055 tinybool
6056 sdp_attr_get_rtcp_fb_remb_enabled(sdp_t *sdp_p,
6057 uint16_t level,
6058 uint16_t payload_type)
6060 sdp_attr_t *attr_p;
6062 attr_p = sdp_find_rtcp_fb_attr(sdp_p, level, payload_type,
6063 SDP_RTCP_FB_REMB,
6064 1); // always check for 1st instance
6065 return (attr_p? TRUE : FALSE); // either exists or not
6068 /* Function: sdp_attr_get_rtcp_fb_transport_cc_enabled
6069 * Description: Returns true if rtcp-fb:...transport-cc attribute exists
6070 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
6071 * level The level to check for the attribute.
6072 * payload_type The payload to get the attribute for
6073 * Returns: true if rtcp-fb:...transport-cc exists
6075 tinybool
6076 sdp_attr_get_rtcp_fb_transport_cc_enabled(sdp_t *sdp_p,
6077 uint16_t level,
6078 uint16_t payload_type)
6080 sdp_attr_t *attr_p;
6082 attr_p = sdp_find_rtcp_fb_attr(sdp_p, level, payload_type,
6083 SDP_RTCP_FB_TRANSPORT_CC,
6084 1); // always check for 1st instance
6085 return (attr_p? TRUE : FALSE); // either exists or not
6088 /* Function: sdp_attr_get_rtcp_fb_ccm
6089 * Description: Returns the value of the rtcp-fb:...ccm attribute
6090 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
6091 * level The level to check for the attribute.
6092 * payload_type The payload to get the attribute for
6093 * inst_num The attribute instance number to check.
6094 * Returns: CCM type (SDP_RTCP_FB_CCM_NOT_FOUND if not present)
6096 sdp_rtcp_fb_ccm_type_e
6097 sdp_attr_get_rtcp_fb_ccm(sdp_t *sdp_p, uint16_t level, uint16_t payload_type, uint16_t inst)
6099 sdp_attr_t *attr_p;
6101 attr_p = sdp_find_rtcp_fb_attr(sdp_p, level, payload_type,
6102 SDP_RTCP_FB_CCM, inst);
6103 if (!attr_p) {
6104 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
6105 SDPLogError(logTag, "%s rtcp-fb attribute, level %u, pt %u, "
6106 "instance %u not found.", sdp_p->debug_str, (unsigned)level,
6107 (unsigned)payload_type, (unsigned)inst);
6109 sdp_p->conf_p->num_invalid_param++;
6110 return SDP_RTCP_FB_CCM_NOT_FOUND;
6112 return (attr_p->attr.rtcp_fb.param.ccm);
6115 /* Function: sdp_attr_set_rtcp_fb_ack
6116 * Description: Sets the value of an rtcp-fb:...ack attribute
6117 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
6118 * level The level to set the attribute.
6119 * payload_type The value to set the payload type to for
6120 * this attribute. Can be SDP_ALL_PAYLOADS.
6121 * inst_num The attribute instance number to check.
6122 * type The ack type to indicate
6123 * Returns: SDP_SUCCESS Attribute param was set successfully.
6124 * SDP_INVALID_PARAMETER Specified attribute is not defined.
6126 sdp_result_e
6127 sdp_attr_set_rtcp_fb_ack(sdp_t *sdp_p, uint16_t level, uint16_t payload_type, uint16_t inst,
6128 sdp_rtcp_fb_ack_type_e type)
6130 sdp_attr_t *attr_p;
6132 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_RTCP_FB, inst);
6133 if (!attr_p) {
6134 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
6135 SDPLogError(logTag, "%s rtcp_fb ack attribute, level %u "
6136 "instance %u not found.", sdp_p->debug_str, (unsigned)level,
6137 (unsigned)inst);
6139 sdp_p->conf_p->num_invalid_param++;
6140 return (SDP_INVALID_PARAMETER);
6143 attr_p->attr.rtcp_fb.payload_num = payload_type;
6144 attr_p->attr.rtcp_fb.feedback_type = SDP_RTCP_FB_ACK;
6145 attr_p->attr.rtcp_fb.param.ack = type;
6146 attr_p->attr.rtcp_fb.extra[0] = '\0';
6147 return (SDP_SUCCESS);
6151 /* Function: sdp_attr_set_rtcp_fb_nack
6152 * Description: Sets the value of an rtcp-fb:...nack attribute
6153 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
6154 * level The level to set the attribute.
6155 * payload_type The value to set the payload type to for
6156 * this attribute. Can be SDP_ALL_PAYLOADS.
6157 * inst_num The attribute instance number to check.
6158 * type The nack type to indicate
6159 * Returns: SDP_SUCCESS Attribute param was set successfully.
6160 * SDP_INVALID_PARAMETER Specified attribute is not defined.
6162 sdp_result_e
6163 sdp_attr_set_rtcp_fb_nack(sdp_t *sdp_p, uint16_t level, uint16_t payload_type, uint16_t inst,
6164 sdp_rtcp_fb_nack_type_e type)
6166 sdp_attr_t *attr_p;
6168 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_RTCP_FB, inst);
6169 if (!attr_p) {
6170 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
6171 SDPLogError(logTag, "%s rtcp_fb nack attribute, level %u "
6172 "instance %u not found.", sdp_p->debug_str, (unsigned)level,
6173 (unsigned)inst);
6175 sdp_p->conf_p->num_invalid_param++;
6176 return (SDP_INVALID_PARAMETER);
6179 attr_p->attr.rtcp_fb.payload_num = payload_type;
6180 attr_p->attr.rtcp_fb.feedback_type = SDP_RTCP_FB_NACK;
6181 attr_p->attr.rtcp_fb.param.nack = type;
6182 attr_p->attr.rtcp_fb.extra[0] = '\0';
6183 return (SDP_SUCCESS);
6186 /* Function: sdp_attr_set_rtcp_fb_trr_int
6187 * Description: Sets the value of an rtcp-fb:...trr-int attribute
6188 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
6189 * level The level to set the attribute.
6190 * payload_type The value to set the payload type to for
6191 * this attribute. Can be SDP_ALL_PAYLOADS.
6192 * inst_num The attribute instance number to check.
6193 * interval The interval time to indicate
6194 * Returns: SDP_SUCCESS Attribute param was set successfully.
6195 * SDP_INVALID_PARAMETER Specified attribute is not defined.
6197 sdp_result_e
6198 sdp_attr_set_rtcp_fb_trr_int(sdp_t *sdp_p, uint16_t level, uint16_t payload_type,
6199 uint16_t inst, uint32_t interval)
6201 sdp_attr_t *attr_p;
6203 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_RTCP_FB, inst);
6204 if (!attr_p) {
6205 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
6206 SDPLogError(logTag, "%s rtcp_fb trr-int attribute, level %u "
6207 "instance %u not found.", sdp_p->debug_str, (unsigned)level,
6208 (unsigned)inst);
6210 sdp_p->conf_p->num_invalid_param++;
6211 return (SDP_INVALID_PARAMETER);
6214 attr_p->attr.rtcp_fb.payload_num = payload_type;
6215 attr_p->attr.rtcp_fb.feedback_type = SDP_RTCP_FB_TRR_INT;
6216 attr_p->attr.rtcp_fb.param.trr_int = interval;
6217 attr_p->attr.rtcp_fb.extra[0] = '\0';
6218 return (SDP_SUCCESS);
6221 /* Function: sdp_attr_set_rtcp_fb_remb
6222 * Description: Sets the value of an rtcp-fb:...goog-remb attribute
6223 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
6224 * level The level to set the attribute.
6225 * payload_type The value to set the payload type to for
6226 * this attribute. Can be SDP_ALL_PAYLOADS.
6227 * inst_num The attribute instance number to check.
6228 * Returns: SDP_SUCCESS Attribute param was set successfully.
6229 * SDP_INVALID_PARAMETER Specified attribute is not defined.
6231 sdp_result_e
6232 sdp_attr_set_rtcp_fb_remb(sdp_t *sdp_p, uint16_t level, uint16_t payload_type,
6233 uint16_t inst)
6235 sdp_attr_t *attr_p;
6237 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_RTCP_FB, inst);
6238 if (!attr_p) {
6239 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
6240 SDPLogError(logTag, "%s rtcp_fb goog-remb attribute, level %u "
6241 "instance %u not found.", sdp_p->debug_str, (unsigned)level,
6242 (unsigned)inst);
6244 sdp_p->conf_p->num_invalid_param++;
6245 return (SDP_INVALID_PARAMETER);
6248 attr_p->attr.rtcp_fb.payload_num = payload_type;
6249 attr_p->attr.rtcp_fb.feedback_type = SDP_RTCP_FB_REMB;
6250 return (SDP_SUCCESS);
6253 /* Function: sdp_attr_set_rtcp_fb_transport_cc
6254 * Description: Sets the value of an rtcp-fb:...transport-cc attribute
6255 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
6256 * level The level to set the attribute.
6257 * payload_type The value to set the payload type to for
6258 * this attribute. Can be SDP_ALL_PAYLOADS.
6259 * inst_num The attribute instance number to check.
6260 * Returns: SDP_SUCCESS Attribute param was set successfully.
6261 * SDP_INVALID_PARAMETER Specified attribute is not defined.
6263 sdp_result_e
6264 sdp_attr_set_rtcp_fb_transport_cc(sdp_t *sdp_p, uint16_t level, uint16_t payload_type,
6265 uint16_t inst)
6267 sdp_attr_t *attr_p;
6269 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_RTCP_FB, inst);
6270 if (!attr_p) {
6271 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
6272 SDPLogError(logTag, "%s rtcp_fb transport-cc attribute, level %u "
6273 "instance %u not found.", sdp_p->debug_str, (unsigned)level,
6274 (unsigned)inst);
6276 sdp_p->conf_p->num_invalid_param++;
6277 return (SDP_INVALID_PARAMETER);
6280 attr_p->attr.rtcp_fb.payload_num = payload_type;
6281 attr_p->attr.rtcp_fb.feedback_type = SDP_RTCP_FB_TRANSPORT_CC;
6282 return (SDP_SUCCESS);
6285 /* Function: sdp_attr_set_rtcp_fb_ccm
6286 * Description: Sets the value of an rtcp-fb:...ccm attribute
6287 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
6288 * level The level to set the attribute.
6289 * payload_type The value to set the payload type to for
6290 * this attribute. Can be SDP_ALL_PAYLOADS.
6291 * inst_num The attribute instance number to check.
6292 * type The ccm type to indicate
6293 * Returns: SDP_SUCCESS Attribute param was set successfully.
6294 * SDP_INVALID_PARAMETER Specified attribute is not defined.
6296 sdp_result_e
6297 sdp_attr_set_rtcp_fb_ccm(sdp_t *sdp_p, uint16_t level, uint16_t payload_type, uint16_t inst,
6298 sdp_rtcp_fb_ccm_type_e type)
6300 sdp_attr_t *attr_p;
6302 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_RTCP_FB, inst);
6303 if (!attr_p) {
6304 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
6305 SDPLogError(logTag, "%s rtcp_fb ccm attribute, level %u "
6306 "instance %u not found.", sdp_p->debug_str, (unsigned)level,
6307 (unsigned)inst);
6309 sdp_p->conf_p->num_invalid_param++;
6310 return (SDP_INVALID_PARAMETER);
6312 attr_p->attr.rtcp_fb.payload_num = payload_type;
6313 attr_p->attr.rtcp_fb.feedback_type = SDP_RTCP_FB_CCM;
6314 attr_p->attr.rtcp_fb.param.ccm = type;
6315 attr_p->attr.rtcp_fb.extra[0] = '\0';
6316 return (SDP_SUCCESS);
6319 /* Function: sdp_attr_get_extmap_uri
6320 * Description: Returns a pointer to the value of the encoding name
6321 * parameter specified for the given attribute. Value is
6322 * returned as a const ptr and so cannot be modified by the
6323 * application. If the given attribute is not defined, NULL
6324 * will be returned.
6325 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
6326 * level The level to check for the attribute.
6327 * inst_num The attribute instance number to check.
6328 * Returns: Codec value or SDP_CODEC_INVALID.
6330 const char *sdp_attr_get_extmap_uri(sdp_t *sdp_p, uint16_t level,
6331 uint16_t inst_num)
6333 sdp_attr_t *attr_p;
6335 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_EXTMAP, inst_num);
6336 if (attr_p == NULL) {
6337 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
6338 SDPLogError(logTag, "%s extmap attribute, level %u instance %u "
6339 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
6341 sdp_p->conf_p->num_invalid_param++;
6342 return (NULL);
6343 } else {
6344 return (attr_p->attr.extmap.uri);
6348 /* Function: sdp_attr_get_extmap_id
6349 * Description: Returns the id of the extmap specified for the given
6350 * attribute. If the given attribute is not defined, 0xFFFF
6351 * will be returned.
6352 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
6353 * level The level to check for the attribute.
6354 * inst_num The attribute instance number to check.
6355 * Returns: The id of the extmap attribute.
6357 uint16_t sdp_attr_get_extmap_id(sdp_t *sdp_p, uint16_t level,
6358 uint16_t inst_num)
6360 sdp_attr_t *attr_p;
6362 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_EXTMAP, inst_num);
6363 if (attr_p == NULL) {
6364 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
6365 SDPLogError(logTag, "%s extmap attribute, level %u instance %u "
6366 "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
6368 sdp_p->conf_p->num_invalid_param++;
6369 return 0xFFFF;
6370 } else {
6371 return (attr_p->attr.extmap.id);
6375 /* Function: sdp_attr_set_extmap
6376 * Description: Sets the value of an rtcp-fb:...ccm attribute
6377 * Parameters: sdp_p The SDP handle returned by sdp_init_description.
6378 * level The level to set the attribute.
6379 * id The id to set the attribute.
6380 * uri The uri to set the attribute.
6381 * inst The attribute instance number to check.
6382 * Returns: SDP_SUCCESS Attribute param was set successfully.
6383 * SDP_INVALID_PARAMETER Specified attribute is not defined.
6385 sdp_result_e
6386 sdp_attr_set_extmap(sdp_t *sdp_p, uint16_t level, uint16_t id, const char* uri, uint16_t inst)
6388 sdp_attr_t *attr_p;
6390 attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_EXTMAP, inst);
6391 if (!attr_p) {
6392 if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
6393 SDPLogError(logTag, "%s extmap attribute, level %u "
6394 "instance %u not found.", sdp_p->debug_str, (unsigned)level,
6395 (unsigned)inst);
6397 sdp_p->conf_p->num_invalid_param++;
6398 return (SDP_INVALID_PARAMETER);
6401 attr_p->attr.extmap.id = id;
6402 sstrncpy(attr_p->attr.extmap.uri, uri, SDP_MAX_STRING_LEN+1);
6403 return (SDP_SUCCESS);
6406 const char *sdp_attr_get_msid_identifier(sdp_t *sdp_p, uint16_t level,
6407 uint8_t cap_num, uint16_t inst)
6409 sdp_attr_t *attr_p = sdp_find_attr(sdp_p, level, cap_num,
6410 SDP_ATTR_MSID, inst);
6411 if (!attr_p) {
6412 return NULL;
6414 return attr_p->attr.msid.identifier;
6417 const char *sdp_attr_get_msid_appdata(sdp_t *sdp_p, uint16_t level,
6418 uint8_t cap_num, uint16_t inst)
6420 sdp_attr_t *attr_p = sdp_find_attr(sdp_p, level, cap_num,
6421 SDP_ATTR_MSID, inst);
6422 if (!attr_p) {
6423 return NULL;
6425 return attr_p->attr.msid.appdata;