initial import
authorJosh Coalson <jcoalson@users.sourceforce.net>
Wed, 7 Aug 2002 17:05:16 +0000 (17:05 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Wed, 7 Aug 2002 17:05:16 +0000 (17:05 +0000)
include/OggFLAC++/Makefile.am [new file with mode: 0644]
include/OggFLAC++/all.h [new file with mode: 0644]
include/OggFLAC++/decoder.h [new file with mode: 0644]
include/OggFLAC++/encoder.h [new file with mode: 0644]
src/libOggFLAC++/Makefile.am [new file with mode: 0644]
src/libOggFLAC++/Makefile.lite [new file with mode: 0644]
src/libOggFLAC++/Makefile.vc [new file with mode: 0644]
src/libOggFLAC++/libOggFLAC++.m4 [new file with mode: 0644]
src/libOggFLAC++/stream_decoder.cc [new file with mode: 0644]
src/libOggFLAC++/stream_encoder.cc [new file with mode: 0644]

diff --git a/include/OggFLAC++/Makefile.am b/include/OggFLAC++/Makefile.am
new file mode 100644 (file)
index 0000000..3b50cb0
--- /dev/null
@@ -0,0 +1,24 @@
+#  libOggFLAC++ - Free Lossless Audio Codec + Ogg library
+#  Copyright (C) 2002  Josh Coalson
+#
+#  This library is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU Library General Public
+#  License as published by the Free Software Foundation; either
+#  version 2 of the License, or (at your option) any later version.
+#
+#  This library is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  Library General Public License for more details.
+#
+#  You should have received a copy of the GNU Library General Public
+#  License along with this library; if not, write to the
+#  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+#  Boston, MA  02111-1307, USA.
+
+includedir = ${prefix}/include/OggFLAC++
+
+include_HEADERS = \
+       all.h \
+       decoder.h \
+       encoder.h
diff --git a/include/OggFLAC++/all.h b/include/OggFLAC++/all.h
new file mode 100644 (file)
index 0000000..b5e3007
--- /dev/null
@@ -0,0 +1,33 @@
+/* libOggFLAC++ - Free Lossless Audio Codec + Ogg library
+ * Copyright (C) 2002  Josh Coalson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA  02111-1307, USA.
+ */
+
+#ifndef OggFLACPP__ALL_H
+#define OggFLACPP__ALL_H
+
+#include "encoder.h"
+#include "decoder.h"
+
+/** \defgroup oggflacpp OggFLAC C++ API
+ *
+ * The OggFLAC C++ API is the interface to libOggFLAC++, a set of classes
+ * that encapsulate the encoders and decoders interfaces in libOggFLAC.
+ *
+ */
+
+#endif
diff --git a/include/OggFLAC++/decoder.h b/include/OggFLAC++/decoder.h
new file mode 100644 (file)
index 0000000..21a7e41
--- /dev/null
@@ -0,0 +1,153 @@
+/* libOggFLAC++ - Free Lossless Audio Codec + Ogg library
+ * Copyright (C) 2002  Josh Coalson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA  02111-1307, USA.
+ */
+
+#ifndef OggFLACPP__DECODER_H
+#define OggFLACPP__DECODER_H
+
+#include "OggFLAC/stream_decoder.h"
+// we only need this for the state abstraction really...
+#include "FLAC++/decoder.h"
+
+// ===============================================================
+//
+//  Full documentation for the decoder interfaces can be found
+//  in the C layer in include/OggFLAC/ *_decoder.h
+//
+// ===============================================================
+
+
+/** \file include/OggFLAC++/decoder.h
+ *
+ *  \brief
+ *  This file contains the classes which implement the various
+ *  decoders.
+ *
+ *  See the detailed documentation in the
+ *  \link oggflacpp_decoder decoder \endlink module.
+ */
+
+/** \defgroup oggflacpp_decoder OggFLAC++/decoder.h: decoder classes
+ *  \ingroup oggflacpp
+ *
+ *  \brief
+ *  Brief XXX.
+ *
+ * Detailed decoder XXX.
+ */
+
+namespace OggFLAC {
+       namespace Decoder {
+
+               // ============================================================
+               //
+               //  The only real difference here is that instead of passing
+               //  in C function pointers for callbacks, you inherit from
+               //  stream and provide implementations for the callbacks in
+               //  the derived class; because of this there is no need for a
+               //  'client_data' property.
+               //
+               // ============================================================
+
+               // ============================================================
+               //
+               //  Equivalent: OggFLAC__StreamDecoder
+               //
+               // ============================================================
+
+               /** \defgroup oggflacpp_stream_decoder OggFLAC++/decoder.h: stream decoder class
+                *  \ingroup oggflacpp_decoder
+                *
+                *  \brief
+                *  Brief XXX.
+                *
+                * Detailed stream decoder XXX.
+                * \{
+                */
+
+               /** stream decoder XXX.
+                */
+               class Stream {
+               public:
+                       class State {
+                       public:
+                               inline State(::OggFLAC__StreamDecoderState state): state_(state) { }
+                               inline operator ::OggFLAC__StreamDecoderState() const { return state_; }
+                               inline const char *as_cstring() const { return ::OggFLAC__StreamDecoderStateString[state_]; }
+                       protected:
+                               ::OggFLAC__StreamDecoderState state_;
+                       };
+
+                       Stream();
+                       virtual ~Stream();
+
+                       bool is_valid() const;
+                       inline operator bool() const { return is_valid(); }
+
+                       bool set_metadata_respond(::FLAC__MetadataType type);
+                       bool set_metadata_respond_application(const FLAC__byte id[4]);
+                       bool set_metadata_respond_all();
+                       bool set_metadata_ignore(::FLAC__MetadataType type);
+                       bool set_metadata_ignore_application(const FLAC__byte id[4]);
+                       bool set_metadata_ignore_all();
+
+                       State get_state() const;
+                       FLAC::Decoder::Stream::State get_FLAC_stream_decoder_state() const;
+                       unsigned get_channels() const;
+                       ::FLAC__ChannelAssignment get_channel_assignment() const;
+                       unsigned get_bits_per_sample() const;
+                       unsigned get_sample_rate() const;
+                       unsigned get_blocksize() const;
+
+                       // Initialize the instance; as with the C interface,
+                       // init() should be called after construction and 'set'
+                       // calls but before any of the 'process' calls.
+                       State init();
+
+                       void finish();
+
+                       bool flush();
+                       bool reset();
+
+                       bool process_single();
+                       bool process_until_end_of_metadata();
+                       bool process_until_end_of_stream();
+               protected:
+                       virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
+                       virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
+                       virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
+                       virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
+
+                       ::OggFLAC__StreamDecoder *decoder_;
+               private:
+                       static ::FLAC__StreamDecoderReadStatus read_callback_(const ::OggFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
+                       static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
+                       static void metadata_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
+                       static void error_callback_(const ::OggFLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
+
+                       // Private and undefined so you can't use them:
+                       Stream(const Stream &);
+                       void operator=(const Stream &);
+               };
+
+               /* \} */
+
+       };
+};
+
+#endif
diff --git a/include/OggFLAC++/encoder.h b/include/OggFLAC++/encoder.h
new file mode 100644 (file)
index 0000000..f89ca15
--- /dev/null
@@ -0,0 +1,168 @@
+/* libOggFLAC++ - Free Lossless Audio Codec + Ogg library
+ * Copyright (C) 2002  Josh Coalson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA  02111-1307, USA.
+ */
+
+#ifndef OggFLACPP__ENCODER_H
+#define OggFLACPP__ENCODER_H
+
+#include "OggFLAC/stream_encoder.h"
+#include "decoder.h"
+// we only need these for the state abstractions really...
+#include "FLAC++/decoder.h"
+#include "FLAC++/encoder.h"
+
+// ===============================================================
+//
+//  Full documentation for the encoder interfaces can be found
+//  in the C layer in include/OggFLAC/ *_encoder.h
+//
+// ===============================================================
+
+
+/** \file include/OggFLAC++/encoder.h
+ *
+ *  \brief
+ *  This module contains the classes which implement the various
+ *  encoders.
+ *
+ *  See the detailed documentation in the
+ *  \link oggflacpp_encoder encoder \endlink module.
+ */
+
+/** \defgroup oggflacpp_encoder OggFLAC++/encoder.h: encoder classes
+ *  \ingroup oggflacpp
+ *
+ *  \brief
+ *  Brief XXX.
+ *
+ * Detailed encoder XXX.
+ */
+
+namespace OggFLAC {
+       namespace Encoder {
+
+               // ============================================================
+               //
+               //  Equivalent: OggFLAC__StreamEncoder
+               //
+               //  ----------------------------------------------------------
+               //
+               //  The only real difference here is that instead of passing
+               //  in C function pointers for callbacks, you inherit from
+               //  stream and provide implementations for the callbacks in
+               //  the derived class; because of this there is no need for a
+               //  'client_data' property.
+               //
+               // ============================================================
+
+               /** \defgroup oggflacpp_stream_encoder OggFLAC++/encoder.h: stream encoder class
+                *  \ingroup oggflacpp_encoder
+                *
+                *  \brief
+                *  Brief XXX.
+                *
+                * Detailed stream encoder XXX.
+                * \{
+                */
+
+               /** stream encoder XXX.
+                */
+               class Stream {
+               public:
+                       class State {
+                       public:
+                               inline State(::OggFLAC__StreamEncoderState state): state_(state) { }
+                               inline operator ::OggFLAC__StreamEncoderState() const { return state_; }
+                               inline const char *as_cstring() const { return ::OggFLAC__StreamEncoderStateString[state_]; }
+                       protected:
+                               ::OggFLAC__StreamEncoderState state_;
+                       };
+
+                       Stream();
+                       virtual ~Stream();
+
+                       bool is_valid() const;
+                       inline operator bool() const { return is_valid(); }
+
+                       bool set_verify(bool value);
+                       bool set_streamable_subset(bool value);
+                       bool set_do_mid_side_stereo(bool value);
+                       bool set_loose_mid_side_stereo(bool value);
+                       bool set_channels(unsigned value);
+                       bool set_bits_per_sample(unsigned value);
+                       bool set_sample_rate(unsigned value);
+                       bool set_blocksize(unsigned value);
+                       bool set_max_lpc_order(unsigned value);
+                       bool set_qlp_coeff_precision(unsigned value);
+                       bool set_do_qlp_coeff_prec_search(bool value);
+                       bool set_do_escape_coding(bool value);
+                       bool set_do_exhaustive_model_search(bool value);
+                       bool set_min_residual_partition_order(unsigned value);
+                       bool set_max_residual_partition_order(unsigned value);
+                       bool set_rice_parameter_search_dist(unsigned value);
+                       bool set_total_samples_estimate(FLAC__uint64 value);
+                       bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
+
+                       State    get_state() const;
+                       FLAC::Encoder::Stream::State get_FLAC_stream_encoder_state() const;
+                       FLAC::Decoder::Stream::State get_verify_decoder_state() const;
+                       bool     get_verify() const;
+                       bool     get_streamable_subset() const;
+                       bool     get_do_mid_side_stereo() const;
+                       bool     get_loose_mid_side_stereo() const;
+                       unsigned get_channels() const;
+                       unsigned get_bits_per_sample() const;
+                       unsigned get_sample_rate() const;
+                       unsigned get_blocksize() const;
+                       unsigned get_max_lpc_order() const;
+                       unsigned get_qlp_coeff_precision() const;
+                       bool     get_do_qlp_coeff_prec_search() const;
+                       bool     get_do_escape_coding() const;
+                       bool     get_do_exhaustive_model_search() const;
+                       unsigned get_min_residual_partition_order() const;
+                       unsigned get_max_residual_partition_order() const;
+                       unsigned get_rice_parameter_search_dist() const;
+                       FLAC__uint64 get_total_samples_estimate() const;
+
+                       // Initialize the instance; as with the C interface,
+                       // init() should be called after construction and 'set'
+                       // calls but before any of the 'process' calls.
+                       State init();
+
+                       void finish();
+
+                       bool process(const FLAC__int32 * const buffer[], unsigned samples);
+                       bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
+               protected:
+                       virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
+
+                       ::OggFLAC__StreamEncoder *encoder_;
+               private:
+                       static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::OggFLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
+
+                       // Private and undefined so you can't use them:
+                       Stream(const Stream &);
+                       void operator=(const Stream &);
+               };
+
+               /* \} */
+
+       };
+};
+
+#endif
diff --git a/src/libOggFLAC++/Makefile.am b/src/libOggFLAC++/Makefile.am
new file mode 100644 (file)
index 0000000..1d8f1ca
--- /dev/null
@@ -0,0 +1,35 @@
+#  libOggFLAC++ - Free Lossless Audio Codec + Ogg library
+#  Copyright (C) 2002  Josh Coalson
+#
+#  This library is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU Library General Public
+#  License as published by the Free Software Foundation; either
+#  version 2 of the License, or (at your option) any later version.
+#
+#  This library is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  Library General Public License for more details.
+#
+#  You should have received a copy of the GNU Library General Public
+#  License along with this library; if not, write to the
+#  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+#  Boston, MA  02111-1307, USA.
+
+lib_LTLIBRARIES = libOggFLAC++.la
+CXXFLAGS = @CXXFLAGS@
+
+m4datadir = $(datadir)/aclocal
+m4data_DATA = libOggFLAC++.m4
+
+EXTRA_DIST = \
+       Makefile.lite \
+       Makefile.vc \
+       libOggFLAC++.m4
+
+# see 'http://www.gnu.org/software/libtool/manual.html#Versioning' for numbering convention
+libOggFLAC___la_LDFLAGS = -version-info 0:0:0
+
+libOggFLAC___la_SOURCES = \
+       stream_decoder.cc \
+       stream_encoder.cc 
diff --git a/src/libOggFLAC++/Makefile.lite b/src/libOggFLAC++/Makefile.lite
new file mode 100644 (file)
index 0000000..025d6e2
--- /dev/null
@@ -0,0 +1,32 @@
+#  libOggFLAC++ - Free Lossless Audio Codec + Ogg library
+#  Copyright (C) 2002  Josh Coalson
+#
+#  This library is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU Library General Public
+#  License as published by the Free Software Foundation; either
+#  version 2 of the License, or (at your option) any later version.
+#
+#  This library is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  Library General Public License for more details.
+#
+#  You should have received a copy of the GNU Library General Public
+#  License along with this library; if not, write to the
+#  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+#  Boston, MA  02111-1307, USA.
+
+#
+# GNU makefile
+#
+
+LIB_NAME = libOggFLAC++
+INCLUDES = -I../../include
+
+OBJS = \
+       stream_decoder.o \
+       stream_encoder.o
+
+include ../../build/lib.mk
+
+# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/libOggFLAC++/Makefile.vc b/src/libOggFLAC++/Makefile.vc
new file mode 100644 (file)
index 0000000..1383fcb
--- /dev/null
@@ -0,0 +1,50 @@
+#  libOggFLAC++ - Free Lossless Audio Codec + Ogg library\r
+#  Copyright (C) 2002  Josh Coalson\r
+#\r
+#  This library is free software; you can redistribute it and/or\r
+#  modify it under the terms of the GNU Library General Public\r
+#  License as published by the Free Software Foundation; either\r
+#  version 2 of the License, or (at your option) any later version.\r
+#\r
+#  This library is distributed in the hope that it will be useful,\r
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+#  Library General Public License for more details.\r
+#\r
+#  You should have received a copy of the GNU Library General Public\r
+#  License along with this library; if not, write to the\r
+#  Free Software Foundation, Inc., 59 Temple Place - Suite 330,\r
+#  Boston, MA  02111-1307, USA.\r
+\r
+!include <win32.mak>\r
+\r
+SUFFIXES = .cc\r
+\r
+!IFDEF DEBUG\r
+.cc.obj:\r
+       $(cc) /D "_LIB" /GX /GR $(cdebug) $(cflags) /I "..\..\include" -DSTRICT -YX /Od /D "_DEBUG" $<\r
+!else\r
+.cc.obj:\r
+       $(cc) /D "_LIB" /O2 /GR $(crelease) $(cflags) /I "..\..\include" -DSTRICT -YX -DNODEBUG $<\r
+!endif\r
+\r
+CC_FILES= \\r
+       stream_decoder.cc \\r
+       stream_encoder.cc\r
+\r
+OBJS= $(CC_FILES:.cc=.obj)\r
+\r
+all: libOggFLAC++.lib\r
+\r
+libOggFLAC++.lib: $(OBJS)\r
+       link.exe -lib /nodefaultlib -out:../../obj/lib/$*.lib $(OBJS)\r
+\r
+# can't figure out how to get it to take .cc so we just hack it for now:\r
+stream_decoder.obj: stream_decoder.cc\r
+       $(cc) /D "_LIB" /O2 /GR $(crelease) $(cflags) /I "..\..\include" -DSTRICT -YX -DNODEBUG /TP stream_decoder.cc\r
+stream_encoder.obj: stream_encoder.cc\r
+       $(cc) /D "_LIB" /O2 /GR $(crelease) $(cflags) /I "..\..\include" -DSTRICT -YX -DNODEBUG /TP stream_encoder.cc\r
+\r
+clean:\r
+       -del *.obj *.pch\r
+       -del ..\..\obj\lib\libOggFLAC++.lib ..\..\obj\lib\libOggFLAC++.pdb\r
diff --git a/src/libOggFLAC++/libOggFLAC++.m4 b/src/libOggFLAC++/libOggFLAC++.m4
new file mode 100644 (file)
index 0000000..ead89d6
--- /dev/null
@@ -0,0 +1,107 @@
+# Configure paths for libOggFLAC++
+# "Inspired" by ogg.m4
+# Caller must first run AM_PATH_LIBOGGFLAC
+
+dnl AM_PATH_LIBOGGFLACPP([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+dnl Test for libOggFLAC++, and define LIBOGGFLACPP_CFLAGS and LIBOGGFLACPP_LIBS
+dnl
+AC_DEFUN(AM_PATH_LIBOGGFLACPP,
+[dnl 
+dnl Get the cflags and libraries
+dnl
+AC_ARG_WITH(libOggFLACPP,[  --with-libOggFLACPP=PFX   Prefix where libOggFLAC++ is installed (optional)], libOggFLACPP_prefix="$withval", libOggFLACPP_prefix="")
+AC_ARG_WITH(libOggFLACPP-libraries,[  --with-libOggFLACPP-libraries=DIR   Directory where libOggFLAC++ library is installed (optional)], libOggFLACPP_libraries="$withval", libOggFLACPP_libraries="")
+AC_ARG_WITH(libOggFLACPP-includes,[  --with-libOggFLACPP-includes=DIR   Directory where libOggFLAC++ header files are installed (optional)], libOggFLACPP_includes="$withval", libOggFLACPP_includes="")
+AC_ARG_ENABLE(libOggFLACPPtest, [  --disable-libOggFLACPPtest       Do not try to compile and run a test libOggFLAC++ program],, enable_libOggFLACPPtest=yes)
+
+  if test "x$libOggFLACPP_libraries" != "x" ; then
+    LIBOGGFLACPP_LIBS="-L$libOggFLACPP_libraries"
+  elif test "x$libOggFLACPP_prefix" != "x" ; then
+    LIBOGGFLACPP_LIBS="-L$libOggFLACPP_prefix/lib"
+  elif test "x$prefix" != "xNONE" ; then
+    LIBOGGFLACPP_LIBS="-L$prefix/lib"
+  fi
+
+  LIBOGGFLACPP_LIBS="$LIBOGGFLACPP_LIBS -lOggFLAC++ $LIBOGGFLAC_LIBS"
+
+  if test "x$libOggFLACPP_includes" != "x" ; then
+    LIBOGGFLACPP_CFLAGS="-I$libOggFLACPP_includes"
+  elif test "x$libOggFLACPP_prefix" != "x" ; then
+    LIBOGGFLACPP_CFLAGS="-I$libOggFLACPP_prefix/include"
+  elif test "$prefix" != "xNONE"; then
+    LIBOGGFLACPP_CFLAGS="-I$prefix/include"
+  fi
+
+  LIBOGGFLACPP_CFLAGS="$LIBOGGFLACPP_CFLAGS $LIBOGGFLAC_CFLAGS"
+
+  AC_MSG_CHECKING(for libOggFLAC++)
+  no_libOggFLACPP=""
+
+
+  if test "x$enable_libOggFLACPPtest" = "xyes" ; then
+    ac_save_CFLAGS="$CFLAGS"
+    ac_save_CXXFLAGS="$CXXFLAGS"
+    ac_save_LIBS="$LIBS"
+    CFLAGS="$CFLAGS $LIBOGGFLACPP_CFLAGS"
+    CXXFLAGS="$CXXFLAGS $LIBOGGFLACPP_CFLAGS"
+    LIBS="$LIBS $LIBOGGFLACPP_LIBS"
+dnl
+dnl Now check if the installed libOggFLAC++ is sufficiently new.
+dnl
+      rm -f conf.libOggFLAC++test
+      AC_TRY_RUN([
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <OggFLAC++/decoder.h>
+
+int main ()
+{
+  system("touch conf.libOggFLAC++test");
+  return 0;
+}
+
+],, no_libOggFLACPP=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
+       CFLAGS="$ac_save_CFLAGS"
+       LIBS="$ac_save_LIBS"
+  fi
+
+  if test "x$no_libOggFLACPP" = "x" ; then
+     AC_MSG_RESULT(yes)
+     ifelse([$1], , :, [$1])     
+  else
+     AC_MSG_RESULT(no)
+     if test -f conf.libOggFLAC++test ; then
+       :
+     else
+       echo "*** Could not run libOggFLAC++ test program, checking why..."
+       CFLAGS="$CFLAGS $LIBOGGFLACPP_CFLAGS"
+       LIBS="$LIBS $LIBOGGFLACPP_LIBS"
+       AC_TRY_LINK([
+#include <stdio.h>
+#include <OggFLAC++/decoder.h>
+],     [ return 0; ],
+       [ echo "*** The test program compiled, but did not run. This usually means"
+       echo "*** that the run-time linker is not finding libOggFLAC++ or finding the wrong"
+       echo "*** version of libOggFLAC++. If it is not finding libOggFLAC++, you'll need to set your"
+       echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
+       echo "*** to the installed location  Also, make sure you have run ldconfig if that"
+       echo "*** is required on your system"
+       echo "***"
+       echo "*** If you have an old version installed, it is best to remove it, although"
+       echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
+       [ echo "*** The test program failed to compile or link. See the file config.log for the"
+       echo "*** exact error that occured. This usually means libOggFLAC++ was incorrectly installed"
+       echo "*** or that you have moved libOggFLAC++ since it was installed. In the latter case, you"
+       echo "*** may want to edit the libOggFLAC++-config script: $LIBFLACPP_CONFIG" ])
+       CFLAGS="$ac_save_CFLAGS"
+       LIBS="$ac_save_LIBS"
+     fi
+     LIBOGGFLACPP_CFLAGS=""
+     LIBOGGFLACPP_LIBS=""
+     ifelse([$2], , :, [$2])
+  fi
+  AC_SUBST(LIBOGGFLACPP_CFLAGS)
+  AC_SUBST(LIBOGGFLACPP_LIBS)
+  rm -f conf.libOggFLAC++test
+])
diff --git a/src/libOggFLAC++/stream_decoder.cc b/src/libOggFLAC++/stream_decoder.cc
new file mode 100644 (file)
index 0000000..ad44142
--- /dev/null
@@ -0,0 +1,205 @@
+/* libOggFLAC++ - Free Lossless Audio Codec + Ogg library
+ * Copyright (C) 2002  Josh Coalson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA  02111-1307, USA.
+ */
+
+#include "OggFLAC++/decoder.h"
+#include "FLAC/assert.h"
+
+namespace OggFLAC {
+       namespace Decoder {
+
+               Stream::Stream():
+               decoder_(::OggFLAC__stream_decoder_new())
+               { }
+
+               Stream::~Stream()
+               {
+                       if(0 != decoder_) {
+                               ::OggFLAC__stream_decoder_finish(decoder_);
+                               ::OggFLAC__stream_decoder_delete(decoder_);
+                       }
+               }
+
+               bool Stream::is_valid() const
+               {
+                       return 0 != decoder_;
+               }
+
+               bool Stream::set_metadata_respond(::FLAC__MetadataType type)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_decoder_set_metadata_respond(decoder_, type);
+               }
+
+               bool Stream::set_metadata_respond_application(const FLAC__byte id[4])
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_decoder_set_metadata_respond_application(decoder_, id);
+               }
+
+               bool Stream::set_metadata_respond_all()
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_decoder_set_metadata_respond_all(decoder_);
+               }
+
+               bool Stream::set_metadata_ignore(::FLAC__MetadataType type)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_decoder_set_metadata_ignore(decoder_, type);
+               }
+
+               bool Stream::set_metadata_ignore_application(const FLAC__byte id[4])
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_decoder_set_metadata_ignore_application(decoder_, id);
+               }
+
+               bool Stream::set_metadata_ignore_all()
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_decoder_set_metadata_ignore_all(decoder_);
+               }
+
+               Stream::State Stream::get_state() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return State(::OggFLAC__stream_decoder_get_state(decoder_));
+               }
+
+               FLAC::Decoder::Stream::State Stream::get_FLAC_stream_decoder_state() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return FLAC::Decoder::Stream::State(::OggFLAC__stream_decoder_get_FLAC_stream_decoder_state(decoder_));
+               }
+
+               unsigned Stream::get_channels() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return ::OggFLAC__stream_decoder_get_channels(decoder_);
+               }
+
+               ::FLAC__ChannelAssignment Stream::get_channel_assignment() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return ::OggFLAC__stream_decoder_get_channel_assignment(decoder_);
+               }
+
+               unsigned Stream::get_bits_per_sample() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return ::OggFLAC__stream_decoder_get_bits_per_sample(decoder_);
+               }
+
+               unsigned Stream::get_sample_rate() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return ::OggFLAC__stream_decoder_get_sample_rate(decoder_);
+               }
+
+               unsigned Stream::get_blocksize() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return ::OggFLAC__stream_decoder_get_blocksize(decoder_);
+               }
+
+               Stream::State Stream::init()
+               {
+                       FLAC__ASSERT(is_valid());
+                       ::OggFLAC__stream_decoder_set_read_callback(decoder_, read_callback_);
+                       ::OggFLAC__stream_decoder_set_write_callback(decoder_, write_callback_);
+                       ::OggFLAC__stream_decoder_set_metadata_callback(decoder_, metadata_callback_);
+                       ::OggFLAC__stream_decoder_set_error_callback(decoder_, error_callback_);
+                       ::OggFLAC__stream_decoder_set_client_data(decoder_, (void*)this);
+                       return State(::OggFLAC__stream_decoder_init(decoder_));
+               }
+
+               void Stream::finish()
+               {
+                       FLAC__ASSERT(is_valid());
+                       ::OggFLAC__stream_decoder_finish(decoder_);
+               }
+
+               bool Stream::flush()
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_decoder_flush(decoder_);
+               }
+
+               bool Stream::reset()
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_decoder_reset(decoder_);
+               }
+
+               bool Stream::process_single()
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_decoder_process_single(decoder_);
+               }
+
+               bool Stream::process_until_end_of_metadata()
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_decoder_process_until_end_of_metadata(decoder_);
+               }
+
+               bool Stream::process_until_end_of_stream()
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_decoder_process_until_end_of_stream(decoder_);
+               }
+
+               ::FLAC__StreamDecoderReadStatus Stream::read_callback_(const ::OggFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data)
+               {
+                       (void)decoder;
+                       FLAC__ASSERT(0 != client_data);
+                       Stream *instance = reinterpret_cast<Stream *>(client_data);
+                       FLAC__ASSERT(0 != instance);
+                       return instance->read_callback(buffer, bytes);
+               }
+
+               ::FLAC__StreamDecoderWriteStatus Stream::write_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
+               {
+                       (void)decoder;
+                       FLAC__ASSERT(0 != client_data);
+                       Stream *instance = reinterpret_cast<Stream *>(client_data);
+                       FLAC__ASSERT(0 != instance);
+                       return instance->write_callback(frame, buffer);
+               }
+
+               void Stream::metadata_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data)
+               {
+                       (void)decoder;
+                       FLAC__ASSERT(0 != client_data);
+                       Stream *instance = reinterpret_cast<Stream *>(client_data);
+                       FLAC__ASSERT(0 != instance);
+                       instance->metadata_callback(metadata);
+               }
+
+               void Stream::error_callback_(const ::OggFLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data)
+               {
+                       (void)decoder;
+                       FLAC__ASSERT(0 != client_data);
+                       Stream *instance = reinterpret_cast<Stream *>(client_data);
+                       FLAC__ASSERT(0 != instance);
+                       instance->error_callback(status);
+               }
+
+       };
+};
diff --git a/src/libOggFLAC++/stream_encoder.cc b/src/libOggFLAC++/stream_encoder.cc
new file mode 100644 (file)
index 0000000..68edfea
--- /dev/null
@@ -0,0 +1,307 @@
+/* libOggFLAC++ - Free Lossless Audio Codec + Ogg library
+ * Copyright (C) 2002  Josh Coalson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA  02111-1307, USA.
+ */
+
+#include "OggFLAC++/encoder.h"
+#include "FLAC/assert.h"
+
+namespace OggFLAC {
+       namespace Encoder {
+
+               Stream::Stream():
+               encoder_(::OggFLAC__stream_encoder_new())
+               { }
+
+               Stream::~Stream()
+               {
+                       if(0 != encoder_) {
+                               ::OggFLAC__stream_encoder_finish(encoder_);
+                               ::OggFLAC__stream_encoder_delete(encoder_);
+                       }
+               }
+
+               bool Stream::is_valid() const
+               {
+                       return 0 != encoder_;
+               }
+
+               bool Stream::set_verify(bool value)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_set_verify(encoder_, value);
+               }
+
+               bool Stream::set_streamable_subset(bool value)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_set_streamable_subset(encoder_, value);
+               }
+
+               bool Stream::set_do_mid_side_stereo(bool value)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_set_do_mid_side_stereo(encoder_, value);
+               }
+
+               bool Stream::set_loose_mid_side_stereo(bool value)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_set_loose_mid_side_stereo(encoder_, value);
+               }
+
+               bool Stream::set_channels(unsigned value)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_set_channels(encoder_, value);
+               }
+
+               bool Stream::set_bits_per_sample(unsigned value)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_set_bits_per_sample(encoder_, value);
+               }
+
+               bool Stream::set_sample_rate(unsigned value)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_set_sample_rate(encoder_, value);
+               }
+
+               bool Stream::set_blocksize(unsigned value)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_set_blocksize(encoder_, value);
+               }
+
+               bool Stream::set_max_lpc_order(unsigned value)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_set_max_lpc_order(encoder_, value);
+               }
+
+               bool Stream::set_qlp_coeff_precision(unsigned value)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_set_qlp_coeff_precision(encoder_, value);
+               }
+
+               bool Stream::set_do_qlp_coeff_prec_search(bool value)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_set_do_qlp_coeff_prec_search(encoder_, value);
+               }
+
+               bool Stream::set_do_escape_coding(bool value)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_set_do_escape_coding(encoder_, value);
+               }
+
+               bool Stream::set_do_exhaustive_model_search(bool value)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_set_do_exhaustive_model_search(encoder_, value);
+               }
+
+               bool Stream::set_min_residual_partition_order(unsigned value)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_set_min_residual_partition_order(encoder_, value);
+               }
+
+               bool Stream::set_max_residual_partition_order(unsigned value)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_set_max_residual_partition_order(encoder_, value);
+               }
+
+               bool Stream::set_rice_parameter_search_dist(unsigned value)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_set_rice_parameter_search_dist(encoder_, value);
+               }
+
+               bool Stream::set_total_samples_estimate(FLAC__uint64 value)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_set_total_samples_estimate(encoder_, value);
+               }
+
+               bool Stream::set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_set_metadata(encoder_, metadata, num_blocks);
+               }
+
+               Stream::State Stream::get_state() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return State(::OggFLAC__stream_encoder_get_state(encoder_));
+               }
+
+               FLAC::Encoder::Stream::State Stream::get_FLAC_stream_encoder_state() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return FLAC::Encoder::Stream::State(::OggFLAC__stream_encoder_get_FLAC_stream_encoder_state(encoder_));
+               }
+
+               FLAC::Decoder::Stream::State Stream::get_verify_decoder_state() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return FLAC::Decoder::Stream::State(::OggFLAC__stream_encoder_get_verify_decoder_state(encoder_));
+               }
+
+               bool Stream::get_verify() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_get_verify(encoder_);
+               }
+
+               bool Stream::get_streamable_subset() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_get_streamable_subset(encoder_);
+               }
+
+               bool Stream::get_do_mid_side_stereo() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_get_do_mid_side_stereo(encoder_);
+               }
+
+               bool Stream::get_loose_mid_side_stereo() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_get_loose_mid_side_stereo(encoder_);
+               }
+
+               unsigned Stream::get_channels() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return ::OggFLAC__stream_encoder_get_channels(encoder_);
+               }
+
+               unsigned Stream::get_bits_per_sample() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return ::OggFLAC__stream_encoder_get_bits_per_sample(encoder_);
+               }
+
+               unsigned Stream::get_sample_rate() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return ::OggFLAC__stream_encoder_get_sample_rate(encoder_);
+               }
+
+               unsigned Stream::get_blocksize() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return ::OggFLAC__stream_encoder_get_blocksize(encoder_);
+               }
+
+               unsigned Stream::get_max_lpc_order() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return ::OggFLAC__stream_encoder_get_max_lpc_order(encoder_);
+               }
+
+               unsigned Stream::get_qlp_coeff_precision() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return ::OggFLAC__stream_encoder_get_qlp_coeff_precision(encoder_);
+               }
+
+               bool Stream::get_do_qlp_coeff_prec_search() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_get_do_qlp_coeff_prec_search(encoder_);
+               }
+
+               bool Stream::get_do_escape_coding() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_get_do_escape_coding(encoder_);
+               }
+
+               bool Stream::get_do_exhaustive_model_search() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_get_do_exhaustive_model_search(encoder_);
+               }
+
+               unsigned Stream::get_min_residual_partition_order() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return ::OggFLAC__stream_encoder_get_min_residual_partition_order(encoder_);
+               }
+
+               unsigned Stream::get_max_residual_partition_order() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return ::OggFLAC__stream_encoder_get_max_residual_partition_order(encoder_);
+               }
+
+               unsigned Stream::get_rice_parameter_search_dist() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return ::OggFLAC__stream_encoder_get_rice_parameter_search_dist(encoder_);
+               }
+
+               FLAC__uint64 Stream::get_total_samples_estimate() const
+               {
+                       FLAC__ASSERT(is_valid());
+                       return ::OggFLAC__stream_encoder_get_total_samples_estimate(encoder_);
+               }
+
+               Stream::State Stream::init()
+               {
+                       FLAC__ASSERT(is_valid());
+                       ::OggFLAC__stream_encoder_set_write_callback(encoder_, write_callback_);
+                       ::OggFLAC__stream_encoder_set_client_data(encoder_, (void*)this);
+                       return State(::OggFLAC__stream_encoder_init(encoder_));
+               }
+
+               void Stream::finish()
+               {
+                       FLAC__ASSERT(is_valid());
+                       ::OggFLAC__stream_encoder_finish(encoder_);
+               }
+
+               bool Stream::process(const FLAC__int32 * const buffer[], unsigned samples)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_process(encoder_, buffer, samples);
+               }
+
+               bool Stream::process_interleaved(const FLAC__int32 buffer[], unsigned samples)
+               {
+                       FLAC__ASSERT(is_valid());
+                       return (bool)::OggFLAC__stream_encoder_process_interleaved(encoder_, buffer, samples);
+               }
+
+               ::FLAC__StreamEncoderWriteStatus Stream::write_callback_(const ::OggFLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data)
+               {
+                       (void)encoder;
+                       FLAC__ASSERT(0 != client_data);
+                       Stream *instance = reinterpret_cast<Stream *>(client_data);
+                       FLAC__ASSERT(0 != instance);
+                       return instance->write_callback(buffer, bytes, samples, current_frame);
+               }
+
+       };
+};