📄 stream_decoder.h
字号:
FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER,
/**< The decoder encountered a corrupted frame header. */
FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH
/**< The frame's data did not match the CRC in the footer. */
} FLAC__StreamDecoderErrorStatus;
/** Maps a FLAC__StreamDecoderErrorStatus to a C string.
*
* Using a FLAC__StreamDecoderErrorStatus as the index to this array
* will give the string equivalent. The contents should not be modified.
*/
extern FLAC_API const char * const FLAC__StreamDecoderErrorStatusString[];
/***********************************************************************
*
* class FLAC__StreamDecoder
*
***********************************************************************/
struct FLAC__StreamDecoderProtected;
struct FLAC__StreamDecoderPrivate;
/** The opaque structure definition for the stream decoder type.
* See the \link flac_stream_decoder stream decoder module \endlink
* for a detailed description.
*/
typedef struct {
struct FLAC__StreamDecoderProtected *protected_; /* avoid the C++ keyword 'protected' */
struct FLAC__StreamDecoderPrivate *private_; /* avoid the C++ keyword 'private' */
} FLAC__StreamDecoder;
/** Signature for the read callback.
* See FLAC__stream_decoder_set_read_callback() for more info.
*
* \param decoder The decoder instance calling the callback.
* \param buffer A pointer to a location for the callee to store
* data to be decoded.
* \param bytes A pointer to the size of the buffer. On entry
* to the callback, it contains the maximum number
* of bytes that may be stored in \a buffer. The
* callee must set it to the actual number of bytes
* stored (0 in case of error or end-of-stream) before
* returning.
* \param client_data The callee's client data set through
* FLAC__stream_decoder_set_client_data().
* \retval FLAC__StreamDecoderReadStatus
* The callee's return status.
*/
typedef FLAC__StreamDecoderReadStatus (*FLAC__StreamDecoderReadCallback)(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
/** Signature for the write callback.
* See FLAC__stream_decoder_set_write_callback() for more info.
*
* \param decoder The decoder instance calling the callback.
* \param frame The description of the decoded frame. See
* FLAC__Frame.
* \param buffer An array of pointers to decoded channels of data.
* Each pointer will point to an array of signed
* samples of length \a frame->header.blocksize.
* Currently, the channel order has no meaning
* except for stereo streams; in this case channel
* 0 is left and 1 is right.
* \param client_data The callee's client data set through
* FLAC__stream_decoder_set_client_data().
* \retval FLAC__StreamDecoderWriteStatus
* The callee's return status.
*/
typedef FLAC__StreamDecoderWriteStatus (*FLAC__StreamDecoderWriteCallback)(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
/** Signature for the metadata callback.
* See FLAC__stream_decoder_set_metadata_callback() for more info.
*
* \param decoder The decoder instance calling the callback.
* \param metadata The decoded metadata block.
* \param client_data The callee's client data set through
* FLAC__stream_decoder_set_client_data().
*/
typedef void (*FLAC__StreamDecoderMetadataCallback)(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
/** Signature for the error callback.
* See FLAC__stream_decoder_set_error_callback() for more info.
*
* \param decoder The decoder instance calling the callback.
* \param status The error encountered by the decoder.
* \param client_data The callee's client data set through
* FLAC__stream_decoder_set_client_data().
*/
typedef void (*FLAC__StreamDecoderErrorCallback)(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
/***********************************************************************
*
* Class constructor/destructor
*
***********************************************************************/
/** Create a new stream decoder instance. The instance is created with
* default settings; see the individual FLAC__stream_decoder_set_*()
* functions for each setting's default.
*
* \retval FLAC__StreamDecoder*
* \c NULL if there was an error allocating memory, else the new instance.
*/
FLAC_API FLAC__StreamDecoder *FLAC__stream_decoder_new();
/** Free a decoder instance. Deletes the object pointed to by \a decoder.
*
* \param decoder A pointer to an existing decoder.
* \assert
* \code decoder != NULL \endcode
*/
FLAC_API void FLAC__stream_decoder_delete(FLAC__StreamDecoder *decoder);
/***********************************************************************
*
* Public class method prototypes
*
***********************************************************************/
/** Set the read callback.
* 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 modify the byte count but must be careful not to
* overflow the buffer. The callback then returns a status code chosen
* from FLAC__StreamDecoderReadStatus.
*
* \note
* The callback is mandatory and must be set before initialization.
*
* \default \c NULL
* \param decoder A decoder instance to set.
* \param value See above.
* \assert
* \code decoder != NULL \endcode
* \code value != NULL \endcode
* \retval FLAC__bool
* \c false if the decoder is already initialized, else \c true.
*/
FLAC_API FLAC__bool FLAC__stream_decoder_set_read_callback(FLAC__StreamDecoder *decoder, FLAC__StreamDecoderReadCallback value);
/** Set the write callback.
* The supplied function will be called when the decoder has decoded a
* single frame of data. The decoder will pass the frame metadata as
* well as an array of pointers (one for each channel) pointing to the
* decoded audio.
*
* \note
* The callback is mandatory and must be set before initialization.
*
* \default \c NULL
* \param decoder A decoder instance to set.
* \param value See above.
* \assert
* \code decoder != NULL \endcode
* \code value != NULL \endcode
* \retval FLAC__bool
* \c false if the decoder is already initialized, else \c true.
*/
FLAC_API FLAC__bool FLAC__stream_decoder_set_write_callback(FLAC__StreamDecoder *decoder, FLAC__StreamDecoderWriteCallback value);
/** Set the metadata callback.
* The supplied function will be called when the decoder has decoded a metadata
* block. In a valid FLAC file there will always be one STREAMINFO block,
* followed by zero or more other metadata blocks. These will be supplied
* by the decoder in the same order as they appear in the stream and always
* before the first audio frame (i.e. write callback). The metadata block
* that is passed in must not be modified, and it doesn't live beyond the
* callback, so you should make a copy of it with
* FLAC__metadata_object_clone() if you will need it elsewhere. Since
* metadata blocks can potentially be large, by default the decoder only
* calls the metadata callback for the STREAMINFO block; you can instruct
* the decoder to pass or filter other blocks with
* FLAC__stream_decoder_set_metadata_*() calls.
*
* \note
* The callback is mandatory and must be set before initialization.
*
* \default \c NULL
* \param decoder A decoder instance to set.
* \param value See above.
* \assert
* \code decoder != NULL \endcode
* \code value != NULL \endcode
* \retval FLAC__bool
* \c false if the decoder is already initialized, else \c true.
*/
FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_callback(FLAC__StreamDecoder *decoder, FLAC__StreamDecoderMetadataCallback value);
/** Set the error callback.
* The supplied function will be called whenever an error occurs during
* decoding.
*
* \note
* The callback is mandatory and must be set before initialization.
*
* \default \c NULL
* \param decoder A decoder instance to set.
* \param value See above.
* \assert
* \code decoder != NULL \endcode
* \code value != NULL \endcode
* \retval FLAC__bool
* \c false if the decoder is already initialized, else \c true.
*/
FLAC_API FLAC__bool FLAC__stream_decoder_set_error_callback(FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorCallback value);
/** Set the client data to be passed back to callbacks.
* This value will be supplied to callbacks in their \a client_data
* argument.
*
* \default \c NULL
* \param decoder A decoder instance to set.
* \param value See above.
* \assert
* \code decoder != NULL \endcode
* \retval FLAC__bool
* \c false if the decoder is already initialized, else \c true.
*/
FLAC_API FLAC__bool FLAC__stream_decoder_set_client_data(FLAC__StreamDecoder *decoder, void *value);
/** Direct the decoder to pass on all metadata blocks of type \a type.
*
* \default By default, only the \c STREAMINFO block is returned via the
* metadata callback.
* \param decoder A decoder instance to set.
* \param type See above.
* \assert
* \code decoder != NULL \endcode
* \a type is valid
* \retval FLAC__bool
* \c false if the decoder is already initialized, else \c true.
*/
FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond(FLAC__StreamDecoder *decoder, FLAC__MetadataType type);
/** Direct the decoder to pass on all APPLICATION metadata blocks of the
* given \a id.
*
* \default By default, only the \c STREAMINFO block is returned via the
* metadata callback.
* \param decoder A decoder instance to set.
* \param id See above.
* \assert
* \code decoder != NULL \endcode
* \code id != NULL \endcode
* \retval FLAC__bool
* \c false if the decoder is already initialized, else \c true.
*/
FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]);
/** Direct the decoder to pass on all metadata blocks of any type.
*
* \default By default, only the \c STREAMINFO block is returned via the
* metadata callback.
* \param decoder A decoder instance to set.
* \assert
* \code decoder != NULL \endcode
* \retval FLAC__bool
* \c false if the decoder is already initialized, else \c true.
*/
FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(FLAC__StreamDecoder *decoder);
/** Direct the decoder to filter out all metadata blocks of type \a type.
*
* \default By default, only the \c STREAMINFO block is returned via the
* metadata callback.
* \param decoder A decoder instance to set.
* \param type See above.
* \assert
* \code decoder != NULL \endcode
* \a type is valid
* \retval FLAC__bool
* \c false if the decoder is already initialized, else \c true.
*/
FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore(FLAC__StreamDecoder *decoder, FLAC__MetadataType type);
/** Direct the decoder to filter out all APPLICATION metadata blocks of
* the given \a id.
*
* \default By default, only the \c STREAMINFO block is returned via the
* metadata callback.
* \param decoder A decoder instance to set.
* \param id See above.
* \assert
* \code decoder != NULL \endcode
* \code id != NULL \endcode
* \retval FLAC__bool
* \c false if the decoder is already initialized, else \c true.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -