📄 file_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__FILE_ENCODER_H
#define OggFLAC__FILE_ENCODER_H
#include "export.h"
#include "seekable_stream_encoder.h"
#ifdef __cplusplus
extern "C" {
#endif
/** \file include/OggFLAC/file_encoder.h
*
* \brief
* This module contains the functions which implement the file
* encoder.
*
* See the detailed documentation in the
* \link oggflac_file_encoder file encoder \endlink module.
*/
/** \defgroup oggflac_file_encoder OggFLAC/file_encoder.h: file encoder interface
* \ingroup oggflac_encoder
*
* \brief
* This module contains the functions which implement the file
* encoder. Unlink the Ogg stream and seekable stream encoders, which
* derive from their FLAC counterparts, the Ogg file encoder is derived
* from the Ogg seekable stream encoder.
*
* The interface here is nearly identical to FLAC's file
* encoder, including the callbacks, with the addition of
* OggFLAC__file_encoder_set_serial_number(). See the
* \link flac_file_encoder FLAC file encoder module \endlink
* for full documentation.
*
* \{
*/
/** State values for a OggFLAC__FileEncoder
*
* The encoder's state can be obtained by calling OggFLAC__file_encoder_get_state().
*/
typedef enum {
OggFLAC__FILE_ENCODER_OK = 0,
/**< The encoder is in the normal OK state. */
OggFLAC__FILE_ENCODER_NO_FILENAME,
/**< OggFLAC__file_encoder_init() was called without first calling
* OggFLAC__file_encoder_set_filename().
*/
OggFLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR,
/**< An error occurred in the underlying seekable stream encoder;
* check OggFLAC__file_encoder_get_seekable_stream_encoder_state().
*/
OggFLAC__FILE_ENCODER_FATAL_ERROR_WHILE_WRITING,
/**< A fatal error occurred while writing to the encoded file. */
OggFLAC__FILE_ENCODER_ERROR_OPENING_FILE,
/**< An error occurred opening the output file for writing. */
OggFLAC__FILE_ENCODER_MEMORY_ALLOCATION_ERROR,
/**< Memory allocation failed. */
OggFLAC__FILE_ENCODER_ALREADY_INITIALIZED,
/**< OggFLAC__file_encoder_init() was called when the encoder was
* already initialized, usually because
* OggFLAC__file_encoder_finish() was not called.
*/
OggFLAC__FILE_ENCODER_UNINITIALIZED
/**< The encoder is in the uninitialized state. */
} OggFLAC__FileEncoderState;
/** Maps a FLAC__FileEncoderState to a C string.
*
* Using a FLAC__FileEncoderState as the index to this array
* will give the string equivalent. The contents should not be modified.
*/
extern OggFLAC_API const char * const OggFLAC__FileEncoderStateString[];
/***********************************************************************
*
* class FLAC__FileEncoder
*
***********************************************************************/
struct OggFLAC__FileEncoderProtected;
struct OggFLAC__FileEncoderPrivate;
/** The opaque structure definition for the file encoder type.
* See the \link oggflac_file_encoder file encoder module \endlink
* for a detailed description.
*/
typedef struct {
struct OggFLAC__FileEncoderProtected *protected_; /* avoid the C++ keyword 'protected' */
struct OggFLAC__FileEncoderPrivate *private_; /* avoid the C++ keyword 'private' */
} OggFLAC__FileEncoder;
/** Signature for the progress callback.
* See OggFLAC__file_encoder_set_progress_callback()
* and FLAC__FileEncoderProgressCallback for more info.
*
* \param encoder The encoder instance calling the callback.
* \param bytes_written Bytes written so far.
* \param samples_written Samples written so far.
* \param frames_written Frames written so far.
* \param total_frames_estimate The estimate of the total number of
* frames to be written.
* \param client_data The callee's client data set through
* OggFLAC__file_encoder_set_client_data().
*/
typedef void (*OggFLAC__FileEncoderProgressCallback)(const OggFLAC__FileEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
/***********************************************************************
*
* Class constructor/destructor
*
***********************************************************************/
/** Create a new file encoder instance. The instance is created with
* default settings; see the individual OggFLAC__file_encoder_set_*()
* functions for each setting's default.
*
* \retval OggFLAC__FileEncoder*
* \c NULL if there was an error allocating memory, else the new instance.
*/
OggFLAC_API OggFLAC__FileEncoder *OggFLAC__file_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__file_encoder_delete(OggFLAC__FileEncoder *encoder);
/***********************************************************************
*
* Public class method prototypes
*
***********************************************************************/
/** Set the serial number for the FLAC stream.
*
* \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__file_encoder_set_serial_number(OggFLAC__FileEncoder *encoder, long serial_number);
/** This is inherited from OggFLAC__SeekableStreamEncoder; see
* OggFLAC__seekable_stream_encoder_set_verify().
*
* \default \c true
* \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__file_encoder_set_verify(OggFLAC__FileEncoder *encoder, FLAC__bool value);
/** This is inherited from OggFLAC__SeekableStreamEncoder; see
* OggFLAC__seekable_stream_encoder_set_streamable_subset().
*
* \default \c true
* \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__file_encoder_set_streamable_subset(OggFLAC__FileEncoder *encoder, FLAC__bool value);
/** This is inherited from OggFLAC__SeekableStreamEncoder; see
* OggFLAC__seekable_stream_encoder_set_do_mid_side_stereo().
*
* \default \c false
* \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__file_encoder_set_do_mid_side_stereo(OggFLAC__FileEncoder *encoder, FLAC__bool value);
/** This is inherited from OggFLAC__SeekableStreamEncoder; see
* OggFLAC__seekable_stream_encoder_set_loose_mid_side_stereo().
*
* \default \c false
* \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__file_encoder_set_loose_mid_side_stereo(OggFLAC__FileEncoder *encoder, FLAC__bool value);
/** This is inherited from OggFLAC__SeekableStreamEncoder; see
* OggFLAC__seekable_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__file_encoder_set_channels(OggFLAC__FileEncoder *encoder, unsigned value);
/** This is inherited from OggFLAC__SeekableStreamEncoder; see
* OggFLAC__seekable_stream_encoder_set_bits_per_sample().
*
* \warning
* Do not feed the encoder data that is wider than the value you
* set here or you will generate an invalid stream.
*
* \default \c 16
* \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__file_encoder_set_bits_per_sample(OggFLAC__FileEncoder *encoder, unsigned value);
/** This is inherited from OggFLAC__SeekableStreamEncoder; see
* OggFLAC__seekable_stream_encoder_set_sample_rate().
*
* \default \c 44100
* \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__file_encoder_set_sample_rate(OggFLAC__FileEncoder *encoder, unsigned value);
/** This is inherited from OggFLAC__SeekableStreamEncoder; see
* OggFLAC__seekable_stream_encoder_set_blocksize().
*
* \default \c 1152
* \param encoder An encoder instance to set.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -