FLAC  1.3.0
stream_decoder.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_DECODER_H
00034 #define FLAC__STREAM_DECODER_H
00035 
00036 #include <stdio.h> /* for FILE */
00037 #include "export.h"
00038 #include "format.h"
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043 
00044 
00202 typedef enum {
00203 
00204     FLAC__STREAM_DECODER_SEARCH_FOR_METADATA = 0,
00207     FLAC__STREAM_DECODER_READ_METADATA,
00210     FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC,
00215     FLAC__STREAM_DECODER_READ_FRAME,
00218     FLAC__STREAM_DECODER_END_OF_STREAM,
00221     FLAC__STREAM_DECODER_OGG_ERROR,
00224     FLAC__STREAM_DECODER_SEEK_ERROR,
00230     FLAC__STREAM_DECODER_ABORTED,
00233     FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR,
00238     FLAC__STREAM_DECODER_UNINITIALIZED
00244 } FLAC__StreamDecoderState;
00245 
00251 extern FLAC_API const char * const FLAC__StreamDecoderStateString[];
00252 
00253 
00256 typedef enum {
00257 
00258     FLAC__STREAM_DECODER_INIT_STATUS_OK = 0,
00261     FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER,
00266     FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS,
00269     FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR,
00272     FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE,
00276     FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED
00282 } FLAC__StreamDecoderInitStatus;
00283 
00289 extern FLAC_API const char * const FLAC__StreamDecoderInitStatusString[];
00290 
00291 
00294 typedef enum {
00295 
00296     FLAC__STREAM_DECODER_READ_STATUS_CONTINUE,
00299     FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM,
00310     FLAC__STREAM_DECODER_READ_STATUS_ABORT
00313 } FLAC__StreamDecoderReadStatus;
00314 
00320 extern FLAC_API const char * const FLAC__StreamDecoderReadStatusString[];
00321 
00322 
00325 typedef enum {
00326 
00327     FLAC__STREAM_DECODER_SEEK_STATUS_OK,
00330     FLAC__STREAM_DECODER_SEEK_STATUS_ERROR,
00333     FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED
00336 } FLAC__StreamDecoderSeekStatus;
00337 
00343 extern FLAC_API const char * const FLAC__StreamDecoderSeekStatusString[];
00344 
00345 
00348 typedef enum {
00349 
00350     FLAC__STREAM_DECODER_TELL_STATUS_OK,
00353     FLAC__STREAM_DECODER_TELL_STATUS_ERROR,
00356     FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED
00359 } FLAC__StreamDecoderTellStatus;
00360 
00366 extern FLAC_API const char * const FLAC__StreamDecoderTellStatusString[];
00367 
00368 
00371 typedef enum {
00372 
00373     FLAC__STREAM_DECODER_LENGTH_STATUS_OK,
00376     FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR,
00379     FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED
00382 } FLAC__StreamDecoderLengthStatus;
00383 
00389 extern FLAC_API const char * const FLAC__StreamDecoderLengthStatusString[];
00390 
00391 
00394 typedef enum {
00395 
00396     FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE,
00399     FLAC__STREAM_DECODER_WRITE_STATUS_ABORT
00402 } FLAC__StreamDecoderWriteStatus;
00403 
00409 extern FLAC_API const char * const FLAC__StreamDecoderWriteStatusString[];
00410 
00411 
00427 typedef enum {
00428 
00429     FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC,
00432     FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER,
00435     FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH,
00438     FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM
00441 } FLAC__StreamDecoderErrorStatus;
00442 
00448 extern FLAC_API const char * const FLAC__StreamDecoderErrorStatusString[];
00449 
00450 
00451 /***********************************************************************
00452  *
00453  * class FLAC__StreamDecoder
00454  *
00455  ***********************************************************************/
00456 
00457 struct FLAC__StreamDecoderProtected;
00458 struct FLAC__StreamDecoderPrivate;
00463 typedef struct {
00464     struct FLAC__StreamDecoderProtected *protected_; /* avoid the C++ keyword 'protected' */
00465     struct FLAC__StreamDecoderPrivate *private_; /* avoid the C++ keyword 'private' */
00466 } FLAC__StreamDecoder;
00467 
00517 typedef FLAC__StreamDecoderReadStatus (*FLAC__StreamDecoderReadCallback)(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
00518 
00552 typedef FLAC__StreamDecoderSeekStatus (*FLAC__StreamDecoderSeekCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
00553 
00590 typedef FLAC__StreamDecoderTellStatus (*FLAC__StreamDecoderTellCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
00591 
00628 typedef FLAC__StreamDecoderLengthStatus (*FLAC__StreamDecoderLengthCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
00629 
00655 typedef FLAC__bool (*FLAC__StreamDecoderEofCallback)(const FLAC__StreamDecoder *decoder, void *client_data);
00656 
00683 typedef FLAC__StreamDecoderWriteStatus (*FLAC__StreamDecoderWriteCallback)(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00684 
00710 typedef void (*FLAC__StreamDecoderMetadataCallback)(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
00711 
00727 typedef void (*FLAC__StreamDecoderErrorCallback)(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
00728 
00729 
00730 /***********************************************************************
00731  *
00732  * Class constructor/destructor
00733  *
00734  ***********************************************************************/
00735 
00743 FLAC_API FLAC__StreamDecoder *FLAC__stream_decoder_new(void);
00744 
00751 FLAC_API void FLAC__stream_decoder_delete(FLAC__StreamDecoder *decoder);
00752 
00753 
00754 /***********************************************************************
00755  *
00756  * Public class method prototypes
00757  *
00758  ***********************************************************************/
00759 
00776 FLAC_API FLAC__bool FLAC__stream_decoder_set_ogg_serial_number(FLAC__StreamDecoder *decoder, long serial_number);
00777 
00798 FLAC_API FLAC__bool FLAC__stream_decoder_set_md5_checking(FLAC__StreamDecoder *decoder, FLAC__bool value);
00799 
00812 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond(FLAC__StreamDecoder *decoder, FLAC__MetadataType type);
00813 
00827 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]);
00828 
00839 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(FLAC__StreamDecoder *decoder);
00840 
00853 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore(FLAC__StreamDecoder *decoder, FLAC__MetadataType type);
00854 
00868 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]);
00869 
00880 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_all(FLAC__StreamDecoder *decoder);
00881 
00890 FLAC_API FLAC__StreamDecoderState FLAC__stream_decoder_get_state(const FLAC__StreamDecoder *decoder);
00891 
00900 FLAC_API const char *FLAC__stream_decoder_get_resolved_state_string(const FLAC__StreamDecoder *decoder);
00901 
00914 FLAC_API FLAC__bool FLAC__stream_decoder_get_md5_checking(const FLAC__StreamDecoder *decoder);
00915 
00926 FLAC_API FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamDecoder *decoder);
00927 
00938 FLAC_API unsigned FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder);
00939 
00950 FLAC_API FLAC__ChannelAssignment FLAC__stream_decoder_get_channel_assignment(const FLAC__StreamDecoder *decoder);
00951 
00962 FLAC_API unsigned FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder);
00963 
00974 FLAC_API unsigned FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder);
00975 
00986 FLAC_API unsigned FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder);
00987 
01007 FLAC_API FLAC__bool FLAC__stream_decoder_get_decode_position(const FLAC__StreamDecoder *decoder, FLAC__uint64 *position);
01008 
01073 FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_stream(
01074     FLAC__StreamDecoder *decoder,
01075     FLAC__StreamDecoderReadCallback read_callback,
01076     FLAC__StreamDecoderSeekCallback seek_callback,
01077     FLAC__StreamDecoderTellCallback tell_callback,
01078     FLAC__StreamDecoderLengthCallback length_callback,
01079     FLAC__StreamDecoderEofCallback eof_callback,
01080     FLAC__StreamDecoderWriteCallback write_callback,
01081     FLAC__StreamDecoderMetadataCallback metadata_callback,
01082     FLAC__StreamDecoderErrorCallback error_callback,
01083     void *client_data
01084 );
01085 
01154 FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_stream(
01155     FLAC__StreamDecoder *decoder,
01156     FLAC__StreamDecoderReadCallback read_callback,
01157     FLAC__StreamDecoderSeekCallback seek_callback,
01158     FLAC__StreamDecoderTellCallback tell_callback,
01159     FLAC__StreamDecoderLengthCallback length_callback,
01160     FLAC__StreamDecoderEofCallback eof_callback,
01161     FLAC__StreamDecoderWriteCallback write_callback,
01162     FLAC__StreamDecoderMetadataCallback metadata_callback,
01163     FLAC__StreamDecoderErrorCallback error_callback,
01164     void *client_data
01165 );
01166 
01204 FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_FILE(
01205     FLAC__StreamDecoder *decoder,
01206     FILE *file,
01207     FLAC__StreamDecoderWriteCallback write_callback,
01208     FLAC__StreamDecoderMetadataCallback metadata_callback,
01209     FLAC__StreamDecoderErrorCallback error_callback,
01210     void *client_data
01211 );
01212 
01254 FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_FILE(
01255     FLAC__StreamDecoder *decoder,
01256     FILE *file,
01257     FLAC__StreamDecoderWriteCallback write_callback,
01258     FLAC__StreamDecoderMetadataCallback metadata_callback,
01259     FLAC__StreamDecoderErrorCallback error_callback,
01260     void *client_data
01261 );
01262 
01296 FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_file(
01297     FLAC__StreamDecoder *decoder,
01298     const char *filename,
01299     FLAC__StreamDecoderWriteCallback write_callback,
01300     FLAC__StreamDecoderMetadataCallback metadata_callback,
01301     FLAC__StreamDecoderErrorCallback error_callback,
01302     void *client_data
01303 );
01304 
01342 FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_file(
01343     FLAC__StreamDecoder *decoder,
01344     const char *filename,
01345     FLAC__StreamDecoderWriteCallback write_callback,
01346     FLAC__StreamDecoderMetadataCallback metadata_callback,
01347     FLAC__StreamDecoderErrorCallback error_callback,
01348     void *client_data
01349 );
01350 
01370 FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder);
01371 
01385 FLAC_API FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder);
01386 
01418 FLAC_API FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder);
01419 
01451 FLAC_API FLAC__bool FLAC__stream_decoder_process_single(FLAC__StreamDecoder *decoder);
01452 
01472 FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_metadata(FLAC__StreamDecoder *decoder);
01473 
01493 FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_stream(FLAC__StreamDecoder *decoder);
01494 
01534 FLAC_API FLAC__bool FLAC__stream_decoder_skip_single_frame(FLAC__StreamDecoder *decoder);
01535 
01552 FLAC_API FLAC__bool FLAC__stream_decoder_seek_absolute(FLAC__StreamDecoder *decoder, FLAC__uint64 sample);
01553 
01554 /* \} */
01555 
01556 #ifdef __cplusplus
01557 }
01558 #endif
01559 
01560 #endif