Blame include/FLAC/all.h

Packit 8f7830
/* libFLAC - Free Lossless Audio Codec library
Packit 8f7830
 * Copyright (C) 2000-2009  Josh Coalson
Packit 8f7830
 * Copyright (C) 2011-2016  Xiph.Org Foundation
Packit 8f7830
 *
Packit 8f7830
 * Redistribution and use in source and binary forms, with or without
Packit 8f7830
 * modification, are permitted provided that the following conditions
Packit 8f7830
 * are met:
Packit 8f7830
 *
Packit 8f7830
 * - Redistributions of source code must retain the above copyright
Packit 8f7830
 * notice, this list of conditions and the following disclaimer.
Packit 8f7830
 *
Packit 8f7830
 * - Redistributions in binary form must reproduce the above copyright
Packit 8f7830
 * notice, this list of conditions and the following disclaimer in the
Packit 8f7830
 * documentation and/or other materials provided with the distribution.
Packit 8f7830
 *
Packit 8f7830
 * - Neither the name of the Xiph.org Foundation nor the names of its
Packit 8f7830
 * contributors may be used to endorse or promote products derived from
Packit 8f7830
 * this software without specific prior written permission.
Packit 8f7830
 *
Packit 8f7830
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 8f7830
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 8f7830
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Packit 8f7830
 * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
Packit 8f7830
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
Packit 8f7830
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
Packit 8f7830
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
Packit 8f7830
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
Packit 8f7830
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
Packit 8f7830
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Packit 8f7830
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 8f7830
 */
