FLAC  1.3.0
stream_encoder.h
Go to the documentation of this file.
00001 /* libFLAC - Free Lossless Audio Codec library
00002  * Copyright (C) 2000-2009  Josh Coalson
00003  * Copyright (C) 2011-2013  Xiph.Org Foundation
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  * notice, this list of conditions and the following disclaimer.
00011  *
00012  * - Redistributions in binary form must reproduce the above copyright
00013  * notice, this list of conditions and the following disclaimer in the
00014  * documentation and/or other materials provided with the distribution.
00015  *
00016  * - Neither the name of the Xiph.org Foundation nor the names of its
00017  * contributors may be used to endorse or promote products derived from
00018  * this software without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00021  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00023  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
00024  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00025  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00026  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00027  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00028  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00029  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00030  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031  */
00032 
00033 #ifndef FLAC__STREAM_ENCODER_H
00034 #define FLAC__STREAM_ENCODER_H
00035 
00036 #include <stdio.h> /* for FILE */
00037 #include "export.h"
00038 #include "format.h"
00039 #include "stream_decoder.h"
00040 
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044 
00045 
00241 typedef enum {
00242 
00243     FLAC__STREAM_ENCODER_OK = 0,
00246     FLAC__STREAM_ENCODER_UNINITIALIZED,
00252     FLAC__STREAM_ENCODER_OGG_ERROR,
00255     FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR,
00260     FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA,
00265     FLAC__STREAM_ENCODER_CLIENT_ERROR,
00268     FLAC__STREAM_ENCODER_IO_ERROR,
00273     FLAC__STREAM_ENCODER_FRAMING_ERROR,
00278     FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR
00281 } FLAC__StreamEncoderState;
00282 
00288 extern FLAC_API const char * const FLAC__StreamEncoderStateString[];
00289 
00290 
00293 typedef enum {
00294 
00295     FLAC__STREAM_ENCODER_INIT_STATUS_OK = 0,
00298     FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR,
00301     FLAC__STREAM_ENCODER_INIT_STATUS_UNSUPPORTED_CONTAINER,
00306     FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_CALLBACKS,
00309     FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_NUMBER_OF_CHANNELS,
00312     FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BITS_PER_SAMPLE,
00318     FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_SAMPLE_RATE,
00321     FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BLOCK_SIZE,
00324     FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_MAX_LPC_ORDER,
00327     FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_QLP_COEFF_PRECISION,
00330     FLAC__STREAM_ENCODER_INIT_STATUS_BLOCK_SIZE_TOO_SMALL_FOR_LPC_ORDER,
00333     FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE,
00336     FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA,
00345     FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED
00351 } FLAC__StreamEncoderInitStatus;
00352 
00358 extern FLAC_API const char * const FLAC__StreamEncoderInitStatusString[];
00359 
00360 
00363 typedef enum {
00364 
00365     FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE,
00368     FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM,
00371     FLAC__STREAM_ENCODER_READ_STATUS_ABORT,
00374     FLAC__STREAM_ENCODER_READ_STATUS_UNSUPPORTED
00377 } FLAC__StreamEncoderReadStatus;
00378 
00384 extern FLAC_API const char * const FLAC__StreamEncoderReadStatusString[];
00385 
00386 
00389 typedef enum {
00390 
00391     FLAC__STREAM_ENCODER_WRITE_STATUS_OK = 0,
00394     FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR
00397 } FLAC__StreamEncoderWriteStatus;
00398 
00404 extern FLAC_API const char * const FLAC__StreamEncoderWriteStatusString[];
00405 
00406 
00409 typedef enum {
00410 
00411     FLAC__STREAM_ENCODER_SEEK_STATUS_OK,
00414     FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR,
00417     FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED
00420 } FLAC__StreamEncoderSeekStatus;
00421 
00427 extern FLAC_API const char * const FLAC__StreamEncoderSeekStatusString[];
00428 
00429 
00432 typedef enum {
00433 
00434     FLAC__STREAM_ENCODER_TELL_STATUS_OK,
00437     FLAC__STREAM_ENCODER_TELL_STATUS_ERROR,
00440     FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED
00443 } FLAC__StreamEncoderTellStatus;
00444 
00450 extern FLAC_API const char * const FLAC__StreamEncoderTellStatusString[];
00451 
00452 
00453 /***********************************************************************
00454  *
00455  * class FLAC__StreamEncoder
00456  *
00457  ***********************************************************************/
00458 
00459 struct FLAC__StreamEncoderProtected;
00460 struct FLAC__StreamEncoderPrivate;
00465 typedef struct {
00466     struct FLAC__StreamEncoderProtected *protected_; /* avoid the C++ keyword 'protected' */
00467     struct FLAC__StreamEncoderPrivate *private_; /* avoid the C++ keyword 'private' */
00468 } FLAC__StreamEncoder;
00469 
00519 typedef FLAC__StreamEncoderReadStatus (*FLAC__StreamEncoderReadCallback)(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
00520 
00557 typedef FLAC__StreamEncoderWriteStatus (*FLAC__StreamEncoderWriteCallback)(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data);
00558 
00591 typedef FLAC__StreamEncoderSeekStatus (*FLAC__StreamEncoderSeekCallback)(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
00592 
00636 typedef FLAC__StreamEncoderTellStatus (*FLAC__StreamEncoderTellCallback)(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
00637 
00655 typedef void (*FLAC__StreamEncoderMetadataCallback)(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetadata *metadata, void *client_data);
00656 
00678 typedef void (*FLAC__StreamEncoderProgressCallback)(const FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
00679 
00680 
00681 /***********************************************************************
00682  *
00683  * Class constructor/destructor
00684  *
00685  ***********************************************************************/
00686 
00694 FLAC_API FLAC__StreamEncoder *FLAC__stream_encoder_new(void);
00695 
00702 FLAC_API void FLAC__stream_encoder_delete(FLAC__StreamEncoder *encoder);
00703 
00704 
00705 /***********************************************************************
00706  *
00707  * Public class method prototypes
00708  *
00709  ***********************************************************************/
00710 
00728 FLAC_API FLAC__bool FLAC__stream_encoder_set_ogg_serial_number(FLAC__StreamEncoder *encoder, long serial_number);
00729 
00744 FLAC_API FLAC__bool FLAC__stream_encoder_set_verify(FLAC__StreamEncoder *encoder, FLAC__bool value);
00745 
00762 FLAC_API FLAC__bool FLAC__stream_encoder_set_streamable_subset(FLAC__StreamEncoder *encoder, FLAC__bool value);
00763 
00774 FLAC_API FLAC__bool FLAC__stream_encoder_set_channels(FLAC__StreamEncoder *encoder, unsigned value);
00775 
00790 FLAC_API FLAC__bool FLAC__stream_encoder_set_bits_per_sample(FLAC__StreamEncoder *encoder, unsigned value);
00791 
00802 FLAC_API FLAC__bool FLAC__stream_encoder_set_sample_rate(FLAC__StreamEncoder *encoder, unsigned value);
00803 
00865 FLAC_API FLAC__bool FLAC__stream_encoder_set_compression_level(FLAC__StreamEncoder *encoder, unsigned value);
00866 
00880 FLAC_API FLAC__bool FLAC__stream_encoder_set_blocksize(FLAC__StreamEncoder *encoder, unsigned value);
00881 
00894 FLAC_API FLAC__bool FLAC__stream_encoder_set_do_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value);
00895 
00910 FLAC_API FLAC__bool FLAC__stream_encoder_set_loose_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value);
00911 
00955 FLAC_API FLAC__bool FLAC__stream_encoder_set_apodization(FLAC__StreamEncoder *encoder, const char *specification);
00956 
00967 FLAC_API FLAC__bool FLAC__stream_encoder_set_max_lpc_order(FLAC__StreamEncoder *encoder, unsigned value);
00968 
00985 FLAC_API FLAC__bool FLAC__stream_encoder_set_qlp_coeff_precision(FLAC__StreamEncoder *encoder, unsigned value);
00986 
00999 FLAC_API FLAC__bool FLAC__stream_encoder_set_do_qlp_coeff_prec_search(FLAC__StreamEncoder *encoder, FLAC__bool value);
01000 
01011 FLAC_API FLAC__bool FLAC__stream_encoder_set_do_escape_coding(FLAC__StreamEncoder *encoder, FLAC__bool value);
01012 
01025 FLAC_API FLAC__bool FLAC__stream_encoder_set_do_exhaustive_model_search(FLAC__StreamEncoder *encoder, FLAC__bool value);
01026 
01048 FLAC_API FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(FLAC__StreamEncoder *encoder, unsigned value);
01049 
01071 FLAC_API FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(FLAC__StreamEncoder *encoder, unsigned value);
01072 
01083 FLAC_API FLAC__bool FLAC__stream_encoder_set_rice_parameter_search_dist(FLAC__StreamEncoder *encoder, unsigned value);
01084 
01099 FLAC_API FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(FLAC__StreamEncoder *encoder, FLAC__uint64 value);
01100 
01182 FLAC_API FLAC__bool FLAC__stream_encoder_set_metadata(FLAC__StreamEncoder *encoder, FLAC__StreamMetadata **metadata, unsigned num_blocks);
01183 
01192 FLAC_API FLAC__StreamEncoderState FLAC__stream_encoder_get_state(const FLAC__StreamEncoder *encoder);
01193 
01204 FLAC_API FLAC__StreamDecoderState FLAC__stream_encoder_get_verify_decoder_state(const FLAC__StreamEncoder *encoder);
01205 
01217 FLAC_API const char *FLAC__stream_encoder_get_resolved_state_string(const FLAC__StreamEncoder *encoder);
01218 
01236 FLAC_API void FLAC__stream_encoder_get_verify_decoder_error_stats(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
01237 
01246 FLAC_API FLAC__bool FLAC__stream_encoder_get_verify(const FLAC__StreamEncoder *encoder);
01247 
01256 FLAC_API FLAC__bool FLAC__stream_encoder_get_streamable_subset(const FLAC__StreamEncoder *encoder);
01257 
01266 FLAC_API unsigned FLAC__stream_encoder_get_channels(const FLAC__StreamEncoder *encoder);
01267 
01276 FLAC_API unsigned FLAC__stream_encoder_get_bits_per_sample(const FLAC__StreamEncoder *encoder);
01277 
01286 FLAC_API unsigned FLAC__stream_encoder_get_sample_rate(const FLAC__StreamEncoder *encoder);
01287 
01296 FLAC_API unsigned FLAC__stream_encoder_get_blocksize(const FLAC__StreamEncoder *encoder);
01297 
01306 FLAC_API FLAC__bool FLAC__stream_encoder_get_do_mid_side_stereo(const FLAC__StreamEncoder *encoder);
01307 
01316 FLAC_API FLAC__bool FLAC__stream_encoder_get_loose_mid_side_stereo(const FLAC__StreamEncoder *encoder);
01317 
01326 FLAC_API unsigned FLAC__stream_encoder_get_max_lpc_order(const FLAC__StreamEncoder *encoder);
01327 
01336 FLAC_API unsigned FLAC__stream_encoder_get_qlp_coeff_precision(const FLAC__StreamEncoder *encoder);
01337 
01346 FLAC_API FLAC__bool FLAC__stream_encoder_get_do_qlp_coeff_prec_search(const FLAC__StreamEncoder *encoder);
01347 
01356 FLAC_API FLAC__bool FLAC__stream_encoder_get_do_escape_coding(const FLAC__StreamEncoder *encoder);
01357 
01366 FLAC_API FLAC__bool FLAC__stream_encoder_get_do_exhaustive_model_search(const FLAC__StreamEncoder *encoder);
01367 
01376 FLAC_API unsigned FLAC__stream_encoder_get_min_residual_partition_order(const FLAC__StreamEncoder *encoder);
01377 
01386 FLAC_API unsigned FLAC__stream_encoder_get_max_residual_partition_order(const FLAC__StreamEncoder *encoder);
01387 
01396 FLAC_API unsigned FLAC__stream_encoder_get_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder);
01397 
01409 FLAC_API FLAC__uint64 FLAC__stream_encoder_get_total_samples_estimate(const FLAC__StreamEncoder *encoder);
01410 
01472 FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_stream(FLAC__StreamEncoder *encoder, FLAC__StreamEncoderWriteCallback write_callback, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderTellCallback tell_callback, FLAC__StreamEncoderMetadataCallback metadata_callback, void *client_data);
01473 
01540 FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_stream(FLAC__StreamEncoder *encoder, FLAC__StreamEncoderReadCallback read_callback, FLAC__StreamEncoderWriteCallback write_callback, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderTellCallback tell_callback, FLAC__StreamEncoderMetadataCallback metadata_callback, void *client_data);
01541 
01575 FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_FILE(FLAC__StreamEncoder *encoder, FILE *file, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data);
01576 
01610 FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_FILE(FLAC__StreamEncoder *encoder, FILE *file, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data);
01611 
01642 FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_file(FLAC__StreamEncoder *encoder, const char *filename, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data);
01643 
01674 FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_file(FLAC__StreamEncoder *encoder, const char *filename, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data);
01675 
01702 FLAC_API FLAC__bool FLAC__stream_encoder_finish(FLAC__StreamEncoder *encoder);
01703 
01729 FLAC_API FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const FLAC__int32 * const buffer[], unsigned samples);
01730 
01761 FLAC_API FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, const FLAC__int32 buffer[], unsigned samples);
01762 
01763 /* \} */
01764 
01765 #ifdef __cplusplus
01766 }
01767 #endif
01768 
01769 #endif