⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdp.c

📁 Sofia SIP is an open-source SIP User-Agent library, compliant with the IETF RFC3261 specification.
💻 C
📖 第 1 页 / 共 4 页
字号:
  return sdp;}/**Duplicate an SDP session description. * * The function sdp_session_dup() duplicates (deeply copies) an SDP * session description燖a sdp allocating memory using memory @a home. * * @param h   Memory home * @param sdp SDP session description to be duplicated * * @return  * If successful, a pointer to newly allocated sdp_session_t structure is * returned, otherwise NULL is returned. */sdp_session_t *sdp_session_dup(su_home_t *h, sdp_session_t const *sdp){   SDP_DUP(session, sdp);}/* ---------------------------------------------------------------------- */static size_t session_without_media_xtra(sdp_session_t const *sdp){  size_t rv = sizeof(*sdp);  PTR_XTRA(rv, sdp->sdp_origin, origin_xtra);  STR_XTRA(rv, sdp->sdp_subject);  STR_XTRA(rv, sdp->sdp_information);  STR_XTRA(rv, sdp->sdp_uri);  LST_XTRA(rv, sdp->sdp_emails, list_xtra);  LST_XTRA(rv, sdp->sdp_phones, list_xtra);  LST_XTRA(rv, sdp->sdp_connection, connection_xtra);  LST_XTRA(rv, sdp->sdp_bandwidths, bandwidth_xtra);  LST_XTRA(rv, sdp->sdp_time, time_xtra);  PTR_XTRA(rv, sdp->sdp_key, key_xtra);  LST_XTRA(rv, sdp->sdp_attributes, attribute_xtra);  STR_XTRA(rv, sdp->sdp_charset);  return rv;}staticsdp_session_t *session_without_media_dup(char **pp, sdp_session_t const *src){  char *p;  sdp_session_t *sdp;  p = *pp;   STRUCT_DUP(p, sdp, src);  sdp->sdp_next = NULL;  PTR_DUP(p, sdp, src, sdp_origin, origin_dup);  STR_DUP(p, sdp, src, sdp_subject);  STR_DUP(p, sdp, src, sdp_information);  STR_DUP(p, sdp, src, sdp_uri);  LST_DUP(p, sdp, src, sdp_emails, list_dup);  LST_DUP(p, sdp, src, sdp_phones, list_dup);  LST_DUP(p, sdp, src, sdp_connection, connection_dup);  LST_DUP(p, sdp, src, sdp_bandwidths, bandwidth_dup);  LST_DUP(p, sdp, src, sdp_time, time_dup);  PTR_DUP(p, sdp, src, sdp_key, key_dup);  LST_DUP(p, sdp, src, sdp_attributes, attribute_dup);  STR_DUP(p, sdp, src, sdp_charset);  sdp->sdp_media = NULL;    assert((size_t)(p - *pp) == session_without_media_xtra(src));  *pp = p;  return sdp;}/* SDP_DUP macro requires this */typedef sdp_session_t sdp_session_without_media_t;/**Duplicate an SDP session description without media descriptions. * * The function sdp_session_dup() duplicates (deeply copies) an SDP session * description燖a sdp allocating memory using memory @a home. It does not * copy the media descriptions, however. * * @param h     memory h * @param sdp   SDP session description to be duplicated * * @return  * If successful, a pointer to newly allocated sdp_session_t structure is * returned, otherwise NULL is returned. */sdp_session_t *sdp_session_dup_without_media(su_home_t *h, 					     sdp_session_t const *sdp){   SDP_DUP(session_without_media, sdp);}/* ---------------------------------------------------------------------- *//* SDP Tag classes */#include <sofia-sip/su_tag_class.h>size_t sdptag_session_xtra(tagi_t const *t, size_t offset){  sdp_session_t const *sdp = (sdp_session_t *)t->t_value;  if (sdp)     return STRUCT_ALIGN(offset) + session_xtra(sdp);  else    return 0;}tagi_t *sdptag_session_dup(tagi_t *dst, tagi_t const *src, void **bb){  sdp_session_t *sdp;  sdp_session_t const *srcsdp;  char *b;  assert(src); assert(*bb);   b = *bb;  b += STRUCT_ALIGN(b);  srcsdp = (sdp_session_t *)src->t_value;  sdp = srcsdp ? session_dup(&b, srcsdp) : NULL;  dst->t_tag = src->t_tag;  dst->t_value = (tag_value_t)sdp;  *bb = b;  return dst + 1;}int sdptag_session_snprintf(tagi_t const *t, char b[], size_t size){  sdp_session_t const *sdp;  sdp_printer_t *print;  size_t retval;  assert(t);  if (!t || !t->t_value) {     if (size && b) b[0] = 0;     return 0;   }  sdp = (sdp_session_t const *)t->t_value;  print = sdp_print(NULL, sdp, b, size, 0);  retval = sdp_message_size(print);    sdp_printer_free(print);  return (int)retval;}/** Tag class for SDP tags. @HIDE */tag_class_t sdptag_session_class[1] =   {{    sizeof(sdptag_session_class),    /* tc_next */     NULL,    /* tc_len */      NULL,    /* tc_move */     NULL,    /* tc_xtra */     sdptag_session_xtra,    /* tc_dup */      sdptag_session_dup,    /* tc_free */     NULL,    /* tc_find */     NULL,    /* tc_snprintf */ sdptag_session_snprintf,    /* tc_filter */   NULL /* msgtag_str_filter */,    /* tc_ref_set */  t_ptr_ref_set,  }};/* ---------------------------------------------------------------------- *//* Compare two string pointers */su_inline int str0cmp(char const *a, char const *b){  if (a == NULL) a = "";  if (b == NULL) b = "";  return strcmp(a, b);}/* Compare two string pointers ignoring case. */su_inline int str0casecmp(char const *a, char const *b){  if (a == NULL) a = "";  if (b == NULL) b = "";  return strcasecmp(a, b);}/** Compare two session descriptions  */int sdp_session_cmp(sdp_session_t const *a, sdp_session_t const *b){  int rv;   sdp_bandwidth_t const *ab, *bb;  sdp_attribute_t const *aa, *ba;  sdp_media_t const *am, *bm;   if ((rv = (a != NULL) - (b != NULL)))     return rv;  if (a == b)    return 0;  if ((rv = (a->sdp_version[0] - b->sdp_version[0])))    return rv;  if ((rv = sdp_origin_cmp(a->sdp_origin, b->sdp_origin)))    return rv;  if ((rv = str0cmp(a->sdp_subject, b->sdp_subject)))    return rv;  if ((rv = str0cmp(a->sdp_information, b->sdp_information)))    return rv;  if ((rv = str0cmp(a->sdp_uri, b->sdp_uri)))    return rv;  if ((rv = sdp_list_cmp(a->sdp_emails, b->sdp_emails)))    return rv;  if ((rv = sdp_list_cmp(a->sdp_phones, b->sdp_phones)))    return rv;  if ((rv = sdp_connection_cmp(a->sdp_connection, b->sdp_connection)))    return rv;  for (ab = a->sdp_bandwidths, bb = b->sdp_bandwidths;        ab || bb;        ab = ab->b_next, bb = bb->b_next)    if ((rv = sdp_bandwidth_cmp(a->sdp_bandwidths, b->sdp_bandwidths)))      return rv;  if ((rv = sdp_time_cmp(a->sdp_time, b->sdp_time)))    return rv;  if ((rv = sdp_key_cmp(a->sdp_key, b->sdp_key)))    return rv;  for (aa = a->sdp_attributes, ba = b->sdp_attributes;        aa || bb;        aa = aa->a_next, ba = ba->a_next)    if ((rv = sdp_attribute_cmp(aa, ba)))      return rv;  for (am = a->sdp_media, bm = b->sdp_media;        am || bm;        am = am->m_next, bm = bm->m_next)    if ((rv = sdp_media_cmp(am, bm)))      return rv;  return 0;}/** Compare two origin fields  */int sdp_origin_cmp(sdp_origin_t const *a, sdp_origin_t const *b){  int rv;  if ((rv = (a != NULL) - (b != NULL)))     return rv;  if (a == b)    return 0;  if (a->o_version != b->o_version)    return a->o_version < b->o_version ? -1 : 1;  if (a->o_id != b->o_id)    return a->o_id < b->o_id ? -1 : 1;  if ((rv = strcasecmp(a->o_username, b->o_username)))    return rv;  if ((rv = strcasecmp(a->o_address->c_address, b->o_address->c_address)))    return rv;  return 0;}/** Compare two connection fields  */int sdp_connection_cmp(sdp_connection_t const *a, sdp_connection_t const *b){  if (a == b)    return 0;  if ((a != NULL) != (b != NULL))    return (a != NULL) < (b != NULL) ? -1 : 1;  if (a->c_nettype != b->c_nettype)    return a->c_nettype < b->c_nettype ? -1 : 1;  if (a->c_addrtype != b->c_addrtype)    return a->c_addrtype < b->c_addrtype ? -1 : 1;  if (a->c_ttl != b->c_ttl)    return a->c_ttl < b->c_ttl ? -1 : 1;  if (a->c_groups != b->c_groups)    return a->c_groups < b->c_groups ? -1 : 1;  return strcmp(a->c_address, b->c_address);}/** Compare two bandwidth (b=) fields */int sdp_bandwidth_cmp(sdp_bandwidth_t const *a, sdp_bandwidth_t const *b){  int rv;  if (a == b)    return 0;  if ((a != NULL) != (b != NULL))    return (a != NULL) < (b != NULL) ? -1 : 1;  if (a->b_modifier != b->b_modifier)    return a->b_modifier < b->b_modifier ? -1 : 1;  if (a->b_modifier == sdp_bw_x &&       (rv = strcmp(a->b_modifier_name, b->b_modifier_name)))    return rv;  if (a->b_value != b->b_value)    return a->b_value < b->b_value ? -1 : 1;  return 0;}/** Compare two time fields */int sdp_time_cmp(sdp_time_t const *a, sdp_time_t const *b){  int rv;   if ((rv = (a != NULL) - (b != NULL)))     return rv;  if (a == b)    return 0;  if (a->t_start != b->t_start)    return a->t_start < b->t_start ? -1 : 1;  if (a->t_stop != b->t_stop)    return a->t_stop < b->t_stop ? -1 : 1;  if ((rv = sdp_zone_cmp(a->t_zone, b->t_zone)))    return rv;  if ((rv = sdp_repeat_cmp(a->t_repeat, b->t_repeat)))    return rv;  return 0;}/** Compare two repeat (r=) fields */int sdp_repeat_cmp(sdp_repeat_t const *a, sdp_repeat_t const *b){  int i, n;    if (a == b)    return 0;  if ((a != NULL) != (b != NULL))    return (a != NULL) < (b != NULL) ? -1 : 1;  if (a->r_interval != b->r_interval)    return a->r_interval < b->r_interval ? -1 : 1;  if (a->r_duration != b->r_duration)    return a->r_duration < b->r_duration ? -1 : 1;  n = a->r_number_of_offsets < b->r_number_of_offsets     ? a->r_number_of_offsets : b->r_number_of_offsets;  for (i = 0; i < n; i++)    if (a->r_offsets[i] != b->r_offsets[i])      return a->r_offsets[i] < b->r_offsets[i] ? -1 : 1;    if (a->r_number_of_offsets != b->r_number_of_offsets)    return a->r_number_of_offsets < b->r_number_of_offsets ? -1 : 1;  return 0; }/** Compare two zone (z=) fields */int sdp_zone_cmp(sdp_zone_t const *a, sdp_zone_t const *b){  int i, n;    if (a == b)    return 0;  if ((a != NULL) != (b != NULL))    return (a != NULL) < (b != NULL) ? -1 : 1;  n = a->z_number_of_adjustments < b->z_number_of_adjustments    ? a->z_number_of_adjustments : b->z_number_of_adjustments;  for (i = 0; i < n; i++) {    if (a->z_adjustments[i].z_at != b->z_adjustments[i].z_at)      return a->z_adjustments[i].z_at < b->z_adjustments[i].z_at ? -1 : 1;    if (a->z_adjustments[i].z_offset != b->z_adjustments[i].z_offset)      return a->z_adjustments[i].z_offset < b->z_adjustments[i].z_offset	? -1 : 1;  }  if (a->z_number_of_adjustments != b->z_number_of_adjustments)    return a->z_number_of_adjustments < b->z_number_of_adjustments ? -1 : 1;  return 0;}/** Compare two key (k=) fields */int sdp_key_cmp(sdp_key_t const *a, sdp_key_t const *b){  int rv;  if (a == b)    return 0;  if ((a != NULL) != (b != NULL))    return (a != NULL) < (b != NULL) ? -1 : 1;  if (a->k_method != b->k_method)    return a->k_method < b->k_method ? -1 : 1;  if (a->k_method == sdp_key_x &&       (rv = str0cmp(a->k_method_name, b->k_method_name)))    return rv;  return str0cmp(a->k_material, b->k_material);}/** Compare two attribute (a=) fields */int sdp_attribute_cmp(sdp_attribute_t const *a, sdp_attribute_t const *b){  int rv;  if (a == b)    return 0;  if ((a != NULL) != (b != NULL))    return (a != NULL) < (b != NULL) ? -1 : 1;  if ((rv = str0cmp(a->a_name, b->a_name)))    return rv;  return str0cmp(a->a_value, b->a_value);}/** Compare two rtpmap structures. */int sdp_rtpmap_cmp(sdp_rtpmap_t const *a, sdp_rtpmap_t const *b){  int rv;  if (a == b)    return 0;  if ((a != NULL) != (b != NULL))    return (a != NULL) < (b != NULL) ? -1 : 1;  if (a->rm_pt != b->rm_pt)    return a->rm_pt < b->rm_pt ? -1 : 1;  /* Case insensitive encoding */  if ((rv = str0cmp(a->rm_encoding, b->rm_encoding)))    return rv;  /* Rate */  if (a->rm_rate != b->rm_rate)    return a->rm_rate < b->rm_rate ? -1 : 1;  {    char const *a_param = "1", *b_param = "1";    if (a->rm_params)      a_param = a->rm_params;    if (b->rm_params)      b_param = b->rm_params;        rv = strcasecmp(a_param, b_param);    if (rv)      return rv;  }  return str0casecmp(a->rm_fmtp, b->rm_fmtp);}/** Compare two lists. */int sdp_list_cmp(sdp_list_t const *a, sdp_list_t const *b){  int rv;  for (;a || b; a = a->l_next, b = b->l_next) {    if (a == b)      return 0;    if ((a != NULL) != (b != NULL))      return (a != NULL) < (b != NULL) ? -1 : 1;    if ((rv = str0cmp(a->l_text, b->l_text)))      return rv;  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -