Commit 7e8bc47d authored by conrad's avatar conrad

updated to 0.8.0


git-svn-id: http://svn.annodex.net/liboggz/trunk@346 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 8bb668dc
...@@ -3,24 +3,39 @@ AC_INIT ...@@ -3,24 +3,39 @@ AC_INIT
AC_CONFIG_SRCDIR([src/liboggz/oggz.c]) AC_CONFIG_SRCDIR([src/liboggz/oggz.c])
AC_PREREQ(2.53) AC_PREREQ(2.53)
AC_CONFIG_AUX_DIR(autotools)
AC_CANONICAL_TARGET AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE(liboggz, 0.5.43) AM_INIT_AUTOMAKE(liboggz, 0.8.0)
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
SHARED_VERSION_INFO="0:5:0" SHARED_VERSION_INFO="1:0:0"
SHLIB_VERSION_ARG="" SHLIB_VERSION_ARG=""
# Checks for programs. # Checks for programs.
AC_PROG_CC AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET AC_PROG_MAKE_SET
AC_PROG_LIBTOOL AC_PROG_LIBTOOL
AC_PROG_RANLIB
AC_C_CONST AC_C_CONST
AC_C_BIGENDIAN AC_C_BIGENDIAN
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h inttypes.h stdlib.h string.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
# Checks for library functions.
AC_FUNC_REALLOC
AC_CHECK_FUNCS([memmove])
# Check for doxygen # Check for doxygen
AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, true, false) AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, true, false)
...@@ -30,15 +45,15 @@ if test $HAVE_DOXYGEN = "false"; then ...@@ -30,15 +45,15 @@ if test $HAVE_DOXYGEN = "false"; then
fi fi
# Check for docbook # Check for docbook
AC_CHECK_PROG(HAVE_DOCBOOK, docbook2man, true, false) AC_CHECK_PROG(HAVE_DOCBOOKTOMAN, docbook-to-man, true, false)
AM_CONDITIONAL(HAVE_DOCBOOK,$HAVE_DOCBOOK) AM_CONDITIONAL(HAVE_DOCBOOKTOMAN,$HAVE_DOCBOOKTOMAN)
AC_CHECK_PROG(HAVE_DOCBOOK2HTML, docbook2html, true, false)
dnl Check for types AM_CONDITIONAL(HAVE_DOCBOOK2HTML,$HAVE_DOCBOOK2HTML)
dnl Checks for libraries. dnl Checks for libraries.
LIBS="" LIBS=""
# check for getopt in standard library # check for getopt in a separate library
HAVE_GETOPT=no HAVE_GETOPT=no
AC_CHECK_LIB(getopt, getopt, HAVE_GETOPT="yes") AC_CHECK_LIB(getopt, getopt, HAVE_GETOPT="yes")
if test "x$HAVE_GETOPT" = xyes ; then if test "x$HAVE_GETOPT" = xyes ; then
...@@ -46,6 +61,13 @@ if test "x$HAVE_GETOPT" = xyes ; then ...@@ -46,6 +61,13 @@ if test "x$HAVE_GETOPT" = xyes ; then
AC_SUBST(GETOPT_LIBS) AC_SUBST(GETOPT_LIBS)
fi fi
# check for getopt_long in standard library
HAVE_GETOPT_LONG=no
AC_CHECK_FUNC(getopt_long, HAVE_GETOPT_LONG="yes")
if test "x$HAVE_GETOPT_LONG" = xyes ; then
AC_DEFINE(HAVE_GETOPT_LONG, [], [Define to 1 if you have the 'getopt_long' function])
fi
dnl Overall configuration success flag dnl Overall configuration success flag
oggz_config_ok=yes oggz_config_ok=yes
...@@ -211,6 +233,7 @@ src/Makefile ...@@ -211,6 +233,7 @@ src/Makefile
src/liboggz/Version_script src/liboggz/Version_script
src/liboggz/Makefile src/liboggz/Makefile
src/tools/Makefile src/tools/Makefile
src/tools/oggzdiff
src/tests/Makefile src/tests/Makefile
src/examples/Makefile src/examples/Makefile
oggz.pc oggz.pc
......
...@@ -419,7 +419,7 @@ EXAMPLE_RECURSIVE = NO ...@@ -419,7 +419,7 @@ EXAMPLE_RECURSIVE = NO
# directories that contain image that are included in the documentation (see # directories that contain image that are included in the documentation (see
# the \image command). # the \image command).
IMAGE_PATH = IMAGE_PATH = .
# The INPUT_FILTER tag can be used to specify a program that doxygen should # The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program # invoke to filter for each input file. Doxygen will invoke the filter program
......
docdir=$(prefix)/share/doc/@PACKAGE@ docdir=$(prefix)/share/doc/@PACKAGE@
EXTRA_DIST = Doxyfile.in liboggz EXTRA_DIST = Doxyfile.in \
forcefeed.fig forcefeed.eps forcefeed.png \
hungry.fig hungry.eps hungry.png \
oggzdump.1.sgml oggzdiff.1.sgml \
oggzdump.1 oggzdiff.1
all: doxygen-build.stamp man_MANS = oggzdump.1 oggzdiff.1
doc_DATA = doxygen-build.stamp
html: oggzdump.1.html
if HAVE_DOCBOOKTOMAN
%.1: %.1.sgml
docbook-to-man $< > $@
else
%.1: %.1.sgml
endif
if HAVE_DOCBOOK2HTML
%.1.html: %.1.sgml
-docbook2html $<
mv index.html $@
endif
if HAVE_DOXYGEN if HAVE_DOXYGEN
doxygen-build.stamp: Doxyfile $(top_srcdir)/include/oggz/*.h doxygen-build.stamp: Doxyfile $(top_srcdir)/include/oggz/*.h $(top_srcdir)/src/examples/*.c
doxygen doxygen
touch doxygen-build.stamp touch doxygen-build.stamp
else else
...@@ -14,6 +35,23 @@ doxygen-build.stamp: ...@@ -14,6 +35,23 @@ doxygen-build.stamp:
touch doxygen-build.stamp touch doxygen-build.stamp
endif endif
dist_docdir = $(distdir)/liboggz
dist-hook:
if test -d liboggz; then \
mkdir $(dist_docdir); \
for dir in liboggz/*; do \
if test -d $$dir; then \
b=`basename $$dir`; \
mkdir $(dist_docdir)/$$b; \
for f in $$dir/*; do \
cp -p $$f $(dist_docdir)/$$b; \
done \
fi \
done \
fi
install-data-local: doxygen-build.stamp install-data-local: doxygen-build.stamp
$(mkinstalldirs) $(docdir) $(mkinstalldirs) $(docdir)
if test -d liboggz; then \ if test -d liboggz; then \
...@@ -21,7 +59,9 @@ install-data-local: doxygen-build.stamp ...@@ -21,7 +59,9 @@ install-data-local: doxygen-build.stamp
if test -d $$dir; then \ if test -d $$dir; then \
b=`basename $$dir`; \ b=`basename $$dir`; \
$(mkinstalldirs) $(docdir)/$$b; \ $(mkinstalldirs) $(docdir)/$$b; \
(cd $$dir && $(INSTALL_DATA) * $(docdir)/$$b) \ for f in $$dir/*; do \
$(INSTALL_DATA) $$f $(docdir)/$$b; \
done \
fi \ fi \
done \ done \
fi fi
......
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
# Include files to install # Include files to install
includedir = $(prefix)/include/oggz includedir = $(prefix)/include/oggz
include_HEADERS = oggz.h oggz_constants.h include_HEADERS = oggz.h oggz_constants.h oggz_table.h
This diff is collapsed.
...@@ -39,6 +39,9 @@ ...@@ -39,6 +39,9 @@
/** /**
* Flags to oggz_new(), oggz_open(), and oggz_openfd(). * Flags to oggz_new(), oggz_open(), and oggz_openfd().
* Can be or'ed together in the following combinations:
* - OGGZ_READ | OGGZ_AUTO
* - OGGZ_WRITE | OGGZ_NONSTRICT
*/ */
enum OggzFlags { enum OggzFlags {
/** Read only */ /** Read only */
...@@ -49,7 +52,15 @@ enum OggzFlags { ...@@ -49,7 +52,15 @@ enum OggzFlags {
/** Disable strict adherence to mapping constraints, eg for /** Disable strict adherence to mapping constraints, eg for
* handling an incomplete stream */ * handling an incomplete stream */
OGGZ_NONSTRICT = 0x10 OGGZ_NONSTRICT = 0x10,
/**
* Scan for known headers while reading, and automatically set
* metrics appropriately. Opening a file for reading with
* \a flags = OGGZ_READ | OGGZ_AUTO will allow seeking on Speex,
* Vorbis, Theora and all Annodex streams in units of milliseconds,
* once all bos pages have been delivered. */
OGGZ_AUTO = 0x20
}; };
/** /**
...@@ -88,12 +99,18 @@ enum OggzError { ...@@ -88,12 +99,18 @@ enum OggzError {
/** Operation is inappropriate for oggz in current eos state */ /** Operation is inappropriate for oggz in current eos state */
OGGZ_ERR_EOS = -6, OGGZ_ERR_EOS = -6,
/** Operation requires a valid metric, but none has been set */
OGGZ_ERR_BAD_METRIC = -7,
/** System specific error; check errno for details */ /** System specific error; check errno for details */
OGGZ_ERR_SYSTEM = -10, OGGZ_ERR_SYSTEM = -10,
/** Functionality disabled at build time */ /** Functionality disabled at build time */
OGGZ_ERR_DISABLED = -11, OGGZ_ERR_DISABLED = -11,
/** Seeking operation is not possible for this OGGZ */
OGGZ_ERR_NOSEEK = -13,
/** The requested serialno does not exist in this OGGZ */ /** The requested serialno does not exist in this OGGZ */
OGGZ_ERR_BAD_SERIALNO = -20, OGGZ_ERR_BAD_SERIALNO = -20,
......
...@@ -17,11 +17,22 @@ if OGGZ_CONFIG_READ ...@@ -17,11 +17,22 @@ if OGGZ_CONFIG_READ
oggz_read_programs = read-file oggz_read_programs = read-file
endif endif
if OGGZ_CONFIG_WRITE
oggz_write_programs = write-feed write-hungry
endif
# Programs to build # Programs to build
noinst_PROGRAMS = $(oggz_rw_programs) $(oggz_read_programs) noinst_PROGRAMS = $(oggz_rw_programs) $(oggz_read_programs) \
$(oggz_write_programs)
identity_SOURCES = identity.c identity_SOURCES = identity.c
identity_LDADD = $(OGGZ_LIBS) identity_LDADD = $(OGGZ_LIBS)
read_file_SOURCES = read-file.c read_file_SOURCES = read-file.c
read_file_LDADD = $(OGGZ_LIBS) read_file_LDADD = $(OGGZ_LIBS)
write_feed_SOURCES = write-feed.c
write_feed_LDADD = $(OGGZ_LIBS)
write_hungry_SOURCES = write-hungry.c
write_hungry_LDADD = $(OGGZ_LIBS)
\ No newline at end of file
...@@ -34,7 +34,8 @@ ...@@ -34,7 +34,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <oggz/oggz.h> #include <oggz/oggz.h>
static int packetno = 0; #define ID_WRITE_DIRECT
static int flush_next = 0; static int flush_next = 0;
static int static int
...@@ -44,12 +45,20 @@ read_packet (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data) ...@@ -44,12 +45,20 @@ read_packet (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
int flush; int flush;
int ret; int ret;
#if 0
flush = flush_next; flush = flush_next;
if (op->granulepos == -1) { if (op->granulepos == -1) {
flush_next = 0; flush_next = 0;
} else { } else {
flush_next = OGGZ_FLUSH_BEFORE; flush_next = OGGZ_FLUSH_BEFORE;
} }
#else
if (op->granulepos == -1) {
flush = 0;
} else {
flush = OGGZ_FLUSH_AFTER;
}
#endif
if ((ret = oggz_write_feed (writer, op, serialno, flush, NULL)) != 0) { if ((ret = oggz_write_feed (writer, op, serialno, flush, NULL)) != 0) {
printf ("oggz_write_feed: %d\n", ret); printf ("oggz_write_feed: %d\n", ret);
...@@ -63,6 +72,8 @@ main (int argc, char ** argv) ...@@ -63,6 +72,8 @@ main (int argc, char ** argv)
{ {
char * infilename, * outfilename; char * infilename, * outfilename;
OGGZ * reader, * writer; OGGZ * reader, * writer;
FILE * outfile;
unsigned char buf[1024];
long n; long n;
if (argc < 3) { if (argc < 3) {
...@@ -77,17 +88,34 @@ main (int argc, char ** argv) ...@@ -77,17 +88,34 @@ main (int argc, char ** argv)
exit (1); exit (1);
} }
#ifdef ID_WRITE_DIRECT
if ((writer = oggz_open (outfilename, OGGZ_WRITE)) == NULL) { if ((writer = oggz_open (outfilename, OGGZ_WRITE)) == NULL) {
printf ("unable to open file %s\n", outfilename); printf ("unable to open file %s\n", outfilename);
exit (1); exit (1);
} }
#else
if ((writer = oggz_new (OGGZ_WRITE)) == NULL) {
printf ("Unable to create new writer\n");
}
outfile = fopen (outfilename, "w");
#endif
oggz_set_read_callback (reader, -1, read_packet, writer); oggz_set_read_callback (reader, -1, read_packet, writer);
while ((n = oggz_read (reader, 1024)) > 0) { while ((n = oggz_read (reader, 1024)) > 0) {
#ifdef ID_WRITE_DIRECT
while (oggz_write (writer, n) > 0); while (oggz_write (writer, n) > 0);
#else
while (oggz_write_output (writer, buf, n) > 0) {
fwrite (buf, 1, n, outfile);
}
#endif
} }
#ifndef ID_WRITE_DIRECT
fclose (outfile);
#endif
oggz_close (writer); oggz_close (writer);
oggz_close (reader); oggz_close (reader);
......
...@@ -68,7 +68,7 @@ main (int argc, char ** argv) ...@@ -68,7 +68,7 @@ main (int argc, char ** argv)
printf ("usage: %s filename\n", argv[0]); printf ("usage: %s filename\n", argv[0]);
} }
if ((oggz = oggz_open ((char *)argv[1], OGGZ_READ)) == NULL) { if ((oggz = oggz_open ((char *)argv[1], OGGZ_READ | OGGZ_AUTO)) == NULL) {
printf ("unable to open file %s\n", argv[1]); printf ("unable to open file %s\n", argv[1]);
exit (1); exit (1);
} }
......
...@@ -11,9 +11,10 @@ lib_LTLIBRARIES = liboggz.la ...@@ -11,9 +11,10 @@ lib_LTLIBRARIES = liboggz.la
liboggz_la_SOURCES = \ liboggz_la_SOURCES = \
oggz.c \ oggz.c \
oggz_private.h \ oggz_private.h oggz_byteorder.h oggz_macros.h \
oggz_read.c oggz_write.c \ oggz_read.c oggz_write.c \
oggz_auto.c oggz_auto.h \
oggz_table.c \
oggz_vector.c oggz_vector.h oggz_vector.c oggz_vector.h
liboggz_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@ @SHLIB_VERSION_ARG@ liboggz_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@ @SHLIB_VERSION_ARG@
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
global: global:
oggz_new; oggz_new;
oggz_open; oggz_open;
oggz_openfd; oggz_open_stdio;
oggz_flush; oggz_flush;
oggz_close; oggz_close;
oggz_get_bos; oggz_get_bos;
...@@ -24,11 +24,19 @@ ...@@ -24,11 +24,19 @@
oggz_write_output; oggz_write_output;
oggz_write_get_next_page_size; oggz_write_get_next_page_size;
oggz_set_metric; oggz_set_metric;
oggz_set_metric_linear;
oggz_seek_units; oggz_seek_units;
oggz_tell; oggz_tell;
oggz_seek; oggz_seek;
oggz_data_begins_here; oggz_set_data_start;
oggz_serialno_new; oggz_serialno_new;
oggz_table_new;
oggz_table_delete;
oggz_table_insert;
oggz_table_lookup;
oggz_table_size;
oggz_table_nth;
local: local:
*; *;
}; };
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include <ogg/ogg.h> #include <ogg/ogg.h>
#include "oggz_private.h" #include "oggz_private.h"
#include "oggz_vector.h"
/*#define DEBUG*/ /*#define DEBUG*/
...@@ -72,12 +73,12 @@ oggz_new (int flags) ...@@ -72,12 +73,12 @@ oggz_new (int flags)
if (oggz == NULL) return NULL; if (oggz == NULL) return NULL;
oggz->flags = flags; oggz->flags = flags;
oggz->fd = -1; oggz->file = NULL;
oggz->offset = 0; oggz->offset = 0;
oggz->offset_data_begin = 0; oggz->offset_data_begin = 0;
oggz_vector_init (&oggz->streams, sizeof (oggz_stream_t)); oggz->streams = oggz_vector_new ();
oggz->all_at_eos = 0; oggz->all_at_eos = 0;
oggz->metric = NULL; oggz->metric = NULL;
...@@ -100,32 +101,32 @@ OGGZ * ...@@ -100,32 +101,32 @@ OGGZ *
oggz_open (char * filename, int flags) oggz_open (char * filename, int flags)
{ {
OGGZ * oggz = NULL; OGGZ * oggz = NULL;
int fd = -1; FILE * file = NULL;
if (oggz_flags_disabled (flags)) return NULL; if (oggz_flags_disabled (flags)) return NULL;
if (flags & OGGZ_WRITE) { if (flags & OGGZ_WRITE) {
fd = open (filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); file = fopen (filename, "w");
} else { } else {
fd = open (filename, O_RDONLY); file = fopen (filename, "r");
} }
if (fd == -1) return NULL; if (file == NULL) return NULL;
oggz = oggz_new (flags); oggz = oggz_new (flags);
oggz->fd = fd; oggz->file = file;
return oggz; return oggz;
} }
OGGZ * OGGZ *
oggz_openfd (int fd, int flags) oggz_open_stdio (FILE * file, int flags)
{ {
OGGZ * oggz = NULL; OGGZ * oggz = NULL;
if (oggz_flags_disabled (flags)) return NULL; if (oggz_flags_disabled (flags)) return NULL;
oggz = oggz_new (flags); oggz = oggz_new (flags);
oggz->fd = fd; oggz->file = file;
return oggz; return oggz;
} }
...@@ -135,9 +136,9 @@ oggz_flush (OGGZ * oggz) ...@@ -135,9 +136,9 @@ oggz_flush (OGGZ * oggz)
{ {
if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
if (oggz->fd == -1) return OGGZ_ERR_INVALID; if (oggz->file == NULL) return OGGZ_ERR_INVALID;
if (fsync (oggz->fd) == -1) { if (fflush (oggz->file) == EOF) {
return OGGZ_ERR_SYSTEM; return OGGZ_ERR_SYSTEM;
} }
...@@ -163,8 +164,8 @@ oggz_close (OGGZ * oggz) ...@@ -163,8 +164,8 @@ oggz_close (OGGZ * oggz)
{ {
if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
oggz_vector_foreach (&oggz->streams, oggz_stream_clear); oggz_vector_foreach (oggz->streams, oggz_stream_clear);
oggz_vector_clear (&oggz->streams); oggz_vector_delete (oggz->streams);
if (OGGZ_CONFIG_WRITE && (oggz->flags & OGGZ_WRITE)) {