示例#1
0
int
sdp_message_b_bandwidth_add (sdp_message_t * sdp, int pos_media, char *bwtype,
                             char *bandwidth)
{
  int i;
  sdp_media_t *med;
  sdp_bandwidth_t *band;

  if (sdp == NULL)
    return -1;
  if ((pos_media != -1) && (osip_list_size (&sdp->m_medias) < pos_media + 1))
    return -1;
  i = sdp_bandwidth_init (&band);
  if (i != 0)
    return -1;
  band->b_bwtype = bwtype;
  band->b_bandwidth = bandwidth;
  if (pos_media == -1)
    {
      osip_list_add (&sdp->b_bandwidths, band, -1);
      return 0;
    }
  med = (sdp_media_t *) osip_list_get (&sdp->m_medias, pos_media);
  osip_list_add (&med->b_bandwidths, band, -1);
  return 0;
}
示例#2
0
int
sdp_message_b_bandwidth_add (sdp_message_t * sdp, int pos_media, char *bwtype, char *bandwidth)
{
  int i;
  sdp_media_t *med;
  sdp_bandwidth_t *band;

  if (sdp == NULL)
    return OSIP_BADPARAMETER;
  if ((pos_media != -1) && (osip_list_size (&sdp->m_medias) < pos_media + 1))
    return OSIP_UNDEFINED_ERROR;
  i = sdp_bandwidth_init (&band);
  if (i != 0)
    return i;
  band->b_bwtype = bwtype;
  band->b_bandwidth = bandwidth;
  if (pos_media == -1) {
    osip_list_add (&sdp->b_bandwidths, band, -1);
    return OSIP_SUCCESS;
  }
  med = (sdp_media_t *) osip_list_get (&sdp->m_medias, pos_media);
  osip_list_add (&med->b_bandwidths, band, -1);
  return OSIP_SUCCESS;
}
示例#3
0
static int
sdp_message_parse_b (sdp_message_t * sdp, char *buf, char **next)
{
  char *equal;
  char *crlf;
  char *tmp;
  char *tmp_next;
  int i;
  sdp_bandwidth_t *b_header;

  *next = buf;

  equal = buf;
  while ((*equal != '=') && (*equal != '\0'))
    equal++;
  if (*equal == '\0')
    return ERR_ERROR;

  /* check if header is "b" */
  if (equal[-1] != 'b')
    return ERR_DISCARD;

  crlf = equal + 1;

  while ((*crlf != '\r') && (*crlf != '\n') && (*crlf != '\0'))
    crlf++;
  if (*crlf == '\0')
    return ERR_ERROR;
  if (crlf == equal + 1)
    return ERR_ERROR;		/* b=\r ?? bad header */

  tmp = equal + 1;
  /* b = bwtype: bandwidth */
  i = sdp_bandwidth_init (&b_header);
  if (i != 0)
    return ERR_ERROR;

  /* bwtype is alpha-numeric */
  i = __osip_set_next_token (&(b_header->b_bwtype), tmp, ':', &tmp_next);
  if (i != 0)
    return -1;
  tmp = tmp_next;

  i = __osip_set_next_token (&(b_header->b_bandwidth), tmp, '\r', &tmp_next);
  if (i != 0)
    {
      i =
	__osip_set_next_token (&(b_header->b_bandwidth), tmp, '\n',
			       &tmp_next);
      if (i != 0)
	{
	  sdp_bandwidth_free (b_header);
	  return -1;
	}
    }

  /* add the bandwidth at the correct place:
     if there is no media line yet, then the "b=" is the
     global one.
   */
  i = osip_list_size (sdp->m_medias);
  if (i == 0)
    osip_list_add (sdp->b_bandwidths, b_header, -1);
  else
    {
      sdp_media_t *last_sdp_media =
	(sdp_media_t *) osip_list_get (sdp->m_medias, i - 1);
      osip_list_add (last_sdp_media->b_bandwidths, b_header, -1);
    }

  if (crlf[1] == '\n')
    *next = crlf + 2;
  else
    *next = crlf + 1;
  return WF;
}