diff --git a/include/FLAC++/all.h b/include/FLAC++/all.h index b03612cc..ca9efe6d 100644 --- a/include/FLAC++/all.h +++ b/include/FLAC++/all.h @@ -43,11 +43,6 @@ * The FLAC C++ API is the interface to libFLAC++, a set of classes * that encapsulate the encoders, decoders, and metadata interfaces * in libFLAC. - * - * Note that Doxygen currently has some quirks (bugs?) in the way - * it deals with some member groups and C++ constructs. You will find - * some document entries in the wrong place under [NOHEADER] sections. - * Hopefully this is not too distracting. */ #endif diff --git a/include/FLAC++/decoder.h b/include/FLAC++/decoder.h index 8537f99a..9d18ed75 100644 --- a/include/FLAC++/decoder.h +++ b/include/FLAC++/decoder.h @@ -66,37 +66,29 @@ * property. * * Second, there are two stream decoder classes. FLAC::Decoder::Stream - * is used for the same cases that FLAC__stream_decoder_init_stream() is - * used, and FLAC::Decoder::File is used for the same cases that - * FLAC__stream_decoder_init_FILE() and FLAC__stream_decoder_init_file() + * is used for the same cases that FLAC__stream_decoder_init_stream() / + * FLAC__stream_decoder_init_ogg_stream() is used, and FLAC::Decoder::File + * is used for the same cases that + * FLAC__stream_decoder_init_FILE() and FLAC__stream_decoder_init_file() / + * FLAC__stream_decoder_init_ogg_FILE() and FLAC__stream_decoder_init_ogg_file() * are used. */ namespace FLAC { namespace Decoder { - /** \defgroup flacpp_stream_decoder FLAC++/decoder.h: stream decoder class - * \ingroup flacpp_decoder - * + /** \ingroup flacpp_decoder * \brief - * This class wraps the ::FLAC__StreamDecoder. - * - * See the \link flac_stream_decoder libFLAC stream decoder module \endlink - * for basic usage. - * - * \{ - */ - - /** This class wraps the ::FLAC__StreamDecoder. If you are + * This class wraps the ::FLAC__StreamDecoder. If you are * decoding from a file, FLAC::Decoder::File may be more * convenient. * * The usage of this class is similar to FLAC__StreamDecoder, * except instead of providing callbacks to - * FLAC__stream_decoder_init_stream(), you will inherit from this + * FLAC__stream_decoder_init*_stream(), you will inherit from this * class and override the virtual callback functions with your - * own implementations, then call Stream::init(). The rest of - * the calls work the same as in the C layer. + * own implementations, then call init() or init_ogg(). The rest + * of the calls work the same as in the C layer. * * Only the read, write, and error callbacks are mandatory. The * others are optional; this class provides default @@ -126,7 +118,7 @@ namespace FLAC { * successfully. If not, use get_state() to find out why not. */ virtual bool is_valid() const; - inline operator bool() const { return is_valid(); } + inline operator bool() const { return is_valid(); } ///< See is_valid() //@} virtual bool set_ogg_serial_number(long value); ///< See FLAC__stream_decoder_set_ogg_serial_number() @@ -210,31 +202,19 @@ namespace FLAC { void operator=(const Stream &); }; - /* \} */ - - /** \defgroup flacpp_file_decoder FLAC++/decoder.h: file decoder class - * \ingroup flacpp_decoder - * + /** \ingroup flacpp_decoder * \brief - * This class wraps the ::FLAC__StreamDecoder. - * - * See the \link flac_stream_decoder libFLAC stream decoder module \endlink - * for basic usage. - * - * \{ - */ - - /** This class wraps the ::FLAC__StreamDecoder. If you are + * This class wraps the ::FLAC__StreamDecoder. If you are * not decoding from a file, you may need to use * FLAC::Decoder::Stream. * * The usage of this class is similar to FLAC__StreamDecoder, * except instead of providing callbacks to - * FLAC__stream_decoder_init_FILE() or - * FLAC__stream_decoder_init_file(), you will inherit from this + * FLAC__stream_decoder_init*_FILE() or + * FLAC__stream_decoder_init*_file(), you will inherit from this * class and override the virtual callback functions with your - * own implementations, then call File::init(). The rest of - * the calls work the same as in the C layer. + * own implementations, then call init() or init_off(). The rest + * of the calls work the same as in the C layer. * * Only the write, and error callbacks from FLAC::Decoder::Stream * are mandatory. The others are optional; this class provides @@ -261,8 +241,6 @@ namespace FLAC { void operator=(const File &); }; - /* \} */ - } } diff --git a/include/FLAC++/encoder.h b/include/FLAC++/encoder.h index d506dc1b..b974cc42 100644 --- a/include/FLAC++/encoder.h +++ b/include/FLAC++/encoder.h @@ -67,36 +67,28 @@ * property. * * Second, there are two stream encoder classes. FLAC::Encoder::Stream - * is used for the same cases that FLAC__stream_encoder_init_stream() is - * used, and FLAC::Encoder::File is used for the same cases that - * FLAC__stream_encoder_init_FILE() and FLAC__stream_encoder_init_file() + * is used for the same cases that FLAC__stream_encoder_init_stream() / + * FLAC__stream_encoder_init_ogg_stream() is used, and FLAC::Encoder::File + * is used for the same cases that + * FLAC__stream_encoder_init_FILE() and FLAC__stream_encoder_init_file() / + * FLAC__stream_encoder_init_ogg_FILE() and FLAC__stream_encoder_init_ogg_file() * are used. */ namespace FLAC { namespace Encoder { - /** \defgroup flacpp_stream_encoder FLAC++/encoder.h: stream encoder class - * \ingroup flacpp_encoder - * + /** \ingroup flacpp_encoder * \brief - * This class wraps the ::FLAC__StreamEncoder. - * - * See the \link flac_stream_encoder libFLAC stream encoder module \endlink - * for basic usage. - * - * \{ - */ - - /** This class wraps the ::FLAC__StreamEncoder. If you are + * This class wraps the ::FLAC__StreamEncoder. If you are * encoding to a file, FLAC::Encoder::File may be more * convenient. * * The usage of this class is similar to FLAC__StreamEncoder, * except instead of providing callbacks to - * FLAC__stream_encoder_init_stream(), you will inherit from this + * FLAC__stream_encoder_init*_stream(), you will inherit from this * class and override the virtual callback functions with your - * own implementations, then call Stream::init(). The rest of + * own implementations, then call init() or init_ogg(). The rest of * the calls work the same as in the C layer. * * Only the write callback is mandatory. The others are @@ -129,7 +121,7 @@ namespace FLAC { * */ virtual bool is_valid() const; - inline operator bool() const { return is_valid(); } + inline operator bool() const { return is_valid(); } ///< See is_valid() //@} virtual bool set_ogg_serial_number(long value); ///< See FLAC__stream_encoder_set_ogg_serial_number() @@ -219,31 +211,19 @@ namespace FLAC { void operator=(const Stream &); }; - /* \} */ - - /** \defgroup flacpp_file_encoder FLAC++/encoder.h: file encoder class - * \ingroup flacpp_encoder - * + /** \ingroup flacpp_encoder * \brief - * This class wraps the ::FLAC__StreamEncoder. - * - * See the \link flac_stream_encoder libFLAC stream encoder module \endlink - * for basic usage. - * - * \{ - */ - - /** This class wraps the ::FLAC__StreamEncoder. If you are + * This class wraps the ::FLAC__StreamEncoder. If you are * not encoding to a file, you may need to use * FLAC::Encoder::Stream. * * The usage of this class is similar to FLAC__StreamEncoder, * except instead of providing callbacks to - * FLAC__stream_encoder_init_FILE() or - * FLAC__stream_encoder_init_file(), you will inherit from this + * FLAC__stream_encoder_init*_FILE() or + * FLAC__stream_encoder_init*_file(), you will inherit from this * class and override the virtual callback functions with your - * own implementations, then call File::init(). The rest of - * the calls work the same as in the C layer. + * own implementations, then call init() or init_ogg(). The rest + * of the calls work the same as in the C layer. * * There are no mandatory callbacks; all the callbacks from * FLAC::Encoder::Stream are implemented here fully and support diff --git a/include/FLAC++/metadata.h b/include/FLAC++/metadata.h index 1f8b7bab..99623140 100644 --- a/include/FLAC++/metadata.h +++ b/include/FLAC++/metadata.h @@ -64,7 +64,8 @@ * * The behavior closely mimics the C layer interface; be sure to read * the detailed description of the - * \link flac_metadata C metadata module \endlink. + * \link flac_metadata C metadata module \endlink. Note that the + * metadata API currently does not support Ogg FLAC files. */ @@ -563,7 +564,7 @@ namespace FLAC { virtual ~Entry(); - virtual bool is_valid() const; + virtual bool is_valid() const; ///< Returns \c true iff object was properly constructed. unsigned get_field_length() const; unsigned get_field_name_length() const; @@ -687,7 +688,8 @@ namespace FLAC { virtual ~Track(); - virtual bool is_valid() const; + virtual bool is_valid() const; ///< Returns \c true iff object was properly constructed. + inline FLAC__uint64 get_offset() const { return object_->offset; } inline FLAC__byte get_number() const { return object_->number; } @@ -1005,9 +1007,10 @@ namespace FLAC { SimpleIterator(); virtual ~SimpleIterator(); + bool is_valid() const; ///< Returns \c true iff object was properly constructed. + bool init(const char *filename, bool read_only, bool preserve_file_stats); ///< See FLAC__metadata_simple_iterator_init(). - bool is_valid() const; Status status(); ///< See FLAC__metadata_simple_iterator_status(). bool is_writable() const; ///< See FLAC__metadata_simple_iterator_is_writable(). @@ -1088,7 +1091,8 @@ namespace FLAC { friend class Iterator; - bool is_valid() const; + bool is_valid() const; ///< Returns \c true iff object was properly constructed. + Status status(); ///< See FLAC__metadata_chain_status(). bool read(const char *filename); ///< See FLAC__metadata_chain_read(). @@ -1118,7 +1122,8 @@ namespace FLAC { Iterator(); virtual ~Iterator(); - bool is_valid() const; + bool is_valid() const; ///< Returns \c true iff object was properly constructed. + void init(Chain &chain); ///< See FLAC__metadata_iterator_init(). diff --git a/include/FLAC/all.h b/include/FLAC/all.h index b1f29b36..a5672f23 100644 --- a/include/FLAC/all.h +++ b/include/FLAC/all.h @@ -80,11 +80,9 @@ * dependency on a thread library. However, libFLAC does not use * global variables and should be thread-safe. * - * There is also a libOggFLAC library which wraps around libFLAC - * to provide routines for encoding to and decoding from FLAC streams - * inside an Ogg container. The interfaces are very similar or identical - * to their counterparts in libFLAC. libOggFLAC is also licensed under - * Xiph's BSD license. + * libFLAC also supports encoding to and decoding from Ogg FLAC. + * However the metadata editing interfaces currently work only for + * native FLAC files. * * \section cpp_api FLAC C++ API * @@ -97,11 +95,11 @@ * for the C++ API will be installed in your include area (for * example /usr/include/FLAC++/...). * - * There is also a libOggFLAC++ library, which provides classes - * for encoding to and decoding from FLAC streams in an Ogg container. - * The classes are very similar to their counterparts in libFLAC++. + * libFLAC++ also supports encoding to and decoding from Ogg FLAC. + * However the metadata editing interfaces currently work only for + * native FLAC files. * - * Both libFLAC++ libOggFLAC++ are also licensed under + * libFLAC++ is also licensed under * Xiph's BSD license. * * \section getting_started Getting Started @@ -139,6 +137,8 @@ * decoder because of the verify feature, but this can be removed if * not needed. * - The metadata interface requires the stream decoder. + * - Ogg support is selectable through the compile time macro + * \c FLAC__HAS_OGG. * * For example, if your application only requires the stream decoder, no * encoder, and no metadata interface, you can remove the stream encoder @@ -172,6 +172,12 @@ * * The the source will work for multiple versions and the legacy code can * easily be removed when the transition is complete. + * + * Another available symbol is FLAC_API_SUPPORTS_OGG_FLAC (defined in + * include/FLAC/export.h), which can be used to determine whether or not + * the library has been compiled with support for Ogg FLAC. This is + * simpler than trying to call an Ogg init function and catching the + * error. */ /** \defgroup porting_1_1_2_to_1_1_3 Porting from FLAC 1.1.2 to 1.1.3 @@ -180,15 +186,18 @@ * \brief * This module describes porting from FLAC 1.1.2 to FLAC 1.1.3. * - * The main change between the APIs in 1.1.2 and 1.1.3 is that the three + * The main change between the APIs in 1.1.2 and 1.1.3 is that they have + * been simplified. First, libOggFLAC has been merged into libFLAC and + * libOggFLAC++ has been merged into libFLAC++. Second, both the three * decoding layers and three encoding layers have been merged into a * single stream decoder and stream encoder. That is, the functionality * of FLAC__SeekableStreamDecoder and FLAC__FileDecoder has been merged * into FLAC__StreamDecoder, and FLAC__SeekableStreamEncoder and * FLAC__FileEncoder into FLAC__StreamEncoder. Only the - * FLAC__StreamDecoder and FLAC__StreamEncoder remain. This can - * simplify code that needs to process both seekable and non-seekable - * streams. + * FLAC__StreamDecoder and FLAC__StreamEncoder remain. What this means + * is there is now a single API that can be used to encode or decode + * streams to/from native FLAC or Ogg FLAC and the single API can work + * on both seekable and non-seekable streams. * * Instead of creating an encoder or decoder of a certain layer, now the * client will always create a FLAC__StreamEncoder or @@ -211,6 +220,10 @@ * FLAC__stream_decoder_set_client_data() are no longer needed. The * rest of the calls to the decoder are the same as before. * + * There are counterpart init functions for Ogg FLAC, e.g. + * FLAC__stream_decoder_init_ogg_stream(). All the rest of the calls + * and callbacks are the same as for native FLAC. + * * As an example, in FLAC 1.1.2 a seekable stream decoder would have * been set up like so: * @@ -299,11 +312,6 @@ * two new convenience functions that may be useful: * FLAC__metadata_object_cuesheet_calculate_cddb_id() and * FLAC__metadata_get_cuesheet(). - * - * In libOggFLAC++, OggFLAC::Decoder::Stream now inherits from - * FLAC::Decoder::Stream and OggFLAC::Encoder::Stream now inherits from - * FLAC::Encoder::Stream, which means both OggFLAC and FLAC can be - * supported by using common code for everything after initialization. */ /** \defgroup flac FLAC C API diff --git a/include/FLAC/export.h b/include/FLAC/export.h index febed1a2..c0f367e8 100644 --- a/include/FLAC/export.h +++ b/include/FLAC/export.h @@ -32,6 +32,26 @@ #ifndef FLAC__EXPORT_H #define FLAC__EXPORT_H +/** \file include/FLAC/export.h + * + * \brief + * This module contains #defines and symbols for exporting function + * calls, and providing version information and compiled-in features. + * + * See the \link flac_export export \endlink module. + */ + +/** \defgroup flac_export FLAC/export.h: export symbols + * \ingroup flac + * + * \brief + * This module contains structure definitions for the representation + * of FLAC format components in memory. These are the basic + * structures used by the rest of the interfaces. + * + * \{ + */ + #if defined(FLAC__NO_DLL) || !defined(_MSC_VER) #define FLAC_API @@ -45,14 +65,16 @@ #endif #endif -/* These #defines will mirror the libtool-based library version number, see +/** These #defines will mirror the libtool-based library version number, see * http://www.gnu.org/software/libtool/manual.html#Libtool-versioning */ #define FLAC_API_VERSION_CURRENT 8 -#define FLAC_API_VERSION_REVISION 0 -#define FLAC_API_VERSION_AGE 0 +#define FLAC_API_VERSION_REVISION 0 /**< see above */ +#define FLAC_API_VERSION_AGE 0 /**< see above */ /** \c 1 if the library has been compiled with support for Ogg FLAC, else \c 0. */ extern int FLAC_API_SUPPORTS_OGG_FLAC; +/* \} */ + #endif diff --git a/include/FLAC/metadata.h b/include/FLAC/metadata.h index 2aa9fb89..136dbcf6 100644 --- a/include/FLAC/metadata.h +++ b/include/FLAC/metadata.h @@ -36,11 +36,11 @@ #include "callback.h" #include "format.h" -/****************************************************************************** - (For an example of how all these routines are used, see the source - code for the unit tests in src/test_libFLAC/metadata_*.c, or metaflac - in src/metaflac/) -******************************************************************************/ +/* -------------------------------------------------------------------- + (For an example of how all these routines are used, see the source + code for the unit tests in src/test_libFLAC/metadata_*.c, or + metaflac in src/metaflac/) + ------------------------------------------------------------------*/ /** \file include/FLAC/metadata.h * @@ -59,7 +59,9 @@ * \brief * This module provides functions for creating and manipulating FLAC * metadata blocks in memory, and three progressively more powerful - * interfaces for traversing and editing metadata in FLAC files. + * interfaces for traversing and editing metadata in native FLAC files. + * Note that this metadata interface currently does not support Ogg + * FLAC files. * * There are three metadata interfaces of increasing complexity: * diff --git a/include/FLAC/stream_decoder.h b/include/FLAC/stream_decoder.h index 2b21c8cc..d076e5be 100644 --- a/include/FLAC/stream_decoder.h +++ b/include/FLAC/stream_decoder.h @@ -57,9 +57,9 @@ extern "C" { * \brief * This module describes the decoder layers provided by libFLAC. * - * The stream decoder can be used decode complete streams either from the - * client via callbacks, or directly from a file, depending on how it is - * initialized. When decoding via callbacks, the client provides + * The stream decoder can be used to decode complete streams either from + * the client via callbacks, or directly from a file, depending on how + * it is initialized. When decoding via callbacks, the client provides * callbacks for reading FLAC data and writing decoded samples, and * handling metadata and errors. If the client also supplies seek-related * callback, the decoder function for sample-accurate seeking within the @@ -76,15 +76,21 @@ extern "C" { * This module contains the functions which implement the stream * decoder. * + * The stream decoder can decode native FLAC, and optionally Ogg FLAC + * (check FLAC_API_SUPPORTS_OGG_FLAC) streams and files. + * * The basic usage of this decoder is as follows: * - The program creates an instance of a decoder using * FLAC__stream_decoder_new(). * - The program overrides the default settings using * FLAC__stream_decoder_set_*() functions. * - The program initializes the instance to validate the settings and - * prepare for decoding using FLAC__stream_decoder_init() or - * FLAC__stream_decoder_init_FILE() or FLAC__stream_decoder_init_file(), - * depending on the nature of the input. + * prepare for decoding using FLAC__stream_decoder_init_stream() or + * FLAC__stream_decoder_init_FILE() or FLAC__stream_decoder_init_file() + * for native FLAC, or FLAC__stream_decoder_init_ogg_stream() or + * FLAC__stream_decoder_init_ogg_FILE() or + * FLAC__stream_decoder_init_ogg_file() for Ogg FLAC, depending on the + * nature of the input. * - The program calls the FLAC__stream_decoder_process_*() functions * to decode data, which subsequently calls the callbacks. * - The program finishes the decoding with FLAC__stream_decoder_finish(), @@ -96,11 +102,11 @@ extern "C" { * In more detail, the program will create a new instance by calling * FLAC__stream_decoder_new(), then call FLAC__stream_decoder_set_*() * functions to override the default decoder options, and call - * on of the FLAC__stream_decoder_init_*() functions. + * one of the FLAC__stream_decoder_init_*() functions. * - * There are three initialization functions, one for setting up the decoder - * to decode FLAC data from the client via callbacks, and two for decoding - * directly from a FLAC file. + * There are three initialization functions for native FLAC, one for + * setting up the decoder to decode FLAC data from the client via + * callbacks, and two for decoding directly from a FLAC file. * * For decoding via callbacks, use FLAC__stream_decoder_init_stream(). * You must also supply several callbacks for handling I/O. Some (like @@ -111,6 +117,10 @@ extern "C" { * filename or open \c FILE* and fewer callbacks; the decoder will handle * the other callbacks internally. * + * There are three similarly-named init functions for decoding from Ogg + * FLAC streams. Check \c FLAC_API_SUPPORTS_OGG_FLAC to find out if the + * library has been built with Ogg support. + * * Once the decoder is initialized, your program will call one of several * functions to start the decoding process: * @@ -120,12 +130,12 @@ extern "C" { * loses sync it will return with only the error callback being called. * - FLAC__stream_decoder_process_until_end_of_metadata() - Tells the decoder * to process the stream from the current location and stop upon reaching - * the first audio frame. The user will get one metadata, write, or error + * the first audio frame. The client will get one metadata, write, or error * callback per metadata block, audio frame, or sync error, respectively. * - FLAC__stream_decoder_process_until_end_of_stream() - Tells the decoder * to process the stream from the current location until the read callback * returns FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM or - * FLAC__STREAM_DECODER_READ_STATUS_ABORT. The user will get one metadata, + * FLAC__STREAM_DECODER_READ_STATUS_ABORT. The client will get one metadata, * write, or error callback per metadata block, audio frame, or sync error, * respectively. * @@ -136,7 +146,7 @@ extern "C" { * again to decode another stream. * * Seeking is exposed through the FLAC__stream_decoder_seek_absolute() method. - * At any point after the stream decoder has been initialized, the user can + * At any point after the stream decoder has been initialized, the client can * call this function to seek to an exact sample within the stream. * Subsequently, the first time the write callback is called it will be * passed a (possibly partial) block starting at that sample. @@ -174,7 +184,7 @@ extern "C" { * The "set" functions may only be called when the decoder is in the * state FLAC__STREAM_DECODER_UNINITIALIZED, i.e. after * FLAC__stream_decoder_new() or FLAC__stream_decoder_finish(), but - * before FLAC__stream_decoder_init(). If this is the case they will + * before FLAC__stream_decoder_init_*(). If this is the case they will * return \c true, otherwise \c false. * * \note @@ -260,7 +270,8 @@ typedef enum { /**< An error occurred allocating memory. */ FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE, - /**< fopen() failed in FLAC__stream_decoder_init_file(). */ + /**< fopen() failed in FLAC__stream_decoder_init_file() or + * FLAC__stream_decoder_init_ogg_file(). */ FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED /**< FLAC__stream_decoder_init_*() was called when the decoder was @@ -457,7 +468,7 @@ typedef struct { /** Signature for the read callback. * * A function pointer matching this signature must be passed to - * FLAC__stream_decoder_init_stream(). The supplied function will be + * FLAC__stream_decoder_init*_stream(). The supplied function will be * called when the decoder needs more input data. The address of the * buffer to be filled is supplied, along with the number of bytes the * buffer can hold. The callback may choose to supply less data and @@ -487,7 +498,7 @@ typedef FLAC__StreamDecoderReadStatus (*FLAC__StreamDecoderReadCallback)(const F /** Signature for the seek callback. * * A function pointer matching this signature may be passed to - * FLAC__stream_decoder_init_stream(). The supplied function will be + * FLAC__stream_decoder_init*_stream(). The supplied function will be * called when the decoder needs to seek the input stream. The decoder * will pass the absolute byte offset to seek to, 0 meaning the * beginning of the stream. @@ -508,7 +519,7 @@ typedef FLAC__StreamDecoderSeekStatus (*FLAC__StreamDecoderSeekCallback)(const F /** Signature for the tell callback. * * A function pointer matching this signature may be passed to - * FLAC__stream_decoder_init_stream(). The supplied function will be + * FLAC__stream_decoder_init*_stream(). The supplied function will be * called when the decoder wants to know the current position of the * stream. The callback should return the byte offset from the * beginning of the stream. @@ -529,7 +540,7 @@ typedef FLAC__StreamDecoderTellStatus (*FLAC__StreamDecoderTellCallback)(const F /** Signature for the length callback. * * A function pointer matching this signature may be passed to - * FLAC__stream_decoder_init_stream(). The supplied function will be + * FLAC__stream_decoder_init*_stream(). The supplied function will be * called when the decoder wants to know the total length of the stream * in bytes. * @@ -549,7 +560,7 @@ typedef FLAC__StreamDecoderLengthStatus (*FLAC__StreamDecoderLengthCallback)(con /** Signature for the EOF callback. * * A function pointer matching this signature may be passed to - * FLAC__stream_decoder_init_stream(). The supplied function will be + * FLAC__stream_decoder_init*_stream(). The supplied function will be * called when the decoder needs to know if the end of the stream has * been reached. * @@ -667,11 +678,14 @@ FLAC_API void FLAC__stream_decoder_delete(FLAC__StreamDecoder *decoder); * ***********************************************************************/ -/** Set the serial number for the Ogg stream. +/** Set the serial number for the FLAC stream within the Ogg container. * The default behavior is to use the serial number of the first Ogg * page. Setting a serial number here will explicitly specify which * stream is to be decoded. * + * \note + * This does not need to be set for native FLAC decoding. + * * \default \c use serial number of first page * \param decoder A decoder instance to set. * \param serial_number See above. @@ -1262,7 +1276,7 @@ FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_file( * * In the event of a prematurely-terminated decode, it is not strictly * necessary to call this immediately before FLAC__stream_decoder_delete() - * but it is good practice to match every FLAC__stream_decoder_init() + * but it is good practice to match every FLAC__stream_decoder_init_*() * with a FLAC__stream_decoder_finish(). * * \param decoder An uninitialized decoder instance. @@ -1295,18 +1309,18 @@ FLAC_API FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder); * The decoder's input buffer will be cleared and the state set to * \c FLAC__STREAM_DECODER_SEARCH_FOR_METADATA. This is similar to * FLAC__stream_decoder_finish() except that the settings are - * preserved; there is no need to call FLAC__stream_decoder_init() + * preserved; there is no need to call FLAC__stream_decoder_init_*() * before decoding again. MD5 checking will be restored to its original * setting. * * If the decoder is seekable, or was initialized with - * FLAC__stream_decoder_init_FILE() or FLAC__stream_decoder_init_file(), + * FLAC__stream_decoder_init*_FILE() or FLAC__stream_decoder_init*_file(), * the decoder will also attempt to seek to the beginning of the file. * If this rewind fails, this function will return \c false. It follows * that FLAC__stream_decoder_reset() cannot be used when decoding from * \c stdin. * - * If the decoder was initialized with FLAC__stream_encoder_init_stream() + * If the decoder was initialized with FLAC__stream_encoder_init*_stream() * and is not seekable (i.e. no seek callback was provided or the seek * callback returns \c FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED), it * is the duty of the client to start feeding data from the beginning of @@ -1414,15 +1428,14 @@ FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_stream(FLAC__Strea * same way that FLAC__stream_decoder_process_single() will return once * one whole frame is decoded. * - * This function, when used from the higher FLAC__SeekableStreamDecoder - * layer, can be used in more quickly determining FLAC frame boundaries - * when decoding of the actual data is not needed, for example when an - * application is separating a FLAC stream into frames for editing or - * storing in a container. To do this, the application can use - * FLAC__seekable_stream_decoder_skip_single_frame() to quickly advance + * This function can be used in more quickly determining FLAC frame + * boundaries when decoding of the actual data is not needed, for + * example when an application is separating a FLAC stream into frames + * for editing or storing in a container. To do this, the application + * can use FLAC__stream_decoder_skip_single_frame() to quickly advance * to the next frame, then use - * FLAC__seekable_stream_decoder_get_decode_position() to find the new - * frame boundary. + * FLAC__stream_decoder_get_decode_position() to find the new frame + * boundary. * * This function should only be called when the stream has advanced * past all the metadata, otherwise it will return \c false. diff --git a/include/FLAC/stream_encoder.h b/include/FLAC/stream_encoder.h index 5aba79f6..ad2f5002 100644 --- a/include/FLAC/stream_encoder.h +++ b/include/FLAC/stream_encoder.h @@ -58,7 +58,7 @@ extern "C" { * \brief * This module describes the encoder layers provided by libFLAC. * - * The stream encoder can be used encode complete streams either to the + * The stream encoder can be used to encode complete streams either to the * client via callbacks, or directly to a file, depending on how it is * initialized. When encoding via callbacks, the client provides a write * callback which will be called whenever FLAC data is ready to be written. @@ -78,6 +78,9 @@ extern "C" { * This module contains the functions which implement the stream * encoder. * + * The stream encoder can encode to native FLAC, and optionally Ogg FLAC + * (check FLAC_API_SUPPORTS_OGG_FLAC) streams and files. + * * The basic usage of this encoder is as follows: * - The program creates an instance of an encoder using * FLAC__stream_encoder_new(). @@ -85,8 +88,11 @@ extern "C" { * FLAC__stream_encoder_set_*() functions. * - The program initializes the instance to validate the settings and * prepare for encoding using FLAC__stream_encoder_init_stream() or - * FLAC__stream_encoder_init_FILE() or FLAC__stream_encoder_init_file(), - * depending on the nature of the output. + * FLAC__stream_encoder_init_FILE() or FLAC__stream_encoder_init_file() + * for native FLAC, or FLAC__stream_encoder_init_ogg_stream() or + * FLAC__stream_encoder_init_ogg_FILE() or + * FLAC__stream_encoder_init_ogg_file() for Ogg FLAC, depending on the + * nature of the input. * - The program calls FLAC__stream_encoder_process() or * FLAC__stream_encoder_process_interleaved() to encode data, which * subsequently calls the callbacks when there is encoder data ready @@ -101,11 +107,10 @@ extern "C" { * * In more detail, the stream encoder functions similarly to the * \link flac_stream_decoder stream decoder \endlink, but has fewer - * callbacks and more options. Typically the user will create a new + * callbacks and more options. Typically the client will create a new * instance by calling FLAC__stream_encoder_new(), then set the necessary * parameters with FLAC__stream_encoder_set_*(), and initialize it by - * calling FLAC__stream_encoder_init_stream() or - * FLAC__stream_encoder_init_file() or FLAC__stream_encoder_init_FILE(). + * calling one of the FLAC__stream_encoder_init_*() functions. * * Unlike the decoders, the stream encoder has many options that can * affect the speed and compression ratio. When setting these parameters @@ -120,9 +125,9 @@ extern "C" { * before FLAC__stream_encoder_init_*() will take on the defaults from * the constructor. * - * There are three initialization functions, one for setting up the encoder - * to encode FLAC data to the client via callbacks, and two for encoding - * directly to a file. + * There are three initialization functions for native FLAC, one for + * setting up the encoder to encode FLAC data to the client via + * callbacks, and two for encoding directly to a file. * * For encoding via callbacks, use FLAC__stream_encoder_init_stream(). * You must also supply a write callback which will be called anytime @@ -138,26 +143,32 @@ extern "C" { * internally. You may also supply a progress callback for periodic * notification of the encoding progress. * + * There are three similarly-named init functions for encoding to Ogg + * FLAC streams. Check \c FLAC_API_SUPPORTS_OGG_FLAC to find out if the + * library has been built with Ogg support. + * * The call to FLAC__stream_encoder_init_*() currently will also immediately * call the write callback several times, once with the \c fLaC signature, - * and once for each encoded metadata block. + * and once for each encoded metadata block. Note that for Ogg FLAC + * encoding you will usually get twice the number of callbacks than with + * native FLAC, one for the Ogg page header and one for the page body. * - * After initializing the instance, the user may feed audio data to the + * After initializing the instance, the client may feed audio data to the * encoder in one of two ways: * - * - Channel separate, through FLAC__stream_encoder_process() - The user + * - Channel separate, through FLAC__stream_encoder_process() - The client * will pass an array of pointers to buffers, one for each channel, to * the encoder, each of the same length. The samples need not be * block-aligned. * - Channel interleaved, through - * FLAC__stream_encoder_process_interleaved() - The user will pass a single + * FLAC__stream_encoder_process_interleaved() - The client will pass a single * pointer to data that is channel-interleaved (i.e. channel0_sample0, * channel1_sample0, ... , channelN_sample0, channel0_sample1, ...). * Again, the samples need not be block-aligned but they must be * sample-aligned, i.e. the first value should be channel0_sample0 and * the last value channelN_sampleM. * - * When the user is finished encoding data, it calls + * When the client is finished encoding data, it calls * FLAC__stream_encoder_finish(), which causes the encoder to encode any * data still in its input pipe, and call the metadata callback with the * final encoding statistics. Then the instance may be deleted with @@ -182,14 +193,14 @@ extern "C" { * is open for update (e.g. mode "w+" for stdio streams). This is because * after the first encoding pass, the encoder will try to seek back to the * beginning of the stream, to the STREAMINFO block, to write some data - * there. (If using FLAC__stream_encoder_init_file() or - * FLAC__stream_encoder_init_FILE(), the file is managed internally.) + * there. (If using FLAC__stream_encoder_init*_file() or + * FLAC__stream_encoder_init*_FILE(), the file is managed internally.) * * \note * The "set" functions may only be called when the encoder is in the * state FLAC__STREAM_ENCODER_UNINITIALIZED, i.e. after * FLAC__stream_encoder_new() or FLAC__stream_encoder_finish(), but - * before FLAC__stream_encoder_init(). If this is the case they will + * before FLAC__stream_encoder_init_*(). If this is the case they will * return \c true, otherwise \c false. * * \note @@ -478,7 +489,7 @@ typedef FLAC__StreamEncoderReadStatus (*FLAC__StreamEncoderReadCallback)(const F /** Signature for the write callback. * * A function pointer matching this signature must be passed to - * FLAC__stream_encoder_init_stream(). The supplied function will be called + * FLAC__stream_encoder_init*_stream(). The supplied function will be called * by the encoder anytime there is raw encoded data ready to write. It may * include metadata mixed with encoded audio frames and the data is not * guaranteed to be aligned on frame or metadata block boundaries. @@ -516,7 +527,7 @@ typedef FLAC__StreamEncoderWriteStatus (*FLAC__StreamEncoderWriteCallback)(const /** Signature for the seek callback. * * A function pointer matching this signature may be passed to - * FLAC__stream_encoder_init_stream(). The supplied function will be called + * FLAC__stream_encoder_init*_stream(). The supplied function will be called * when the encoder needs to seek the output stream. The encoder will pass * the absolute byte offset to seek to, 0 meaning the beginning of the stream. * @@ -536,7 +547,7 @@ typedef FLAC__StreamEncoderSeekStatus (*FLAC__StreamEncoderSeekCallback)(const F /** Signature for the tell callback. * * A function pointer matching this signature may be passed to - * FLAC__stream_encoder_init_stream(). The supplied function will be called + * FLAC__stream_encoder_init*_stream(). The supplied function will be called * when the encoder needs to know the current position of the output stream. * * \warning @@ -564,7 +575,7 @@ typedef FLAC__StreamEncoderTellStatus (*FLAC__StreamEncoderTellCallback)(const F /** Signature for the metadata callback. * * A function pointer matching this signature may be passed to - * FLAC__stream_encoder_init_stream(). The supplied function will be called + * FLAC__stream_encoder_init*_stream(). The supplied function will be called * once at the end of encoding with the populated STREAMINFO structure. This * is so the client can seek back to the beginning of the file and write the * STREAMINFO block with the correct statistics after encoding (like @@ -583,11 +594,11 @@ typedef void (*FLAC__StreamEncoderMetadataCallback)(const FLAC__StreamEncoder *e /** Signature for the progress callback. * * A function pointer matching this signature may be passed to - * FLAC__stream_encoder_init_file() or FLAC__stream_encoder_init_FILE(). + * FLAC__stream_encoder_init*_file() or FLAC__stream_encoder_init*_FILE(). * The supplied function will be called when the encoder has finished * writing a frame. The \c total_frames_estimate argument to the * callback will be based on the value from - * FLAC__file_encoder_set_total_samples_estimate(). + * FLAC__stream_encoder_set_total_samples_estimate(). * * \note In general, FLAC__StreamEncoder functions which change the * state should not be called on the \a encoder while in the callback. @@ -671,7 +682,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_verify(FLAC__StreamEncoder *encoder /** Set the Subset flag. If \c true, * the encoder will comply with the Subset and will check the - * settings during FLAC__stream_encoder_init() to see if all settings + * settings during FLAC__stream_encoder_init_*() to see if all settings * comply. If \c false, the settings may take advantage of the full * range that the format allows. * @@ -968,7 +979,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(FLAC__Stream * * \note * The encoder stores only the \a metadata pointer; the passed-in array - * must survive at least until after FLAC__stream_encoder_init() returns. + * must survive at least until after FLAC__stream_encoder_init_*() returns. * Do not modify the array or free the blocks until then. * * \note @@ -990,8 +1001,9 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(FLAC__Stream * required sample numbers (or placeholder points), with \c 0 for the * \a frame_samples and \a stream_offset fields for each point. If the * client has specified that it supports seeking by providing a seek - * callback to FLAC__stream_encoder_init_stream() (or by using - * FLAC__stream_encoder_init_file() or FLAC__stream_encoder_init_FILE()), + * callback to FLAC__stream_encoder_init_stream() or both seek AND read + * callback to FLAC__stream_encoder_init_ogg_stream() (or by using + * FLAC__stream_encoder_init*_file() or FLAC__stream_encoder_init*_FILE()), * then while it is encoding the encoder will fill the stream offsets in * for you and when encoding is finished, it will seek back and write the * real values into the SEEKTABLE block in the stream. There are helper @@ -1019,7 +1031,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(FLAC__Stream * the STREAMINFO block automatically. If \a metadata does not contain a * VORBIS_COMMENT block, the encoder will supply that too. Otherwise, if * \a metadata does contain a VORBIS_COMMENT block and it is not the - * first, this function will reorder \a metadata by moving the + * first, the init function will reorder \a metadata by moving the * VORBIS_COMMENT block to the front; the relative ordering of the other * blocks will remain as they were. * @@ -1257,7 +1269,7 @@ FLAC_API unsigned FLAC__stream_encoder_get_rice_parameter_search_dist(const FLAC /** Get the previously set estimate of the total samples to be encoded. * The encoder merely mimics back the value given to * FLAC__stream_encoder_set_total_samples_estimate() since it has no - * other way of knowing how many samples the user will encode. + * other way of knowing how many samples the client will encode. * * \param encoder An encoder instance to set. * \assert @@ -1541,7 +1553,7 @@ FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_file(FLAC__ * * In the event of a prematurely-terminated encode, it is not strictly * necessary to call this immediately before FLAC__stream_encoder_delete() - * but it is good practice to match every FLAC__stream_encoder_init() + * but it is good practice to match every FLAC__stream_encoder_init_*() * with a FLAC__stream_encoder_finish(). * * \param encoder An uninitialized encoder instance.