Example #1
0
const OggzComment *
oggz_comment_first_byname (OGGZ * oggz, long serialno, char * name)
{
    oggz_stream_t * stream;
    OggzComment * comment;
    int i;

    if (oggz == NULL) return NULL;

    stream = oggz_get_stream (oggz, serialno);
    if (stream == NULL) return NULL;

    if (name == NULL) return oggz_vector_nth_p (stream->comments, 0);

    if (!oggz_comment_validate_byname (name, ""))
        return NULL;

    for (i = 0; i < oggz_vector_size (stream->comments); i++) {
        comment = (OggzComment *) oggz_vector_nth_p (stream->comments, i);
        if (comment->name && !strcasecmp (name, comment->name))
            return comment;
    }

    return NULL;
}
Example #2
0
int
oggz_set_eos (OGGZ * oggz, long serialno)
{
  oggz_stream_t * stream;
  int i, size;

  if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;

  if (serialno == -1) {
    size = oggz_vector_size (oggz->streams);
    for (i = 0; i < size; i++) {
      stream = (oggz_stream_t *) oggz_vector_nth_p (oggz->streams, i);
      stream->e_o_s = 1;
    }
    oggz->all_at_eos = 1;
  } else {
    stream = oggz_get_stream (oggz, serialno);
    if (stream == NULL)
      return OGGZ_ERR_BAD_SERIALNO;

    stream->e_o_s = 1;

    if (oggz_get_eos (oggz, -1))
      oggz->all_at_eos = 1;
  }

  return 0;
}
Example #3
0
int
oggz_get_bos (OGGZ * oggz, long serialno)
{
  oggz_stream_t * stream;
  int i, size;

  if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;

  if (serialno == -1) {
    size = oggz_vector_size (oggz->streams);
    for (i = 0; i < size; i++) {
      stream = (oggz_stream_t *)oggz_vector_nth_p (oggz->streams, i);
#if 1
      /* If this stream has delivered a non bos packet, return FALSE */
      if (stream->delivered_non_b_o_s) return 0;
#else
      /* If this stream has delivered its bos packet, return FALSE */
      if (!stream->b_o_s) return 0;
#endif
    }
    return 1;
  } else {
    stream = oggz_get_stream (oggz, serialno);
    if (stream == NULL)
      return OGGZ_ERR_BAD_SERIALNO;

    return stream->b_o_s;
  }
}
Example #4
0
int
oggz_comment_remove_byname (OGGZ * oggz, long serialno, char * name)
{
    oggz_stream_t * stream;
    OggzComment * comment;
    int i, ret = 0;

    if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;

    stream = oggz_get_stream (oggz, serialno);
    if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO;

    if (oggz->flags & OGGZ_WRITE) {
        if (OGGZ_CONFIG_WRITE) {
            for (i = 0; i < oggz_vector_size (stream->comments); i++) {
                comment = (OggzComment *) oggz_vector_nth_p (stream->comments, i);
                if (!strcasecmp (name, comment->name)) {
                    oggz_comment_remove (oggz, serialno, comment);
                    i--;
                    ret++;
                }
            }
            return ret;
        } else {
            return OGGZ_ERR_DISABLED;
        }
    } else {
        return OGGZ_ERR_INVALID;
    }
}
Example #5
0
void *
oggz_table_nth (OggzTable * table, int n, long * key)
{
  if (table == NULL) return NULL;
  if (key) *key = oggz_vector_nth_l (table->keys, n);
  return oggz_vector_nth_p (table->data, n);
}
static OggzComment *
_oggz_comment_add_byname (oggz_stream_t * stream, const char * name, const char * value)
{
  OggzComment * comment, * new_comment;
  int i;

  /* Check that the same name=value pair is not already present */
  for (i = 0; i < oggz_vector_size (stream->comments); i++) {
    comment = (OggzComment *) oggz_vector_nth_p (stream->comments, i);
    if (comment->name && !strcasecmp (name, comment->name)) {
      if (comment->value == NULL) {
        if (value == NULL) return comment;
      } else if ((value && !strcmp (value, comment->value)) || 
                 (value == NULL && comment->value == NULL)) {
        return comment;
      }
    }
  }

  /* Allocate new comment and insert it */
  if ((new_comment = oggz_comment_new (name, value)) == NULL)
    return NULL;

  return oggz_vector_insert_p (stream->comments, new_comment);
}
Example #7
0
const OggzComment *
oggz_comment_first (OGGZ * oggz, long serialno)
{
    oggz_stream_t * stream;

    if (oggz == NULL) return NULL;

    stream = oggz_get_stream (oggz, serialno);
    if (stream == NULL) return NULL;

    return oggz_vector_nth_p (stream->comments, 0);
}
Example #8
0
void *
oggz_table_lookup (OggzTable * table, long key)
{
  int i, size;

  size = oggz_vector_size (table->keys);
  for (i = 0; i < size; i++) {
    if (oggz_vector_nth_l (table->keys, i) == key) {
      return oggz_vector_nth_p (table->data, i);
    }
  }

  return NULL;
}
Example #9
0
const OggzComment *
oggz_comment_next (OGGZ * oggz, long serialno, const OggzComment * comment)
{
    oggz_stream_t * stream;
    int i;

    if (oggz == NULL || comment == NULL) return NULL;

    stream = oggz_get_stream (oggz, serialno);
    if (stream == NULL) return NULL;

    i = oggz_vector_find_index_p (stream->comments, comment);

    return oggz_vector_nth_p (stream->comments, i+1);
}
Example #10
0
/*
 * Check if an oggz has metrics for all streams
 */
int
oggz_has_metrics (OGGZ * oggz)
{
  int i, size;
  oggz_stream_t * stream;

  if (oggz->metric != NULL) return 1;

  size = oggz_vector_size (oggz->streams);
  for (i = 0; i < size; i++) {
    stream = (oggz_stream_t *)oggz_vector_nth_p (oggz->streams, i);
    if (stream->metric == NULL) return 0;
  }

  return 1;
}
Example #11
0
const OggzComment *
oggz_comment_next_byname (OGGZ * oggz, long serialno,
                          const OggzComment * comment)
{
    oggz_stream_t * stream;
    OggzComment * v_comment;
    int i;

    if (oggz == NULL || comment == NULL) return NULL;

    stream = oggz_get_stream (oggz, serialno);
    if (stream == NULL) return NULL;

    i = oggz_vector_find_index_p (stream->comments, comment);

    for (i++; i < oggz_vector_size (stream->comments); i++) {
        v_comment = (OggzComment *) oggz_vector_nth_p (stream->comments, i);
        if (v_comment->name && !strcasecmp (comment->name, v_comment->name))
            return v_comment;
    }

    return NULL;
}