Packit 8f7830
Packit 8f7830
#ifndef FLAC__ALL_H
Packit 8f7830
#define FLAC__ALL_H
Packit 8f7830
Packit 8f7830
#include "export.h"
Packit 8f7830
Packit 8f7830
#include "assert.h"
Packit 8f7830
#include "callback.h"
Packit 8f7830
#include "format.h"
Packit 8f7830
#include "metadata.h"
Packit 8f7830
#include "ordinals.h"
Packit 8f7830
#include "stream_decoder.h"
Packit 8f7830
#include "stream_encoder.h"
Packit 8f7830
Packit 8f7830
/** \mainpage
Packit 8f7830
 *
Packit 8f7830
 * \section intro Introduction
Packit 8f7830
 *
Packit 8f7830
 * This is the documentation for the FLAC C and C++ APIs.  It is
Packit 8f7830
 * highly interconnected; this introduction should give you a top
Packit 8f7830
 * level idea of the structure and how to find the information you
Packit 8f7830
 * need.  As a prerequisite you should have at least a basic
Packit 8f7830
 * knowledge of the FLAC format, documented
Packit 8f7830
 * here.
Packit 8f7830
 *
Packit 8f7830
 * \section c_api FLAC C API
Packit 8f7830
 *
Packit 8f7830
 * The FLAC C API is the interface to libFLAC, a set of structures
Packit 8f7830
 * describing the components of FLAC streams, and functions for
Packit 8f7830
 * encoding and decoding streams, as well as manipulating FLAC
Packit 8f7830
 * metadata in files.  The public include files will be installed
Packit 8f7830
 * in your include area (for example /usr/include/FLAC/...).
Packit 8f7830
 *
Packit 8f7830
 * By writing a little code and linking against libFLAC, it is
Packit 8f7830
 * relatively easy to add FLAC support to another program.  The
Packit 8f7830
 * library is licensed under Xiph's BSD license.
Packit 8f7830
 * Complete source code of libFLAC as well as the command-line
Packit 8f7830
 * encoder and plugins is available and is a useful source of
Packit 8f7830
 * examples.
Packit 8f7830
 *
Packit 8f7830
 * Aside from encoders and decoders, libFLAC provides a powerful
Packit 8f7830
 * metadata interface for manipulating metadata in FLAC files.  It
Packit 8f7830
 * allows the user to add, delete, and modify FLAC metadata blocks
Packit 8f7830
 * and it can automatically take advantage of PADDING blocks to avoid
Packit 8f7830
 * rewriting the entire FLAC file when changing the size of the
Packit 8f7830
 * metadata.
Packit 8f7830
 *
Packit 8f7830
 * libFLAC usually only requires the standard C library and C math
Packit 8f7830
 * library. In particular, threading is not used so there is no
Packit 8f7830
 * dependency on a thread library. However, libFLAC does not use
Packit 8f7830
 * global variables and should be thread-safe.
Packit 8f7830
 *
Packit 8f7830
 * libFLAC also supports encoding to and decoding from Ogg FLAC.
Packit 8f7830
 * However the metadata editing interfaces currently have limited
Packit 8f7830
 * read-only support for Ogg FLAC files.
Packit 8f7830
 *
Packit 8f7830
 * \section cpp_api FLAC C++ API
Packit 8f7830
 *
Packit 8f7830
 * The FLAC C++ API is a set of classes that encapsulate the
Packit 8f7830
 * structures and functions in libFLAC.  They provide slightly more
Packit 8f7830
 * functionality with respect to metadata but are otherwise
Packit 8f7830
 * equivalent.  For the most part, they share the same usage as
Packit 8f7830
 * their counterparts in libFLAC, and the FLAC C API documentation
Packit 8f7830
 * can be used as a supplement.  The public include files
Packit 8f7830
 * for the C++ API will be installed in your include area (for
Packit 8f7830
 * example /usr/include/FLAC++/...).
Packit 8f7830
 *
Packit 8f7830
 * libFLAC++ is also licensed under
Packit 8f7830
 * Xiph's BSD license.
Packit 8f7830
 *
Packit 8f7830
 * \section getting_started Getting Started
Packit 8f7830
 *
Packit 8f7830
 * A good starting point for learning the API is to browse through
Packit 8f7830
 * the modules.  Modules are logical
Packit 8f7830
 * groupings of related functions or classes, which correspond roughly
Packit 8f7830
 * to header files or sections of header files.  Each module includes a
Packit 8f7830
 * detailed description of the general usage of its functions or
Packit 8f7830
 * classes.
Packit 8f7830
 *
Packit 8f7830
 * From there you can go on to look at the documentation of
Packit 8f7830
 * individual functions.  You can see different views of the individual
Packit 8f7830
 * functions through the links in top bar across this page.
Packit 8f7830
 *
Packit 8f7830
 * If you prefer a more hands-on approach, you can jump right to some
Packit 8f7830
 * example code.
Packit 8f7830
 *
Packit 8f7830
 * \section porting_guide Porting Guide
Packit 8f7830
 *
Packit 8f7830
 * Starting with FLAC 1.1.3 a \link porting Porting Guide \endlink
Packit 8f7830
 * has been introduced which gives detailed instructions on how to
Packit 8f7830
 * port your code to newer versions of FLAC.
Packit 8f7830
 *
Packit 8f7830
 * \section embedded_developers Embedded Developers
Packit 8f7830
 *
Packit 8f7830
 * libFLAC has grown larger over time as more functionality has been
Packit 8f7830
 * included, but much of it may be unnecessary for a particular embedded
Packit 8f7830
 * implementation.  Unused parts may be pruned by some simple editing of
Packit 8f7830
 * src/libFLAC/Makefile.am.  In general, the decoders, encoders, and
Packit 8f7830
 * metadata interface are all independent from each other.
Packit 8f7830
 *
Packit 8f7830
 * It is easiest to just describe the dependencies:
Packit 8f7830
 *
Packit 8f7830
 * - All modules depend on the \link flac_format Format \endlink module.
Packit 8f7830
 * - The decoders and encoders depend on the bitbuffer.
Packit 8f7830
 * - The decoder is independent of the encoder.  The encoder uses the
Packit 8f7830
 *   decoder because of the verify feature, but this can be removed if
Packit 8f7830
 *   not needed.
Packit 8f7830
 * - Parts of the metadata interface require the stream decoder (but not
Packit 8f7830
 *   the encoder).
Packit 8f7830
 * - Ogg support is selectable through the compile time macro
Packit 8f7830
 *   \c FLAC__HAS_OGG.
Packit 8f7830
 *
Packit 8f7830
 * For example, if your application only requires the stream decoder, no
Packit 8f7830
 * encoder, and no metadata interface, you can remove the stream encoder
Packit 8f7830
 * and the metadata interface, which will greatly reduce the size of the
Packit 8f7830
 * library.
Packit 8f7830
 *
Packit 8f7830
 * Also, there are several places in the libFLAC code with comments marked
Packit 8f7830
 * with "OPT:" where a #define can be changed to enable code that might be
Packit 8f7830
 * faster on a specific platform.  Experimenting with these can yield faster
Packit 8f7830
 * binaries.
Packit 8f7830
 */
Packit 8f7830
Packit 8f7830
/** \defgroup porting Porting Guide for New Versions
Packit 8f7830
 *
Packit 8f7830
 * This module describes differences in the library interfaces from
Packit 8f7830
 * version to version.  It assists in the porting of code that uses
Packit 8f7830
 * the libraries to newer versions of FLAC.
Packit 8f7830
 *
Packit 8f7830
 * One simple facility for making porting easier that has been added
Packit 8f7830
 * in FLAC 1.1.3 is a set of \c #defines in \c export.h of each
Packit 8f7830
 * library's includes (e.g. \c include/FLAC/export.h).  The
Packit 8f7830
 * \c #defines mirror the libraries'
Packit 8f7830
 * libtool version numbers,
Packit 8f7830
 * e.g. in libFLAC there are \c FLAC_API_VERSION_CURRENT,
Packit 8f7830
 * \c FLAC_API_VERSION_REVISION, and \c FLAC_API_VERSION_AGE.
Packit 8f7830
 * These can be used to support multiple versions of an API during the
Packit 8f7830
 * transition phase, e.g.
Packit 8f7830
 *
Packit 8f7830
 * \code
Packit 8f7830
 * #if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7
Packit 8f7830
 *   legacy code
Packit 8f7830
 * #else
Packit 8f7830
 *   new code
Packit 8f7830
 * #endif
Packit 8f7830
 * \endcode
Packit 8f7830
 *
Packit 8f7830
 * The source will work for multiple versions and the legacy code can
Packit 8f7830
 * easily be removed when the transition is complete.
Packit 8f7830
 *
Packit 8f7830
 * Another available symbol is FLAC_API_SUPPORTS_OGG_FLAC (defined in
Packit 8f7830
 * include/FLAC/export.h), which can be used to determine whether or not
Packit 8f7830
 * the library has been compiled with support for Ogg FLAC.  This is
Packit 8f7830
 * simpler than trying to call an Ogg init function and catching the
Packit 8f7830
 * error.
Packit 8f7830
 */
Packit 8f7830
Packit 8f7830
/** \defgroup porting_1_1_2_to_1_1_3 Porting from FLAC 1.1.2 to 1.1.3
Packit 8f7830
 *  \ingroup porting
Packit 8f7830
 *
Packit 8f7830
 *  \brief
Packit 8f7830
 *  This module describes porting from FLAC 1.1.2 to FLAC 1.1.3.
Packit 8f7830
 *
Packit 8f7830
 * The main change between the APIs in 1.1.2 and 1.1.3 is that they have
Packit 8f7830
 * been simplified.  First, libOggFLAC has been merged into libFLAC and
Packit 8f7830
 * libOggFLAC++ has been merged into libFLAC++.  Second, both the three
Packit 8f7830
 * decoding layers and three encoding layers have been merged into a
Packit 8f7830
 * single stream decoder and stream encoder.  That is, the functionality
Packit 8f7830
 * of FLAC__SeekableStreamDecoder and FLAC__FileDecoder has been merged
Packit 8f7830
 * into FLAC__StreamDecoder, and FLAC__SeekableStreamEncoder and
Packit 8f7830
 * FLAC__FileEncoder into FLAC__StreamEncoder.  Only the
Packit 8f7830
 * FLAC__StreamDecoder and FLAC__StreamEncoder remain.  What this means
Packit 8f7830
 * is there is now a single API that can be used to encode or decode
Packit 8f7830
 * streams to/from native FLAC or Ogg FLAC and the single API can work
Packit 8f7830
 * on both seekable and non-seekable streams.
Packit 8f7830
 *
Packit 8f7830
 * Instead of creating an encoder or decoder of a certain layer, now the
Packit 8f7830
 * client will always create a FLAC__StreamEncoder or
Packit 8f7830
 * FLAC__StreamDecoder.  The old layers are now differentiated by the
Packit 8f7830
 * initialization function.  For example, for the decoder,
Packit 8f7830
 * FLAC__stream_decoder_init() has been replaced by
Packit 8f7830
 * FLAC__stream_decoder_init_stream().  This init function takes
Packit 8f7830
 * callbacks for the I/O, and the seeking callbacks are optional.  This
Packit 8f7830
 * allows the client to use the same object for seekable and
Packit 8f7830
 * non-seekable streams.  For decoding a FLAC file directly, the client
Packit 8f7830
 * can use FLAC__stream_decoder_init_file() and pass just a filename
Packit 8f7830
 * and fewer callbacks; most of the other callbacks are supplied
Packit 8f7830
 * internally.  For situations where fopen()ing by filename is not
Packit 8f7830
 * possible (e.g. Unicode filenames on Windows) the client can instead
Packit 8f7830
 * open the file itself and supply the FILE* to
Packit 8f7830
 * FLAC__stream_decoder_init_FILE().  The init functions now returns a
Packit 8f7830
 * FLAC__StreamDecoderInitStatus instead of FLAC__StreamDecoderState.
Packit 8f7830
 * Since the callbacks and client data are now passed to the init
Packit 8f7830
 * function, the FLAC__stream_decoder_set_*_callback() functions and
Packit 8f7830
 * FLAC__stream_decoder_set_client_data() are no longer needed.  The
Packit 8f7830
 * rest of the calls to the decoder are the same as before.
Packit 8f7830
 *
Packit 8f7830
 * There are counterpart init functions for Ogg FLAC, e.g.
Packit 8f7830
 * FLAC__stream_decoder_init_ogg_stream().  All the rest of the calls
Packit 8f7830
 * and callbacks are the same as for native FLAC.
Packit 8f7830
 *
Packit 8f7830
 * As an example, in FLAC 1.1.2 a seekable stream decoder would have
Packit 8f7830
 * been set up like so:
Packit 8f7830
 *
Packit 8f7830
 * \code
Packit 8f7830
 * FLAC__SeekableStreamDecoder *decoder = FLAC__seekable_stream_decoder_new();
Packit 8f7830
 * if(decoder == NULL) do_something;
Packit 8f7830
 * FLAC__seekable_stream_decoder_set_md5_checking(decoder, true);
Packit 8f7830
 * [... other settings ...]
Packit 8f7830
 * FLAC__seekable_stream_decoder_set_read_callback(decoder, my_read_callback);
Packit 8f7830
 * FLAC__seekable_stream_decoder_set_seek_callback(decoder, my_seek_callback);
Packit 8f7830
 * FLAC__seekable_stream_decoder_set_tell_callback(decoder, my_tell_callback);
Packit 8f7830
 * FLAC__seekable_stream_decoder_set_length_callback(decoder, my_length_callback);
Packit 8f7830
 * FLAC__seekable_stream_decoder_set_eof_callback(decoder, my_eof_callback);
Packit 8f7830
 * FLAC__seekable_stream_decoder_set_write_callback(decoder, my_write_callback);
Packit 8f7830
 * FLAC__seekable_stream_decoder_set_metadata_callback(decoder, my_metadata_callback);
Packit 8f7830
 * FLAC__seekable_stream_decoder_set_error_callback(decoder, my_error_callback);
Packit 8f7830
 * FLAC__seekable_stream_decoder_set_client_data(decoder, my_client_data);
Packit 8f7830
 * if(FLAC__seekable_stream_decoder_init(decoder) != FLAC__SEEKABLE_STREAM_DECODER_OK) do_something;
Packit 8f7830
 * \endcode
Packit 8f7830
 *
Packit 8f7830
 * In FLAC 1.1.3 it is like this:
Packit 8f7830
 *
Packit 8f7830
 * \code
Packit 8f7830
 * FLAC__StreamDecoder *decoder = FLAC__stream_decoder_new();
Packit 8f7830
 * if(decoder == NULL) do_something;
Packit 8f7830
 * FLAC__stream_decoder_set_md5_checking(decoder, true);
Packit 8f7830
 * [... other settings ...]
Packit 8f7830
 * if(FLAC__stream_decoder_init_stream(
Packit 8f7830
 *   decoder,
Packit 8f7830
 *   my_read_callback,
Packit 8f7830
 *   my_seek_callback,      // or NULL
Packit 8f7830
 *   my_tell_callback,      // or NULL
Packit 8f7830
 *   my_length_callback,    // or NULL
Packit 8f7830
 *   my_eof_callback,       // or NULL
Packit 8f7830
 *   my_write_callback,
Packit 8f7830
 *   my_metadata_callback,  // or NULL
Packit 8f7830
 *   my_error_callback,
Packit 8f7830
 *   my_client_data
Packit 8f7830
 * ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something;
Packit 8f7830
 * \endcode
Packit 8f7830
 *
Packit 8f7830
 * or you could do;
Packit 8f7830
 *
Packit 8f7830
 * \code
Packit 8f7830
 * [...]
Packit 8f7830
 * FILE *file = fopen("somefile.flac","rb");
Packit 8f7830
 * if(file == NULL) do_somthing;
Packit 8f7830
 * if(FLAC__stream_decoder_init_FILE(
Packit 8f7830
 *   decoder,
Packit 8f7830
 *   file,
Packit 8f7830
 *   my_write_callback,
Packit 8f7830
 *   my_metadata_callback,  // or NULL
Packit 8f7830
 *   my_error_callback,
Packit 8f7830
 *   my_client_data
Packit 8f7830
 * ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something;
Packit 8f7830
 * \endcode
Packit 8f7830
 *
Packit 8f7830
 * or just:
Packit 8f7830
 *
Packit 8f7830
 * \code
Packit 8f7830
 * [...]
Packit 8f7830
 * if(FLAC__stream_decoder_init_file(
Packit 8f7830
 *   decoder,
Packit 8f7830
 *   "somefile.flac",
Packit 8f7830
 *   my_write_callback,
Packit 8f7830
 *   my_metadata_callback,  // or NULL
Packit 8f7830
 *   my_error_callback,
Packit 8f7830
 *   my_client_data
Packit 8f7830
 * ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something;
Packit 8f7830
 * \endcode
Packit 8f7830
 *
Packit 8f7830
 * Another small change to the decoder is in how it handles unparseable
Packit 8f7830
 * streams.  Before, when the decoder found an unparseable stream
Packit 8f7830
 * (reserved for when the decoder encounters a stream from a future
Packit 8f7830
 * encoder that it can't parse), it changed the state to
Packit 8f7830
 * \c FLAC__STREAM_DECODER_UNPARSEABLE_STREAM.  Now the decoder instead
Packit 8f7830
 * drops sync and calls the error callback with a new error code
Packit 8f7830
 * \c FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM.  This is
Packit 8f7830
 * more robust.  If your error callback does not discriminate on the the
Packit 8f7830
 * error state, your code does not need to be changed.
Packit 8f7830
 *
Packit 8f7830
 * The encoder now has a new setting:
Packit 8f7830
 * FLAC__stream_encoder_set_apodization().  This is for setting the
Packit 8f7830
 * method used to window the data before LPC analysis.  You only need to
Packit 8f7830
 * add a call to this function if the default is not suitable.   There
Packit 8f7830
 * are also two new convenience functions that may be useful:
Packit 8f7830
 * FLAC__metadata_object_cuesheet_calculate_cddb_id() and
Packit 8f7830
 * FLAC__metadata_get_cuesheet().
Packit 8f7830
 *
Packit 8f7830
 * The \a bytes parameter to FLAC__StreamDecoderReadCallback,
Packit 8f7830
 * FLAC__StreamEncoderReadCallback, and FLAC__StreamEncoderWriteCallback
Packit 8f7830
 * is now \c size_t instead of \c unsigned.
Packit 8f7830
 */
Packit 8f7830
Packit 8f7830
/** \defgroup porting_1_1_3_to_1_1_4 Porting from FLAC 1.1.3 to 1.1.4
Packit 8f7830
 *  \ingroup porting
Packit 8f7830
 *
Packit 8f7830
 *  \brief
Packit 8f7830
 *  This module describes porting from FLAC 1.1.3 to FLAC 1.1.4.
Packit 8f7830
 *
Packit 8f7830
 * There were no changes to any of the interfaces from 1.1.3 to 1.1.4.
Packit 8f7830
 * There was a slight change in the implementation of
Packit 8f7830
 * FLAC__stream_encoder_set_metadata(); the function now makes a copy
Packit 8f7830
 * of the \a metadata array of pointers so the client no longer needs
Packit 8f7830
 * to maintain it after the call.  The objects themselves that are
Packit 8f7830
 * pointed to by the array are still not copied though and must be
Packit 8f7830
 * maintained until the call to FLAC__stream_encoder_finish().
Packit 8f7830
 */
Packit 8f7830
Packit 8f7830
/** \defgroup porting_1_1_4_to_1_2_0 Porting from FLAC 1.1.4 to 1.2.0
Packit 8f7830
 *  \ingroup porting
Packit 8f7830
 *
Packit 8f7830
 *  \brief
Packit 8f7830
 *  This module describes porting from FLAC 1.1.4 to FLAC 1.2.0.
Packit 8f7830
 *
Packit 8f7830
 * There were only very minor changes to the interfaces from 1.1.4 to 1.2.0.
Packit 8f7830
 * In libFLAC, \c FLAC__format_sample_rate_is_subset() was added.
Packit 8f7830
 * In libFLAC++, \c FLAC::Decoder::Stream::get_decode_position() was added.
Packit 8f7830
 *
Packit 8f7830
 * Finally, value of the constant \c FLAC__FRAME_HEADER_RESERVED_LEN
Packit 8f7830
 * has changed to reflect the conversion of one of the reserved bits
Packit 8f7830
 * into active use.  It used to be \c 2 and now is \c 1.  However the
Packit 8f7830
 * FLAC frame header length has not changed, so to skip the proper
Packit 8f7830
 * number of bits, use \c FLAC__FRAME_HEADER_RESERVED_LEN +
Packit 8f7830
 * \c FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN
Packit 8f7830
 */
Packit 8f7830
Packit 8f7830
/** \defgroup flac FLAC C API
Packit 8f7830
 *
Packit 8f7830
 * The FLAC C API is the interface to libFLAC, a set of structures
Packit 8f7830
 * describing the components of FLAC streams, and functions for
Packit 8f7830
 * encoding and decoding streams, as well as manipulating FLAC
Packit 8f7830
 * metadata in files.
Packit 8f7830
 *
Packit 8f7830
 * You should start with the format components as all other modules
Packit 8f7830
 * are dependent on it.
Packit 8f7830
 */
Packit 8f7830
Packit 8f7830
#endif