LCOV - code coverage report
Current view: top level - media/webrtc/signaling/src/sdp/sipcc - sdp_attr_access.c (source / functions) Hit Total Coverage
Test: output.info Lines: 0 1932 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 180 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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/. */
       4             : 
       5             : #include "sdp_os_defs.h"
       6             : #include "sdp.h"
       7             : #include "sdp_private.h"
       8             : 
       9             : #include "CSFLog.h"
      10             : 
      11             : static const char* logTag = "sdp_attr_access";
      12             : 
      13             : /* Attribute access routines are all defined by the following parameters.
      14             :  *
      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.
      41             :  */
      42             : 
      43             : /* Attribute handling:
      44             :  *
      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.
      48             :  *
      49             :  * Simple (non X-cpar attributes):
      50             :  *
      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.
      54             :  *
      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.
      62             :  *
      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.
      67             :  *
      68             :  * X-cpar attribute processing:
      69             :  *
      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:
      73             :  *
      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
      92             :  *
      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.
      97             :  *
      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.
     110             :  *
     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
     122             :  *
     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.
     126             :  *
     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
     135             :  *
     136             :  * The individual embedded attributes can then be accessed by level,
     137             :  * cap_num, and instance number.
     138             :  *
     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
     148             :  */
     149             : 
     150             : 
     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.
     165             :  */
     166           0 : 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)
     168             : {
     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           0 :     sdp_attr_t  *prev_attr_p=NULL;
     175             :     sdp_fmtp_t  *fmtp_p;
     176             :     sdp_comediadir_t  *comediadir_p;
     177             : 
     178           0 :     *inst_num = 0;
     179             : 
     180           0 :     if ((cap_num != 0) &&
     181           0 :         ((attr_type == SDP_ATTR_X_CAP) || (attr_type == SDP_ATTR_X_CPAR) ||
     182           0 :          (attr_type == SDP_ATTR_X_SQN) || (attr_type == SDP_ATTR_CDSC) ||
     183           0 :          (attr_type == SDP_ATTR_CPAR) || (attr_type == SDP_ATTR_SQN))) {
     184           0 :         if (sdp_p->debug_flag[SDP_DEBUG_WARNINGS]) {
     185           0 :             CSFLogDebug(logTag, "%s Warning: Invalid attribute type for X-cpar/cdsc "
     186             :                      "parameter.", sdp_p->debug_str);
     187             :         }
     188           0 :         sdp_p->conf_p->num_invalid_param++;
     189           0 :         return (SDP_INVALID_PARAMETER);
     190             :     }
     191             : 
     192             :     /* Some attributes are valid only under media level */
     193           0 :     if (level == SDP_SESSION_LEVEL) {
     194           0 :         switch (attr_type) {
     195             :             case SDP_ATTR_RTCP:
     196             :             case SDP_ATTR_LABEL:
     197           0 :                 return (SDP_INVALID_MEDIA_LEVEL);
     198             : 
     199             :             default:
     200           0 :                 break;
     201             :         }
     202             :     }
     203             : 
     204           0 :     new_attr_p = (sdp_attr_t *)SDP_MALLOC(sizeof(sdp_attr_t));
     205           0 :     if (new_attr_p == NULL) {
     206           0 :         sdp_p->conf_p->num_no_resource++;
     207           0 :         return (SDP_NO_RESOURCE);
     208             :     }
     209             : 
     210           0 :     new_attr_p->type = attr_type;
     211           0 :     new_attr_p->next_p = NULL;
     212             : 
     213             :     /* Initialize the new attribute structure */
     214           0 :     if ((new_attr_p->type == SDP_ATTR_X_CAP) ||
     215           0 :         (new_attr_p->type == SDP_ATTR_CDSC)) {
     216           0 :         new_attr_p->attr.cap_p = (sdp_mca_t *)SDP_MALLOC(sizeof(sdp_mca_t));
     217           0 :         if (new_attr_p->attr.cap_p == NULL) {
     218           0 :             sdp_free_attr(new_attr_p);
     219           0 :             sdp_p->conf_p->num_no_resource++;
     220           0 :             return (SDP_NO_RESOURCE);
     221             :         }
     222           0 :     } else if (new_attr_p->type == SDP_ATTR_FMTP) {
     223           0 :         fmtp_p = &(new_attr_p->attr.fmtp);
     224           0 :         fmtp_p->fmtp_format = SDP_FMTP_UNKNOWN_TYPE;
     225             :         // set to invalid value
     226           0 :         fmtp_p->packetization_mode = SDP_INVALID_PACKETIZATION_MODE_VALUE;
     227           0 :         fmtp_p->level_asymmetry_allowed = SDP_INVALID_LEVEL_ASYMMETRY_ALLOWED_VALUE;
     228           0 :         fmtp_p->annexb_required = FALSE;
     229           0 :         fmtp_p->annexa_required = FALSE;
     230           0 :         fmtp_p->maxval = 0;
     231           0 :         fmtp_p->bitrate = 0;
     232           0 :         fmtp_p->cif = 0;
     233           0 :         fmtp_p->qcif = 0;
     234           0 :         fmtp_p->profile = SDP_INVALID_VALUE;
     235           0 :         fmtp_p->level = SDP_INVALID_VALUE;
     236           0 :         fmtp_p->parameter_add = SDP_FMTP_UNUSED;
     237           0 :         fmtp_p->usedtx = SDP_FMTP_UNUSED;
     238           0 :         fmtp_p->stereo = SDP_FMTP_UNUSED;
     239           0 :         fmtp_p->useinbandfec = SDP_FMTP_UNUSED;
     240           0 :         fmtp_p->cbr = SDP_FMTP_UNUSED;
     241           0 :         for (i=0; i < SDP_NE_NUM_BMAP_WORDS; i++) {
     242           0 :             fmtp_p->bmap[i] = 0;
     243             :         }
     244           0 :     } else if ((new_attr_p->type == SDP_ATTR_RTPMAP) ||
     245           0 :                (new_attr_p->type == SDP_ATTR_SPRTMAP)) {
     246           0 :         new_attr_p->attr.transport_map.num_chan = 1;
     247           0 :     } else if (new_attr_p->type == SDP_ATTR_DIRECTION) {
     248           0 :         comediadir_p = &(new_attr_p->attr.comediadir);
     249           0 :         comediadir_p->role = SDP_MEDIADIR_ROLE_PASSIVE;
     250           0 :         comediadir_p->conn_info_present = FALSE;
     251           0 :     } else if (new_attr_p->type == SDP_ATTR_MPTIME) {
     252           0 :         sdp_mptime_t *mptime = &(new_attr_p->attr.mptime);
     253           0 :         mptime->num_intervals = 0;
     254             :     }
     255             : 
     256           0 :     if (cap_num == 0) {
     257             :         /* Add a new attribute. */
     258           0 :         if (level == SDP_SESSION_LEVEL) {
     259           0 :             if (sdp_p->sess_attrs_p == NULL) {
     260           0 :                 sdp_p->sess_attrs_p = new_attr_p;
     261             :             } else {
     262           0 :                 for (attr_p = sdp_p->sess_attrs_p;
     263             :                      attr_p != NULL;
     264           0 :                      prev_attr_p = attr_p, attr_p = attr_p->next_p) {
     265             :                     /* Count the num instances of this type. */
     266           0 :                     if (attr_p->type == attr_type) {
     267           0 :                         (*inst_num)++;
     268             :                     }
     269             :                 }
     270           0 :                 prev_attr_p->next_p = new_attr_p;
     271             :             }
     272             :         } else {
     273           0 :             mca_p = sdp_find_media_level(sdp_p, level);
     274           0 :             if (mca_p == NULL) {
     275           0 :                 sdp_free_attr(new_attr_p);
     276           0 :                 sdp_p->conf_p->num_invalid_param++;
     277           0 :                 return (SDP_INVALID_PARAMETER);
     278             :             }
     279           0 :             if (mca_p->media_attrs_p == NULL) {
     280           0 :                 mca_p->media_attrs_p = new_attr_p;
     281             :             } else {
     282           0 :                 for (attr_p = mca_p->media_attrs_p;
     283             :                      attr_p != NULL;
     284           0 :                      prev_attr_p = attr_p, attr_p = attr_p->next_p) {
     285             :                     /* Count the num instances of this type. */
     286           0 :                     if (attr_p->type == attr_type) {
     287           0 :                         (*inst_num)++;
     288             :                     }
     289             :                 }
     290           0 :                 prev_attr_p->next_p = new_attr_p;
     291             :             }
     292             :         }
     293             :     } else {
     294             :         /* Add a new capability attribute - find the capability attr. */
     295           0 :         attr_p = sdp_find_capability(sdp_p, level, cap_num);
     296           0 :         if (attr_p == NULL) {
     297           0 :             sdp_free_attr(new_attr_p);
     298           0 :             sdp_p->conf_p->num_invalid_param++;
     299           0 :             return (SDP_INVALID_PARAMETER);
     300             :         }
     301           0 :         cap_p = attr_p->attr.cap_p;
     302           0 :         if (cap_p->media_attrs_p == NULL) {
     303           0 :             cap_p->media_attrs_p = new_attr_p;
     304             :         } else {
     305           0 :             for (attr_p = cap_p->media_attrs_p;
     306             :                  attr_p != NULL;
     307           0 :                  prev_attr_p = attr_p, attr_p = attr_p->next_p) {
     308             :                 /* Count the num instances of this type. */
     309           0 :                 if (attr_p->type == attr_type) {
     310           0 :                     (*inst_num)++;
     311             :                 }
     312             :             }
     313           0 :             prev_attr_p->next_p = new_attr_p;
     314             :         }
     315             :     }
     316             : 
     317             :     /* Increment the instance num for the attr just added. */
     318           0 :     (*inst_num)++;
     319           0 :     return (SDP_SUCCESS);
     320             : }
     321             : 
     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.
     334             :  */
     335           0 : 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)
     337             : {
     338             :     sdp_attr_t  *attr_p;
     339             :     sdp_result_e rc;
     340             :     static char  fname[] = "attr_num_instances";
     341             : 
     342           0 :     *num_attr_inst = 0;
     343             : 
     344           0 :     rc = sdp_find_attr_list(sdp_p, level, cap_num, &attr_p, fname);
     345           0 :     if (rc == SDP_SUCCESS) {
     346             :         /* Found the attr list. Count the number of attrs of the given
     347             :          * type at this level. */
     348           0 :         for (; attr_p != NULL; attr_p = attr_p->next_p) {
     349           0 :             if (attr_p->type == attr_type) {
     350           0 :                 (*num_attr_inst)++;
     351             :             }
     352             :         }
     353             : 
     354             :     }
     355             : 
     356           0 :     return (rc);
     357             : }
     358             : 
     359             : /* Forward declaration for use in sdp_free_attr */
     360             : static boolean sdp_attr_is_long_string(sdp_attr_e attr_type);
     361             : 
     362             : 
     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.
     370             :  */
     371           0 : void sdp_free_attr (sdp_attr_t *attr_p)
     372             : {
     373             :     sdp_mca_t   *cap_p;
     374             :     sdp_attr_t  *cpar_p;
     375             :     sdp_attr_t  *next_cpar_p;
     376             :     int          i;
     377             : 
     378             :     /* If this is an X-cap/cdsc attr, free the cap_p structure and
     379             :      * all X-cpar/cpar attributes. */
     380           0 :     if ((attr_p->type == SDP_ATTR_X_CAP) ||
     381           0 :         (attr_p->type == SDP_ATTR_CDSC)) {
     382           0 :         cap_p = attr_p->attr.cap_p;
     383           0 :         if (cap_p != NULL) {
     384           0 :             for (cpar_p = cap_p->media_attrs_p; cpar_p != NULL;) {
     385           0 :                 next_cpar_p = cpar_p->next_p;
     386           0 :                 sdp_free_attr(cpar_p);
     387           0 :                 cpar_p = next_cpar_p;
     388             :             }
     389           0 :             SDP_FREE(cap_p);
     390             :         }
     391           0 :     } else if ((attr_p->type == SDP_ATTR_SDESCRIPTIONS) ||
     392           0 :               (attr_p->type == SDP_ATTR_SRTP_CONTEXT)) {
     393           0 :         SDP_FREE(attr_p->attr.srtp_context.session_parameters);
     394           0 :     } else if (sdp_attr_is_long_string(attr_p->type)) {
     395           0 :         SDP_FREE(attr_p->attr.stringp);
     396             :     }
     397             : 
     398           0 :     if (attr_p->type == SDP_ATTR_GROUP) {
     399           0 :         for (i = 0; i < attr_p->attr.stream_data.num_group_id; i++) {
     400           0 :             SDP_FREE(attr_p->attr.stream_data.group_ids[i]);
     401             :         }
     402           0 :     } else if (attr_p->type == SDP_ATTR_MSID_SEMANTIC) {
     403           0 :         for (i = 0; i < SDP_MAX_MEDIA_STREAMS; ++i) {
     404           0 :             SDP_FREE(attr_p->attr.msid_semantic.msids[i]);
     405             :         }
     406             :     }
     407             : 
     408             :     /* Now free the actual attribute memory. */
     409           0 :     SDP_FREE(attr_p);
     410             : 
     411           0 : }
     412             : 
     413             : 
     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
     430             :  */
     431           0 : 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)
     433             : {
     434             :     sdp_mca_t   *mca_p;
     435             :     sdp_mca_t   *cap_p;
     436             :     sdp_attr_t  *cap_attr_p;
     437             : 
     438             :     /* Initialize the attr pointer. */
     439           0 :     *attr_p = NULL;
     440             : 
     441           0 :     if (cap_num == 0) {
     442             :         /* Find attribute list at the specified level. */
     443           0 :         if (level == SDP_SESSION_LEVEL) {
     444           0 :             *attr_p = sdp_p->sess_attrs_p;
     445             :         } else {
     446           0 :             mca_p = sdp_find_media_level(sdp_p, level);
     447           0 :             if (mca_p == NULL) {
     448           0 :                 sdp_p->conf_p->num_invalid_param++;
     449           0 :                 return (SDP_INVALID_PARAMETER);
     450             :             }
     451           0 :             *attr_p = mca_p->media_attrs_p;
     452             :         }
     453             :     } else {
     454             :         /* Find the attr list for the capability specified. */
     455           0 :         cap_attr_p = sdp_find_capability(sdp_p, level, cap_num);
     456           0 :         if (cap_attr_p == NULL) {
     457           0 :             if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
     458           0 :                 CSFLogError(logTag, "%s %s, invalid capability %u at "
     459             :                           "level %u specified.", sdp_p->debug_str, fname,
     460             :                           (unsigned)cap_num, (unsigned)level);
     461             :             }
     462           0 :             sdp_p->conf_p->num_invalid_param++;
     463           0 :             return (SDP_INVALID_CAPABILITY);
     464             :         }
     465           0 :         cap_p = cap_attr_p->attr.cap_p;
     466           0 :         *attr_p = cap_p->media_attrs_p;
     467             :     }
     468             : 
     469           0 :     return (SDP_SUCCESS);
     470             : }
     471             : 
     472             : /* Find fmtp inst_num with correct payload value or -1 for failure */
     473           0 : int sdp_find_fmtp_inst (sdp_t *sdp_p, uint16_t level, uint16_t payload_num)
     474             : {
     475           0 :     uint16_t          attr_count=0;
     476             :     sdp_mca_t   *mca_p;
     477             :     sdp_attr_t  *attr_p;
     478             : 
     479             :     /* Attr is at a media level */
     480           0 :     mca_p = sdp_find_media_level(sdp_p, level);
     481           0 :     if (mca_p == NULL) {
     482           0 :       return (-1);
     483             :     }
     484           0 :     for (attr_p = mca_p->media_attrs_p; attr_p != NULL;
     485           0 :          attr_p = attr_p->next_p) {
     486           0 :       if (attr_p->type == SDP_ATTR_FMTP) {
     487           0 :         attr_count++;
     488           0 :         if (attr_p->attr.fmtp.payload_num == payload_num) {
     489           0 :           return (attr_count);
     490             :         }
     491             :       }
     492             :     }
     493             : 
     494           0 :     return (-1);
     495             : 
     496             : }
     497             : 
     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.
     511             :  */
     512           0 : 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)
     514             : {
     515           0 :     uint16_t          attr_count=0;
     516             :     sdp_mca_t   *mca_p;
     517             :     sdp_mca_t   *cap_p;
     518             :     sdp_attr_t  *attr_p;
     519             : 
     520           0 :     if (inst_num < 1) {
     521           0 :         return (NULL);
     522             :     }
     523             : 
     524           0 :     if (cap_num == 0) {
     525           0 :         if (level == SDP_SESSION_LEVEL) {
     526           0 :             for (attr_p = sdp_p->sess_attrs_p; attr_p != NULL;
     527           0 :                  attr_p = attr_p->next_p) {
     528           0 :                 if (attr_p->type == attr_type) {
     529           0 :                     attr_count++;
     530           0 :                     if (attr_count == inst_num) {
     531           0 :                         return (attr_p);
     532             :                     }
     533             :                 }
     534             :             }
     535             :         } else {  /* Attr is at a media level */
     536           0 :             mca_p = sdp_find_media_level(sdp_p, level);
     537           0 :             if (mca_p == NULL) {
     538           0 :                 return (NULL);
     539             :             }
     540           0 :             for (attr_p = mca_p->media_attrs_p; attr_p != NULL;
     541           0 :                  attr_p = attr_p->next_p) {
     542           0 :                 if (attr_p->type == attr_type) {
     543           0 :                     attr_count++;
     544           0 :                     if (attr_count == inst_num) {
     545           0 :                         return (attr_p);
     546             :                     }
     547             :                 }
     548             :             }
     549             :         }  /* Attr is at a media level */
     550             :     } else {
     551             :         /* Attr is a capability X-cpar/cpar attribute. */
     552           0 :         attr_p = sdp_find_capability(sdp_p, level, cap_num);
     553           0 :         if (attr_p == NULL) {
     554           0 :             return (NULL);
     555             :         }
     556           0 :         cap_p = attr_p->attr.cap_p;
     557             :         /* Now find the specific attribute. */
     558           0 :         for (attr_p = cap_p->media_attrs_p; attr_p != NULL;
     559           0 :              attr_p = attr_p->next_p) {
     560           0 :             if (attr_p->type == attr_type) {
     561           0 :                 attr_count++;
     562           0 :                 if (attr_count == inst_num) {
     563           0 :                     return (attr_p);
     564             :                 }
     565             :             }
     566             :         }
     567             :     }
     568             : 
     569           0 :     return (NULL);
     570             : }
     571             : 
     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.
     580             :  */
     581           0 : sdp_attr_t *sdp_find_capability (sdp_t *sdp_p, uint16_t level, uint8_t cap_num)
     582             : {
     583           0 :     uint8_t           cur_cap_num=0;
     584             :     sdp_mca_t   *mca_p;
     585             :     sdp_mca_t   *cap_p;
     586             :     sdp_attr_t  *attr_p;
     587             : 
     588           0 :     if (level == SDP_SESSION_LEVEL) {
     589           0 :         for (attr_p = sdp_p->sess_attrs_p; attr_p != NULL;
     590           0 :              attr_p = attr_p->next_p) {
     591           0 :             if ((attr_p->type == SDP_ATTR_X_CAP) ||
     592           0 :                 (attr_p->type == SDP_ATTR_CDSC)) {
     593           0 :                 cap_p = attr_p->attr.cap_p;
     594           0 :                 cur_cap_num += cap_p->num_payloads;
     595           0 :                 if (cap_num <= cur_cap_num) {
     596             :                     /* This is the right capability */
     597           0 :                     return (attr_p);
     598             :                 }
     599             :             }
     600             :         }
     601             :     } else {  /* Capability is at a media level */
     602           0 :         mca_p = sdp_find_media_level(sdp_p, level);
     603           0 :         if (mca_p == NULL) {
     604           0 :             return (NULL);
     605             :         }
     606           0 :         for (attr_p = mca_p->media_attrs_p; attr_p != NULL;
     607           0 :              attr_p = attr_p->next_p) {
     608           0 :             if ((attr_p->type == SDP_ATTR_X_CAP) ||
     609           0 :                 (attr_p->type == SDP_ATTR_CDSC)) {
     610           0 :                 cap_p = attr_p->attr.cap_p;
     611           0 :                 cur_cap_num += cap_p->num_payloads;
     612           0 :                 if (cap_num <= cur_cap_num) {
     613             :                     /* This is the right capability */
     614           0 :                     return (attr_p);
     615             :                 }
     616             :             }
     617             :         }
     618             :     }
     619             : 
     620             :     /* We didn't find the specified capability. */
     621           0 :     if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
     622           0 :         CSFLogError(logTag, "%s Unable to find specified capability (level %u, "
     623             :                   "cap_num %u).", sdp_p->debug_str, (unsigned)level, (unsigned)cap_num);
     624             :     }
     625           0 :     sdp_p->conf_p->num_invalid_param++;
     626           0 :     return (NULL);
     627             : }
     628             : 
     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.
     640             :  */
     641           0 : 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)
     643             : {
     644           0 :     if (sdp_find_attr(sdp_p, level, cap_num, attr_type, inst_num) == NULL) {
     645           0 :         return (FALSE);
     646             :     } else {
     647           0 :         return (TRUE);
     648             :     }
     649             : }
     650             : 
     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
     662             :  */
     663           0 : 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)
     665             : {
     666             :     sdp_attr_t  *attr_p;
     667             : 
     668           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, attr_type, inst_num);
     669           0 :     if (attr_p == NULL) {
     670           0 :         return 0;
     671             :     } else {
     672           0 :         return attr_p->line_number;
     673             :     }
     674             : }
     675             : 
     676           0 : static boolean sdp_attr_is_simple_string(sdp_attr_e attr_type) {
     677           0 :     if ((attr_type != SDP_ATTR_BEARER) &&
     678           0 :         (attr_type != SDP_ATTR_CALLED) &&
     679           0 :         (attr_type != SDP_ATTR_CONN_TYPE) &&
     680           0 :         (attr_type != SDP_ATTR_DIALED) &&
     681           0 :         (attr_type != SDP_ATTR_DIALING) &&
     682           0 :         (attr_type != SDP_ATTR_FRAMING) &&
     683           0 :         (attr_type != SDP_ATTR_MID) &&
     684           0 :         (attr_type != SDP_ATTR_X_SIDIN) &&
     685           0 :         (attr_type != SDP_ATTR_X_SIDOUT)&&
     686           0 :         (attr_type != SDP_ATTR_X_CONFID) &&
     687           0 :         (attr_type != SDP_ATTR_LABEL) &&
     688           0 :         (attr_type != SDP_ATTR_ICE_OPTIONS) &&
     689           0 :         (attr_type != SDP_ATTR_IMAGEATTR) &&
     690           0 :         (attr_type != SDP_ATTR_SIMULCAST) &&
     691             :         (attr_type != SDP_ATTR_RID)) {
     692           0 :       return FALSE;
     693             :     }
     694           0 :     return TRUE;
     695             : }
     696             : 
     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.
     713             :  */
     714           0 : 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)
     716             : {
     717             :     sdp_attr_t  *attr_p;
     718             : 
     719           0 :     if (!sdp_attr_is_simple_string(attr_type)) {
     720           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
     721           0 :             CSFLogError(logTag, "%s Attribute type is not a simple string (%s)",
     722             :                       sdp_p->debug_str, sdp_get_attr_name(attr_type));
     723             :         }
     724           0 :         sdp_p->conf_p->num_invalid_param++;
     725           0 :         return (NULL);
     726             :     }
     727             : 
     728           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, attr_type, inst_num);
     729           0 :     if (attr_p == NULL) {
     730           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
     731           0 :             CSFLogError(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);
     734             :         }
     735           0 :         sdp_p->conf_p->num_invalid_param++;
     736           0 :         return (NULL);
     737             :     } else {
     738           0 :         return (attr_p->attr.string_val);
     739             :     }
     740             : }
     741             : 
     742           0 : static boolean sdp_attr_is_long_string(sdp_attr_e attr_type) {
     743           0 :   return (attr_type == SDP_ATTR_IDENTITY || attr_type == SDP_ATTR_DTLS_MESSAGE);
     744             : }
     745             : 
     746             : /* Identical in usage to sdp_attr_get_simple_string() */
     747           0 : 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)
     749             : {
     750             :     sdp_attr_t  *attr_p;
     751             : 
     752           0 :     if (!sdp_attr_is_long_string(attr_type)) {
     753           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
     754           0 :             CSFLogError(logTag, "%s Attribute type is not a long string (%s)",
     755             :                       sdp_p->debug_str, sdp_get_attr_name(attr_type));
     756             :         }
     757           0 :         sdp_p->conf_p->num_invalid_param++;
     758           0 :         return (NULL);
     759             :     }
     760             : 
     761           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, attr_type, inst_num);
     762           0 :     if (attr_p == NULL) {
     763           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
     764           0 :             CSFLogError(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);
     767             :         }
     768           0 :         sdp_p->conf_p->num_invalid_param++;
     769           0 :         return (NULL);
     770             :     } else {
     771           0 :         return (attr_p->attr.stringp);
     772             :     }
     773             : }
     774             : 
     775           0 : static boolean sdp_attr_is_simple_u32(sdp_attr_e attr_type) {
     776           0 :     if ((attr_type != SDP_ATTR_EECID) &&
     777           0 :         (attr_type != SDP_ATTR_PTIME) &&
     778           0 :         (attr_type != SDP_ATTR_MAXPTIME) &&
     779           0 :         (attr_type != SDP_ATTR_SCTPPORT) &&
     780           0 :         (attr_type != SDP_ATTR_MAXMESSAGESIZE) &&
     781           0 :         (attr_type != SDP_ATTR_T38_VERSION) &&
     782           0 :         (attr_type != SDP_ATTR_T38_MAXBITRATE) &&
     783           0 :         (attr_type != SDP_ATTR_T38_MAXBUFFER) &&
     784           0 :         (attr_type != SDP_ATTR_T38_MAXDGRAM) &&
     785           0 :         (attr_type != SDP_ATTR_X_SQN) &&
     786           0 :         (attr_type != SDP_ATTR_TC1_PAYLOAD_BYTES) &&
     787           0 :         (attr_type != SDP_ATTR_TC1_WINDOW_SIZE) &&
     788           0 :         (attr_type != SDP_ATTR_TC2_PAYLOAD_BYTES) &&
     789           0 :         (attr_type != SDP_ATTR_TC2_WINDOW_SIZE) &&
     790             :         (attr_type != SDP_ATTR_FRAMERATE)) {
     791           0 :         return FALSE;
     792             :     }
     793             : 
     794           0 :     return TRUE;
     795             : }
     796             : 
     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.
     816             :  */
     817           0 : 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)
     819             : {
     820             :     sdp_attr_t  *attr_p;
     821             : 
     822           0 :     if (!sdp_attr_is_simple_u32(attr_type)) {
     823           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
     824           0 :             CSFLogError(logTag, "%s Attribute type is not a simple uint32_t (%s)",
     825             :                       sdp_p->debug_str, sdp_get_attr_name(attr_type));
     826             :         }
     827           0 :         sdp_p->conf_p->num_invalid_param++;
     828           0 :         return (0);
     829             :     }
     830             : 
     831           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, attr_type, inst_num);
     832           0 :     if (attr_p == NULL) {
     833           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
     834           0 :             CSFLogError(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);
     837             :         }
     838           0 :         sdp_p->conf_p->num_invalid_param++;
     839           0 :         return (0);
     840             :     } else {
     841           0 :         return (attr_p->attr.u32_val);
     842             :     }
     843             : }
     844             : 
     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.
     863             :  */
     864           0 : 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)
     866             : {
     867             :     sdp_attr_t  *attr_p;
     868             : 
     869           0 :     if ((attr_type != SDP_ATTR_T38_FILLBITREMOVAL) &&
     870           0 :         (attr_type != SDP_ATTR_T38_TRANSCODINGMMR) &&
     871           0 :         (attr_type != SDP_ATTR_T38_TRANSCODINGJBIG) &&
     872             :         (attr_type != SDP_ATTR_TMRGWXID)) {
     873           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
     874           0 :             CSFLogError(logTag, "%s Attribute type is not a simple boolean (%s)",
     875             :                       sdp_p->debug_str, sdp_get_attr_name(attr_type));
     876             :         }
     877           0 :         sdp_p->conf_p->num_invalid_param++;
     878           0 :         return (FALSE);
     879             :     }
     880             : 
     881           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, attr_type, inst_num);
     882           0 :     if (attr_p == NULL) {
     883           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
     884           0 :             CSFLogError(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);
     887             :         }
     888           0 :         sdp_p->conf_p->num_invalid_param++;
     889           0 :         return (FALSE);
     890             :     } else {
     891           0 :         return (attr_p->attr.boolean_val);
     892             :     }
     893             : }
     894             : 
     895             : /*
     896             :  * sdp_attr_get_maxprate
     897             :  *
     898             :  * This function is used by the application layer to get the packet-rate
     899             :  * within the maxprate attribute.
     900             :  *
     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.
     904             :  *
     905             :  * Returns a pointer to a constant char array that stores the packet-rate,
     906             :  * OR null if the attribute does not exist.
     907             :  */
     908             : const char*
     909           0 : sdp_attr_get_maxprate (sdp_t *sdp_p, uint16_t level, uint16_t inst_num)
     910             : {
     911             :     sdp_attr_t  *attr_p;
     912             : 
     913           0 :     attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_MAXPRATE, inst_num);
     914           0 :     if (attr_p == NULL) {
     915           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
     916           0 :             CSFLogError(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);
     919             :         }
     920           0 :         sdp_p->conf_p->num_invalid_param++;
     921           0 :         return (NULL);
     922             :     } else {
     923           0 :         return (attr_p->attr.string_val);
     924             :     }
     925             : }
     926             : 
     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.
     937             :  */
     938           0 : sdp_t38_ratemgmt_e sdp_attr_get_t38ratemgmt (sdp_t *sdp_p, uint16_t level,
     939             :                                              uint8_t cap_num, uint16_t inst_num)
     940             : {
     941             :     sdp_attr_t  *attr_p;
     942             : 
     943           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
     944             :                            SDP_ATTR_T38_RATEMGMT, inst_num);
     945           0 :     if (attr_p == NULL) {
     946           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
     947           0 :             CSFLogError(logTag, "%s t38ratemgmt attribute, level %u instance %u "
     948             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
     949             :         }
     950           0 :         sdp_p->conf_p->num_invalid_param++;
     951           0 :         return (SDP_T38_UNKNOWN_RATE);
     952             :     } else {
     953           0 :         return (attr_p->attr.t38ratemgmt);
     954             :     }
     955             : }
     956             : 
     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.
     967             :  */
     968           0 : sdp_t38_udpec_e sdp_attr_get_t38udpec (sdp_t *sdp_p, uint16_t level,
     969             :                                        uint8_t cap_num, uint16_t inst_num)
     970             : {
     971             :     sdp_attr_t  *attr_p;
     972             : 
     973           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
     974             :                            SDP_ATTR_T38_UDPEC, inst_num);
     975           0 :     if (attr_p == NULL) {
     976           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
     977           0 :             CSFLogError(logTag, "%s t38udpec attribute, level %u instance %u "
     978             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
     979             :         }
     980           0 :         sdp_p->conf_p->num_invalid_param++;
     981           0 :         return (SDP_T38_UDPEC_UNKNOWN);
     982             :     } else {
     983           0 :         return (attr_p->attr.t38udpec);
     984             :     }
     985             : }
     986             : 
     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.
     998             :  */
     999           0 : sdp_direction_e sdp_get_media_direction (sdp_t *sdp_p, uint16_t level,
    1000             :                                          uint8_t cap_num)
    1001             : {
    1002             :     sdp_mca_t   *mca_p;
    1003             :     sdp_attr_t  *attr_p;
    1004           0 :     sdp_direction_e direction = SDP_DIRECTION_SENDRECV;
    1005             : 
    1006           0 :     if (cap_num == 0) {
    1007             :         /* Find the pointer to the attr list for this level. */
    1008           0 :         if (level == SDP_SESSION_LEVEL) {
    1009           0 :             attr_p = sdp_p->sess_attrs_p;
    1010             :         } else {  /* Attr is at a media level */
    1011           0 :             mca_p = sdp_find_media_level(sdp_p, level);
    1012           0 :             if (mca_p == NULL) {
    1013           0 :                 return (direction);
    1014             :             }
    1015           0 :             attr_p = mca_p->media_attrs_p;
    1016             :         }
    1017             : 
    1018             :         /* Scan for direction oriented attributes.  Last one wins. */
    1019           0 :         for (; attr_p != NULL; attr_p = attr_p->next_p) {
    1020           0 :             if (attr_p->type == SDP_ATTR_INACTIVE) {
    1021           0 :                 direction = SDP_DIRECTION_INACTIVE;
    1022           0 :             } else if (attr_p->type == SDP_ATTR_SENDONLY) {
    1023           0 :                 direction = SDP_DIRECTION_SENDONLY;
    1024           0 :             } else if (attr_p->type == SDP_ATTR_RECVONLY) {
    1025           0 :                 direction = SDP_DIRECTION_RECVONLY;
    1026           0 :             } else if (attr_p->type == SDP_ATTR_SENDRECV) {
    1027           0 :                 direction = SDP_DIRECTION_SENDRECV;
    1028             :             }
    1029             :         }
    1030             :     } else {
    1031           0 :         if (sdp_p->debug_flag[SDP_DEBUG_WARNINGS]) {
    1032           0 :             CSFLogDebug(logTag, "%s Warning: Invalid cap_num for media direction.",
    1033             :                      sdp_p->debug_str);
    1034             :         }
    1035             :     }
    1036             : 
    1037           0 :     return (direction);
    1038             : }
    1039             : 
    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.
    1045             :  */
    1046           0 : tinybool sdp_validate_qos_attr (sdp_attr_e qos_attr)
    1047             : {
    1048           0 :     if ((qos_attr == SDP_ATTR_QOS) ||
    1049           0 :         (qos_attr == SDP_ATTR_SECURE) ||
    1050           0 :         (qos_attr == SDP_ATTR_X_PC_QOS) ||
    1051           0 :         (qos_attr == SDP_ATTR_X_QOS) ||
    1052           0 :         (qos_attr == SDP_ATTR_CURR) ||
    1053           0 :         (qos_attr == SDP_ATTR_DES) ||
    1054             :         (qos_attr == SDP_ATTR_CONF)){
    1055           0 :         return (TRUE);
    1056             :     } else {
    1057           0 :         return (FALSE);
    1058             :     }
    1059             : }
    1060             : 
    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.
    1074             :  */
    1075           0 : 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)
    1077             : {
    1078             :     sdp_attr_t  *attr_p;
    1079             : 
    1080           0 :     if (sdp_validate_qos_attr(qos_attr) == FALSE) {
    1081           0 :         if (sdp_p->debug_flag[SDP_DEBUG_WARNINGS]) {
    1082           0 :             CSFLogDebug(logTag, "%s Warning: Invalid QOS attribute specified for"
    1083             :                      "get qos strength.", sdp_p->debug_str);
    1084             :         }
    1085           0 :         return (SDP_QOS_STRENGTH_UNKNOWN);
    1086             :     }
    1087           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, qos_attr, inst_num);
    1088           0 :     if (attr_p == NULL) {
    1089           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1090           0 :             CSFLogError(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);
    1093             :         }
    1094           0 :         sdp_p->conf_p->num_invalid_param++;
    1095           0 :         return (SDP_QOS_STRENGTH_UNKNOWN);
    1096             :     } else {
    1097           0 :         switch (qos_attr) {
    1098             :             case SDP_ATTR_QOS:
    1099           0 :                 return (attr_p->attr.qos.strength);
    1100             :             case SDP_ATTR_DES:
    1101           0 :                 return (attr_p->attr.des.strength);
    1102             :             default:
    1103           0 :                 return SDP_QOS_STRENGTH_UNKNOWN;
    1104             : 
    1105             :         }
    1106             :     }
    1107             : }
    1108             : 
    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.
    1122             :  */
    1123           0 : 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)
    1125             : {
    1126             :     sdp_attr_t  *attr_p;
    1127             : 
    1128           0 :     if (sdp_validate_qos_attr(qos_attr) == FALSE) {
    1129           0 :         if (sdp_p->debug_flag[SDP_DEBUG_WARNINGS]) {
    1130           0 :             CSFLogDebug(logTag, "%s Warning: Invalid QOS attribute specified "
    1131             :                      "for get qos direction.", sdp_p->debug_str);
    1132             :         }
    1133           0 :         return (SDP_QOS_DIR_UNKNOWN);
    1134             :     }
    1135           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, qos_attr, inst_num);
    1136           0 :     if (attr_p == NULL) {
    1137           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1138           0 :             CSFLogError(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);
    1141             :         }
    1142           0 :         sdp_p->conf_p->num_invalid_param++;
    1143           0 :         return (SDP_QOS_DIR_UNKNOWN);
    1144             :     } else {
    1145           0 :          switch (qos_attr) {
    1146             :             case SDP_ATTR_QOS:
    1147           0 :                  return (attr_p->attr.qos.direction);
    1148             :             case SDP_ATTR_CURR:
    1149           0 :                  return (attr_p->attr.curr.direction);
    1150             :             case SDP_ATTR_DES:
    1151           0 :                  return (attr_p->attr.des.direction);
    1152             :             case SDP_ATTR_CONF:
    1153           0 :                  return (attr_p->attr.conf.direction);
    1154             :             default:
    1155           0 :                 return SDP_QOS_DIR_UNKNOWN;
    1156             : 
    1157             :         }
    1158             :     }
    1159             : }
    1160             : 
    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.
    1174             :  */
    1175           0 : 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)
    1177             : {
    1178             :     sdp_attr_t  *attr_p;
    1179             : 
    1180           0 :     if (sdp_validate_qos_attr(qos_attr) == FALSE) {
    1181           0 :         if (sdp_p->debug_flag[SDP_DEBUG_WARNINGS]) {
    1182           0 :             CSFLogDebug(logTag, "%s Warning: Invalid QOS attribute specified "
    1183             :                      "for get qos status_type.", sdp_p->debug_str);
    1184             :         }
    1185           0 :         return (SDP_QOS_STATUS_TYPE_UNKNOWN);
    1186             :     }
    1187           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, qos_attr, inst_num);
    1188           0 :     if (attr_p == NULL) {
    1189           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1190           0 :             CSFLogError(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);
    1193             :         }
    1194           0 :         sdp_p->conf_p->num_invalid_param++;
    1195           0 :         return (SDP_QOS_STATUS_TYPE_UNKNOWN);
    1196             :     } else {
    1197           0 :         switch (qos_attr) {
    1198             :             case SDP_ATTR_CURR:
    1199           0 :                 return (attr_p->attr.curr.status_type);
    1200             :             case SDP_ATTR_DES:
    1201           0 :                 return (attr_p->attr.des.status_type);
    1202             :             case SDP_ATTR_CONF:
    1203           0 :                 return (attr_p->attr.conf.status_type);
    1204             :             default:
    1205           0 :                 return SDP_QOS_STATUS_TYPE_UNKNOWN;
    1206             : 
    1207             :         }
    1208             :     }
    1209             : }
    1210             : 
    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.
    1223             :  */
    1224           0 : 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)
    1226             : {
    1227             :     sdp_attr_t  *attr_p;
    1228             : 
    1229           0 :     if (sdp_validate_qos_attr(qos_attr) == FALSE) {
    1230           0 :         if (sdp_p->debug_flag[SDP_DEBUG_WARNINGS]) {
    1231           0 :             CSFLogDebug(logTag, "%s Warning: Invalid QOS attribute specified "
    1232             :                      "for get qos confirm.", sdp_p->debug_str);
    1233             :         }
    1234           0 :         return (FALSE);
    1235             :     }
    1236           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, qos_attr, inst_num);
    1237           0 :     if (attr_p == NULL) {
    1238           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1239           0 :             CSFLogError(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);
    1242             :         }
    1243           0 :         sdp_p->conf_p->num_invalid_param++;
    1244           0 :         return (FALSE);
    1245             :     } else {
    1246           0 :         return (attr_p->attr.qos.confirm);
    1247             :     }
    1248             : }
    1249             : 
    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.
    1263             :  */
    1264           0 : 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)
    1266             : {
    1267             :     sdp_attr_t  *attr_p;
    1268             : 
    1269           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, qos_attr, inst_num);
    1270           0 :     if (attr_p == NULL) {
    1271           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1272           0 :             CSFLogError(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);
    1275             :         }
    1276           0 :         sdp_p->conf_p->num_invalid_param++;
    1277           0 :         return (SDP_CURR_UNKNOWN_TYPE);
    1278             :     } else {
    1279           0 :         return (attr_p->attr.curr.type);
    1280             :     }
    1281             : }
    1282             : 
    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.
    1296             :  */
    1297           0 : 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)
    1299             : {
    1300             :     sdp_attr_t  *attr_p;
    1301             : 
    1302           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, qos_attr, inst_num);
    1303           0 :     if (attr_p == NULL) {
    1304           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1305           0 :             CSFLogError(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);
    1308             :         }
    1309           0 :         sdp_p->conf_p->num_invalid_param++;
    1310           0 :         return (SDP_DES_UNKNOWN_TYPE);
    1311             :     } else {
    1312           0 :         return (attr_p->attr.des.type);
    1313             :     }
    1314             : }
    1315             : 
    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.
    1329             :  */
    1330           0 : 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)
    1332             : {
    1333             :     sdp_attr_t  *attr_p;
    1334             : 
    1335           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, qos_attr, inst_num);
    1336           0 :     if (attr_p == NULL) {
    1337           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1338           0 :             CSFLogError(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);
    1341             :         }
    1342           0 :         sdp_p->conf_p->num_invalid_param++;
    1343           0 :         return (SDP_CONF_UNKNOWN_TYPE);
    1344             :     } else {
    1345           0 :         return (attr_p->attr.conf.type);
    1346             :     }
    1347             : }
    1348             : 
    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.
    1359             :  */
    1360           0 : sdp_nettype_e sdp_attr_get_subnet_nettype (sdp_t *sdp_p, uint16_t level,
    1361             :                                            uint8_t cap_num, uint16_t inst_num)
    1362             : {
    1363             :     sdp_attr_t  *attr_p;
    1364             : 
    1365           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    1366             :                            SDP_ATTR_SUBNET, inst_num);
    1367           0 :     if (attr_p == NULL) {
    1368           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1369           0 :             CSFLogError(logTag, "%s Subnet attribute, level %u instance %u "
    1370             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    1371             :         }
    1372           0 :         sdp_p->conf_p->num_invalid_param++;
    1373           0 :         return (SDP_NT_INVALID);
    1374             :     } else {
    1375           0 :         return (attr_p->attr.subnet.nettype);
    1376             :     }
    1377             : }
    1378             : 
    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.
    1389             :  */
    1390           0 : sdp_addrtype_e sdp_attr_get_subnet_addrtype (sdp_t *sdp_p, uint16_t level,
    1391             :                                              uint8_t cap_num, uint16_t inst_num)
    1392             : {
    1393             :     sdp_attr_t  *attr_p;
    1394             : 
    1395           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    1396             :                            SDP_ATTR_SUBNET, inst_num);
    1397           0 :     if (attr_p == NULL) {
    1398           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1399           0 :             CSFLogError(logTag, "%s Subnet attribute, level %u instance %u "
    1400             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    1401             :         }
    1402           0 :         sdp_p->conf_p->num_invalid_param++;
    1403           0 :         return (SDP_AT_INVALID);
    1404             :     } else {
    1405           0 :         return (attr_p->attr.subnet.addrtype);
    1406             :     }
    1407             : }
    1408             : 
    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.
    1421             :  */
    1422           0 : const char *sdp_attr_get_subnet_addr (sdp_t *sdp_p, uint16_t level,
    1423             :                                       uint8_t cap_num, uint16_t inst_num)
    1424             : {
    1425             :     sdp_attr_t  *attr_p;
    1426             : 
    1427           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    1428             :                            SDP_ATTR_SUBNET, inst_num);
    1429           0 :     if (attr_p == NULL) {
    1430           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1431           0 :             CSFLogError(logTag, "%s Subnet attribute, level %u instance %u "
    1432             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    1433             :         }
    1434           0 :         sdp_p->conf_p->num_invalid_param++;
    1435           0 :         return (NULL);
    1436             :     } else {
    1437           0 :         return (attr_p->attr.subnet.addr);
    1438             :     }
    1439             : }
    1440             : 
    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.
    1453             :  */
    1454           0 : int32_t sdp_attr_get_subnet_prefix (sdp_t *sdp_p, uint16_t level,
    1455             :                                   uint8_t cap_num, uint16_t inst_num)
    1456             : {
    1457             :     sdp_attr_t  *attr_p;
    1458             : 
    1459           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    1460             :                            SDP_ATTR_SUBNET, inst_num);
    1461           0 :     if (attr_p == NULL) {
    1462           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1463           0 :             CSFLogError(logTag, "%s Subnet attribute, level %u instance %u "
    1464             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    1465             :         }
    1466           0 :         sdp_p->conf_p->num_invalid_param++;
    1467           0 :         return (SDP_INVALID_VALUE);
    1468             :     } else {
    1469           0 :         return (attr_p->attr.subnet.prefix);
    1470             :     }
    1471             : }
    1472             : 
    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.
    1485             :  */
    1486           0 : 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)
    1488             : {
    1489             :     uint16_t          i;
    1490             :     sdp_attr_t  *attr_p;
    1491             :     uint16_t          num_instances;
    1492             : 
    1493           0 :     *inst_num = 0;
    1494             : 
    1495           0 :     if (sdp_attr_num_instances(sdp_p, level, cap_num,
    1496             :                           SDP_ATTR_RTPMAP, &num_instances) != SDP_SUCCESS) {
    1497           0 :         return (FALSE);
    1498             :     }
    1499             : 
    1500           0 :     for (i=1; i <= num_instances; i++) {
    1501           0 :         attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_RTPMAP, i);
    1502           0 :         if ((attr_p != NULL) &&
    1503           0 :             (attr_p->attr.transport_map.payload_num == payload_type)) {
    1504           0 :             *inst_num = i;
    1505           0 :             return (TRUE);
    1506             :         }
    1507             :     }
    1508             : 
    1509           0 :     return (FALSE);
    1510             : }
    1511             : 
    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.
    1522             :  */
    1523           0 : uint16_t sdp_attr_get_rtpmap_payload_type (sdp_t *sdp_p, uint16_t level,
    1524             :                                       uint8_t cap_num, uint16_t inst_num)
    1525             : {
    1526             :     sdp_attr_t  *attr_p;
    1527             : 
    1528           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_RTPMAP, inst_num);
    1529           0 :     if (attr_p == NULL) {
    1530           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1531           0 :             CSFLogError(logTag, "%s rtpmap attribute, level %u instance %u "
    1532             :                                 "not found.",
    1533             :                                 sdp_p->debug_str,
    1534             :                                 (unsigned)level,
    1535             :                                 (unsigned)inst_num);
    1536             :         }
    1537           0 :         sdp_p->conf_p->num_invalid_param++;
    1538           0 :         return (0);
    1539             :     } else {
    1540           0 :         return (attr_p->attr.transport_map.payload_num);
    1541             :     }
    1542             : }
    1543             : 
    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.
    1556             :  */
    1557           0 : const char *sdp_attr_get_rtpmap_encname (sdp_t *sdp_p, uint16_t level,
    1558             :                                          uint8_t cap_num, uint16_t inst_num)
    1559             : {
    1560             :     sdp_attr_t  *attr_p;
    1561             : 
    1562           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_RTPMAP, inst_num);
    1563           0 :     if (attr_p == NULL) {
    1564           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1565           0 :             CSFLogError(logTag, "%s rtpmap attribute, level %u instance %u "
    1566             :                                 "not found.",
    1567             :                                 sdp_p->debug_str,
    1568             :                                 (unsigned)level,
    1569             :                                 (unsigned)inst_num);
    1570             :         }
    1571           0 :         sdp_p->conf_p->num_invalid_param++;
    1572           0 :         return (NULL);
    1573             :     } else {
    1574           0 :         return (attr_p->attr.transport_map.encname);
    1575             :     }
    1576             : }
    1577             : 
    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.
    1588             :  */
    1589           0 : uint32_t sdp_attr_get_rtpmap_clockrate (sdp_t *sdp_p, uint16_t level,
    1590             :                                    uint8_t cap_num, uint16_t inst_num)
    1591             : {
    1592             :     sdp_attr_t  *attr_p;
    1593             : 
    1594           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_RTPMAP, inst_num);
    1595           0 :     if (attr_p == NULL) {
    1596           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1597           0 :             CSFLogError(logTag, "%s rtpmap attribute, level %u instance %u "
    1598             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    1599             :         }
    1600           0 :         sdp_p->conf_p->num_invalid_param++;
    1601           0 :         return (0);
    1602             :     } else {
    1603           0 :         return (attr_p->attr.transport_map.clockrate);
    1604             :     }
    1605             : }
    1606             : 
    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.
    1617             :  */
    1618           0 : uint16_t sdp_attr_get_rtpmap_num_chan (sdp_t *sdp_p, uint16_t level,
    1619             :                                   uint8_t cap_num, uint16_t inst_num)
    1620             : {
    1621             :     sdp_attr_t  *attr_p;
    1622             : 
    1623           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_RTPMAP, inst_num);
    1624           0 :     if (attr_p == NULL) {
    1625           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1626           0 :             CSFLogError(logTag, "%s rtpmap attribute, level %u instance %u "
    1627             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    1628             :         }
    1629           0 :         sdp_p->conf_p->num_invalid_param++;
    1630           0 :         return (0);
    1631             :     } else {
    1632           0 :         return (attr_p->attr.transport_map.num_chan);
    1633             :     }
    1634             : }
    1635             : 
    1636             : /* Function:    sdp_attr_get_ice_attribute
    1637             :  * Description: Returns the value of an ice attribute at a given level
    1638             :  *
    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.
    1649             :  */
    1650             : 
    1651           0 : 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)
    1654             : {
    1655             :     sdp_attr_t  *attr_p;
    1656             : 
    1657           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, sdp_attr, inst_num);
    1658           0 :     if (attr_p != NULL) {
    1659           0 :         *out = attr_p->attr.ice_attr;
    1660           0 :         return (SDP_SUCCESS);
    1661             :     } else {
    1662           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1663           0 :                 CSFLogError(logTag, "%s ice attribute, level %u instance %u "
    1664             :                           "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    1665             :         }
    1666           0 :         sdp_p->conf_p->num_invalid_param++;
    1667           0 :         return (SDP_INVALID_PARAMETER);
    1668             :     }
    1669             : }
    1670             : 
    1671             : /* Function:    sdp_attr_is_present
    1672             :  * Description: Returns a boolean value based on attribute being present or
    1673             :  *              not
    1674             :  *
    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.
    1682             :  */
    1683             : 
    1684           0 : tinybool sdp_attr_is_present (sdp_t *sdp_p, sdp_attr_e attr_type, uint16_t level,
    1685             :                               uint8_t cap_num)
    1686             : {
    1687             :     sdp_attr_t  *attr_p;
    1688             : 
    1689           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, attr_type, 1);
    1690           0 :     if (attr_p != NULL) {
    1691           0 :         return (TRUE);
    1692             :     }
    1693           0 :     if (sdp_p->debug_flag[SDP_DEBUG_WARNINGS]) {
    1694           0 :         CSFLogDebug(logTag, "%s Attribute %s, level %u not found.",
    1695             :                     sdp_p->debug_str, sdp_get_attr_name(attr_type), level);
    1696             :     }
    1697             : 
    1698           0 :     return (FALSE);
    1699             : }
    1700             : 
    1701             : 
    1702             : 
    1703             : /* Function:    sdp_attr_get_rtcp_mux_attribute
    1704             :  * Description: Returns the value of an rtcp-mux attribute at a given level
    1705             :  *
    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.
    1716             :  */
    1717           0 : 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)
    1720             : {
    1721             :     sdp_attr_t  *attr_p;
    1722             : 
    1723           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, sdp_attr, inst_num);
    1724           0 :     if (attr_p != NULL) {
    1725           0 :         *rtcp_mux = attr_p->attr.boolean_val;
    1726           0 :         return (SDP_SUCCESS);
    1727             :     } else {
    1728           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1729           0 :                 CSFLogError(logTag, "%s rtcp-mux attribute, level %u instance %u "
    1730             :                           "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    1731             :         }
    1732           0 :         sdp_p->conf_p->num_invalid_param++;
    1733           0 :         return (SDP_INVALID_PARAMETER);
    1734             :     }
    1735             : }
    1736             : 
    1737             : /* Function:    sdp_attr_get_setup_attribute
    1738             :  * Description: Returns the value of a setup attribute at a given level
    1739             :  *
    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.
    1750             :  */
    1751           0 : 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)
    1753             : {
    1754             :     sdp_attr_t  *attr_p;
    1755             : 
    1756           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_SETUP, inst_num);
    1757           0 :     if (!attr_p) {
    1758           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1759           0 :             CSFLogError(logTag,
    1760             :                 "%s setup attribute, level %u instance %u not found.",
    1761             :                 sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    1762             :         }
    1763           0 :         sdp_p->conf_p->num_invalid_param++;
    1764           0 :         return SDP_INVALID_PARAMETER;
    1765             :     }
    1766             : 
    1767           0 :     *setup_type = attr_p->attr.setup;
    1768           0 :     return SDP_SUCCESS;
    1769             : }
    1770             : 
    1771             : /* Function:    sdp_attr_get_connection_attribute
    1772             :  * Description: Returns the value of a connection attribute at a given level
    1773             :  *
    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.
    1784             :  */
    1785           0 : 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)
    1787             : {
    1788             :     sdp_attr_t  *attr_p;
    1789             : 
    1790           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_CONNECTION,
    1791             :         inst_num);
    1792           0 :     if (!attr_p) {
    1793           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1794           0 :             CSFLogError(logTag,
    1795             :                 "%s setup attribute, level %u instance %u not found.",
    1796             :                 sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    1797             :         }
    1798           0 :         sdp_p->conf_p->num_invalid_param++;
    1799           0 :         return SDP_INVALID_PARAMETER;
    1800             :     }
    1801             : 
    1802           0 :     *connection_type = attr_p->attr.connection;
    1803           0 :     return SDP_SUCCESS;
    1804             : }
    1805             : 
    1806             : /* Function:    sdp_attr_get_dtls_fingerprint_attribute
    1807             :  * Description: Returns the value of dtls fingerprint attribute at a given level
    1808             :  *
    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.
    1819             :  */
    1820           0 : 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)
    1823             : {
    1824             :     sdp_attr_t  *attr_p;
    1825             : 
    1826           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, sdp_attr, inst_num);
    1827           0 :     if (attr_p != NULL) {
    1828           0 :         *out = attr_p->attr.string_val;
    1829           0 :         return (SDP_SUCCESS);
    1830             :     } else {
    1831           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1832           0 :                 CSFLogError(logTag, "%s dtls fingerprint attribute, level %u instance %u "
    1833             :                           "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    1834             :         }
    1835           0 :         sdp_p->conf_p->num_invalid_param++;
    1836           0 :         return (SDP_INVALID_PARAMETER);
    1837             :     }
    1838             : }
    1839             : 
    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.
    1852             :  */
    1853           0 : 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)
    1855             : {
    1856             :     uint16_t          i;
    1857             :     sdp_attr_t  *attr_p;
    1858             :     uint16_t          num_instances;
    1859             : 
    1860           0 :     *inst_num = 0;
    1861             : 
    1862           0 :     if (sdp_attr_num_instances(sdp_p, level, cap_num,
    1863             :                           SDP_ATTR_SPRTMAP, &num_instances) != SDP_SUCCESS) {
    1864           0 :         return (FALSE);
    1865             :     }
    1866             : 
    1867           0 :     for (i=1; i <= num_instances; i++) {
    1868           0 :         attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_SPRTMAP, i);
    1869           0 :         if ((attr_p != NULL) &&
    1870           0 :             (attr_p->attr.transport_map.payload_num == payload_type)) {
    1871           0 :             *inst_num = i;
    1872           0 :             return (TRUE);
    1873             :         }
    1874             :     }
    1875             : 
    1876           0 :     return (FALSE);
    1877             : }
    1878             : 
    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.
    1889             :  */
    1890           0 : uint16_t sdp_attr_get_sprtmap_payload_type (sdp_t *sdp_p, uint16_t level,
    1891             :                                       uint8_t cap_num, uint16_t inst_num)
    1892             : {
    1893             :     sdp_attr_t  *attr_p;
    1894             : 
    1895           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_SPRTMAP, inst_num);
    1896           0 :     if (attr_p == NULL) {
    1897           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1898           0 :             CSFLogError(logTag, "%s sprtmap attribute, level %u instance %u "
    1899             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    1900             :         }
    1901           0 :         sdp_p->conf_p->num_invalid_param++;
    1902           0 :         return (0);
    1903             :     } else {
    1904           0 :         return (attr_p->attr.transport_map.payload_num);
    1905             :     }
    1906             : }
    1907             : 
    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.
    1920             :  */
    1921           0 : const char *sdp_attr_get_sprtmap_encname (sdp_t *sdp_p, uint16_t level,
    1922             :                                          uint8_t cap_num, uint16_t inst_num)
    1923             : {
    1924             :     sdp_attr_t  *attr_p;
    1925             : 
    1926           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_SPRTMAP, inst_num);
    1927           0 :     if (attr_p == NULL) {
    1928           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1929           0 :             CSFLogError(logTag, "%s sprtmap attribute, level %u instance %u "
    1930             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    1931             :         }
    1932           0 :         sdp_p->conf_p->num_invalid_param++;
    1933           0 :         return (NULL);
    1934             :     } else {
    1935           0 :         return (attr_p->attr.transport_map.encname);
    1936             :     }
    1937             : }
    1938             : 
    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.
    1949             :  */
    1950           0 : uint32_t sdp_attr_get_sprtmap_clockrate (sdp_t *sdp_p, uint16_t level,
    1951             :                                    uint8_t cap_num, uint16_t inst_num)
    1952             : {
    1953             :     sdp_attr_t  *attr_p;
    1954             : 
    1955           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_SPRTMAP, inst_num);
    1956           0 :     if (attr_p == NULL) {
    1957           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1958           0 :             CSFLogError(logTag, "%s sprtmap attribute, level %u instance %u "
    1959             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    1960             :         }
    1961           0 :         sdp_p->conf_p->num_invalid_param++;
    1962           0 :         return (0);
    1963             :     } else {
    1964           0 :         return (attr_p->attr.transport_map.clockrate);
    1965             :     }
    1966             : }
    1967             : 
    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.
    1978             :  */
    1979           0 : uint16_t sdp_attr_get_sprtmap_num_chan (sdp_t *sdp_p, uint16_t level,
    1980             :                                   uint8_t cap_num, uint16_t inst_num)
    1981             : {
    1982             :     sdp_attr_t  *attr_p;
    1983             : 
    1984           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_SPRTMAP, inst_num);
    1985           0 :     if (attr_p == NULL) {
    1986           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    1987           0 :             CSFLogError(logTag, "%s sprtmap attribute, level %u instance %u "
    1988             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    1989             :         }
    1990           0 :         sdp_p->conf_p->num_invalid_param++;
    1991           0 :         return (0);
    1992             :     } else {
    1993           0 :         return (attr_p->attr.transport_map.num_chan);
    1994             :     }
    1995             : }
    1996             : 
    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
    2004             :  */
    2005             : 
    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.
    2017             :  */
    2018           0 : 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)
    2020             : {
    2021             :     uint16_t          i;
    2022             :     sdp_attr_t  *attr_p;
    2023             :     uint16_t          num_instances;
    2024             : 
    2025           0 :     if (sdp_attr_num_instances(sdp_p, level, cap_num,
    2026             :                                SDP_ATTR_FMTP, &num_instances) != SDP_SUCCESS) {
    2027           0 :         return (FALSE);
    2028             :     }
    2029             : 
    2030           0 :     for (i=1; i <= num_instances; i++) {
    2031           0 :         attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, i);
    2032           0 :         if ((attr_p != NULL) &&
    2033           0 :             (attr_p->attr.fmtp.payload_num == payload_type)) {
    2034           0 :             *inst_num = i;
    2035           0 :             return (TRUE);
    2036             :         }
    2037             :     }
    2038             : 
    2039           0 :     return (FALSE);
    2040             : }
    2041             : 
    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.
    2052             :  */
    2053           0 : uint16_t sdp_attr_get_fmtp_payload_type (sdp_t *sdp_p, uint16_t level,
    2054             :                                     uint8_t cap_num, uint16_t inst_num)
    2055             : {
    2056             :     sdp_attr_t  *attr_p;
    2057             : 
    2058           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, inst_num);
    2059           0 :     if (attr_p == NULL) {
    2060           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2061           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2062             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2063             :         }
    2064           0 :         sdp_p->conf_p->num_invalid_param++;
    2065           0 :         return (0);
    2066             :     } else {
    2067           0 :         return (attr_p->attr.fmtp.payload_num);
    2068             :     }
    2069             : }
    2070             : 
    2071             : 
    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
    2088             :  */
    2089           0 : 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)
    2091             : {
    2092             :     uint16_t          i;
    2093             :     uint32_t          mapword;
    2094             :     uint32_t          bmap;
    2095           0 :     uint32_t          num_vals = 0;
    2096           0 :     uint32_t          num_vals_set = 0;
    2097             :     sdp_attr_t  *attr_p;
    2098             :     sdp_fmtp_t  *fmtp_p;
    2099             : 
    2100           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, inst_num);
    2101           0 :     if (attr_p == NULL) {
    2102           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2103           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2104             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2105             :         }
    2106           0 :         sdp_p->conf_p->num_invalid_param++;
    2107           0 :         return (SDP_NO_MATCH);
    2108             :     }
    2109             : 
    2110           0 :     fmtp_p = &(attr_p->attr.fmtp);
    2111           0 :     for (i = low_val; i <= high_val; i++) {
    2112           0 :         num_vals++;
    2113           0 :         mapword = i/SDP_NE_BITS_PER_WORD;
    2114           0 :         bmap = SDP_NE_BIT_0 << (i%32);
    2115           0 :         if (fmtp_p->bmap[ mapword ] & bmap) {
    2116           0 :             num_vals_set++;
    2117             :         }
    2118             :     }
    2119             : 
    2120           0 :     if (num_vals == num_vals_set) {
    2121           0 :         return (SDP_FULL_MATCH);
    2122           0 :     } else if (num_vals_set == 0) {
    2123           0 :         return (SDP_NO_MATCH);
    2124             :     } else {
    2125           0 :         return (SDP_PARTIAL_MATCH);
    2126             :     }
    2127             : }
    2128             : 
    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.
    2134             :  *
    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
    2146             :  */
    2147             : tinybool
    2148           0 : 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)
    2150             : {
    2151             :     uint16_t          i;
    2152             :     uint32_t          mapword;
    2153             :     sdp_attr_t  *attr_p;
    2154             :     sdp_fmtp_t  *fmtp_p;
    2155             : 
    2156           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, inst_num);
    2157           0 :     if (attr_p == NULL) {
    2158           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2159           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2160             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2161             :         }
    2162           0 :         sdp_p->conf_p->num_invalid_param++;
    2163           0 :         return FALSE;
    2164             :     }
    2165             : 
    2166           0 :     fmtp_p = &(attr_p->attr.fmtp);
    2167             : 
    2168             :     /* Do quick test. If application max value is lower than fmtp's then error */
    2169           0 :     if (fmtp_p->maxval > appl_maxval)
    2170           0 :       return FALSE;
    2171             : 
    2172             :     /* Ok, events are within range. Now check that only
    2173             :      * allowed events have been received
    2174             :      */
    2175           0 :     mapword = appl_maxval/SDP_NE_BITS_PER_WORD;
    2176           0 :     for (i=0; i<mapword; i++) {
    2177           0 :       if (fmtp_p->bmap[i] & ~(evt_array[i])) {
    2178             :         /* Remote SDP is requesting events not supported by Application */
    2179           0 :         return FALSE;
    2180             :       }
    2181             :     }
    2182           0 :     return TRUE;
    2183             : }
    2184             : 
    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.
    2196             :  */
    2197           0 : 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)
    2200             : {
    2201             :     sdp_attr_t  *attr_p;
    2202             : 
    2203           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, inst_num);
    2204           0 :     if (attr_p == NULL) {
    2205           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2206           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2207             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2208             :         }
    2209           0 :         sdp_p->conf_p->num_invalid_param++;
    2210           0 :         return (SDP_INVALID_PARAMETER);
    2211             :     } else {
    2212           0 :         attr_p->attr.fmtp.payload_num = payload_num;
    2213           0 :         return (SDP_SUCCESS);
    2214             :     }
    2215             : }
    2216             : 
    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
    2226             :  */
    2227           0 : 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)
    2229             : {
    2230             :     sdp_attr_t  *attr_p;
    2231             :     sdp_fmtp_t  *fmtp_p;
    2232             : 
    2233           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, inst_num);
    2234           0 :     if (attr_p == NULL) {
    2235           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2236           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2237             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2238             :         }
    2239           0 :         sdp_p->conf_p->num_invalid_param++;
    2240           0 :         return (SDP_INVALID_PARAMETER);
    2241             :     }
    2242             : 
    2243           0 :     fmtp_p = &(attr_p->attr.fmtp);
    2244           0 :     memcpy(bmap, fmtp_p->bmap, SDP_NE_NUM_BMAP_WORDS * sizeof(uint32_t) );
    2245             : 
    2246           0 :     return (SDP_SUCCESS);
    2247             : }
    2248             : 
    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
    2260             :  */
    2261           0 : 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)
    2263             : {
    2264             :     uint16_t          i;
    2265             :     uint32_t          mapword;
    2266             :     uint32_t          bmap;
    2267             :     sdp_attr_t  *attr_p;
    2268             :     sdp_fmtp_t  *fmtp_p;
    2269             : 
    2270           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, inst_num);
    2271           0 :     if (attr_p == NULL) {
    2272           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2273           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2274             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2275             :         }
    2276           0 :         sdp_p->conf_p->num_invalid_param++;
    2277           0 :         return (SDP_INVALID_PARAMETER);
    2278             :     }
    2279             : 
    2280           0 :     fmtp_p = &(attr_p->attr.fmtp);
    2281           0 :     for (i = low_val; i <= high_val; i++) {
    2282           0 :         mapword = i/SDP_NE_BITS_PER_WORD;
    2283           0 :         bmap = SDP_NE_BIT_0 << (i%32);
    2284           0 :         fmtp_p->bmap[ mapword ] &= ~bmap;
    2285             :     }
    2286           0 :     if (high_val > fmtp_p->maxval) {
    2287           0 :         fmtp_p->maxval = high_val;
    2288             :     }
    2289           0 :     return (SDP_SUCCESS);
    2290             : }
    2291             : 
    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.
    2307             :  */
    2308           0 : 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)
    2312             : {
    2313             :     uint16_t          i,j;
    2314             :     uint32_t          bmap;
    2315           0 :     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;
    2320             : 
    2321           0 :     src_attr_p = sdp_find_attr(src_sdp_p, src_level, src_cap_num,
    2322             :                                SDP_ATTR_FMTP, src_inst_num);
    2323           0 :     dst_attr_p = sdp_find_attr(dst_sdp_p, dst_level, dst_cap_num,
    2324             :                                SDP_ATTR_FMTP, dst_inst_num);
    2325           0 :     if ((src_attr_p == NULL) || (dst_attr_p == NULL)) {
    2326           0 :         if (src_sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2327           0 :             CSFLogError(logTag, "%s source or destination fmtp attribute for "
    2328             :                       "compare not found.", src_sdp_p->debug_str);
    2329             :         }
    2330           0 :         src_sdp_p->conf_p->num_invalid_param++;
    2331           0 :         return (SDP_NO_MATCH);
    2332             :     }
    2333             : 
    2334           0 :     src_fmtp_p = &(src_attr_p->attr.fmtp);
    2335           0 :     dst_fmtp_p = &(dst_attr_p->attr.fmtp);
    2336           0 :     for (i = 0; i < SDP_NE_NUM_BMAP_WORDS; i++) {
    2337           0 :         for (j = 0; j < SDP_NE_BITS_PER_WORD; j++) {
    2338           0 :             bmap = SDP_NE_BIT_0 << j;
    2339           0 :             if ((src_fmtp_p->bmap[i] & bmap) && (dst_fmtp_p->bmap[i] & bmap)) {
    2340           0 :                 num_vals_match++;
    2341           0 :             } else if ((!(src_fmtp_p->bmap[i] & bmap)) &&
    2342           0 :                        (!(dst_fmtp_p->bmap[i] & bmap))) {
    2343           0 :                 num_vals_match++;
    2344             :             }
    2345             :         }
    2346             :     }
    2347             : 
    2348           0 :     if (num_vals_match == (SDP_NE_NUM_BMAP_WORDS * SDP_NE_BITS_PER_WORD)) {
    2349           0 :         return (SDP_FULL_MATCH);
    2350           0 :     } else if (num_vals_match == 0) {
    2351           0 :         return (SDP_NO_MATCH);
    2352             :     } else {
    2353           0 :         return (SDP_PARTIAL_MATCH);
    2354             :     }
    2355             : }
    2356             : 
    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
    2368             :  */
    2369           0 : 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)
    2373             : {
    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;
    2379             : 
    2380           0 :     if (!src_sdp_p || !dst_sdp_p) {
    2381           0 :         return (SDP_INVALID_SDP_PTR);
    2382             :     }
    2383             : 
    2384           0 :     src_attr_p = sdp_find_attr(src_sdp_p, src_level, src_cap_num,
    2385             :                                SDP_ATTR_FMTP, src_inst_num);
    2386           0 :     dst_attr_p = sdp_find_attr(dst_sdp_p, dst_level, dst_cap_num,
    2387             :                                SDP_ATTR_FMTP, dst_inst_num);
    2388           0 :     if ((src_attr_p == NULL) || (dst_attr_p == NULL)) {
    2389           0 :         if (src_sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2390           0 :             CSFLogError(logTag, "%s source or destination fmtp attribute for "
    2391             :                       "copy not found.", src_sdp_p->debug_str);
    2392             :         }
    2393           0 :         src_sdp_p->conf_p->num_invalid_param++;
    2394           0 :         return (SDP_INVALID_PARAMETER);
    2395             :     }
    2396             : 
    2397           0 :     src_fmtp_p = &(src_attr_p->attr.fmtp);
    2398           0 :     dst_fmtp_p = &(dst_attr_p->attr.fmtp);
    2399           0 :     dst_fmtp_p->maxval = src_fmtp_p->maxval;
    2400           0 :     for (i = 0; i < SDP_NE_NUM_BMAP_WORDS; i++) {
    2401           0 :         dst_fmtp_p->bmap[i] = src_fmtp_p->bmap[i];
    2402             :     }
    2403           0 :     return (SDP_SUCCESS);
    2404             : }
    2405             : 
    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
    2415             :  */
    2416           0 : 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)
    2418             : {
    2419           0 :     uint16_t          num_a_lines = 0;
    2420             :     int          i;
    2421             :     sdp_attr_t  *attr_p;
    2422             : 
    2423             :     /*
    2424             :      * Get number of FMTP attributes for the AUDIO line
    2425             :      */
    2426           0 :     (void) sdp_attr_num_instances(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    2427             :                                   &num_a_lines);
    2428           0 :     for (i = 0; i < num_a_lines; i++) {
    2429           0 :         attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, (uint16_t) (i + 1));
    2430           0 :         if ((attr_p != NULL) &&
    2431           0 :             (attr_p->attr.fmtp.payload_num == (uint16_t)payload_type)) {
    2432           0 :             if (attr_p->attr.fmtp.fmtp_format == SDP_FMTP_MODE) {
    2433           0 :                 return attr_p->attr.fmtp.mode;
    2434             :             }
    2435             :         }
    2436             :     }
    2437           0 :    return 0;
    2438             : }
    2439             : 
    2440           0 : 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)
    2443             : {
    2444             :     sdp_attr_t  *attr_p;
    2445             :     sdp_fmtp_t  *fmtp_p;
    2446             : 
    2447           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, inst_num);
    2448           0 :     if (attr_p == NULL) {
    2449           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2450           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2451             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2452             :         }
    2453           0 :         sdp_p->conf_p->num_invalid_param++;
    2454           0 :         return (SDP_INVALID_PARAMETER);
    2455             :     }
    2456             : 
    2457           0 :     fmtp_p = &(attr_p->attr.fmtp);
    2458           0 :     fmtp_p->fmtp_format = SDP_FMTP_CODEC_INFO;
    2459             : 
    2460           0 :     if (max_fs > 0) {
    2461           0 :         fmtp_p->max_fs  = max_fs;
    2462           0 :         return (SDP_SUCCESS);
    2463             :     } else {
    2464           0 :         return (SDP_FAILURE);
    2465             :     }
    2466             : }
    2467             : 
    2468           0 : 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)
    2471             : {
    2472             :     sdp_attr_t  *attr_p;
    2473             :     sdp_fmtp_t  *fmtp_p;
    2474             : 
    2475           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, inst_num);
    2476           0 :     if (attr_p == NULL) {
    2477           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2478           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2479             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2480             :         }
    2481           0 :         sdp_p->conf_p->num_invalid_param++;
    2482           0 :         return (SDP_INVALID_PARAMETER);
    2483             :     }
    2484             : 
    2485           0 :     fmtp_p = &(attr_p->attr.fmtp);
    2486           0 :     fmtp_p->fmtp_format = SDP_FMTP_CODEC_INFO;
    2487             : 
    2488           0 :     if (max_fr > 0) {
    2489           0 :         fmtp_p->max_fr  = max_fr;
    2490           0 :         return (SDP_SUCCESS);
    2491             :     } else {
    2492           0 :         return (SDP_FAILURE);
    2493             :     }
    2494             : }
    2495             : 
    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.
    2504             :  */
    2505             : 
    2506           0 : 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)
    2508             : {
    2509             :     sdp_attr_t  *attr_p;
    2510             : 
    2511           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP, 1);
    2512           0 :     if (attr_p == NULL) {
    2513           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2514           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2515             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2516             :         }
    2517           0 :         sdp_p->conf_p->num_invalid_param++;
    2518           0 :         return (SDP_INVALID_PARAMETER);
    2519             :     } else {
    2520           0 :         *val = attr_p->attr.fmtp.maxaveragebitrate;
    2521           0 :         return (SDP_SUCCESS);
    2522             :     }
    2523             : }
    2524             : 
    2525             : 
    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.
    2534             :  */
    2535             : 
    2536           0 : 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)
    2538             : {
    2539             :     sdp_attr_t  *attr_p;
    2540             : 
    2541           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    2542             :                            inst_num);
    2543           0 :     if (attr_p == NULL) {
    2544           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2545           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2546             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2547             :         }
    2548           0 :         sdp_p->conf_p->num_invalid_param++;
    2549           0 :         return (SDP_INVALID_PARAMETER);
    2550             :     } else {
    2551           0 :         *val = (tinybool)attr_p->attr.fmtp.usedtx;
    2552           0 :         return (SDP_SUCCESS);
    2553             :     }
    2554             : }
    2555             : 
    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.
    2564             :  */
    2565             : 
    2566           0 : 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)
    2568             : {
    2569             :     sdp_attr_t  *attr_p;
    2570             : 
    2571           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    2572             :                            inst_num);
    2573           0 :     if (attr_p == NULL) {
    2574           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2575           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2576             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2577             :         }
    2578           0 :         sdp_p->conf_p->num_invalid_param++;
    2579           0 :         return (SDP_INVALID_PARAMETER);
    2580             :     } else {
    2581           0 :         *val = (tinybool)attr_p->attr.fmtp.stereo;
    2582           0 :         return (SDP_SUCCESS);
    2583             :     }
    2584             : }
    2585             : 
    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.
    2594             :  */
    2595             : 
    2596           0 : 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)
    2598             : {
    2599             :     sdp_attr_t  *attr_p;
    2600             : 
    2601           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    2602             :                            inst_num);
    2603           0 :     if (attr_p == NULL) {
    2604           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2605           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2606             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2607             :         }
    2608           0 :         sdp_p->conf_p->num_invalid_param++;
    2609           0 :         return (SDP_INVALID_PARAMETER);
    2610             :     } else {
    2611           0 :         *val = (tinybool)attr_p->attr.fmtp.useinbandfec;
    2612           0 :         return (SDP_SUCCESS);
    2613             :     }
    2614             : }
    2615             : 
    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.
    2624             :  */
    2625           0 : char* sdp_attr_get_fmtp_maxcodedaudiobandwidth (sdp_t *sdp_p, uint16_t level,
    2626             :                                           uint8_t cap_num, uint16_t inst_num)
    2627             : {
    2628             : 
    2629             :     sdp_attr_t  *attr_p;
    2630             : 
    2631           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    2632             :                            inst_num);
    2633           0 :     if (attr_p == NULL) {
    2634           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2635           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2636             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2637             :         }
    2638           0 :         sdp_p->conf_p->num_invalid_param++;
    2639           0 :         return (0);
    2640             :     } else {
    2641           0 :         return (attr_p->attr.fmtp.maxcodedaudiobandwidth);
    2642             :     }
    2643             : }
    2644             : 
    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.
    2653             :  */
    2654             : 
    2655           0 : 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)
    2657             : {
    2658             :     sdp_attr_t  *attr_p;
    2659             : 
    2660           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    2661             :                            inst_num);
    2662           0 :     if (attr_p == NULL) {
    2663           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2664           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2665             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2666             :         }
    2667           0 :         sdp_p->conf_p->num_invalid_param++;
    2668           0 :         return (SDP_INVALID_PARAMETER);
    2669             :     } else {
    2670           0 :         *val = (tinybool)attr_p->attr.fmtp.cbr;
    2671           0 :         return (SDP_SUCCESS);
    2672             :     }
    2673             : }
    2674             : 
    2675           0 : uint16_t sdp_attr_get_sctpmap_port(sdp_t *sdp_p, uint16_t level,
    2676             :                               uint8_t cap_num, uint16_t inst_num)
    2677             : {
    2678             :     sdp_attr_t  *attr_p;
    2679             : 
    2680           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_SCTPMAP, inst_num);
    2681           0 :     if (!attr_p) {
    2682           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2683           0 :             CSFLogError(logTag, "%s sctpmap port, level %u instance %u "
    2684             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2685             :         }
    2686           0 :         sdp_p->conf_p->num_invalid_param++;
    2687           0 :         return 0;
    2688             :     } else {
    2689           0 :         return attr_p->attr.sctpmap.port;
    2690             :     }
    2691             : }
    2692             : 
    2693           0 : 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)
    2695             : {
    2696             :     sdp_attr_t  *attr_p;
    2697             : 
    2698           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_SCTPMAP, inst_num);
    2699           0 :     if (!attr_p) {
    2700           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2701           0 :             CSFLogError(logTag, "%s sctpmap streams, level %u instance %u "
    2702             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2703             :         }
    2704           0 :         sdp_p->conf_p->num_invalid_param++;
    2705           0 :         return (SDP_INVALID_PARAMETER);
    2706             :     } else {
    2707           0 :         *val = attr_p->attr.sctpmap.streams;
    2708           0 :         return (SDP_SUCCESS);
    2709             :     }
    2710             : }
    2711             : 
    2712           0 : 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)
    2715             : {
    2716             : 
    2717             :     sdp_attr_t  *attr_p;
    2718             : 
    2719           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_SCTPMAP,
    2720             :                            inst_num);
    2721           0 :     if (!attr_p) {
    2722           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2723           0 :             CSFLogError(logTag, "%s sctpmap, level %u instance %u "
    2724             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2725             :         }
    2726           0 :         sdp_p->conf_p->num_invalid_param++;
    2727           0 :         return (SDP_INVALID_PARAMETER);
    2728             :     } else {
    2729           0 :         sstrncpy(protocol, attr_p->attr.sctpmap.protocol, SDP_MAX_STRING_LEN+1);
    2730             :     }
    2731           0 :     return (SDP_SUCCESS);
    2732             : }
    2733             : 
    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.
    2742             :  *
    2743             :  *
    2744             :  * Returns:     TRUE or FALSE.
    2745             :  */
    2746           0 : tinybool sdp_attr_fmtp_is_annexb_set (sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
    2747             :                                       uint16_t inst_num)
    2748             : {
    2749             : 
    2750             :     sdp_attr_t  *attr_p;
    2751             : 
    2752           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    2753             :                            inst_num);
    2754           0 :     if (attr_p == NULL) {
    2755           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2756           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2757             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2758             :         }
    2759           0 :         sdp_p->conf_p->num_invalid_param++;
    2760           0 :         return (FALSE);
    2761             :     } else {
    2762           0 :         return (attr_p->attr.fmtp.annexb);
    2763             :     }
    2764             : }
    2765             : 
    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.
    2774             :  *
    2775             :  *
    2776             :  * Returns:     TRUE or FALSE.
    2777             :  */
    2778           0 : tinybool sdp_attr_fmtp_is_annexa_set (sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
    2779             :                                       uint16_t inst_num)
    2780             : {
    2781             :     sdp_attr_t  *attr_p;
    2782             : 
    2783           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    2784             :                            inst_num);
    2785           0 :     if (attr_p == NULL) {
    2786           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2787           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2788             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2789             :         }
    2790           0 :         sdp_p->conf_p->num_invalid_param++;
    2791           0 :         return (FALSE);
    2792             :     } else {
    2793           0 :         return (attr_p->attr.fmtp.annexa);
    2794             :     }
    2795             : }
    2796             : 
    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.
    2806             :  */
    2807           0 : int32_t sdp_attr_get_fmtp_bitrate_type (sdp_t *sdp_p, uint16_t level,
    2808             :                                       uint8_t cap_num, uint16_t inst_num)
    2809             : {
    2810             : 
    2811             :     sdp_attr_t  *attr_p;
    2812             : 
    2813           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    2814             :                            inst_num);
    2815           0 :     if (attr_p == NULL) {
    2816           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2817           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2818             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2819             :         }
    2820           0 :         sdp_p->conf_p->num_invalid_param++;
    2821           0 :         return (SDP_INVALID_VALUE);
    2822             :     } else {
    2823           0 :         return (attr_p->attr.fmtp.bitrate);
    2824             :     }
    2825             : }
    2826             : 
    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.
    2836             :  */
    2837           0 : int32_t sdp_attr_get_fmtp_qcif (sdp_t *sdp_p, uint16_t level,
    2838             :                             uint8_t cap_num, uint16_t inst_num)
    2839             : {
    2840             : 
    2841             :     sdp_attr_t  *attr_p;
    2842             : 
    2843           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    2844             :                            inst_num);
    2845           0 :     if (attr_p == NULL) {
    2846           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2847           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2848             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2849             :         }
    2850           0 :         sdp_p->conf_p->num_invalid_param++;
    2851           0 :         return (SDP_INVALID_VALUE);
    2852             :     } else {
    2853           0 :         return (attr_p->attr.fmtp.qcif);
    2854             :     }
    2855             : }
    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.
    2865             :  */
    2866           0 : int32_t sdp_attr_get_fmtp_cif (sdp_t *sdp_p, uint16_t level,
    2867             :                              uint8_t cap_num, uint16_t inst_num)
    2868             : {
    2869             : 
    2870             :     sdp_attr_t  *attr_p;
    2871             : 
    2872           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    2873             :                            inst_num);
    2874           0 :     if (attr_p == NULL) {
    2875           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2876           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2877             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2878             :         }
    2879           0 :         sdp_p->conf_p->num_invalid_param++;
    2880           0 :         return (SDP_INVALID_VALUE);
    2881             :     } else {
    2882           0 :         return (attr_p->attr.fmtp.cif);
    2883             :     }
    2884             : }
    2885             : 
    2886             : 
    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.
    2896             :  */
    2897           0 : int32_t sdp_attr_get_fmtp_sqcif (sdp_t *sdp_p, uint16_t level,
    2898             :                                uint8_t cap_num, uint16_t inst_num)
    2899             : {
    2900             : 
    2901             :     sdp_attr_t  *attr_p;
    2902             : 
    2903           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    2904             :                            inst_num);
    2905           0 :     if (attr_p == NULL) {
    2906           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2907           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2908             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2909             :         }
    2910           0 :         sdp_p->conf_p->num_invalid_param++;
    2911           0 :         return (SDP_INVALID_VALUE);
    2912             :     } else {
    2913           0 :         return (attr_p->attr.fmtp.sqcif);
    2914             :     }
    2915             : }
    2916             : 
    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.
    2926             :  */
    2927           0 : int32_t sdp_attr_get_fmtp_cif4 (sdp_t *sdp_p, uint16_t level,
    2928             :                               uint8_t cap_num, uint16_t inst_num)
    2929             : {
    2930             : 
    2931             :     sdp_attr_t  *attr_p;
    2932             : 
    2933           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    2934             :                            inst_num);
    2935           0 :     if (attr_p == NULL) {
    2936           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2937           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2938             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2939             :         }
    2940           0 :         sdp_p->conf_p->num_invalid_param++;
    2941           0 :         return (SDP_INVALID_VALUE);
    2942             :     } else {
    2943           0 :         return (attr_p->attr.fmtp.cif4);
    2944             :     }
    2945             : }
    2946             : 
    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.
    2956             :  */
    2957             : 
    2958           0 : int32_t sdp_attr_get_fmtp_cif16 (sdp_t *sdp_p, uint16_t level,
    2959             :                                uint8_t cap_num, uint16_t inst_num)
    2960             : {
    2961             : 
    2962             :     sdp_attr_t  *attr_p;
    2963             : 
    2964           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    2965             :                            inst_num);
    2966           0 :     if (attr_p == NULL) {
    2967           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2968           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    2969             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    2970             :         }
    2971           0 :         sdp_p->conf_p->num_invalid_param++;
    2972           0 :         return (SDP_INVALID_VALUE);
    2973             :     } else {
    2974           0 :         return (attr_p->attr.fmtp.cif16);
    2975             :     }
    2976             : }
    2977             : 
    2978             : 
    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.
    2988             :  */
    2989           0 : int32_t sdp_attr_get_fmtp_maxbr (sdp_t *sdp_p, uint16_t level,
    2990             :                                uint8_t cap_num, uint16_t inst_num)
    2991             : {
    2992             : 
    2993             :     sdp_attr_t  *attr_p;
    2994             : 
    2995           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    2996             :                            inst_num);
    2997           0 :     if (attr_p == NULL) {
    2998           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    2999           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3000             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3001             :         }
    3002           0 :         sdp_p->conf_p->num_invalid_param++;
    3003           0 :         return (SDP_INVALID_VALUE);
    3004             :     } else {
    3005           0 :         return (attr_p->attr.fmtp.maxbr);
    3006             :     }
    3007             : }
    3008             : 
    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.
    3018             :  */
    3019             : 
    3020           0 : int32_t sdp_attr_get_fmtp_custom_x (sdp_t *sdp_p, uint16_t level,
    3021             :                                   uint8_t cap_num, uint16_t inst_num)
    3022             : {
    3023             : 
    3024             :     sdp_attr_t  *attr_p;
    3025             : 
    3026           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3027             :                            inst_num);
    3028           0 :     if (attr_p == NULL) {
    3029           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3030           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3031             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3032             :         }
    3033           0 :         sdp_p->conf_p->num_invalid_param++;
    3034           0 :         return (SDP_INVALID_VALUE);
    3035             :     } else {
    3036           0 :         return (attr_p->attr.fmtp.custom_x);
    3037             :     }
    3038             : }
    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.
    3048             :  */
    3049             : 
    3050           0 : int32_t sdp_attr_get_fmtp_custom_y (sdp_t *sdp_p, uint16_t level,
    3051             :                                   uint8_t cap_num, uint16_t inst_num)
    3052             : {
    3053             : 
    3054             :     sdp_attr_t  *attr_p;
    3055             : 
    3056           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3057             :                            inst_num);
    3058           0 :     if (attr_p == NULL) {
    3059           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3060           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3061             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3062             :         }
    3063           0 :         sdp_p->conf_p->num_invalid_param++;
    3064           0 :         return (SDP_INVALID_VALUE);
    3065             :     } else {
    3066           0 :         return (attr_p->attr.fmtp.custom_y);
    3067             :     }
    3068             : }
    3069             : 
    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.
    3079             :  */
    3080             : 
    3081           0 : int32_t sdp_attr_get_fmtp_custom_mpi (sdp_t *sdp_p, uint16_t level,
    3082             :                                     uint8_t cap_num, uint16_t inst_num)
    3083             : {
    3084             : 
    3085             :     sdp_attr_t  *attr_p;
    3086             : 
    3087           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3088             :                            inst_num);
    3089           0 :     if (attr_p == NULL) {
    3090           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3091           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3092             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3093             :         }
    3094           0 :         sdp_p->conf_p->num_invalid_param++;
    3095           0 :         return (SDP_INVALID_VALUE);
    3096             :     } else {
    3097           0 :         return (attr_p->attr.fmtp.custom_mpi);
    3098             :     }
    3099             : }
    3100             : 
    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.
    3109             :  */
    3110           0 : int32_t sdp_attr_get_fmtp_par_width (sdp_t *sdp_p, uint16_t level,
    3111             :                                    uint8_t cap_num, uint16_t inst_num)
    3112             : {
    3113             : 
    3114             :     sdp_attr_t  *attr_p;
    3115             : 
    3116           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3117             :                            inst_num);
    3118           0 :     if (attr_p == NULL) {
    3119           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3120           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3121             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3122             :         }
    3123           0 :         sdp_p->conf_p->num_invalid_param++;
    3124           0 :         return (SDP_INVALID_VALUE);
    3125             :     } else {
    3126           0 :         return (attr_p->attr.fmtp.par_width);
    3127             :     }
    3128             : }
    3129             : 
    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.
    3138             :  */
    3139           0 : int32_t sdp_attr_get_fmtp_par_height (sdp_t *sdp_p, uint16_t level,
    3140             :                                     uint8_t cap_num, uint16_t inst_num)
    3141             : {
    3142             : 
    3143             :     sdp_attr_t  *attr_p;
    3144             : 
    3145           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3146             :                            inst_num);
    3147           0 :     if (attr_p == NULL) {
    3148           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3149           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3150             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3151             :         }
    3152           0 :         sdp_p->conf_p->num_invalid_param++;
    3153           0 :         return (SDP_INVALID_VALUE);
    3154             :     } else {
    3155           0 :         return (attr_p->attr.fmtp.par_height);
    3156             :     }
    3157             : }
    3158             : 
    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.
    3167             :  */
    3168           0 : int32_t sdp_attr_get_fmtp_cpcf (sdp_t *sdp_p, uint16_t level,
    3169             :                               uint8_t cap_num, uint16_t inst_num)
    3170             : {
    3171             : 
    3172             :     sdp_attr_t  *attr_p;
    3173             : 
    3174           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3175             :                            inst_num);
    3176           0 :     if (attr_p == NULL) {
    3177           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3178           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3179             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3180             :         }
    3181           0 :         sdp_p->conf_p->num_invalid_param++;
    3182           0 :         return (SDP_INVALID_VALUE);
    3183             :     } else {
    3184           0 :         return (attr_p->attr.fmtp.cpcf);
    3185             :     }
    3186             : }
    3187             : 
    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.
    3196             :  */
    3197           0 : int32_t sdp_attr_get_fmtp_bpp (sdp_t *sdp_p, uint16_t level,
    3198             :                              uint8_t cap_num, uint16_t inst_num)
    3199             : {
    3200             : 
    3201             :     sdp_attr_t  *attr_p;
    3202             : 
    3203           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3204             :                            inst_num);
    3205           0 :     if (attr_p == NULL) {
    3206           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3207           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3208             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3209             :         }
    3210           0 :         sdp_p->conf_p->num_invalid_param++;
    3211           0 :         return (SDP_INVALID_VALUE);
    3212             :     } else {
    3213           0 :         return (attr_p->attr.fmtp.bpp);
    3214             :     }
    3215             : }
    3216             : 
    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.
    3225             :  */
    3226           0 : int32_t sdp_attr_get_fmtp_hrd (sdp_t *sdp_p, uint16_t level,
    3227             :                              uint8_t cap_num, uint16_t inst_num)
    3228             : {
    3229             : 
    3230             :     sdp_attr_t  *attr_p;
    3231             : 
    3232           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3233             :                            inst_num);
    3234           0 :     if (attr_p == NULL) {
    3235           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3236           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3237             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3238             :         }
    3239           0 :         sdp_p->conf_p->num_invalid_param++;
    3240           0 :         return (SDP_INVALID_VALUE);
    3241             :     } else {
    3242           0 :         return (attr_p->attr.fmtp.hrd);
    3243             :     }
    3244             : }
    3245             : 
    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.
    3254             :  */
    3255           0 : int32_t sdp_attr_get_fmtp_profile (sdp_t *sdp_p, uint16_t level,
    3256             :                                  uint8_t cap_num, uint16_t inst_num)
    3257             : {
    3258             : 
    3259             :     sdp_attr_t  *attr_p;
    3260             : 
    3261           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3262             :                            inst_num);
    3263           0 :     if (attr_p == NULL) {
    3264           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3265           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3266             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3267             :         }
    3268           0 :         sdp_p->conf_p->num_invalid_param++;
    3269           0 :         return (SDP_INVALID_VALUE);
    3270             :     } else {
    3271           0 :         return (attr_p->attr.fmtp.profile);
    3272             :     }
    3273             : }
    3274             : 
    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.
    3283             :  */
    3284           0 : int32_t sdp_attr_get_fmtp_level (sdp_t *sdp_p, uint16_t level,
    3285             :                                uint8_t cap_num, uint16_t inst_num)
    3286             : {
    3287             : 
    3288             :     sdp_attr_t  *attr_p;
    3289             : 
    3290           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3291             :                            inst_num);
    3292           0 :     if (attr_p == NULL) {
    3293           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3294           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3295             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3296             :         }
    3297           0 :         sdp_p->conf_p->num_invalid_param++;
    3298           0 :         return (SDP_INVALID_VALUE);
    3299             :     } else {
    3300           0 :         return (attr_p->attr.fmtp.level);
    3301             :     }
    3302             : }
    3303             : 
    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.
    3312             :  */
    3313           0 : tinybool sdp_attr_get_fmtp_interlace (sdp_t *sdp_p, uint16_t level,
    3314             :                                       uint8_t cap_num, uint16_t inst_num)
    3315             : {
    3316             : 
    3317             :     sdp_attr_t  *attr_p;
    3318             : 
    3319           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3320             :                            inst_num);
    3321           0 :     if (attr_p == NULL) {
    3322           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3323           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3324             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3325             :         }
    3326           0 :         sdp_p->conf_p->num_invalid_param++;
    3327           0 :         return FALSE;
    3328             :     } else {
    3329           0 :         return (attr_p->attr.fmtp.is_interlace);
    3330             :     }
    3331             : }
    3332             : 
    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.
    3341             :  */
    3342             : 
    3343           0 : 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)
    3345             : {
    3346             : 
    3347             :     sdp_attr_t  *attr_p;
    3348             : 
    3349           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3350             :                            inst_num);
    3351           0 :     if (attr_p == NULL) {
    3352           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3353           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3354             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3355             :         }
    3356           0 :         sdp_p->conf_p->num_invalid_param++;
    3357           0 :         return (SDP_INVALID_PARAMETER);
    3358             :     } else {
    3359           0 :         if (SDP_INVALID_PACKETIZATION_MODE_VALUE == attr_p->attr.fmtp.packetization_mode) {
    3360             :             /* packetization mode unspecified (optional) */
    3361           0 :             *val = SDP_DEFAULT_PACKETIZATION_MODE_VALUE;
    3362             :         } else {
    3363           0 :             *val = attr_p->attr.fmtp.packetization_mode;
    3364             :         }
    3365           0 :         return (SDP_SUCCESS);
    3366             :     }
    3367             : }
    3368             : 
    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).
    3377             :  */
    3378             : 
    3379           0 : 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)
    3381             : {
    3382             : 
    3383             :     sdp_attr_t  *attr_p;
    3384             : 
    3385           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3386             :                            inst_num);
    3387           0 :     if (attr_p == NULL) {
    3388           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3389           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3390             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3391             :         }
    3392           0 :         sdp_p->conf_p->num_invalid_param++;
    3393           0 :         return (SDP_INVALID_PARAMETER);
    3394             :     } else {
    3395           0 :         *val = attr_p->attr.fmtp.level_asymmetry_allowed;
    3396           0 :         return (SDP_SUCCESS);
    3397             :     }
    3398             : }
    3399             : 
    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.
    3408             :  */
    3409           0 : const char* sdp_attr_get_fmtp_profile_id (sdp_t *sdp_p, uint16_t level,
    3410             :                                           uint8_t cap_num, uint16_t inst_num)
    3411             : {
    3412             : 
    3413             :     sdp_attr_t  *attr_p;
    3414             : 
    3415           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3416             :                            inst_num);
    3417           0 :     if (attr_p == NULL) {
    3418           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3419           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3420             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3421             :         }
    3422           0 :         sdp_p->conf_p->num_invalid_param++;
    3423           0 :         return (0);
    3424             :     } else {
    3425           0 :         return (attr_p->attr.fmtp.profile_level_id);
    3426             :     }
    3427             : }
    3428             : 
    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.
    3437             :  */
    3438           0 : const char* sdp_attr_get_fmtp_param_sets (sdp_t *sdp_p, uint16_t level,
    3439             :                                           uint8_t cap_num, uint16_t inst_num)
    3440             : {
    3441             : 
    3442             :     sdp_attr_t  *attr_p;
    3443             : 
    3444           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3445             :                            inst_num);
    3446           0 :     if (attr_p == NULL) {
    3447           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3448           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3449             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3450             :         }
    3451           0 :         sdp_p->conf_p->num_invalid_param++;
    3452           0 :         return (0);
    3453             :     } else {
    3454           0 :         return (attr_p->attr.fmtp.parameter_sets);
    3455             :     }
    3456             : }
    3457             : 
    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
    3466             :  */
    3467             : 
    3468           0 : 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)
    3470             : {
    3471             :     sdp_attr_t  *attr_p;
    3472             : 
    3473           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3474             :                            inst_num);
    3475           0 :     if (attr_p == NULL) {
    3476           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3477           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3478             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3479             :         }
    3480           0 :         sdp_p->conf_p->num_invalid_param++;
    3481           0 :         return (SDP_INVALID_PARAMETER);
    3482             :     } else {
    3483           0 :         *val = attr_p->attr.fmtp.interleaving_depth;
    3484           0 :         return (SDP_SUCCESS);
    3485             :     }
    3486             : }
    3487             : 
    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.
    3496             :  */
    3497             : 
    3498           0 : 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)
    3501             : {
    3502             :     sdp_attr_t  *attr_p;
    3503             : 
    3504           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3505             :                            inst_num);
    3506           0 :     if (attr_p == NULL) {
    3507           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3508           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3509             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3510             :         }
    3511           0 :         sdp_p->conf_p->num_invalid_param++;
    3512           0 :         return (SDP_INVALID_PARAMETER);
    3513             :     } else {
    3514           0 :         if (attr_p->attr.fmtp.flag & SDP_DEINT_BUF_REQ_FLAG) {
    3515           0 :             *val = attr_p->attr.fmtp.deint_buf_req;
    3516           0 :             return (SDP_SUCCESS);
    3517             :         } else {
    3518           0 :             return (SDP_FAILURE);
    3519             :         }
    3520             :     }
    3521             : }
    3522             : 
    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.
    3531             :  */
    3532           0 : 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)
    3535             : {
    3536             :     sdp_attr_t  *attr_p;
    3537             : 
    3538           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3539             :                            inst_num);
    3540           0 :     if (attr_p == NULL) {
    3541           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3542           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3543             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3544             :         }
    3545           0 :         sdp_p->conf_p->num_invalid_param++;
    3546           0 :         return (SDP_INVALID_PARAMETER);
    3547             :     } else {
    3548           0 :         *val = attr_p->attr.fmtp.max_don_diff;
    3549           0 :         return (SDP_SUCCESS);
    3550             :     }
    3551             : }
    3552             : 
    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.
    3561             :  */
    3562           0 : 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)
    3565             : {
    3566             :     sdp_attr_t  *attr_p;
    3567             : 
    3568           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3569             :                            inst_num);
    3570           0 :     if (attr_p == NULL) {
    3571           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3572           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3573             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3574             :         }
    3575           0 :         sdp_p->conf_p->num_invalid_param++;
    3576           0 :         return (SDP_INVALID_PARAMETER);
    3577             :     } else {
    3578           0 :         if (attr_p->attr.fmtp.flag & SDP_INIT_BUF_TIME_FLAG) {
    3579           0 :             *val = attr_p->attr.fmtp.init_buf_time;
    3580           0 :             return (SDP_SUCCESS);
    3581             :         } else {
    3582           0 :             return (SDP_FAILURE);
    3583             :         }
    3584             :     }
    3585             : }
    3586             : 
    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.
    3595             :  */
    3596             : 
    3597           0 : 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)
    3600             : {
    3601             :     sdp_attr_t  *attr_p;
    3602             : 
    3603           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3604             :                            inst_num);
    3605           0 :     if (attr_p == NULL) {
    3606           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3607           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3608             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3609             :         }
    3610           0 :         sdp_p->conf_p->num_invalid_param++;
    3611           0 :         return (SDP_INVALID_PARAMETER);
    3612             :     } else {
    3613           0 :         *val = attr_p->attr.fmtp.max_mbps;
    3614           0 :         return (SDP_SUCCESS);
    3615             :     }
    3616             : }
    3617             : 
    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.
    3626             :  */
    3627             : 
    3628           0 : 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)
    3630             : {
    3631             :     sdp_attr_t  *attr_p;
    3632             : 
    3633           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3634             :                            inst_num);
    3635           0 :     if (attr_p == NULL) {
    3636           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3637           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3638             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3639             :         }
    3640           0 :         sdp_p->conf_p->num_invalid_param++;
    3641           0 :         return (SDP_INVALID_PARAMETER);
    3642             :     } else {
    3643           0 :         *val = attr_p->attr.fmtp.max_fs;
    3644           0 :         return (SDP_SUCCESS);
    3645             :     }
    3646             : }
    3647             : 
    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.
    3656             :  */
    3657             : 
    3658           0 : 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)
    3660             : {
    3661             :     sdp_attr_t  *attr_p;
    3662             : 
    3663           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3664             :                            inst_num);
    3665           0 :     if (attr_p == NULL) {
    3666           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3667           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3668             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3669             :         }
    3670           0 :         sdp_p->conf_p->num_invalid_param++;
    3671           0 :         return (SDP_INVALID_PARAMETER);
    3672             :     } else {
    3673           0 :         *val = attr_p->attr.fmtp.max_fr;
    3674           0 :         return (SDP_SUCCESS);
    3675             :     }
    3676             : }
    3677             : 
    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.
    3686             :  */
    3687             : 
    3688           0 : 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)
    3690             : {
    3691             :     sdp_attr_t  *attr_p;
    3692             : 
    3693           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3694             :                            inst_num);
    3695           0 :     if (attr_p == NULL) {
    3696           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3697           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3698             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3699             :         }
    3700           0 :         sdp_p->conf_p->num_invalid_param++;
    3701           0 :         return (SDP_INVALID_PARAMETER);
    3702             :     } else {
    3703           0 :         *val = attr_p->attr.fmtp.max_cpb;
    3704           0 :         return (SDP_SUCCESS);
    3705             :     }
    3706             : }
    3707             : 
    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.
    3716             :  */
    3717             : 
    3718           0 : 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)
    3720             : {
    3721             :     sdp_attr_t  *attr_p;
    3722             : 
    3723           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3724             :                            inst_num);
    3725           0 :     if (attr_p == NULL) {
    3726           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3727           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3728             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3729             :         }
    3730           0 :         sdp_p->conf_p->num_invalid_param++;
    3731           0 :         return (SDP_INVALID_PARAMETER);
    3732             :     } else {
    3733           0 :         *val = attr_p->attr.fmtp.max_dpb;
    3734           0 :         return (SDP_SUCCESS);
    3735             :     }
    3736             : }
    3737             : 
    3738             : 
    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.
    3747             :  */
    3748             : 
    3749           0 : 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)
    3751             : {
    3752             :     sdp_attr_t  *attr_p;
    3753             : 
    3754           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3755             :                            inst_num);
    3756           0 :     if (attr_p == NULL) {
    3757           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3758           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3759             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3760             :         }
    3761           0 :         sdp_p->conf_p->num_invalid_param++;
    3762           0 :         return (SDP_INVALID_PARAMETER);
    3763             :     } else {
    3764           0 :         *val = attr_p->attr.fmtp.max_br;
    3765           0 :         return (SDP_SUCCESS);
    3766             :     }
    3767             : }
    3768             : 
    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.
    3777             :  */
    3778           0 : tinybool sdp_attr_fmtp_is_redundant_pic_cap (sdp_t *sdp_p, uint16_t level,
    3779             :                                              uint8_t cap_num, uint16_t inst_num)
    3780             : {
    3781             : 
    3782             :     sdp_attr_t  *attr_p;
    3783             : 
    3784           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3785             :                            inst_num);
    3786           0 :     if (attr_p == NULL) {
    3787           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3788           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3789             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3790             :         }
    3791           0 :         sdp_p->conf_p->num_invalid_param++;
    3792           0 :         return (FALSE);
    3793             :     } else {
    3794           0 :         return (attr_p->attr.fmtp.redundant_pic_cap);
    3795             :     }
    3796             : }
    3797             : 
    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.
    3806             :  */
    3807             : 
    3808           0 : 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)
    3811             : {
    3812             : 
    3813             :     sdp_attr_t  *attr_p;
    3814             : 
    3815           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3816             :                            inst_num);
    3817           0 :     if (attr_p == NULL) {
    3818           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3819           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3820             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3821             :         }
    3822           0 :         sdp_p->conf_p->num_invalid_param++;
    3823           0 :         return (SDP_INVALID_PARAMETER);
    3824             :     } else {
    3825           0 :         if (attr_p->attr.fmtp.flag & SDP_DEINT_BUF_CAP_FLAG) {
    3826           0 :             *val = attr_p->attr.fmtp.deint_buf_cap;
    3827           0 :             return (SDP_SUCCESS);
    3828             :         } else {
    3829           0 :             return (SDP_FAILURE);
    3830             :         }
    3831             :     }
    3832             : }
    3833             : 
    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.
    3842             :  */
    3843           0 : 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)
    3846             : {
    3847             : 
    3848             :     sdp_attr_t  *attr_p;
    3849             : 
    3850           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3851             :                            inst_num);
    3852           0 :     if (attr_p == NULL) {
    3853           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3854           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3855             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3856             :         }
    3857           0 :         sdp_p->conf_p->num_invalid_param++;
    3858           0 :         return (SDP_INVALID_PARAMETER);
    3859             :     } else {
    3860           0 :         if (attr_p->attr.fmtp.flag & SDP_MAX_RCMD_NALU_SIZE_FLAG) {
    3861           0 :             *val = attr_p->attr.fmtp.max_rcmd_nalu_size;
    3862           0 :             return (SDP_SUCCESS);
    3863             :         } else {
    3864           0 :             return (SDP_FAILURE);
    3865             :         }
    3866             :     }
    3867             : }
    3868             : 
    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)
    3877             :  */
    3878           0 : tinybool sdp_attr_fmtp_is_parameter_add (sdp_t *sdp_p, uint16_t level,
    3879             :                                          uint8_t cap_num, uint16_t inst_num)
    3880             : {
    3881             : 
    3882             :     sdp_attr_t  *attr_p;
    3883             : 
    3884           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3885             :                            inst_num);
    3886           0 :     if (attr_p == NULL) {
    3887           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3888           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3889             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3890             :         }
    3891           0 :         sdp_p->conf_p->num_invalid_param++;
    3892           0 :         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           0 :         return (attr_p->attr.fmtp.parameter_add != 0);
    3897             :     }
    3898             : }
    3899             : 
    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.
    3904             :  *
    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
    3911             :  */
    3912             : 
    3913           0 : tinybool sdp_attr_get_fmtp_annex_d (sdp_t *sdp_p, uint16_t level,
    3914             :                                     uint8_t cap_num, uint16_t inst_num)
    3915             : {
    3916             : 
    3917             :     sdp_attr_t  *attr_p;
    3918             : 
    3919           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3920             :                            inst_num);
    3921           0 :     if (attr_p == NULL) {
    3922           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3923           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3924             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3925             :         }
    3926           0 :         sdp_p->conf_p->num_invalid_param++;
    3927           0 :         return (FALSE);
    3928             :     } else {
    3929           0 :         return (attr_p->attr.fmtp.annex_d);
    3930             :     }
    3931             : }
    3932             : 
    3933           0 : tinybool sdp_attr_get_fmtp_annex_f (sdp_t *sdp_p, uint16_t level,
    3934             :                                     uint8_t cap_num, uint16_t inst_num)
    3935             : {
    3936             : 
    3937             :     sdp_attr_t  *attr_p;
    3938             : 
    3939           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3940             :                            inst_num);
    3941           0 :     if (attr_p == NULL) {
    3942           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3943           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3944             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3945             :         }
    3946           0 :         sdp_p->conf_p->num_invalid_param++;
    3947           0 :         return (FALSE);
    3948             :     } else {
    3949           0 :         return (attr_p->attr.fmtp.annex_f);
    3950             :     }
    3951             : }
    3952             : 
    3953           0 : tinybool sdp_attr_get_fmtp_annex_i (sdp_t *sdp_p, uint16_t level,
    3954             :                                     uint8_t cap_num, uint16_t inst_num)
    3955             : {
    3956             : 
    3957             :     sdp_attr_t  *attr_p;
    3958             : 
    3959           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3960             :                            inst_num);
    3961           0 :     if (attr_p == NULL) {
    3962           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3963           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3964             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3965             :         }
    3966           0 :         sdp_p->conf_p->num_invalid_param++;
    3967           0 :         return (FALSE);
    3968             :     } else {
    3969           0 :         return (attr_p->attr.fmtp.annex_i);
    3970             :     }
    3971             : }
    3972             : 
    3973           0 : tinybool sdp_attr_get_fmtp_annex_j (sdp_t *sdp_p, uint16_t level,
    3974             :                                     uint8_t cap_num, uint16_t inst_num)
    3975             : {
    3976             : 
    3977             :     sdp_attr_t  *attr_p;
    3978             : 
    3979           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    3980             :                            inst_num);
    3981           0 :     if (attr_p == NULL) {
    3982           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    3983           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    3984             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    3985             :         }
    3986           0 :         sdp_p->conf_p->num_invalid_param++;
    3987           0 :         return (FALSE);
    3988             :     } else {
    3989           0 :         return (attr_p->attr.fmtp.annex_j);
    3990             :     }
    3991             : }
    3992             : 
    3993           0 : tinybool sdp_attr_get_fmtp_annex_t (sdp_t *sdp_p, uint16_t level,
    3994             :                                     uint8_t cap_num, uint16_t inst_num)
    3995             : {
    3996             : 
    3997             :     sdp_attr_t  *attr_p;
    3998             : 
    3999           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    4000             :                            inst_num);
    4001           0 :     if (attr_p == NULL) {
    4002           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4003           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    4004             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4005             :         }
    4006           0 :         sdp_p->conf_p->num_invalid_param++;
    4007           0 :         return (FALSE);
    4008             :     } else {
    4009           0 :         return (attr_p->attr.fmtp.annex_t);
    4010             :     }
    4011             : }
    4012             : 
    4013           0 : 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)
    4015             : {
    4016             : 
    4017             :     sdp_attr_t  *attr_p;
    4018             : 
    4019           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    4020             :                            inst_num);
    4021           0 :     if (attr_p == NULL) {
    4022           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4023           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    4024             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4025             :         }
    4026           0 :         sdp_p->conf_p->num_invalid_param++;
    4027           0 :         return (SDP_INVALID_VALUE);
    4028             :     } else {
    4029           0 :         return (attr_p->attr.fmtp.annex_k_val);
    4030             :     }
    4031             : }
    4032             : 
    4033           0 : 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)
    4035             : {
    4036             : 
    4037             :     sdp_attr_t  *attr_p;
    4038             : 
    4039           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    4040             :                            inst_num);
    4041           0 :     if (attr_p == NULL) {
    4042           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4043           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    4044             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4045             :         }
    4046           0 :         sdp_p->conf_p->num_invalid_param++;
    4047           0 :         return (SDP_INVALID_VALUE);
    4048             :     } else {
    4049           0 :         return (attr_p->attr.fmtp.annex_n_val);
    4050             :     }
    4051             : }
    4052             : 
    4053           0 : 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)
    4055             : {
    4056             : 
    4057             : 
    4058             :     sdp_attr_t  *attr_p;
    4059             : 
    4060           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    4061             :                            inst_num);
    4062           0 :     if (attr_p == NULL) {
    4063           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4064           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    4065             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4066             :         }
    4067           0 :         sdp_p->conf_p->num_invalid_param++;
    4068           0 :         return (SDP_INVALID_VALUE);
    4069             :     } else {
    4070           0 :         return (attr_p->attr.fmtp.annex_p_val_picture_resize);
    4071             :     }
    4072             : }
    4073             : 
    4074           0 : 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)
    4076             : {
    4077             : 
    4078             :     sdp_attr_t  *attr_p;
    4079             : 
    4080           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    4081             :                            inst_num);
    4082           0 :     if (attr_p == NULL) {
    4083           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4084           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    4085             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4086             :         }
    4087           0 :         sdp_p->conf_p->num_invalid_param++;
    4088           0 :         return (SDP_INVALID_VALUE);
    4089             :     } else {
    4090           0 :         return (attr_p->attr.fmtp.annex_p_val_warp);
    4091             :     }
    4092             : }
    4093             : 
    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.
    4103             :  *
    4104             :  *
    4105             :  * Returns:     Enum type sdp_fmtp_format_type_e
    4106             :  */
    4107           0 : 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)
    4110             : {
    4111             :     sdp_attr_t  *attr_p;
    4112             : 
    4113           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_FMTP,
    4114             :                            inst_num);
    4115           0 :     if (attr_p == NULL) {
    4116           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4117           0 :             CSFLogError(logTag, "%s fmtp attribute, level %u instance %u "
    4118             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4119             :         }
    4120           0 :         sdp_p->conf_p->num_invalid_param++;
    4121           0 :         return (SDP_FMTP_UNKNOWN_TYPE);
    4122             :     } else {
    4123           0 :         return (attr_p->attr.fmtp.fmtp_format);
    4124             :     }
    4125             : }
    4126             : 
    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.
    4137             :  */
    4138           0 : 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)
    4140             : {
    4141             :     sdp_attr_t  *attr_p;
    4142             : 
    4143           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_X_PC_CODEC,
    4144             :                            inst_num);
    4145           0 :     if (attr_p == NULL) {
    4146           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4147           0 :             CSFLogError(logTag, "%s X-pc-codec attribute, level %u instance %u "
    4148             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4149             :         }
    4150           0 :         sdp_p->conf_p->num_invalid_param++;
    4151           0 :         return (0);
    4152             :     } else {
    4153           0 :         return (attr_p->attr.pccodec.num_payloads);
    4154             :     }
    4155             : }
    4156             : 
    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.
    4169             :  */
    4170           0 : 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)
    4172             : {
    4173             :     sdp_attr_t  *attr_p;
    4174             : 
    4175           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_X_PC_CODEC,
    4176             :                            inst_num);
    4177           0 :     if (attr_p == NULL) {
    4178           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4179           0 :             CSFLogError(logTag, "%s X-pc-codec attribute, level %u instance %u "
    4180             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4181             :         }
    4182           0 :         sdp_p->conf_p->num_invalid_param++;
    4183           0 :         return (0);
    4184             :     } else {
    4185           0 :         if ((payload_num < 1) ||
    4186           0 :             (payload_num > attr_p->attr.pccodec.num_payloads)) {
    4187           0 :             if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4188           0 :                 CSFLogError(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);
    4191             :             }
    4192           0 :             sdp_p->conf_p->num_invalid_param++;
    4193           0 :             return (0);
    4194             :         } else {
    4195           0 :             return (attr_p->attr.pccodec.payload_type[payload_num-1]);
    4196             :         }
    4197             :     }
    4198             : }
    4199             : 
    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.
    4213             :  */
    4214           0 : 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)
    4217             : {
    4218             :     uint16_t          payload_num;
    4219             :     sdp_attr_t  *attr_p;
    4220             : 
    4221           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_X_PC_CODEC,
    4222             :                            inst_num);
    4223           0 :     if (attr_p == NULL) {
    4224           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4225           0 :             CSFLogError(logTag, "%s X-pc-codec attribute, level %u instance %u "
    4226             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4227             :         }
    4228           0 :         sdp_p->conf_p->num_invalid_param++;
    4229           0 :         return (SDP_INVALID_PARAMETER);
    4230             :     } else {
    4231           0 :         payload_num = attr_p->attr.pccodec.num_payloads++;
    4232           0 :         attr_p->attr.pccodec.payload_type[payload_num] = payload_type;
    4233           0 :         return (SDP_SUCCESS);
    4234             :     }
    4235             : }
    4236             : 
    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.
    4246             :  */
    4247           0 : uint16_t sdp_attr_get_xcap_first_cap_num (sdp_t *sdp_p, uint16_t level, uint16_t inst_num)
    4248             : {
    4249           0 :     uint16_t          cap_num=1;
    4250           0 :     uint16_t          attr_count=0;
    4251             :     sdp_attr_t  *attr_p;
    4252             :     sdp_mca_t   *mca_p;
    4253             : 
    4254           0 :     if (level == SDP_SESSION_LEVEL) {
    4255           0 :         for (attr_p = sdp_p->sess_attrs_p; attr_p != NULL;
    4256           0 :              attr_p = attr_p->next_p) {
    4257           0 :             if (attr_p->type == SDP_ATTR_X_CAP) {
    4258           0 :                 attr_count++;
    4259           0 :                 if (attr_count == inst_num) {
    4260           0 :                     return (cap_num);
    4261             :                 } else {
    4262           0 :                     cap_num += attr_p->attr.cap_p->num_payloads;
    4263             :                 }
    4264             :             }
    4265             :         }
    4266             :     } else {  /* Capability is at a media level */
    4267           0 :         mca_p = sdp_find_media_level(sdp_p, level);
    4268           0 :         if (mca_p == NULL) {
    4269           0 :             sdp_p->conf_p->num_invalid_param++;
    4270           0 :             return (0);
    4271             :         }
    4272           0 :         for (attr_p = mca_p->media_attrs_p; attr_p != NULL;
    4273           0 :              attr_p = attr_p->next_p) {
    4274           0 :             if (attr_p->type == SDP_ATTR_X_CAP) {
    4275           0 :                 attr_count++;
    4276           0 :                 if (attr_count == inst_num) {
    4277           0 :                     return (cap_num);
    4278             :                 } else {
    4279           0 :                     cap_num += attr_p->attr.cap_p->num_payloads;
    4280             :                 }
    4281             :             }
    4282             :         }
    4283             :     }  /* Attr is at a media level */
    4284             : 
    4285           0 :     if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4286           0 :         CSFLogError(logTag, "%s X-cap attribute, level %u instance %u "
    4287             :                   "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4288             :     }
    4289           0 :     sdp_p->conf_p->num_invalid_param++;
    4290           0 :     return (0);
    4291             : }
    4292             : 
    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.
    4302             :  */
    4303           0 : sdp_media_e sdp_attr_get_xcap_media_type (sdp_t *sdp_p, uint16_t level,
    4304             :                                           uint16_t inst_num)
    4305             : {
    4306             :     sdp_attr_t  *attr_p;
    4307             :     sdp_mca_t   *cap_p;
    4308             : 
    4309           0 :     attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_X_CAP, inst_num);
    4310           0 :     if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
    4311           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4312           0 :             CSFLogError(logTag, "%s X-cap attribute, level %u instance %u "
    4313             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4314             :         }
    4315           0 :         sdp_p->conf_p->num_invalid_param++;
    4316           0 :         return (SDP_MEDIA_INVALID);
    4317             :     } else {
    4318           0 :         cap_p = attr_p->attr.cap_p;
    4319           0 :         return (cap_p->media);
    4320             :     }
    4321             : }
    4322             : 
    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.
    4332             :  */
    4333           0 : sdp_transport_e sdp_attr_get_xcap_transport_type (sdp_t *sdp_p, uint16_t level,
    4334             :                                                   uint16_t inst_num)
    4335             : {
    4336             :     sdp_attr_t  *attr_p;
    4337             :     sdp_mca_t   *cap_p;
    4338             : 
    4339           0 :     attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_X_CAP,
    4340             :                            inst_num);
    4341           0 :     if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
    4342           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4343           0 :             CSFLogError(logTag, "%s X-cap attribute, level %u instance %u "
    4344             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4345             :         }
    4346           0 :         sdp_p->conf_p->num_invalid_param++;
    4347           0 :         return (SDP_TRANSPORT_INVALID);
    4348             :     } else {
    4349           0 :         cap_p = attr_p->attr.cap_p;
    4350           0 :         return (cap_p->transport);
    4351             :     }
    4352             : }
    4353             : 
    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.
    4366             :  */
    4367           0 : uint16_t sdp_attr_get_xcap_num_payload_types (sdp_t *sdp_p, uint16_t level,
    4368             :                                          uint16_t inst_num)
    4369             : {
    4370             :     sdp_attr_t  *attr_p;
    4371             :     sdp_mca_t   *cap_p;
    4372             : 
    4373           0 :     attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_X_CAP, inst_num);
    4374           0 :     if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
    4375           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4376           0 :             CSFLogError(logTag, "%s X-cap attribute, level %u instance %u "
    4377             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4378             :         }
    4379           0 :         sdp_p->conf_p->num_invalid_param++;
    4380           0 :         return (0);
    4381             :     } else {
    4382           0 :         cap_p = attr_p->attr.cap_p;
    4383           0 :         return (cap_p->num_payloads);
    4384             :     }
    4385             : }
    4386             : 
    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.
    4399             :  */
    4400           0 : 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)
    4403             : {
    4404             :     sdp_attr_t  *attr_p;
    4405             :     sdp_mca_t   *cap_p;
    4406             : 
    4407           0 :     attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_X_CAP, inst_num);
    4408           0 :     if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
    4409           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4410           0 :             CSFLogError(logTag, "%s X-cap attribute, level %u instance %u "
    4411             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4412             :         }
    4413           0 :         sdp_p->conf_p->num_invalid_param++;
    4414           0 :         return (0);
    4415             :     } else {
    4416           0 :         cap_p = attr_p->attr.cap_p;
    4417           0 :         if ((payload_num < 1) ||
    4418           0 :             (payload_num > cap_p->num_payloads)) {
    4419           0 :             if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4420           0 :                 CSFLogError(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);
    4423             :             }
    4424           0 :             sdp_p->conf_p->num_invalid_param++;
    4425           0 :             return (0);
    4426             :         } else {
    4427           0 :             *indicator = cap_p->payload_indicator[payload_num-1];
    4428           0 :             return (cap_p->payload_type[payload_num-1]);
    4429             :         }
    4430             :     }
    4431             : }
    4432             : 
    4433             : 
    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
    4444             :  */
    4445           0 : 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)
    4448             : {
    4449             :     sdp_attr_t  *attr_p;
    4450             :     sdp_mca_t   *cap_p;
    4451             : 
    4452           0 :     attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_X_CAP, inst_num);
    4453           0 :     if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
    4454           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4455           0 :             CSFLogError(logTag, "%s X-cap attribute, level %u instance %u "
    4456             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4457             :         }
    4458           0 :         sdp_p->conf_p->num_invalid_param++;
    4459           0 :         return (SDP_INVALID_PARAMETER);
    4460             :     }
    4461             : 
    4462           0 :     cap_p = attr_p->attr.cap_p;
    4463           0 :     cap_p->payload_indicator[cap_p->num_payloads] = indicator;
    4464           0 :     cap_p->payload_type[cap_p->num_payloads++] = payload_type;
    4465           0 :     return (SDP_SUCCESS);
    4466             : }
    4467             : 
    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.
    4477             :  */
    4478           0 : uint16_t sdp_attr_get_cdsc_first_cap_num(sdp_t *sdp_p, uint16_t level, uint16_t inst_num)
    4479             : {
    4480           0 :     uint16_t          cap_num=1;
    4481           0 :     uint16_t          attr_count=0;
    4482             :     sdp_attr_t  *attr_p;
    4483             :     sdp_mca_t   *mca_p;
    4484             : 
    4485           0 :     if (level == SDP_SESSION_LEVEL) {
    4486           0 :         for (attr_p = sdp_p->sess_attrs_p; attr_p != NULL;
    4487           0 :              attr_p = attr_p->next_p) {
    4488           0 :             if (attr_p->type == SDP_ATTR_CDSC) {
    4489           0 :                 attr_count++;
    4490           0 :                 if (attr_count == inst_num) {
    4491           0 :                     return (cap_num);
    4492             :                 } else {
    4493           0 :                     cap_num += attr_p->attr.cap_p->num_payloads;
    4494             :                 }
    4495             :             }
    4496             :         }
    4497             :     } else {  /* Capability is at a media level */
    4498           0 :         mca_p = sdp_find_media_level(sdp_p, level);
    4499           0 :         if (mca_p == NULL) {
    4500           0 :             sdp_p->conf_p->num_invalid_param++;
    4501           0 :             return (0);
    4502             :         }
    4503           0 :         for (attr_p = mca_p->media_attrs_p; attr_p != NULL;
    4504           0 :              attr_p = attr_p->next_p) {
    4505           0 :             if (attr_p->type == SDP_ATTR_CDSC) {
    4506           0 :                 attr_count++;
    4507           0 :                 if (attr_count == inst_num) {
    4508           0 :                     return (cap_num);
    4509             :                 } else {
    4510           0 :                     cap_num += attr_p->attr.cap_p->num_payloads;
    4511             :                 }
    4512             :             }
    4513             :         }
    4514             :     }  /* Attr is at a media level */
    4515             : 
    4516           0 :     if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4517           0 :         CSFLogError(logTag, "%s CDSC attribute, level %u instance %u "
    4518             :                   "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4519             :     }
    4520           0 :     sdp_p->conf_p->num_invalid_param++;
    4521           0 :     return (0);
    4522             : }
    4523             : 
    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.
    4533             :  */
    4534           0 : sdp_media_e sdp_attr_get_cdsc_media_type(sdp_t *sdp_p, uint16_t level,
    4535             :                                          uint16_t inst_num)
    4536             : {
    4537             :     sdp_attr_t  *attr_p;
    4538             :     sdp_mca_t   *cdsc_p;
    4539             : 
    4540           0 :     attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_CDSC, inst_num);
    4541           0 :     if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
    4542           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4543           0 :             CSFLogError(logTag, "%s CDSC attribute, level %u instance %u "
    4544             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4545             :         }
    4546           0 :         sdp_p->conf_p->num_invalid_param++;
    4547           0 :         return (SDP_MEDIA_INVALID);
    4548             :     } else {
    4549           0 :         cdsc_p = attr_p->attr.cap_p;
    4550           0 :         return (cdsc_p->media);
    4551             :     }
    4552             : }
    4553             : 
    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.
    4563             :  */
    4564           0 : sdp_transport_e sdp_attr_get_cdsc_transport_type(sdp_t *sdp_p, uint16_t level,
    4565             :                                                  uint16_t inst_num)
    4566             : {
    4567             :     sdp_attr_t  *attr_p;
    4568             :     sdp_mca_t   *cdsc_p;
    4569             : 
    4570           0 :     attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_CDSC,
    4571             :                            inst_num);
    4572           0 :     if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
    4573           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4574           0 :             CSFLogError(logTag, "%s CDSC attribute, level %u instance %u "
    4575             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4576             :         }
    4577           0 :         sdp_p->conf_p->num_invalid_param++;
    4578           0 :         return (SDP_TRANSPORT_INVALID);
    4579             :     } else {
    4580           0 :         cdsc_p = attr_p->attr.cap_p;
    4581           0 :         return (cdsc_p->transport);
    4582             :     }
    4583             : }
    4584             : 
    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.
    4597             :  */
    4598           0 : uint16_t sdp_attr_get_cdsc_num_payload_types (sdp_t *sdp_p, uint16_t level,
    4599             :                                          uint16_t inst_num)
    4600             : {
    4601             :     sdp_attr_t  *attr_p;
    4602             :     sdp_mca_t   *cdsc_p;
    4603             : 
    4604           0 :     attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_CDSC, inst_num);
    4605           0 :     if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
    4606           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4607           0 :             CSFLogError(logTag, "%s CDSC attribute, level %u instance %u "
    4608             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4609             :         }
    4610           0 :         sdp_p->conf_p->num_invalid_param++;
    4611           0 :         return (0);
    4612             :     } else {
    4613           0 :         cdsc_p = attr_p->attr.cap_p;
    4614           0 :         return (cdsc_p->num_payloads);
    4615             :     }
    4616             : }
    4617             : 
    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.
    4630             :  */
    4631           0 : 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)
    4634             : {
    4635             :     sdp_attr_t  *attr_p;
    4636             :     sdp_mca_t   *cdsc_p;
    4637             : 
    4638           0 :     attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_CDSC, inst_num);
    4639           0 :     if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
    4640           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4641           0 :             CSFLogError(logTag, "%s CDSC attribute, level %u instance %u "
    4642             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4643             :         }
    4644           0 :         sdp_p->conf_p->num_invalid_param++;
    4645           0 :         return (0);
    4646             :     } else {
    4647           0 :         cdsc_p = attr_p->attr.cap_p;
    4648           0 :         if ((payload_num < 1) ||
    4649           0 :             (payload_num > cdsc_p->num_payloads)) {
    4650           0 :             if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4651           0 :                 CSFLogError(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);
    4654             :             }
    4655           0 :             sdp_p->conf_p->num_invalid_param++;
    4656           0 :             return (0);
    4657             :         } else {
    4658           0 :             *indicator = cdsc_p->payload_indicator[payload_num-1];
    4659           0 :             return (cdsc_p->payload_type[payload_num-1]);
    4660             :         }
    4661             :     }
    4662             : }
    4663             : 
    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
    4674             :  */
    4675           0 : 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)
    4678             : {
    4679             :     sdp_attr_t  *attr_p;
    4680             :     sdp_mca_t   *cdsc_p;
    4681             : 
    4682           0 :     attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_CDSC, inst_num);
    4683           0 :     if ((attr_p == NULL) || (attr_p->attr.cap_p == NULL)) {
    4684           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4685           0 :             CSFLogError(logTag, "%s CDSC attribute, level %u instance %u "
    4686             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4687             :         }
    4688           0 :         sdp_p->conf_p->num_invalid_param++;
    4689           0 :         return (SDP_INVALID_PARAMETER);
    4690             :     }
    4691             : 
    4692           0 :     cdsc_p = attr_p->attr.cap_p;
    4693           0 :     cdsc_p->payload_indicator[cdsc_p->num_payloads] = indicator;
    4694           0 :     cdsc_p->payload_type[cdsc_p->num_payloads++] = payload_type;
    4695           0 :     return (SDP_SUCCESS);
    4696             : }
    4697             : 
    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
    4703             :  *
    4704             :  * Returns:     TRUE or FALSE. Returns TRUE if payload type is defined on the
    4705             :  *              media line, else returns FALSE
    4706             :  */
    4707             : 
    4708           0 : tinybool sdp_media_dynamic_payload_valid (sdp_t *sdp_p, uint16_t payload_type,
    4709             :                                           uint16_t m_line)
    4710             : {
    4711             :    uint16_t p_type,m_ptype;
    4712             :    ushort num_payload_types;
    4713             :    sdp_payload_ind_e ind;
    4714           0 :    tinybool payload_matches = FALSE;
    4715           0 :    tinybool result = TRUE;
    4716             : 
    4717           0 :    if ((payload_type < SDP_MIN_DYNAMIC_PAYLOAD) ||
    4718             :        (payload_type > SDP_MAX_DYNAMIC_PAYLOAD)) {
    4719           0 :        return FALSE;
    4720             :    }
    4721             : 
    4722           0 :    num_payload_types =
    4723           0 :        sdp_get_media_num_payload_types(sdp_p, m_line);
    4724             : 
    4725           0 :    for(p_type=1; p_type <=num_payload_types;p_type++){
    4726             : 
    4727           0 :        m_ptype = (uint16_t)sdp_get_media_payload_type(sdp_p,
    4728             :                                             m_line, p_type, &ind);
    4729           0 :        if (payload_type == m_ptype) {
    4730           0 :            payload_matches = TRUE;
    4731           0 :            break;
    4732             :        }
    4733             : 
    4734             :    }
    4735             : 
    4736           0 :    if (!payload_matches) {
    4737           0 :        return FALSE;
    4738             :    }
    4739             : 
    4740           0 :    return (result);
    4741             : 
    4742             : }
    4743             : 
    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.
    4754             :  */
    4755           0 : tinybool sdp_attr_get_rtr_confirm (sdp_t *sdp_p, uint16_t level,
    4756             :                                 uint8_t cap_num, uint16_t inst_num)
    4757             : {
    4758             :     sdp_attr_t  *attr_p;
    4759             : 
    4760           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_RTR, inst_num);
    4761           0 :     if (attr_p == NULL) {
    4762           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4763           0 :             CSFLogError(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);
    4766             :         }
    4767           0 :         sdp_p->conf_p->num_invalid_param++;
    4768           0 :         return (FALSE);
    4769             :     } else {
    4770           0 :         return (attr_p->attr.rtr.confirm);
    4771             :     }
    4772             : }
    4773             : 
    4774             : 
    4775             : 
    4776           0 : 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)
    4778             : {
    4779             :     sdp_attr_t  *attr_p;
    4780             : 
    4781           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    4782             :                            SDP_ATTR_DIRECTION, inst_num);
    4783           0 :     if (attr_p == NULL) {
    4784           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4785           0 :             CSFLogError(logTag, "%s Comediadir role attribute, level %u instance %u "
    4786             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4787             :         }
    4788           0 :         sdp_p->conf_p->num_invalid_param++;
    4789           0 :         return (SDP_MEDIADIR_ROLE_UNKNOWN);
    4790             :     } else {
    4791           0 :         return (attr_p->attr.comediadir.role);
    4792             :     }
    4793             : }
    4794             : 
    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.
    4805             :  */
    4806           0 : tinybool sdp_attr_get_silencesupp_enabled (sdp_t *sdp_p, uint16_t level,
    4807             :                                            uint8_t cap_num, uint16_t inst_num)
    4808             : {
    4809             :     sdp_attr_t  *attr_p;
    4810             : 
    4811           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    4812             :                            SDP_ATTR_SILENCESUPP, inst_num);
    4813           0 :     if (attr_p == NULL) {
    4814           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4815           0 :             CSFLogError(logTag, "%s silenceSuppEnable attribute, level %u instance %u "
    4816             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4817             :         }
    4818           0 :         sdp_p->conf_p->num_invalid_param++;
    4819           0 :         return (FALSE);
    4820             :     } else {
    4821           0 :         return (attr_p->attr.silencesupp.enabled);
    4822             :     }
    4823             : }
    4824             : 
    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
    4837             :  */
    4838           0 : 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)
    4841             : {
    4842             :     sdp_attr_t  *attr_p;
    4843             : 
    4844           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    4845             :                            SDP_ATTR_SILENCESUPP, inst_num);
    4846           0 :     if (attr_p == NULL) {
    4847           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4848           0 :             CSFLogError(logTag, "%s silenceTimer attribute, level %u instance %u "
    4849             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4850             :         }
    4851           0 :         sdp_p->conf_p->num_invalid_param++;
    4852           0 :         return (0);
    4853             :     } else {
    4854           0 :         *null_ind = attr_p->attr.silencesupp.timer_null;
    4855           0 :         return (attr_p->attr.silencesupp.timer);
    4856             :     }
    4857             : }
    4858             : 
    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.
    4871             :  */
    4872           0 : 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)
    4875             : {
    4876             :     sdp_attr_t  *attr_p;
    4877             : 
    4878           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    4879             :                            SDP_ATTR_SILENCESUPP, inst_num);
    4880           0 :     if (attr_p == NULL) {
    4881           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4882           0 :             CSFLogError(logTag, "%s silence suppPref attribute, level %u instance %u "
    4883             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4884             :         }
    4885           0 :         sdp_p->conf_p->num_invalid_param++;
    4886           0 :         return (SDP_SILENCESUPP_PREF_UNKNOWN);
    4887             :     } else {
    4888           0 :         return (attr_p->attr.silencesupp.pref);
    4889             :     }
    4890             : }
    4891             : 
    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.
    4903             :  */
    4904           0 : 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)
    4908             : {
    4909             :     sdp_attr_t  *attr_p;
    4910             : 
    4911           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    4912             :                            SDP_ATTR_SILENCESUPP, inst_num);
    4913           0 :     if (attr_p == NULL) {
    4914           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4915           0 :             CSFLogError(logTag, "%s silence sidUse attribute, level %u instance %u "
    4916             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4917             :         }
    4918           0 :         sdp_p->conf_p->num_invalid_param++;
    4919           0 :         return (SDP_SILENCESUPP_SIDUSE_UNKNOWN);
    4920             :     } else {
    4921           0 :         return (attr_p->attr.silencesupp.siduse);
    4922             :     }
    4923             : }
    4924             : 
    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
    4937             :  */
    4938           0 : 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)
    4941             : {
    4942             :     sdp_attr_t  *attr_p;
    4943             : 
    4944           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    4945             :                            SDP_ATTR_SILENCESUPP, inst_num);
    4946           0 :     if (attr_p == NULL) {
    4947           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4948           0 :             CSFLogError(logTag, "%s silence fxnslevel attribute, level %u instance %u "
    4949             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4950             :         }
    4951           0 :         sdp_p->conf_p->num_invalid_param++;
    4952           0 :         return (0);
    4953             :     } else {
    4954           0 :         *null_ind = attr_p->attr.silencesupp.fxnslevel_null;
    4955           0 :         return (attr_p->attr.silencesupp.fxnslevel);
    4956             :     }
    4957             : }
    4958             : 
    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.
    4969             :  */
    4970           0 : 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) {
    4975             : 
    4976             :     sdp_attr_t *attr_p;
    4977             : 
    4978           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_MPTIME, inst_num);
    4979           0 :     if (attr_p != NULL) {
    4980           0 :         return attr_p->attr.mptime.num_intervals;
    4981             :     }
    4982             : 
    4983           0 :     if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    4984           0 :         CSFLogError(logTag, "%s mptime attribute, level %u instance %u not found.",
    4985             :                   sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    4986             :     }
    4987           0 :     sdp_p->conf_p->num_invalid_param++;
    4988           0 :     return 0;
    4989             : }
    4990             : 
    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.
    5003             :  */
    5004           0 : 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) {
    5010             : 
    5011             :     sdp_attr_t *attr_p;
    5012             : 
    5013           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_MPTIME, inst_num);
    5014           0 :     if (attr_p == NULL) {
    5015           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5016           0 :             CSFLogError(logTag, "%s mptime attribute, level %u instance %u "
    5017             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5018             :         }
    5019           0 :         sdp_p->conf_p->num_invalid_param++;
    5020           0 :         return 0;
    5021             :     }
    5022             : 
    5023           0 :     if ((interval_num<1) || (interval_num>attr_p->attr.mptime.num_intervals)) {
    5024           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5025           0 :             CSFLogError(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);
    5028             :         }
    5029           0 :         sdp_p->conf_p->num_invalid_param++;
    5030           0 :         return 0;
    5031             :     }
    5032             : 
    5033           0 :     return attr_p->attr.mptime.intervals[interval_num-1];
    5034             : }
    5035             : 
    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
    5050             :  */
    5051           0 : 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) {
    5057             : 
    5058             :     uint16_t interval_num;
    5059             :     sdp_attr_t *attr_p;
    5060             : 
    5061           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num, SDP_ATTR_MPTIME, inst_num);
    5062           0 :     if (attr_p == NULL) {
    5063           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5064           0 :             CSFLogError(logTag, "%s mptime attribute, level %u instance %u "
    5065             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5066             :         }
    5067           0 :         sdp_p->conf_p->num_invalid_param++;
    5068           0 :         return SDP_INVALID_PARAMETER;
    5069             :     }
    5070             : 
    5071           0 :     interval_num = attr_p->attr.mptime.num_intervals;
    5072           0 :     if (interval_num>=SDP_MAX_PAYLOAD_TYPES) {
    5073           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5074           0 :             CSFLogError(logTag, "%s mptime attribute, level %u instance %u "
    5075             :                       "exceeds maximum length.",
    5076             :                       sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5077             :         }
    5078           0 :         sdp_p->conf_p->num_invalid_param++;
    5079           0 :         return SDP_INVALID_PARAMETER;
    5080             :     }
    5081             : 
    5082           0 :     attr_p->attr.mptime.intervals[interval_num] = mp_interval;
    5083           0 :     ++attr_p->attr.mptime.num_intervals;
    5084           0 :     return SDP_SUCCESS;
    5085             : }
    5086             : 
    5087             : 
    5088             : 
    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.
    5096             :  */
    5097           0 : sdp_group_attr_e sdp_get_group_attr (sdp_t *sdp_p, uint16_t level,
    5098             :                                      uint8_t cap_num, uint16_t inst_num)
    5099             : {
    5100             :     sdp_attr_t          *attr_p;
    5101             : 
    5102           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5103             :                            SDP_ATTR_GROUP, inst_num);
    5104           0 :     if (attr_p == NULL) {
    5105           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5106           0 :             CSFLogError(logTag, "%s Group (a= group line) attribute, level %u instance %u "
    5107             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5108             :         }
    5109           0 :         sdp_p->conf_p->num_invalid_param++;
    5110           0 :         return (SDP_GROUP_ATTR_UNSUPPORTED);
    5111             :     } else {
    5112           0 :        if (sdp_p->debug_flag[SDP_DEBUG_TRACE]) {
    5113           0 :            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) );
    5116             :         }
    5117           0 :         return (attr_p->attr.stream_data.group_attr);
    5118             :     }
    5119             : }
    5120             : 
    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.
    5126             :  */
    5127           0 : uint16_t sdp_get_group_num_id (sdp_t *sdp_p, uint16_t level,
    5128             :                           uint8_t cap_num, uint16_t inst_num)
    5129             : {
    5130             :     sdp_attr_t          *attr_p;
    5131             : 
    5132           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5133             :                            SDP_ATTR_GROUP, inst_num);
    5134           0 :     if (attr_p == NULL) {
    5135           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5136           0 :             CSFLogError(logTag, "%s a=group level attribute, level %u instance %u "
    5137             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5138             :         }
    5139           0 :         sdp_p->conf_p->num_invalid_param++;
    5140           0 :         return (0);
    5141             :     } else {
    5142           0 :         if (sdp_p->debug_flag[SDP_DEBUG_TRACE]) {
    5143           0 :             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);
    5146             :         }
    5147             :     }
    5148           0 :     return (attr_p->attr.stream_data.num_group_id);
    5149             : }
    5150             : 
    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
    5159             :  */
    5160           0 : 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)
    5162             : {
    5163             :     sdp_attr_t          *attr_p;
    5164             : 
    5165           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5166             :                            SDP_ATTR_GROUP, inst_num);
    5167           0 :     if (attr_p == NULL) {
    5168           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5169           0 :             CSFLogError(logTag, "%s a=group level attribute, level %u instance %u "
    5170             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5171             :         }
    5172           0 :         sdp_p->conf_p->num_invalid_param++;
    5173           0 :         return (NULL);
    5174             :     } else {
    5175           0 :         if (sdp_p->debug_flag[SDP_DEBUG_TRACE]) {
    5176           0 :             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);
    5179             :         }
    5180           0 :         if ((id_num < 1) || (id_num > attr_p->attr.stream_data.num_group_id)) {
    5181           0 :             return (NULL);
    5182             :         }
    5183             :     }
    5184           0 :     return (attr_p->attr.stream_data.group_ids[id_num-1]);
    5185             : }
    5186             : 
    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.
    5196             :  */
    5197           0 : const char* sdp_attr_get_x_sidin (sdp_t *sdp_p, uint16_t level,
    5198             :                                      uint8_t cap_num, uint16_t inst_num)
    5199             : {
    5200             :     sdp_attr_t          *attr_p;
    5201             : 
    5202           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5203             :                            SDP_ATTR_X_SIDIN, inst_num);
    5204           0 :     if (attr_p == NULL) {
    5205           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5206           0 :             CSFLogError(logTag, "%s X-sidin attribute, level %u instance %u "
    5207             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5208             :         }
    5209           0 :         sdp_p->conf_p->num_invalid_param++;
    5210           0 :         return (NULL);
    5211             :     } else {
    5212           0 :         if (sdp_p->debug_flag[SDP_DEBUG_TRACE]) {
    5213           0 :             SDP_PRINT("%s Stream X-sidin attr field is :%s ",
    5214             :                       sdp_p->debug_str,
    5215             :                       attr_p->attr.stream_data.x_sidin);
    5216             :         }
    5217           0 :         return (attr_p->attr.stream_data.x_sidin);
    5218             :     }
    5219             : }
    5220             : 
    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.
    5230             :  */
    5231           0 : const char* sdp_attr_get_x_sidout (sdp_t *sdp_p, uint16_t level,
    5232             :                                      uint8_t cap_num, uint16_t inst_num)
    5233             : {
    5234             :     sdp_attr_t          *attr_p;
    5235             : 
    5236           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5237             :                            SDP_ATTR_X_SIDOUT, inst_num);
    5238           0 :     if (attr_p == NULL) {
    5239           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5240           0 :             CSFLogError(logTag, "%s X-sidout attribute, level %u instance %u "
    5241             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5242             :         }
    5243           0 :         sdp_p->conf_p->num_invalid_param++;
    5244           0 :         return (NULL);
    5245             :     } else {
    5246           0 :         if (sdp_p->debug_flag[SDP_DEBUG_TRACE]) {
    5247           0 :             SDP_PRINT("%s Stream X-sidout attr field is :%s ",
    5248             :                       sdp_p->debug_str,
    5249             :                       attr_p->attr.stream_data.x_sidout);
    5250             :         }
    5251           0 :         return (attr_p->attr.stream_data.x_sidout);
    5252             :     }
    5253             : }
    5254             : 
    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.
    5264             :  */
    5265           0 : const char* sdp_attr_get_x_confid (sdp_t *sdp_p, uint16_t level,
    5266             :                                      uint8_t cap_num, uint16_t inst_num)
    5267             : {
    5268             :     sdp_attr_t          *attr_p;
    5269             : 
    5270           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5271             :                            SDP_ATTR_X_CONFID, inst_num);
    5272           0 :     if (attr_p == NULL) {
    5273           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5274           0 :             CSFLogError(logTag, "%s X-confid attribute, level %u instance %u "
    5275             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5276             :         }
    5277           0 :         sdp_p->conf_p->num_invalid_param++;
    5278           0 :         return (NULL);
    5279             :     } else {
    5280           0 :         if (sdp_p->debug_flag[SDP_DEBUG_TRACE]) {
    5281           0 :             SDP_PRINT("%s Stream X-confid attr field is :%s ",
    5282             :                       sdp_p->debug_str,
    5283             :                       attr_p->attr.stream_data.x_confid);
    5284             :         }
    5285           0 :         return (attr_p->attr.stream_data.x_confid);
    5286             :     }
    5287             : }
    5288             : 
    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)
    5295             :  */
    5296             : sdp_src_filter_mode_e
    5297           0 : sdp_get_source_filter_mode (sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
    5298             :                             uint16_t inst_num)
    5299             : {
    5300             :     sdp_attr_t *attr_p;
    5301             : 
    5302           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5303             :                            SDP_ATTR_SOURCE_FILTER, inst_num);
    5304           0 :     if (attr_p == NULL) {
    5305           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5306           0 :             CSFLogError(logTag, "%s Source filter attribute, level %u, "
    5307             :                       "instance %u not found", sdp_p->debug_str,
    5308             :                       (unsigned)level, (unsigned)inst_num);
    5309             :         }
    5310           0 :         sdp_p->conf_p->num_invalid_param++;
    5311           0 :         return (SDP_FILTER_MODE_NOT_PRESENT);
    5312             :     }
    5313           0 :     return (attr_p->attr.source_filter.mode);
    5314             : }
    5315             : 
    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
    5322             :  */
    5323             : sdp_result_e
    5324           0 : 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)
    5328             : {
    5329             :     sdp_attr_t *attr_p;
    5330             : 
    5331           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5332             :                            SDP_ATTR_SOURCE_FILTER, inst_num);
    5333           0 :     if (attr_p == NULL) {
    5334           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5335           0 :             CSFLogError(logTag, "%s Source filter attribute, level %u instance %u "
    5336             :                       "not found", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5337             :         }
    5338           0 :         sdp_p->conf_p->num_invalid_param++;
    5339           0 :         return (SDP_INVALID_PARAMETER);
    5340             :     }
    5341           0 :     if (nettype) {
    5342           0 :         *nettype = attr_p->attr.source_filter.nettype;
    5343             :     }
    5344           0 :     if (addrtype) {
    5345           0 :         *addrtype = attr_p->attr.source_filter.addrtype;
    5346             :     }
    5347           0 :     sstrncpy(dest_addr, attr_p->attr.source_filter.dest_addr,
    5348             :              SDP_MAX_STRING_LEN+1);
    5349             : 
    5350           0 :     return (SDP_SUCCESS);
    5351             : }
    5352             : 
    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
    5359             :  */
    5360             : 
    5361             : int32_t
    5362           0 : sdp_get_filter_source_address_count (sdp_t *sdp_p, uint16_t level,
    5363             :                                      uint8_t cap_num, uint16_t inst_num)
    5364             : {
    5365             :     sdp_attr_t *attr_p;
    5366             : 
    5367           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5368             :                            SDP_ATTR_SOURCE_FILTER, inst_num);
    5369           0 :     if (attr_p == NULL) {
    5370           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5371           0 :             CSFLogError(logTag, "%s Source filter attribute, level %u instance %u "
    5372             :                       "not found", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5373             :         }
    5374           0 :         sdp_p->conf_p->num_invalid_param++;
    5375           0 :         return (SDP_INVALID_VALUE);
    5376             :     }
    5377           0 :     return (attr_p->attr.source_filter.num_src_addr);
    5378             : }
    5379             : 
    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
    5390             :  */
    5391             : sdp_result_e
    5392           0 : 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)
    5395             : {
    5396             :     sdp_attr_t *attr_p;
    5397             : 
    5398           0 :     src_addr[0] = '\0';
    5399             : 
    5400           0 :     if (src_addr_id >= SDP_MAX_SRC_ADDR_LIST) {
    5401           0 :         return (SDP_INVALID_PARAMETER);
    5402             :     }
    5403           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5404             :                            SDP_ATTR_SOURCE_FILTER, inst_num);
    5405           0 :     if (attr_p == NULL) {
    5406           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5407           0 :             CSFLogError(logTag, "%s Source filter attribute, level %u instance %u "
    5408             :                       "not found", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5409             :         }
    5410           0 :         sdp_p->conf_p->num_invalid_param++;
    5411           0 :         return (SDP_INVALID_PARAMETER);
    5412             :     }
    5413           0 :     if (src_addr_id >= attr_p->attr.source_filter.num_src_addr) {
    5414           0 :         return (SDP_INVALID_PARAMETER);
    5415             :     }
    5416           0 :     sstrncpy(src_addr, attr_p->attr.source_filter.src_list[src_addr_id],
    5417             :              SDP_MAX_STRING_LEN+1);
    5418             : 
    5419           0 :     return (SDP_SUCCESS);
    5420             : }
    5421             : 
    5422             : sdp_rtcp_unicast_mode_e
    5423           0 : sdp_get_rtcp_unicast_mode(sdp_t *sdp_p, uint16_t level, uint8_t cap_num,
    5424             :                           uint16_t inst_num)
    5425             : {
    5426             :     sdp_attr_t *attr_p;
    5427             : 
    5428           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5429             :                            SDP_ATTR_RTCP_UNICAST, inst_num);
    5430           0 :     if (attr_p == NULL) {
    5431           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5432           0 :             CSFLogError(logTag, "%s RTCP Unicast attribute, level %u, "
    5433             :                       "instance %u not found", sdp_p->debug_str,
    5434             :                       (unsigned)level, (unsigned)inst_num);
    5435             :         }
    5436           0 :         sdp_p->conf_p->num_invalid_param++;
    5437           0 :         return (SDP_RTCP_UNICAST_MODE_NOT_PRESENT);
    5438             :     }
    5439           0 :     return ((sdp_rtcp_unicast_mode_e)attr_p->attr.u32_val);
    5440             : }
    5441             : 
    5442             : 
    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.
    5452             :  */
    5453             : 
    5454             : int32_t
    5455           0 : sdp_attr_get_sdescriptions_tag (sdp_t *sdp_p, uint16_t level,
    5456             :                                 uint8_t cap_num, uint16_t inst_num)
    5457             : {
    5458             :     sdp_attr_t  *attr_p;
    5459             : 
    5460           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5461             :                            SDP_ATTR_SDESCRIPTIONS, inst_num);
    5462             : 
    5463           0 :     if (attr_p == NULL) {
    5464           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5465           0 :             CSFLogError(logTag, "%s srtp attribute tag, level %u instance %u "
    5466             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5467             :         }
    5468           0 :         sdp_p->conf_p->num_invalid_param++;
    5469           0 :         return SDP_INVALID_VALUE;
    5470             :     } else {
    5471           0 :         return attr_p->attr.srtp_context.tag;
    5472             :     }
    5473             : }
    5474             : 
    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.
    5484             :  *
    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.
    5492             :  */
    5493             : 
    5494             : sdp_srtp_crypto_suite_t
    5495           0 : sdp_attr_get_sdescriptions_crypto_suite (sdp_t *sdp_p, uint16_t level,
    5496             :                                          uint8_t cap_num, uint16_t inst_num)
    5497             : {
    5498             :     sdp_attr_t  *attr_p;
    5499             : 
    5500             : 
    5501             :     /* Try version 2 first */
    5502           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5503             :                            SDP_ATTR_SRTP_CONTEXT, inst_num);
    5504             : 
    5505           0 :     if (attr_p == NULL) {
    5506             :         /* There's no version 2 so now try version 9 */
    5507           0 :         attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5508             :                                SDP_ATTR_SDESCRIPTIONS, inst_num);
    5509           0 :         if (attr_p == NULL) {
    5510           0 :             if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5511           0 :                 CSFLogError(logTag, "%s srtp attribute suite, level %u instance %u "
    5512             :                           "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5513             :             }
    5514           0 :             sdp_p->conf_p->num_invalid_param++;
    5515           0 :             return SDP_SRTP_UNKNOWN_CRYPTO_SUITE;
    5516             :         }
    5517             :     }
    5518             : 
    5519           0 :     return attr_p->attr.srtp_context.suite;
    5520             : 
    5521             : }
    5522             : 
    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.
    5532             :  *
    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
    5539             :  */
    5540             : 
    5541             : const char*
    5542           0 : sdp_attr_get_sdescriptions_key (sdp_t *sdp_p, uint16_t level,
    5543             :                                 uint8_t cap_num, uint16_t inst_num)
    5544             : {
    5545             :     sdp_attr_t  *attr_p;
    5546             : 
    5547             :     /* Try version 2 first */
    5548           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5549             :                            SDP_ATTR_SRTP_CONTEXT, inst_num);
    5550             : 
    5551           0 :     if (attr_p == NULL) {
    5552             :         /* Couldn't find version 2 now try version 9 */
    5553           0 :         attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5554             :                                SDP_ATTR_SDESCRIPTIONS, inst_num);
    5555             : 
    5556           0 :         if (attr_p == NULL) {
    5557           0 :             if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5558           0 :                 CSFLogError(logTag, "%s srtp attribute key, level %u instance %u "
    5559             :                           "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5560             :             }
    5561           0 :             sdp_p->conf_p->num_invalid_param++;
    5562           0 :             return NULL;
    5563             :         }
    5564             :     }
    5565             : 
    5566           0 :     return (char*)attr_p->attr.srtp_context.master_key;
    5567             : }
    5568             : 
    5569             : 
    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.
    5579             :  *
    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
    5586             :  */
    5587             : 
    5588             : const char*
    5589           0 : sdp_attr_get_sdescriptions_salt (sdp_t *sdp_p, uint16_t level,
    5590             :                                  uint8_t cap_num, uint16_t inst_num)
    5591             : {
    5592             :     sdp_attr_t  *attr_p;
    5593             : 
    5594             :     /* Try version 2 first */
    5595           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5596             :                            SDP_ATTR_SRTP_CONTEXT, inst_num);
    5597             : 
    5598           0 :     if (attr_p == NULL) {
    5599             :         /* Couldn't find version 2 now try version 9 */
    5600           0 :         attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5601             :                                SDP_ATTR_SDESCRIPTIONS, inst_num);
    5602             : 
    5603           0 :         if (attr_p == NULL) {
    5604           0 :             if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5605           0 :                 CSFLogError(logTag, "%s srtp attribute salt, level %u instance %u "
    5606             :                           "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5607             :             }
    5608           0 :             sdp_p->conf_p->num_invalid_param++;
    5609           0 :             return NULL;
    5610             :         }
    5611             :     }
    5612             : 
    5613           0 :     return (char*) attr_p->attr.srtp_context.master_salt;
    5614             : 
    5615             : }
    5616             : 
    5617             : 
    5618             : 
    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.
    5628             :  *
    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
    5635             :  */
    5636             : 
    5637             : const char*
    5638           0 : sdp_attr_get_sdescriptions_lifetime (sdp_t *sdp_p, uint16_t level,
    5639             :                                      uint8_t cap_num, uint16_t inst_num)
    5640             : {
    5641             :     sdp_attr_t  *attr_p;
    5642             : 
    5643             :     /* Try version 2 first. */
    5644           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5645             :                            SDP_ATTR_SRTP_CONTEXT, inst_num);
    5646             : 
    5647           0 :     if (attr_p == NULL) {
    5648             :         /* Couldn't find version 2 now try version 9 */
    5649           0 :         attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5650             :                                SDP_ATTR_SDESCRIPTIONS, inst_num);
    5651             : 
    5652           0 :         if (attr_p == NULL) {
    5653           0 :             if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5654           0 :                 CSFLogError(logTag, "%s srtp attribute lifetime, level %u instance %u "
    5655             :                           "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5656             :             }
    5657           0 :             sdp_p->conf_p->num_invalid_param++;
    5658           0 :             return NULL;
    5659             :         }
    5660             :     }
    5661             : 
    5662           0 :     return (char*)attr_p->attr.srtp_context.master_key_lifetime;
    5663             : 
    5664             : }
    5665             : 
    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.
    5675             :  *
    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.
    5687             :  */
    5688             : 
    5689             : sdp_result_e
    5690           0 : 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)
    5694             : {
    5695             :     sdp_attr_t  *attr_p;
    5696             : 
    5697           0 :     *mki_value = NULL;
    5698           0 :     *mki_length = 0;
    5699             : 
    5700             :     /* Try version 2 first */
    5701           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5702             :                            SDP_ATTR_SRTP_CONTEXT, inst_num);
    5703             : 
    5704           0 :     if (attr_p == NULL) {
    5705             :         /* Couldn't find version 2 now try version 9 */
    5706           0 :         attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5707             :                                SDP_ATTR_SDESCRIPTIONS, inst_num);
    5708           0 :         if (attr_p == NULL) {
    5709           0 :             if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5710           0 :                 CSFLogError(logTag, "%s srtp attribute MKI, level %u instance %u "
    5711             :                           "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5712             :             }
    5713           0 :             sdp_p->conf_p->num_invalid_param++;
    5714           0 :             return SDP_INVALID_PARAMETER;
    5715             :         }
    5716             :     }
    5717             : 
    5718           0 :     *mki_value = (char*)attr_p->attr.srtp_context.mki;
    5719           0 :     *mki_length = attr_p->attr.srtp_context.mki_size_bytes;
    5720           0 :     return SDP_SUCCESS;
    5721             : 
    5722             : }
    5723             : 
    5724             : 
    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.
    5733             :  *
    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.
    5743             :  */
    5744             : 
    5745             : const char*
    5746           0 : sdp_attr_get_sdescriptions_session_params (sdp_t *sdp_p, uint16_t level,
    5747             :                                            uint8_t cap_num, uint16_t inst_num)
    5748             : {
    5749             :     sdp_attr_t  *attr_p;
    5750             : 
    5751             :     /* Try version 2 first */
    5752           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5753             :                            SDP_ATTR_SRTP_CONTEXT, inst_num);
    5754             : 
    5755           0 :     if (attr_p == NULL) {
    5756             :         /* Couldn't find version 2 try version 9 */
    5757           0 :         attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5758             :                            SDP_ATTR_SDESCRIPTIONS, inst_num);
    5759           0 :         if (attr_p == NULL) {
    5760           0 :             if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5761           0 :                 CSFLogError(logTag, "%s srtp attribute session params, level %u instance %u "
    5762             :                           "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5763             :             }
    5764           0 :             sdp_p->conf_p->num_invalid_param++;
    5765           0 :             return NULL;
    5766             :         }
    5767             :     }
    5768             : 
    5769           0 :     return attr_p->attr.srtp_context.session_parameters;
    5770             : }
    5771             : 
    5772             : 
    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.
    5781             :  *
    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.
    5789             :  */
    5790             : 
    5791             : unsigned char
    5792           0 : sdp_attr_get_sdescriptions_key_size (sdp_t *sdp_p,
    5793             :                                      uint16_t level,
    5794             :                                      uint8_t cap_num,
    5795             :                                      uint16_t inst_num)
    5796             : {
    5797             : 
    5798             :     sdp_attr_t  *attr_p;
    5799             : 
    5800             :     /* Try version 2 first */
    5801           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5802             :                            SDP_ATTR_SRTP_CONTEXT, inst_num);
    5803             : 
    5804           0 :     if (attr_p == NULL) {
    5805             :         /* Couldn't find version 2 now try version 9 */
    5806           0 :         attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5807             :                                SDP_ATTR_SDESCRIPTIONS, inst_num);
    5808           0 :         if (attr_p == NULL) {
    5809           0 :             if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5810           0 :                 CSFLogError(logTag, "%s srtp attribute MKI, level %u instance %u "
    5811             :                           "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5812             :             }
    5813           0 :             sdp_p->conf_p->num_invalid_param++;
    5814           0 :             return SDP_SDESCRIPTIONS_KEY_SIZE_UNKNOWN;
    5815             :         }
    5816             :     }
    5817             : 
    5818           0 :     return attr_p->attr.srtp_context.master_key_size_bytes;
    5819             : 
    5820             : }
    5821             : 
    5822             : 
    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.
    5831             :  *
    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.
    5839             :  */
    5840             : 
    5841             : unsigned char
    5842           0 : sdp_attr_get_sdescriptions_salt_size (sdp_t *sdp_p,
    5843             :                                       uint16_t level,
    5844             :                                       uint8_t cap_num,
    5845             :                                       uint16_t inst_num)
    5846             : {
    5847             : 
    5848             :     sdp_attr_t  *attr_p;
    5849             : 
    5850             :     /* Try version 2 first */
    5851           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5852             :                            SDP_ATTR_SRTP_CONTEXT, inst_num);
    5853             : 
    5854           0 :     if (attr_p == NULL) {
    5855             :         /* Couldn't find version 2 now try version 9 */
    5856           0 :         attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5857             :                                SDP_ATTR_SDESCRIPTIONS, inst_num);
    5858           0 :         if (attr_p == NULL) {
    5859           0 :             if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5860           0 :                 CSFLogError(logTag, "%s srtp attribute MKI, level %u instance %u "
    5861             :                           "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5862             :             }
    5863           0 :             sdp_p->conf_p->num_invalid_param++;
    5864           0 :             return SDP_SDESCRIPTIONS_KEY_SIZE_UNKNOWN;
    5865             :         }
    5866             :     }
    5867             : 
    5868           0 :     return attr_p->attr.srtp_context.master_salt_size_bytes;
    5869             : 
    5870             : }
    5871             : 
    5872             : 
    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.
    5882             :  *
    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.
    5890             :  */
    5891             : 
    5892             : unsigned long
    5893           0 : 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)
    5897             : {
    5898             : 
    5899             : 
    5900             :     sdp_attr_t  *attr_p;
    5901             : 
    5902             :     /* Try version 2 first */
    5903           0 :     attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5904             :                            SDP_ATTR_SRTP_CONTEXT, inst_num);
    5905             : 
    5906           0 :     if (attr_p == NULL) {
    5907             :         /* Couldn't find version 2 now try version 9 */
    5908           0 :         attr_p = sdp_find_attr(sdp_p, level, cap_num,
    5909             :                                SDP_ATTR_SDESCRIPTIONS, inst_num);
    5910           0 :         if (attr_p == NULL) {
    5911           0 :             if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5912           0 :                 CSFLogError(logTag, "%s srtp attribute MKI, level %u instance %u "
    5913             :                           "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    5914             :             }
    5915           0 :             sdp_p->conf_p->num_invalid_param++;
    5916           0 :             return SDP_SRTP_CRYPTO_SELECTION_FLAGS_UNKNOWN;
    5917             :         }
    5918             :     }
    5919             : 
    5920           0 :     return attr_p->attr.srtp_context.selection_flags;
    5921             : 
    5922             : }
    5923             : 
    5924             : 
    5925             : 
    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.
    5935             :  */
    5936             : 
    5937             : sdp_attr_t *
    5938           0 : 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)
    5943             : {
    5944           0 :     uint16_t          attr_count=0;
    5945             :     sdp_mca_t   *mca_p;
    5946             :     sdp_attr_t  *attr_p;
    5947             : 
    5948           0 :     mca_p = sdp_find_media_level(sdp_p, level);
    5949           0 :     if (!mca_p) {
    5950           0 :         return (NULL);
    5951             :     }
    5952           0 :     for (attr_p = mca_p->media_attrs_p; attr_p; attr_p = attr_p->next_p) {
    5953           0 :         if (attr_p->type == SDP_ATTR_RTCP_FB &&
    5954           0 :             (attr_p->attr.rtcp_fb.payload_num == payload_type ||
    5955           0 :              attr_p->attr.rtcp_fb.payload_num == SDP_ALL_PAYLOADS) &&
    5956           0 :             attr_p->attr.rtcp_fb.feedback_type == fb_type) {
    5957           0 :             attr_count++;
    5958           0 :             if (attr_count == inst_num) {
    5959           0 :                 return (attr_p);
    5960             :             }
    5961             :         }
    5962             :     }
    5963           0 :     return NULL;
    5964             : }
    5965             : 
    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)
    5973             :  */
    5974             : sdp_rtcp_fb_ack_type_e
    5975           0 : sdp_attr_get_rtcp_fb_ack(sdp_t *sdp_p, uint16_t level, uint16_t payload_type, uint16_t inst)
    5976             : {
    5977             :     sdp_attr_t  *attr_p;
    5978             : 
    5979           0 :     attr_p = sdp_find_rtcp_fb_attr(sdp_p, level, payload_type,
    5980             :                                    SDP_RTCP_FB_ACK, inst);
    5981           0 :     if (!attr_p) {
    5982           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    5983           0 :             CSFLogError(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);
    5986             :         }
    5987           0 :         sdp_p->conf_p->num_invalid_param++;
    5988           0 :         return SDP_RTCP_FB_ACK_NOT_FOUND;
    5989             :     }
    5990           0 :     return (attr_p->attr.rtcp_fb.param.ack);
    5991             : }
    5992             : 
    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)
    6000             :  */
    6001             : sdp_rtcp_fb_nack_type_e
    6002           0 : sdp_attr_get_rtcp_fb_nack(sdp_t *sdp_p, uint16_t level, uint16_t payload_type, uint16_t inst)
    6003             : {
    6004             :     sdp_attr_t  *attr_p;
    6005             : 
    6006           0 :     attr_p = sdp_find_rtcp_fb_attr(sdp_p, level, payload_type,
    6007             :                                    SDP_RTCP_FB_NACK, inst);
    6008           0 :     if (!attr_p) {
    6009           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    6010           0 :             CSFLogError(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);
    6013             :         }
    6014           0 :         sdp_p->conf_p->num_invalid_param++;
    6015           0 :         return SDP_RTCP_FB_NACK_NOT_FOUND;
    6016             :     }
    6017           0 :     return (attr_p->attr.rtcp_fb.param.nack);
    6018             : }
    6019             : 
    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)
    6027             :  */
    6028             : uint32_t
    6029           0 : sdp_attr_get_rtcp_fb_trr_int(sdp_t *sdp_p, uint16_t level,
    6030             :                              uint16_t payload_type, uint16_t inst)
    6031             : {
    6032             :     sdp_attr_t  *attr_p;
    6033             : 
    6034           0 :     attr_p = sdp_find_rtcp_fb_attr(sdp_p, level, payload_type,
    6035             :                                    SDP_RTCP_FB_TRR_INT, inst);
    6036           0 :     if (!attr_p) {
    6037           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    6038           0 :             CSFLogError(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);
    6041             :         }
    6042           0 :         sdp_p->conf_p->num_invalid_param++;
    6043           0 :         return 0xFFFFFFFF;
    6044             :     }
    6045           0 :     return (attr_p->attr.rtcp_fb.param.trr_int);
    6046             : }
    6047             : 
    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
    6054             :  */
    6055             : tinybool
    6056           0 : sdp_attr_get_rtcp_fb_remb_enabled(sdp_t *sdp_p,
    6057             :                                   uint16_t level,
    6058             :                                   uint16_t payload_type)
    6059             : {
    6060             :     sdp_attr_t  *attr_p;
    6061             : 
    6062           0 :     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           0 :     return (attr_p? TRUE : FALSE); // either exists or not
    6066             : }
    6067             : 
    6068             : /* Function:    sdp_attr_get_rtcp_fb_ccm
    6069             :  * Description: Returns the value of the rtcp-fb:...ccm attribute
    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             :  *              inst_num    The attribute instance number to check.
    6074             :  * Returns:     CCM type (SDP_RTCP_FB_CCM_NOT_FOUND if not present)
    6075             :  */
    6076             : sdp_rtcp_fb_ccm_type_e
    6077           0 : sdp_attr_get_rtcp_fb_ccm(sdp_t *sdp_p, uint16_t level, uint16_t payload_type, uint16_t inst)
    6078             : {
    6079             :     sdp_attr_t  *attr_p;
    6080             : 
    6081           0 :     attr_p = sdp_find_rtcp_fb_attr(sdp_p, level, payload_type,
    6082             :                                    SDP_RTCP_FB_CCM, inst);
    6083           0 :     if (!attr_p) {
    6084           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    6085           0 :             CSFLogError(logTag, "%s rtcp-fb attribute, level %u, pt %u, "
    6086             :                       "instance %u not found.", sdp_p->debug_str, (unsigned)level,
    6087             :                       (unsigned)payload_type, (unsigned)inst);
    6088             :         }
    6089           0 :         sdp_p->conf_p->num_invalid_param++;
    6090           0 :         return SDP_RTCP_FB_CCM_NOT_FOUND;
    6091             :     }
    6092           0 :     return (attr_p->attr.rtcp_fb.param.ccm);
    6093             : }
    6094             : 
    6095             : /* Function:    sdp_attr_set_rtcp_fb_ack
    6096             :  * Description: Sets the value of an rtcp-fb:...ack attribute
    6097             :  * Parameters:  sdp_p        The SDP handle returned by sdp_init_description.
    6098             :  *              level          The level to set the attribute.
    6099             :  *              payload_type   The value to set the payload type to for
    6100             :  *                             this attribute. Can be SDP_ALL_PAYLOADS.
    6101             :  *              inst_num       The attribute instance number to check.
    6102             :  *              type           The ack type to indicate
    6103             :  * Returns:     SDP_SUCCESS            Attribute param was set successfully.
    6104             :  *              SDP_INVALID_PARAMETER  Specified attribute is not defined.
    6105             :  */
    6106             : sdp_result_e
    6107           0 : sdp_attr_set_rtcp_fb_ack(sdp_t *sdp_p, uint16_t level, uint16_t payload_type, uint16_t inst,
    6108             :                          sdp_rtcp_fb_ack_type_e type)
    6109             : {
    6110             :     sdp_attr_t  *attr_p;
    6111             : 
    6112           0 :     attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_RTCP_FB, inst);
    6113           0 :     if (!attr_p) {
    6114           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    6115           0 :             CSFLogError(logTag, "%s rtcp_fb ack attribute, level %u "
    6116             :                       "instance %u not found.", sdp_p->debug_str, (unsigned)level,
    6117             :                       (unsigned)inst);
    6118             :         }
    6119           0 :         sdp_p->conf_p->num_invalid_param++;
    6120           0 :         return (SDP_INVALID_PARAMETER);
    6121             :     }
    6122             : 
    6123           0 :     attr_p->attr.rtcp_fb.payload_num = payload_type;
    6124           0 :     attr_p->attr.rtcp_fb.feedback_type = SDP_RTCP_FB_ACK;
    6125           0 :     attr_p->attr.rtcp_fb.param.ack = type;
    6126           0 :     attr_p->attr.rtcp_fb.extra[0] = '\0';
    6127           0 :     return (SDP_SUCCESS);
    6128             : }
    6129             : 
    6130             : 
    6131             : /* Function:    sdp_attr_set_rtcp_fb_nack
    6132             :  * Description: Sets the value of an rtcp-fb:...nack attribute
    6133             :  * Parameters:  sdp_p        The SDP handle returned by sdp_init_description.
    6134             :  *              level          The level to set the attribute.
    6135             :  *              payload_type   The value to set the payload type to for
    6136             :  *                             this attribute. Can be SDP_ALL_PAYLOADS.
    6137             :  *              inst_num       The attribute instance number to check.
    6138             :  *              type           The nack type to indicate
    6139             :  * Returns:     SDP_SUCCESS            Attribute param was set successfully.
    6140             :  *              SDP_INVALID_PARAMETER  Specified attribute is not defined.
    6141             :  */
    6142             : sdp_result_e
    6143           0 : sdp_attr_set_rtcp_fb_nack(sdp_t *sdp_p, uint16_t level, uint16_t payload_type, uint16_t inst,
    6144             :                           sdp_rtcp_fb_nack_type_e type)
    6145             : {
    6146             :     sdp_attr_t  *attr_p;
    6147             : 
    6148           0 :     attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_RTCP_FB, inst);
    6149           0 :     if (!attr_p) {
    6150           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    6151           0 :             CSFLogError(logTag, "%s rtcp_fb nack attribute, level %u "
    6152             :                       "instance %u not found.", sdp_p->debug_str, (unsigned)level,
    6153             :                       (unsigned)inst);
    6154             :         }
    6155           0 :         sdp_p->conf_p->num_invalid_param++;
    6156           0 :         return (SDP_INVALID_PARAMETER);
    6157             :     }
    6158             : 
    6159           0 :     attr_p->attr.rtcp_fb.payload_num = payload_type;
    6160           0 :     attr_p->attr.rtcp_fb.feedback_type = SDP_RTCP_FB_NACK;
    6161           0 :     attr_p->attr.rtcp_fb.param.nack = type;
    6162           0 :     attr_p->attr.rtcp_fb.extra[0] = '\0';
    6163           0 :     return (SDP_SUCCESS);
    6164             : }
    6165             : 
    6166             : /* Function:    sdp_attr_set_rtcp_fb_trr_int
    6167             :  * Description: Sets the value of an rtcp-fb:...trr-int attribute
    6168             :  * Parameters:  sdp_p        The SDP handle returned by sdp_init_description.
    6169             :  *              level          The level to set the attribute.
    6170             :  *              payload_type   The value to set the payload type to for
    6171             :  *                             this attribute. Can be SDP_ALL_PAYLOADS.
    6172             :  *              inst_num       The attribute instance number to check.
    6173             :  *              interval       The interval time to indicate
    6174             :  * Returns:     SDP_SUCCESS            Attribute param was set successfully.
    6175             :  *              SDP_INVALID_PARAMETER  Specified attribute is not defined.
    6176             :  */
    6177             : sdp_result_e
    6178           0 : sdp_attr_set_rtcp_fb_trr_int(sdp_t *sdp_p, uint16_t level, uint16_t payload_type,
    6179             :                              uint16_t inst, uint32_t interval)
    6180             : {
    6181             :     sdp_attr_t  *attr_p;
    6182             : 
    6183           0 :     attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_RTCP_FB, inst);
    6184           0 :     if (!attr_p) {
    6185           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    6186           0 :             CSFLogError(logTag, "%s rtcp_fb trr-int attribute, level %u "
    6187             :                       "instance %u not found.", sdp_p->debug_str, (unsigned)level,
    6188             :                       (unsigned)inst);
    6189             :         }
    6190           0 :         sdp_p->conf_p->num_invalid_param++;
    6191           0 :         return (SDP_INVALID_PARAMETER);
    6192             :     }
    6193             : 
    6194           0 :     attr_p->attr.rtcp_fb.payload_num = payload_type;
    6195           0 :     attr_p->attr.rtcp_fb.feedback_type = SDP_RTCP_FB_TRR_INT;
    6196           0 :     attr_p->attr.rtcp_fb.param.trr_int = interval;
    6197           0 :     attr_p->attr.rtcp_fb.extra[0] = '\0';
    6198           0 :     return (SDP_SUCCESS);
    6199             : }
    6200             : 
    6201             : /* Function:    sdp_attr_set_rtcp_fb_remb
    6202             :  * Description: Sets the value of an rtcp-fb:...goog-remb attribute
    6203             :  * Parameters:  sdp_p        The SDP handle returned by sdp_init_description.
    6204             :  *              level          The level to set the attribute.
    6205             :  *              payload_type   The value to set the payload type to for
    6206             :  *                             this attribute. Can be SDP_ALL_PAYLOADS.
    6207             :  *              inst_num       The attribute instance number to check.
    6208             :  * Returns:     SDP_SUCCESS            Attribute param was set successfully.
    6209             :  *              SDP_INVALID_PARAMETER  Specified attribute is not defined.
    6210             :  */
    6211             : sdp_result_e
    6212           0 : sdp_attr_set_rtcp_fb_remb(sdp_t *sdp_p, uint16_t level, uint16_t payload_type,
    6213             :                           uint16_t inst)
    6214             : {
    6215             :     sdp_attr_t  *attr_p;
    6216             : 
    6217           0 :     attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_RTCP_FB, inst);
    6218           0 :     if (!attr_p) {
    6219           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    6220           0 :             CSFLogError(logTag, "%s rtcp_fb goog-remb attribute, level %u "
    6221             :                       "instance %u not found.", sdp_p->debug_str, (unsigned)level,
    6222             :                       (unsigned)inst);
    6223             :         }
    6224           0 :         sdp_p->conf_p->num_invalid_param++;
    6225           0 :         return (SDP_INVALID_PARAMETER);
    6226             :     }
    6227             : 
    6228           0 :     attr_p->attr.rtcp_fb.payload_num = payload_type;
    6229           0 :     attr_p->attr.rtcp_fb.feedback_type = SDP_RTCP_FB_REMB;
    6230           0 :     return (SDP_SUCCESS);
    6231             : }
    6232             : 
    6233             : /* Function:    sdp_attr_set_rtcp_fb_ccm
    6234             :  * Description: Sets the value of an rtcp-fb:...ccm attribute
    6235             :  * Parameters:  sdp_p        The SDP handle returned by sdp_init_description.
    6236             :  *              level          The level to set the attribute.
    6237             :  *              payload_type   The value to set the payload type to for
    6238             :  *                             this attribute. Can be SDP_ALL_PAYLOADS.
    6239             :  *              inst_num       The attribute instance number to check.
    6240             :  *              type           The ccm type to indicate
    6241             :  * Returns:     SDP_SUCCESS            Attribute param was set successfully.
    6242             :  *              SDP_INVALID_PARAMETER  Specified attribute is not defined.
    6243             :  */
    6244             : sdp_result_e
    6245           0 : sdp_attr_set_rtcp_fb_ccm(sdp_t *sdp_p, uint16_t level, uint16_t payload_type, uint16_t inst,
    6246             :                          sdp_rtcp_fb_ccm_type_e type)
    6247             : {
    6248             :     sdp_attr_t  *attr_p;
    6249             : 
    6250           0 :     attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_RTCP_FB, inst);
    6251           0 :     if (!attr_p) {
    6252           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    6253           0 :             CSFLogError(logTag, "%s rtcp_fb ccm attribute, level %u "
    6254             :                       "instance %u not found.", sdp_p->debug_str, (unsigned)level,
    6255             :                       (unsigned)inst);
    6256             :         }
    6257           0 :         sdp_p->conf_p->num_invalid_param++;
    6258           0 :         return (SDP_INVALID_PARAMETER);
    6259             :     }
    6260           0 :     attr_p->attr.rtcp_fb.payload_num = payload_type;
    6261           0 :     attr_p->attr.rtcp_fb.feedback_type = SDP_RTCP_FB_CCM;
    6262           0 :     attr_p->attr.rtcp_fb.param.ccm = type;
    6263           0 :     attr_p->attr.rtcp_fb.extra[0] = '\0';
    6264           0 :     return (SDP_SUCCESS);
    6265             : }
    6266             : 
    6267             : /* Function:    sdp_attr_get_extmap_uri
    6268             :  * Description: Returns a pointer to the value of the encoding name
    6269             :  *              parameter specified for the given attribute.  Value is
    6270             :  *              returned as a const ptr and so cannot be modified by the
    6271             :  *              application.  If the given attribute is not defined, NULL
    6272             :  *              will be returned.
    6273             :  * Parameters:  sdp_p     The SDP handle returned by sdp_init_description.
    6274             :  *              level       The level to check for the attribute.
    6275             :  *              inst_num    The attribute instance number to check.
    6276             :  * Returns:     Codec value or SDP_CODEC_INVALID.
    6277             :  */
    6278           0 : const char *sdp_attr_get_extmap_uri(sdp_t *sdp_p, uint16_t level,
    6279             :                                     uint16_t inst_num)
    6280             : {
    6281             :     sdp_attr_t  *attr_p;
    6282             : 
    6283           0 :     attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_EXTMAP, inst_num);
    6284           0 :     if (attr_p == NULL) {
    6285           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    6286           0 :             CSFLogError(logTag, "%s extmap attribute, level %u instance %u "
    6287             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    6288             :         }
    6289           0 :         sdp_p->conf_p->num_invalid_param++;
    6290           0 :         return (NULL);
    6291             :     } else {
    6292           0 :         return (attr_p->attr.extmap.uri);
    6293             :     }
    6294             : }
    6295             : 
    6296             : /* Function:    sdp_attr_get_extmap_id
    6297             :  * Description: Returns the id of the  extmap specified for the given
    6298             :  *              attribute.  If the given attribute is not defined, 0xFFFF
    6299             :  *              will be returned.
    6300             :  * Parameters:  sdp_p     The SDP handle returned by sdp_init_description.
    6301             :  *              level       The level to check for the attribute.
    6302             :  *              inst_num    The attribute instance number to check.
    6303             :  * Returns:     The id of the extmap attribute.
    6304             :  */
    6305           0 : uint16_t sdp_attr_get_extmap_id(sdp_t *sdp_p, uint16_t level,
    6306             :                            uint16_t inst_num)
    6307             : {
    6308             :     sdp_attr_t  *attr_p;
    6309             : 
    6310           0 :     attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_EXTMAP, inst_num);
    6311           0 :     if (attr_p == NULL) {
    6312           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    6313           0 :             CSFLogError(logTag, "%s extmap attribute, level %u instance %u "
    6314             :                       "not found.", sdp_p->debug_str, (unsigned)level, (unsigned)inst_num);
    6315             :         }
    6316           0 :         sdp_p->conf_p->num_invalid_param++;
    6317           0 :         return 0xFFFF;
    6318             :     } else {
    6319           0 :         return (attr_p->attr.extmap.id);
    6320             :     }
    6321             : }
    6322             : 
    6323             : /* Function:    sdp_attr_set_extmap
    6324             :  * Description: Sets the value of an rtcp-fb:...ccm attribute
    6325             :  * Parameters:  sdp_p        The SDP handle returned by sdp_init_description.
    6326             :  *              level          The level to set the attribute.
    6327             :  *              id             The id to set the attribute.
    6328             :  *              uri            The uri to set the attribute.
    6329             :  *              inst           The attribute instance number to check.
    6330             :  * Returns:     SDP_SUCCESS            Attribute param was set successfully.
    6331             :  *              SDP_INVALID_PARAMETER  Specified attribute is not defined.
    6332             :  */
    6333             : sdp_result_e
    6334           0 : sdp_attr_set_extmap(sdp_t *sdp_p, uint16_t level, uint16_t id, const char* uri, uint16_t inst)
    6335             : {
    6336             :     sdp_attr_t  *attr_p;
    6337             : 
    6338           0 :     attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_EXTMAP, inst);
    6339           0 :     if (!attr_p) {
    6340           0 :         if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
    6341           0 :             CSFLogError(logTag, "%s extmap attribute, level %u "
    6342             :                       "instance %u not found.", sdp_p->debug_str, (unsigned)level,
    6343             :                       (unsigned)inst);
    6344             :         }
    6345           0 :         sdp_p->conf_p->num_invalid_param++;
    6346           0 :         return (SDP_INVALID_PARAMETER);
    6347             :     }
    6348             : 
    6349           0 :     attr_p->attr.extmap.id = id;
    6350           0 :     sstrncpy(attr_p->attr.extmap.uri, uri, SDP_MAX_STRING_LEN+1);
    6351           0 :     return (SDP_SUCCESS);
    6352             : }
    6353             : 
    6354           0 : const char *sdp_attr_get_msid_identifier(sdp_t *sdp_p, uint16_t level,
    6355             :                                        uint8_t cap_num, uint16_t inst)
    6356             : {
    6357           0 :     sdp_attr_t  *attr_p = sdp_find_attr(sdp_p, level, cap_num,
    6358             :                                         SDP_ATTR_MSID, inst);
    6359           0 :     if (!attr_p) {
    6360           0 :       return NULL;
    6361             :     }
    6362           0 :     return attr_p->attr.msid.identifier;
    6363             : }
    6364             : 
    6365           0 : const char *sdp_attr_get_msid_appdata(sdp_t *sdp_p, uint16_t level,
    6366             :                                       uint8_t cap_num, uint16_t inst)
    6367             : {
    6368           0 :     sdp_attr_t  *attr_p = sdp_find_attr(sdp_p, level, cap_num,
    6369             :                                         SDP_ATTR_MSID, inst);
    6370           0 :     if (!attr_p) {
    6371           0 :       return NULL;
    6372             :     }
    6373           0 :     return attr_p->attr.msid.appdata;
    6374             : }

Generated by: LCOV version 1.13