📄 stream_encoder.h
字号:
/* libOggFLAC - Free Lossless Audio Codec + Ogg library * Copyright (C) 2002,2003,2004,2005 Josh Coalson * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Xiph.org Foundation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */#ifndef OggFLAC__STREAM_ENCODER_H#define OggFLAC__STREAM_ENCODER_H#include "export.h"#include "FLAC/stream_encoder.h"#ifdef __cplusplusextern "C" {#endif/** \file include/OggFLAC/stream_encoder.h * * \brief * This module contains the functions which implement the stream * encoder. * * See the detailed documentation in the * \link oggflac_stream_encoder stream encoder \endlink module. *//** \defgroup oggflac_encoder OggFLAC/ *_encoder.h: encoder interfaces * \ingroup oggflac * * \brief * This module describes the three encoder layers provided by libOggFLAC. * * libOggFLAC currently provides the same three layers of access as libFLAC; * the interfaces are nearly identical, with the addition of a method for * specifying the Ogg serial number. See the \link flac_encoder FLAC * encoder module \endlink for full documentation. *//** \defgroup oggflac_stream_encoder OggFLAC/stream_encoder.h: stream encoder interface * \ingroup oggflac_encoder * * \brief * This module contains the functions which implement the stream * encoder. The Ogg stream encoder is derived * from the FLAC stream encoder. * * The interface here is nearly identical to FLAC's stream encoder, * including the callbacks, with the addition of * OggFLAC__stream_encoder_set_serial_number(). See the * \link flac_stream_encoder FLAC stream encoder module \endlink * for full documentation. * * \{ *//** State values for an OggFLAC__StreamEncoder * * The encoder's state can be obtained by calling OggFLAC__stream_encoder_get_state(). */typedef enum { OggFLAC__STREAM_ENCODER_OK = 0, /**< The encoder is in the normal OK state. */ OggFLAC__STREAM_ENCODER_OGG_ERROR, /**< An error occurred in the underlying Ogg layer. */ OggFLAC__STREAM_ENCODER_FLAC_STREAM_ENCODER_ERROR, /**< An error occurred in the underlying FLAC stream encoder; * check OggFLAC__stream_encoder_get_FLAC_stream_encoder_state(). */ OggFLAC__STREAM_ENCODER_INVALID_CALLBACK, /**< The encoder was initialized before setting all the required callbacks. */ OggFLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR, /**< Memory allocation failed. */ OggFLAC__STREAM_ENCODER_ALREADY_INITIALIZED, /**< OggFLAC__stream_encoder_init() was called when the encoder was * already initialized, usually because * OggFLAC__stream_encoder_finish() was not called. */ OggFLAC__STREAM_ENCODER_UNINITIALIZED /**< The encoder is in the uninitialized state. */} OggFLAC__StreamEncoderState;/** Maps an OggFLAC__StreamEncoderState to a C string. * * Using an OggFLAC__StreamEncoderState as the index to this array * will give the string equivalent. The contents should not be modified. */extern OggFLAC_API const char * const OggFLAC__StreamEncoderStateString[];/*********************************************************************** * * class OggFLAC__StreamEncoder * ***********************************************************************/struct OggFLAC__StreamEncoderProtected;struct OggFLAC__StreamEncoderPrivate;/** The opaque structure definition for the stream encoder type. * See the \link oggflac_stream_encoder stream encoder module \endlink * for a detailed description. */typedef struct { struct OggFLAC__StreamEncoderProtected *protected_; /* avoid the C++ keyword 'protected' */ struct OggFLAC__StreamEncoderPrivate *private_; /* avoid the C++ keyword 'private' */} OggFLAC__StreamEncoder;/** Signature for the write callback. * See OggFLAC__stream_encoder_set_write_callback() * and FLAC__StreamEncoderWriteCallback for more info. * * \param encoder The encoder instance calling the callback. * \param buffer An array of encoded data of length \a bytes. * \param bytes The byte length of \a buffer. * \param samples The number of samples encoded by \a buffer. * \c 0 has a special meaning; see * OggFLAC__stream_encoder_set_write_callback(). * \param current_frame The number of current frame being encoded. * \param client_data The callee's client data set through * OggFLAC__stream_encoder_set_client_data(). * \retval FLAC__StreamEncoderWriteStatus * The callee's return status. */typedef FLAC__StreamEncoderWriteStatus (*OggFLAC__StreamEncoderWriteCallback)(const OggFLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);/** Signature for the metadata callback. * See OggFLAC__stream_encoder_set_metadata_callback() * and FLAC__stream_encoder_set_metadata_callback() for more info. * * \param encoder The encoder instance calling the callback. * \param metadata The final populated STREAMINFO block. * \param client_data The callee's client data set through * FLAC__stream_encoder_set_client_data(). */typedef void (*OggFLAC__StreamEncoderMetadataCallback)(const OggFLAC__StreamEncoder *encoder, const FLAC__StreamMetadata *metadata, void *client_data);/*********************************************************************** * * Class constructor/destructor * ***********************************************************************//** Create a new stream encoder instance. The instance is created with * default settings; see the individual OggFLAC__stream_encoder_set_*() * functions for each setting's default. * * \retval OggFLAC__StreamEncoder* * \c NULL if there was an error allocating memory, else the new instance. */OggFLAC_API OggFLAC__StreamEncoder *OggFLAC__stream_encoder_new();/** Free an encoder instance. Deletes the object pointed to by \a encoder. * * \param encoder A pointer to an existing encoder. * \assert * \code encoder != NULL \endcode */OggFLAC_API void OggFLAC__stream_encoder_delete(OggFLAC__StreamEncoder *encoder);/*********************************************************************** * * Public class method prototypes * ***********************************************************************//** Set the serial number for the FLAC stream. * * \note * It is recommended to set a serial number explicitly as the default of '0' * may collide with other streams. * * \default \c 0 * \param encoder An encoder instance to set. * \param serial_number See above. * \assert * \code encoder != NULL \endcode * \retval FLAC__bool * \c false if the encoder is already initialized, else \c true. */OggFLAC_API FLAC__bool OggFLAC__stream_encoder_set_serial_number(OggFLAC__StreamEncoder *encoder, long serial_number);/** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_verify() * * \default \c false * \param encoder An encoder instance to set. * \param value Flag value (see above). * \assert * \code encoder != NULL \endcode * \retval FLAC__bool * \c false if the encoder is already initialized, else \c true. */OggFLAC_API FLAC__bool OggFLAC__stream_encoder_set_verify(OggFLAC__StreamEncoder *encoder, FLAC__bool value);/** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_streamable_subset() * * \default \c true * \param encoder An encoder instance to set. * \param value Flag value (see above). * \assert * \code encoder != NULL \endcode * \retval FLAC__bool * \c false if the encoder is already initialized, else \c true. */OggFLAC_API FLAC__bool OggFLAC__stream_encoder_set_streamable_subset(OggFLAC__StreamEncoder *encoder, FLAC__bool value);/** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_do_mid_side_stereo() * * \default \c false * \param encoder An encoder instance to set. * \param value Flag value (see above). * \assert * \code encoder != NULL \endcode * \retval FLAC__bool * \c false if the encoder is already initialized, else \c true. */OggFLAC_API FLAC__bool OggFLAC__stream_encoder_set_do_mid_side_stereo(OggFLAC__StreamEncoder *encoder, FLAC__bool value);/** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_loose_mid_side_stereo() * * \default \c false * \param encoder An encoder instance to set. * \param value Flag value (see above). * \assert * \code encoder != NULL \endcode * \retval FLAC__bool * \c false if the encoder is already initialized, else \c true. */OggFLAC_API FLAC__bool OggFLAC__stream_encoder_set_loose_mid_side_stereo(OggFLAC__StreamEncoder *encoder, FLAC__bool value);/** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_channels() * * \default \c 2 * \param encoder An encoder instance to set. * \param value See above. * \assert * \code encoder != NULL \endcode * \retval FLAC__bool * \c false if the encoder is already initialized, else \c true. */OggFLAC_API FLAC__bool OggFLAC__stream_encoder_set_channels(OggFLAC__StreamEncoder *encoder, unsigned value);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -