Commit a1b3377d authored by conrad's avatar conrad

add oggz_stream.c, basic stream identification and fishead/fisbone consistency

checking


git-svn-id: http://svn.annodex.net/liboggz/trunk@710 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent ae0eace5
......@@ -15,6 +15,7 @@ liboggz_la_SOURCES = \
oggz_io.c \
oggz_read.c oggz_write.c \
oggz_auto.c oggz_auto.h \
oggz_stream.c oggz_stream.h \
oggz_table.c \
oggz_vector.c oggz_vector.h
......
......@@ -260,6 +260,8 @@ oggz_add_stream (OGGZ * oggz, long serialno)
ogg_stream_init (&stream->ogg_stream, (int)serialno);
stream->content = OGGZ_CONTENT_UNKNOWN;
stream->delivered_non_b_o_s = 0;
stream->b_o_s = 1;
stream->e_o_s = 0;
......
......@@ -277,27 +277,31 @@ auto_cmml (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
return 1;
}
#if 0
static int
auto_fishead (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
{
unsigned char * header = op->packet;
if (op->bytes < 8) return 0;
if (strncmp ((char *)header, "fishead", 8)) return 0;
if (!op->b_o_s) return 0;
/* Yeah ... set it up with a "linear" metric with numerator 0 :) */
oggz_set_metric_linear (oggz, serialno, 0, 1);
int content;
if (op->b_o_s) {
if (op->bytes < 8) return 0;
if (strncmp ((char *)header, "fishead", 8)) return 0;
oggz_stream_set_content (oggz, serialno, OGGZ_CONTENT_SKELETON);
} else if (op->e_o_s) {
content = oggz_stream_get_content (oggz, serialno);
if (content != OGGZ_CONTENT_SKELETON) return 0;
/* Finished processing the skeleton; apply a zero metric */
oggz_set_metric_linear (oggz, serialno, 0, 1);
}
return 1;
}
#endif
static int
auto_fisbone (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
{
int content;
unsigned char * header = op->packet;
long fisbone_serialno; /* The serialno referred to in this fisbone */
ogg_int64_t granule_rate_numerator = 0, granule_rate_denominator = 0;
......@@ -305,6 +309,8 @@ auto_fisbone (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
if (op->bytes < 48) return 0;
if (strncmp ((char *)header, "fisbone", 7)) return 0;
content = oggz_stream_get_content (oggz, serialno);
if (content != OGGZ_CONTENT_SKELETON) return 0;
fisbone_serialno = (long) INT32_LE_AT(&header[12]);
......
......@@ -74,6 +74,8 @@ typedef int (*OggzIOFlush) (void * user_handle);
struct _oggz_stream_t {
ogg_stream_state ogg_stream;
int content;
/* non b_o_s packet has been written (not just queued) */
int delivered_non_b_o_s;
......
/*
Copyright (C) 2003 Commonwealth Scientific and Industrial Research
Organisation (CSIRO) Australia
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of CSIRO Australia nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "oggz_private.h"
int
oggz_stream_set_content (OGGZ * oggz, long serialno, int content)
{
oggz_stream_t * stream;
stream = oggz_get_stream (oggz, serialno);
if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO;
stream->content = content;
return 0;
}
int
oggz_stream_get_content (OGGZ * oggz, long serialno)
{
oggz_stream_t * stream;
stream = oggz_get_stream (oggz, serialno);
if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO;
return stream->content;
}
......@@ -33,11 +33,18 @@
#ifndef __OGGZ_STREAM_H__
#define __OGGZ_STREAM_H__
enum {
OGGZ_CONTENT_UNKNOWN = 0,
OGGZ_CONTENT_SKELETON = 1
};
typedef struct _oggz_stream_t oggz_stream_t;
oggz_stream_t * oggz_get_stream (OGGZ * oggz, long serialno);
oggz_stream_t * oggz_add_stream (OGGZ * oggz, long serialno);
int oggz_stream_has_metric (OGGZ * oggz, long serialno);
int oggz_stream_set_content (OGGZ * oggz, long serialno, int content);
int oggz_stream_get_content (OGGZ * oggz, long serialno);
#endif /* __OGGZ_STREAM_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment