Example #1
0
static int
sdp_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 = __osip_sdp_append_string (string, size, tmp, "t=");
  tmp =
    __osip_sdp_append_string (string, size, tmp, time_descr->t_start_time);
  tmp = __osip_sdp_append_string (string, size, tmp, " ");
  tmp = __osip_sdp_append_string (string, size, tmp, time_descr->t_stop_time);

  tmp = __osip_sdp_append_string (string, size, tmp, CRLF);

  pos = 0;
  while (!osip_list_eol (time_descr->r_repeats, pos))
    {
      char *str = (char *) osip_list_get (time_descr->r_repeats, pos);

      tmp = __osip_sdp_append_string (string, size, tmp, "r=");
      tmp = __osip_sdp_append_string (string, size, tmp, str);
      tmp = __osip_sdp_append_string (string, size, tmp, CRLF);
      pos++;
    }

  *next_tmp = tmp;
  return 0;
}
Example #2
0
static int
sdp_append_key (char *string, int size, char *tmp, sdp_key_t * key,
		char **next_tmp)
{
  if (key->k_keytype == NULL)
    return -1;

  tmp = __osip_sdp_append_string (string, size, tmp, "k=");
  tmp = __osip_sdp_append_string (string, size, tmp, key->k_keytype);
  if (key->k_keydata != NULL)
    {
      tmp = __osip_sdp_append_string (string, size, tmp, ":");
      tmp = __osip_sdp_append_string (string, size, tmp, key->k_keydata);
    }
  tmp = __osip_sdp_append_string (string, size, tmp, CRLF);
  *next_tmp = tmp;
  return 0;
}
Example #3
0
static int
sdp_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 = __osip_sdp_append_string (string, size, tmp, "b=");
  tmp = __osip_sdp_append_string (string, size, tmp, bandwidth->b_bwtype);
  tmp = __osip_sdp_append_string (string, size, tmp, ":");
  tmp = __osip_sdp_append_string (string, size, tmp, bandwidth->b_bandwidth);
  tmp = __osip_sdp_append_string (string, size, tmp, CRLF);

  *next_tmp = tmp;
  return 0;
}
Example #4
0
/* internal facility */
int
sdp_append_attribute (char *string, int size, char *tmp,
		      sdp_attribute_t * attribute, char **next_tmp)
{
  if (attribute->a_att_field == NULL)
    return -1;

  tmp = __osip_sdp_append_string (string, size, tmp, "a=");
  tmp = __osip_sdp_append_string (string, size, tmp, attribute->a_att_field);
  if (attribute->a_att_value != NULL)
    {
      tmp = __osip_sdp_append_string (string, size, tmp, ":");
      tmp = __osip_sdp_append_string (string, size, tmp, attribute->a_att_value);
    }
  tmp = __osip_sdp_append_string (string, size, tmp, CRLF);

  *next_tmp = tmp;
  return 0;
}
Example #5
0
int
sdp_message_to_str (sdp_message_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 *) osip_malloc (size);
  string = tmp;

  tmp = __osip_sdp_append_string (string, size, tmp, "v=");
  tmp = __osip_sdp_append_string (string, size, tmp, sdp->v_version);
  tmp = __osip_sdp_append_string (string, size, tmp, CRLF);
  tmp = __osip_sdp_append_string (string, size, tmp, "o=");
  tmp = __osip_sdp_append_string (string, size, tmp, sdp->o_username);
  tmp = __osip_sdp_append_string (string, size, tmp, " ");
  tmp = __osip_sdp_append_string (string, size, tmp, sdp->o_sess_id);
  tmp = __osip_sdp_append_string (string, size, tmp, " ");
  tmp = __osip_sdp_append_string (string, size, tmp, sdp->o_sess_version);
  tmp = __osip_sdp_append_string (string, size, tmp, " ");
  tmp = __osip_sdp_append_string (string, size, tmp, sdp->o_nettype);
  tmp = __osip_sdp_append_string (string, size, tmp, " ");
  tmp = __osip_sdp_append_string (string, size, tmp, sdp->o_addrtype);
  tmp = __osip_sdp_append_string (string, size, tmp, " ");
  tmp = __osip_sdp_append_string (string, size, tmp, sdp->o_addr);
  tmp = __osip_sdp_append_string (string, size, tmp, CRLF);
  if (sdp->s_name != NULL)
    {
      tmp = __osip_sdp_append_string (string, size, tmp, "s=");
      tmp = __osip_sdp_append_string (string, size, tmp, sdp->s_name);
      tmp = __osip_sdp_append_string (string, size, tmp, CRLF);
    }
  if (sdp->i_info != NULL)
    {
      tmp = __osip_sdp_append_string (string, size, tmp, "i=");
      tmp = __osip_sdp_append_string (string, size, tmp, sdp->i_info);
      tmp = __osip_sdp_append_string (string, size, tmp, CRLF);
    }
  if (sdp->u_uri != NULL)
    {
      tmp = __osip_sdp_append_string (string, size, tmp, "u=");
      tmp = __osip_sdp_append_string (string, size, tmp, sdp->u_uri);
      tmp = __osip_sdp_append_string (string, size, tmp, CRLF);
    }
  pos = 0;
  while (!osip_list_eol (sdp->e_emails, pos))
    {
      char *email = (char *) osip_list_get (sdp->e_emails, pos);

      tmp = __osip_sdp_append_string (string, size, tmp, "e=");
      tmp = __osip_sdp_append_string (string, size, tmp, email);
      tmp = __osip_sdp_append_string (string, size, tmp, CRLF);
      pos++;
    }
  pos = 0;
  while (!osip_list_eol (sdp->p_phones, pos))
    {
      char *phone = (char *) osip_list_get (sdp->p_phones, pos);

      tmp = __osip_sdp_append_string (string, size, tmp, "p=");
      tmp = __osip_sdp_append_string (string, size, tmp, phone);
      tmp = __osip_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 (!osip_list_eol (sdp->b_bandwidths, pos))
    {
      sdp_bandwidth_t *header =
	(sdp_bandwidth_t *) osip_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 (!osip_list_eol (sdp->t_descrs, pos))
    {
      sdp_time_descr_t *header =
	(sdp_time_descr_t *) osip_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 = __osip_sdp_append_string (string, size, tmp, "z=");
      tmp = __osip_sdp_append_string (string, size, tmp, sdp->z_adjustments);
      tmp = __osip_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 (!osip_list_eol (sdp->a_attributes, pos))
    {
      sdp_attribute_t *header =
	(sdp_attribute_t *) osip_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 (!osip_list_eol (sdp->m_medias, pos))
    {
      sdp_media_t *header =
	(sdp_media_t *) osip_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;
}
Example #6
0
/* internal facility */
static int
sdp_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 = __osip_sdp_append_string (string, size, tmp, "m=");
  tmp = __osip_sdp_append_string (string, size, tmp, media->m_media);
  tmp = __osip_sdp_append_string (string, size, tmp, " ");
  tmp = __osip_sdp_append_string (string, size, tmp, media->m_port);
  if (media->m_number_of_port != NULL)
    {
      tmp = __osip_sdp_append_string (string, size, tmp, "/");
      tmp =
	__osip_sdp_append_string (string, size, tmp, media->m_number_of_port);
    }
  tmp = __osip_sdp_append_string (string, size, tmp, " ");
  tmp = __osip_sdp_append_string (string, size, tmp, media->m_proto);
  pos = 0;
  while (!osip_list_eol (media->m_payloads, pos))
    {
      char *str = (char *) osip_list_get (media->m_payloads, pos);

      tmp = __osip_sdp_append_string (string, size, tmp, " ");
      tmp = __osip_sdp_append_string (string, size, tmp, str);
      pos++;
    }
  tmp = __osip_sdp_append_string (string, size, tmp, CRLF);

  if (media->i_info != NULL)
    {
      tmp = __osip_sdp_append_string (string, size, tmp, "i=");
      tmp = __osip_sdp_append_string (string, size, tmp, media->i_info);
      tmp = __osip_sdp_append_string (string, size, tmp, CRLF);
    }

  pos = 0;
  while (!osip_list_eol (media->c_connections, pos))
    {
      sdp_connection_t *conn =
	(sdp_connection_t *) osip_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 (!osip_list_eol (media->b_bandwidths, pos))
    {
      sdp_bandwidth_t *band =
	(sdp_bandwidth_t *) osip_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 (!osip_list_eol (media->a_attributes, pos))
    {
      sdp_attribute_t *attr =
	(sdp_attribute_t *) osip_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;
}
Example #7
0
static int
sdp_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 = __osip_sdp_append_string (string, size, tmp, "c=");
  tmp = __osip_sdp_append_string (string, size, tmp, conn->c_nettype);
  tmp = __osip_sdp_append_string (string, size, tmp, " ");
  tmp = __osip_sdp_append_string (string, size, tmp, conn->c_addrtype);
  tmp = __osip_sdp_append_string (string, size, tmp, " ");
  tmp = __osip_sdp_append_string (string, size, tmp, conn->c_addr);
  if (conn->c_addr_multicast_ttl != NULL)
    {
      tmp = __osip_sdp_append_string (string, size, tmp, "/");
      tmp =
	__osip_sdp_append_string (string, size, tmp,
				  conn->c_addr_multicast_ttl);
    }
  if (conn->c_addr_multicast_int != NULL)
    {
      tmp = __osip_sdp_append_string (string, size, tmp, "/");
      tmp =
	__osip_sdp_append_string (string, size, tmp,
				  conn->c_addr_multicast_int);
    }
  tmp = __osip_sdp_append_string (string, size, tmp, CRLF);
  *next_tmp = tmp;
  return 0;
}