Commit ae0eace5 authored by conrad's avatar conrad

cleaning up -- remove oggz_private.h dependence from oggz_auto.c


git-svn-id: http://svn.annodex.net/liboggz/trunk@709 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent e8fe316a
......@@ -449,6 +449,24 @@ oggz_set_metric_linear (OGGZ * oggz, long serialno,
linear_data, 1);
}
/*
* Check if a stream in an oggz has a metric
*/
int
oggz_stream_has_metric (OGGZ * oggz, long serialno)
{
oggz_stream_t * stream;
if (oggz->metric != NULL) return 1;
stream = oggz_get_stream (oggz, serialno);
if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO;
if (stream->metric != NULL) return 1;
return 0;
}
/*
* Check if an oggz has metrics for all streams
*/
......
......@@ -42,10 +42,11 @@
#include <stdlib.h>
#include <string.h>
#include "oggz_private.h"
#include <oggz/oggz.h>
#include "oggz_auto.h"
#include "oggz_byteorder.h"
#include "oggz_macros.h"
#include "oggz_stream.h"
/* Allow use of internal metrics; ie. the user_data for these gets free'd
* when the metric is overwritten, or on close */
......@@ -299,7 +300,6 @@ auto_fisbone (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
{
unsigned char * header = op->packet;
long fisbone_serialno; /* The serialno referred to in this fisbone */
oggz_stream_t * fisbone_stream; /* The stream of that serialno */
ogg_int64_t granule_rate_numerator = 0, granule_rate_denominator = 0;
if (op->bytes < 48) return 0;
......@@ -307,10 +307,9 @@ auto_fisbone (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
if (strncmp ((char *)header, "fisbone", 7)) return 0;
fisbone_serialno = (long) INT32_LE_AT(&header[12]);
fisbone_stream = oggz_get_stream (oggz, fisbone_serialno);
/* Don't override an already assigned metric */
if (fisbone_stream->metric) return 1;
if (oggz_stream_has_metric (oggz, fisbone_serialno)) return 1;
granule_rate_numerator = INT64_LE_AT(&header[20]);
granule_rate_denominator = INT64_LE_AT(&header[28]);
......
......@@ -47,6 +47,9 @@ typedef struct _OggzIO OggzIO;
typedef struct _OggzReader OggzReader;
typedef struct _OggzWriter OggzWriter;
/* oggz_stream */
#include "oggz_stream.h"
typedef int (*OggzReadPacket) (OGGZ * oggz, ogg_packet * op, long serialno,
void * user_data);
typedef int (*OggzReadPage) (OGGZ * oggz, const ogg_page * og, long serialno,
......@@ -68,7 +71,7 @@ typedef int (*OggzIOSeek) (void * user_handle, long offset, int whence);
typedef long (*OggzIOTell) (void * user_handle);
typedef int (*OggzIOFlush) (void * user_handle);
typedef struct {
struct _oggz_stream_t {
ogg_stream_state ogg_stream;
/* non b_o_s packet has been written (not just queued) */
......@@ -91,7 +94,7 @@ typedef struct {
OggzReadPage read_page;
void * read_page_user_data;
} oggz_stream_t;
};
struct _OggzReader {
ogg_sync_state ogg_sync;
......@@ -207,9 +210,6 @@ OGGZ * oggz_write_init (OGGZ * oggz);
int oggz_write_flush (OGGZ * oggz);
OGGZ * oggz_write_close (OGGZ * oggz);
oggz_stream_t * oggz_get_stream (OGGZ * oggz, long serialno);
oggz_stream_t * oggz_add_stream (OGGZ * oggz, long serialno);
int oggz_get_bos (OGGZ * oggz, long serialno);
ogg_int64_t oggz_get_unit (OGGZ * oggz, long serialno, ogg_int64_t granulepos);
......
/*
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.
*/
#ifndef __OGGZ_STREAM_H__
#define __OGGZ_STREAM_H__
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);
#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