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

📄 sdp_rfc2327.c

📁 libosip-0.9.7源码
💻 C
📖 第 1 页 / 共 4 页
字号:
	    if (*ptr == '\0' || (*ptr == '\r') || (*ptr == '\n'))	      return 0;	  }	i = 1;	while (i == 1)	  {	    i = sdp_parse_b (sdp, ptr, &next_buf);	    if (i == -1)	/* header is bad */	      return -1;	    ptr = next_buf;	    if (*ptr == '\0' || (*ptr == '\r') || (*ptr == '\n'))	      return 0;	  }	i = sdp_parse_k (sdp, ptr, &next_buf);	if (i == -1)		/* header is bad */	  return -1;	ptr = next_buf;	if (*ptr == '\0' || (*ptr == '\r') || (*ptr == '\n'))	  return 0;	/* 0 or more a headers */	i = 1;	while (i == 1)	  {	    i = sdp_parse_a (sdp, ptr, &next_buf);	    if (i == -1)	/* header is bad */	      return -1;	    ptr = next_buf;	    if (*ptr == '\0' || (*ptr == '\r') || (*ptr == '\n'))	      return 0;	  }      }  }  return 0;}/* internal facility */intsdp_append_connection (char *string, int size, char *tmp,		       sdp_connection_t * conn, char **next_tmp){  if (conn->c_nettype == NULL)    return -1;  if (conn->c_addrtype == NULL)    return -1;  if (conn->c_addr == NULL)    return -1;  tmp = sdp_append_string (string, size, tmp, "c=");  tmp = sdp_append_string (string, size, tmp, conn->c_nettype);  tmp = sdp_append_string (string, size, tmp, " ");  tmp = sdp_append_string (string, size, tmp, conn->c_addrtype);  tmp = sdp_append_string (string, size, tmp, " ");  tmp = sdp_append_string (string, size, tmp, conn->c_addr);  if (conn->c_addr_multicast_ttl != NULL)    {      tmp = sdp_append_string (string, size, tmp, "/");      tmp = sdp_append_string (string, size, tmp, conn->c_addr_multicast_ttl);    }  if (conn->c_addr_multicast_int != NULL)    {      tmp = sdp_append_string (string, size, tmp, "/");      tmp = sdp_append_string (string, size, tmp, conn->c_addr_multicast_int);    }  tmp = sdp_append_string (string, size, tmp, CRLF);  *next_tmp = tmp;  return 0;}/* internal facility */intsdp_append_bandwidth (char *string, int size, char *tmp,		      sdp_bandwidth_t * bandwidth, char **next_tmp){  if (bandwidth->b_bwtype == NULL)    return -1;  if (bandwidth->b_bandwidth == NULL)    return -1;  tmp = sdp_append_string (string, size, tmp, "b=");  tmp = sdp_append_string (string, size, tmp, bandwidth->b_bwtype);  tmp = sdp_append_string (string, size, tmp, ":");  tmp = sdp_append_string (string, size, tmp, bandwidth->b_bandwidth);  tmp = sdp_append_string (string, size, tmp, CRLF);  *next_tmp = tmp;  return 0;}intsdp_append_time_descr (char *string, int size, char *tmp,		       sdp_time_descr_t * time_descr, char **next_tmp){  int pos;  if (time_descr->t_start_time == NULL)    return -1;  if (time_descr->t_stop_time == NULL)    return -1;  tmp = sdp_append_string (string, size, tmp, "t=");  tmp = sdp_append_string (string, size, tmp, time_descr->t_start_time);  tmp = sdp_append_string (string, size, tmp, " ");  tmp = sdp_append_string (string, size, tmp, time_descr->t_stop_time);  tmp = sdp_append_string (string, size, tmp, CRLF);  pos = 0;  while (!list_eol (time_descr->r_repeats, pos))    {      char *str = (char *) list_get (time_descr->r_repeats, pos);      tmp = sdp_append_string (string, size, tmp, "r=");      tmp = sdp_append_string (string, size, tmp, str);      tmp = sdp_append_string (string, size, tmp, CRLF);      pos++;    }  *next_tmp = tmp;  return 0;}intsdp_append_key (char *string, int size, char *tmp, sdp_key_t * key,		char **next_tmp){  if (key->k_keytype == NULL)    return -1;  tmp = sdp_append_string (string, size, tmp, "k=");  tmp = sdp_append_string (string, size, tmp, key->k_keytype);  if (key->k_keydata != NULL)    {      tmp = sdp_append_string (string, size, tmp, ":");      tmp = sdp_append_string (string, size, tmp, key->k_keydata);    }  tmp = sdp_append_string (string, size, tmp, CRLF);  *next_tmp = tmp;  return 0;}/* internal facility */intsdp_append_attribute (char *string, int size, char *tmp,		      sdp_attribute_t * attribute, char **next_tmp){  if (attribute->a_att_field == NULL)    return -1;  tmp = sdp_append_string (string, size, tmp, "a=");  tmp = sdp_append_string (string, size, tmp, attribute->a_att_field);  if (attribute->a_att_value != NULL)    {      tmp = sdp_append_string (string, size, tmp, ":");      tmp = sdp_append_string (string, size, tmp, attribute->a_att_value);    }  tmp = sdp_append_string (string, size, tmp, CRLF);  *next_tmp = tmp;  return 0;}/* internal facility */intsdp_append_media (char *string, int size, char *tmp, sdp_media_t * media,		  char **next_tmp){  int pos;  if (media->m_media == NULL)    return -1;  if (media->m_port == NULL)    return -1;  if (media->m_proto == NULL)    return -1;  tmp = sdp_append_string (string, size, tmp, "m=");  tmp = sdp_append_string (string, size, tmp, media->m_media);  tmp = sdp_append_string (string, size, tmp, " ");  tmp = sdp_append_string (string, size, tmp, media->m_port);  if (media->m_number_of_port != NULL)    {      tmp = sdp_append_string (string, size, tmp, "/");      tmp = sdp_append_string (string, size, tmp, media->m_number_of_port);    }  tmp = sdp_append_string (string, size, tmp, " ");  tmp = sdp_append_string (string, size, tmp, media->m_proto);  pos = 0;  while (!list_eol (media->m_payloads, pos))    {      char *str = (char *) list_get (media->m_payloads, pos);      tmp = sdp_append_string (string, size, tmp, " ");      tmp = sdp_append_string (string, size, tmp, str);      pos++;    }  tmp = sdp_append_string (string, size, tmp, CRLF);  if (media->i_info != NULL)    {      tmp = sdp_append_string (string, size, tmp, "i=");      tmp = sdp_append_string (string, size, tmp, media->i_info);      tmp = sdp_append_string (string, size, tmp, CRLF);    }  pos = 0;  while (!list_eol (media->c_connections, pos))    {      sdp_connection_t *conn =	(sdp_connection_t *) list_get (media->c_connections, pos);      char *next_tmp2;      int i;      i = sdp_append_connection (string, size, tmp, conn, &next_tmp2);      if (i != 0)	return -1;      tmp = next_tmp2;      pos++;    }  pos = 0;  while (!list_eol (media->b_bandwidths, pos))    {      sdp_bandwidth_t *band =	(sdp_bandwidth_t *) list_get (media->b_bandwidths, pos);      char *next_tmp2;      int i;      i = sdp_append_bandwidth (string, size, tmp, band, &next_tmp2);      if (i != 0)	return -1;      tmp = next_tmp2;      pos++;    }  if (media->k_key != NULL)    {      char *next_tmp2;      int i;      i = sdp_append_key (string, size, tmp, media->k_key, &next_tmp2);      if (i != 0)	return -1;      tmp = next_tmp2;    }  pos = 0;  while (!list_eol (media->a_attributes, pos))    {      sdp_attribute_t *attr =	(sdp_attribute_t *) list_get (media->a_attributes, pos);      char *next_tmp2;      int i;      i = sdp_append_attribute (string, size, tmp, attr, &next_tmp2);      if (i != 0)	return -1;      tmp = next_tmp2;      pos++;    }  *next_tmp = tmp;  return 0;}intsdp_2char (sdp_t * sdp, char **dest){  int size;  int pos;  char *tmp;  char *string;  *dest = NULL;  if (sdp->v_version == NULL)    return -1;  if (sdp->o_username == NULL ||      sdp->o_sess_id == NULL ||      sdp->o_sess_version == NULL ||      sdp->o_nettype == NULL || sdp->o_addrtype == NULL      || sdp->o_addr == NULL)    return -1;  /* RFC says "s=" is mandatory... rfc2543 (SIP) recommends to     accept SDP datas without s_name... as some buggy implementations     often forget it...   */  /* if (sdp->s_name == NULL)     return -1; */  size = 4000;  tmp = (char *) smalloc (size);  string = tmp;  tmp = sdp_append_string (string, size, tmp, "v=");  tmp = sdp_append_string (string, size, tmp, sdp->v_version);  tmp = sdp_append_string (string, size, tmp, CRLF);  tmp = sdp_append_string (string, size, tmp, "o=");  tmp = sdp_append_string (string, size, tmp, sdp->o_username);  tmp = sdp_append_string (string, size, tmp, " ");  tmp = sdp_append_string (string, size, tmp, sdp->o_sess_id);  tmp = sdp_append_string (string, size, tmp, " ");  tmp = sdp_append_string (string, size, tmp, sdp->o_sess_version);  tmp = sdp_append_string (string, size, tmp, " ");  tmp = sdp_append_string (string, size, tmp, sdp->o_nettype);  tmp = sdp_append_string (string, size, tmp, " ");  tmp = sdp_append_string (string, size, tmp, sdp->o_addrtype);  tmp = sdp_append_string (string, size, tmp, " ");  tmp = sdp_append_string (string, size, tmp, sdp->o_addr);  tmp = sdp_append_string (string, size, tmp, CRLF);  if (sdp->s_name != NULL)    {      tmp = sdp_append_string (string, size, tmp, "s=");      tmp = sdp_append_string (string, size, tmp, sdp->s_name);      tmp = sdp_append_string (string, size, tmp, CRLF);    }  if (sdp->i_info != NULL)    {      tmp = sdp_append_string (string, size, tmp, "i=");      tmp = sdp_append_string (string, size, tmp, sdp->i_info);      tmp = sdp_append_string (string, size, tmp, CRLF);    }  if (sdp->u_uri != NULL)    {      tmp = sdp_append_string (string, size, tmp, "u=");      tmp = sdp_append_string (string, size, tmp, sdp->u_uri);      tmp = sdp_append_string (string, size, tmp, CRLF);    }  pos = 0;  while (!list_eol (sdp->e_emails, pos))    {      char *email = (char *) list_get (sdp->e_emails, pos);      tmp = sdp_append_string (string, size, tmp, "e=");      tmp = sdp_append_string (string, size, tmp, email);      tmp = sdp_append_string (string, size, tmp, CRLF);      pos++;    }  pos = 0;  while (!list_eol (sdp->p_phones, pos))    {      char *phone = (char *) list_get (sdp->p_phones, pos);      tmp = sdp_append_string (string, size, tmp, "p=");      tmp = sdp_append_string (string, size, tmp, phone);      tmp = sdp_append_string (string, size, tmp, CRLF);      pos++;    }  if (sdp->c_connection != NULL)    {      char *next_tmp;      int i;      i =	sdp_append_connection (string, size, tmp, sdp->c_connection,			       &next_tmp);      if (i != 0)	return -1;      tmp = next_tmp;    }  pos = 0;  while (!list_eol (sdp->b_bandwidths, pos))    {      sdp_bandwidth_t *header =	(sdp_bandwidth_t *) list_get (sdp->b_bandwidths, pos);      char *next_tmp;      int i;      i = sdp_append_bandwidth (string, size, tmp, header, &next_tmp);      if (i != 0)	return -1;      tmp = next_tmp;      pos++;    }  pos = 0;  while (!list_eol (sdp->t_descrs, pos))    {      sdp_time_descr_t *header =	(sdp_time_descr_t *) list_get (sdp->t_descrs, pos);      char *next_tmp;      int i;      i = sdp_append_time_descr (string, size, tmp, header, &next_tmp);      if (i != 0)	return -1;      tmp = next_tmp;      pos++;    }  if (sdp->z_adjustments != NULL)    {      tmp = sdp_append_string (string, size, tmp, "z=");      tmp = sdp_append_string (string, size, tmp, sdp->z_adjustments);      tmp = sdp_append_string (string, size, tmp, CRLF);    }  if (sdp->k_key != NULL)    {      char *next_tmp;      int i;      i = sdp_append_key (string, size, tmp, sdp->k_key, &next_tmp);      if (i != 0)	return -1;      tmp = next_tmp;    }  pos = 0;  while (!list_eol (sdp->a_attributes, pos))    {      sdp_attribute_t *header =	(sdp_attribute_t *) list_get (sdp->a_attributes, pos);      char *next_tmp;      int i;      i = sdp_append_attribute (string, size, tmp, header, &next_tmp);      if (i != 0)	return -1;      tmp = next_tmp;      pos++;    }  pos = 0;  while (!list_eol (sdp->m_medias, pos))    {      sdp_media_t *header = (sdp_media_t *) list_get (sdp->m_medias, pos);      char *next_tmp;      int i;      i = sdp_append_media (string, size, tmp, header, &next_tmp);      if (i != 0)	return -1;      tmp = next_tmp;      pos++;    }  *dest = string;  return 0;}voidsdp_free (sdp_t * sdp){  if (sdp == NULL)    return;  sfree (sdp->v_version);  sfree (sdp->o_username);  sfree (sdp->o_sess_id);  sfree (sdp->o_sess_version);  sfree (sdp->o_nettype);  sfree (sdp->o_addrtype);  sfree (sdp->o_addr);  sfree (sdp->s_name);  sfree (sdp->i_info);  sfree (sdp->u_uri);  listofchar_free (sdp->e_emails);  sfree (sdp->e_emails);  listofchar_free (sdp->p_phones);  sfree (sdp->p_phones);  sdp_connection_free (sdp->c_connection);  sfree (sdp->c_connection);  list_special_free (sdp->b_bandwidths,		     (void *(*)(void *)) &sdp_bandwidth_free);  sfree (sdp->b_bandwidths);  list_special_free (sdp->t_descrs, (void *(*)(void *)) &sdp_time_descr_free);  sfree (sdp->t_descrs);  sfree (sdp->z_adjustments);  sdp_key_free (sdp->k_key);  sfree (sdp->k_key);  list_special_free (sdp->a_attributes,		     (void *(*)(void *)) &sdp_attribute_free);  sfree (sdp->a_attributes);  list_special_free (sdp->m_medias, (void *(*)(void *)) &sdp_media_free);  sfree (sdp->m_medias);}intsdp_clone (sdp_t * sdp, sdp_t ** dest){  int i;  char *body;  i = sdp_init (dest);  if (i != 0)    return -1;  i = sdp_2char (sdp, &body);  if (i != 0)    goto error_sc1;  i = sdp_parse (*dest, body);  sfree (body);  if (i != 0)    goto error_sc1;  return 0;error_sc1:  sdp_free (*dest);  sfree (*dest);  return -1;}

⌨️ 快捷键说明

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