Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

stream_decoder.h

Go to the documentation of this file.
00001 /* libFLAC - Free Lossless Audio Codec library
00002  * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007  Josh Coalson
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions
00006  * are met:
00007  *
00008  * - Redistributions of source code must retain the above copyright
00009  * notice, this list of conditions and the following disclaimer.
00010  *
00011  * - Redistributions in binary form must reproduce the above copyright
00012  * notice, this list of conditions and the following disclaimer in the
00013  * documentation and/or other materials provided with the distribution.
00014  *
00015  * - Neither the name of the Xiph.org Foundation nor the names of its
00016  * contributors may be used to endorse or promote products derived from
00017  * this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00022  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
00023  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00024  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00025  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00026  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00027  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00028  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00029  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030  */
00031 
00032 #ifndef FLAC__STREAM_DECODER_H
00033 #define FLAC__STREAM_DECODER_H
00034 
00035 #include <stdio.h> /* for FILE */
00036 #include "export.h"
00037 #include "format.h"
00038 
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042 
00043 
00201 typedef enum {
00202 
00203     FLAC__STREAM_DECODER_SEARCH_FOR_METADATA = 0,
00206     FLAC__STREAM_DECODER_READ_METADATA,
00209     FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC,
00214     FLAC__STREAM_DECODER_READ_FRAME,
00217     FLAC__STREAM_DECODER_END_OF_STREAM,
00220     FLAC__STREAM_DECODER_OGG_ERROR,
00223     FLAC__STREAM_DECODER_SEEK_ERROR,
00229     FLAC__STREAM_DECODER_ABORTED,
00232     FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR,
00237     FLAC__STREAM_DECODER_UNINITIALIZED
00243 } FLAC__StreamDecoderState;
00244 
00250 extern FLAC_API const char * const FLAC__StreamDecoderStateString[];
00251 
00252 
00255 typedef enum {
00256 
00257     FLAC__STREAM_DECODER_INIT_STATUS_OK = 0,
00260     FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER,
00265     FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS,
00268     FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR,
00271     FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE,
00275     FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED
00281 } FLAC__StreamDecoderInitStatus;
00282 
00288 extern FLAC_API const char * const FLAC__StreamDecoderInitStatusString[];
00289 
00290 
00293 typedef enum {
00294 
00295     FLAC__STREAM_DECODER_READ_STATUS_CONTINUE,
00298     FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM,
00309     FLAC__STREAM_DECODER_READ_STATUS_ABORT
00312 } FLAC__StreamDecoderReadStatus;
00313 
00319 extern FLAC_API const char * const FLAC__StreamDecoderReadStatusString[];
00320 
00321 
00324 typedef enum {
00325 
00326     FLAC__STREAM_DECODER_SEEK_STATUS_OK,
00329     FLAC__STREAM_DECODER_SEEK_STATUS_ERROR,
00332     FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED
00335 } FLAC__StreamDecoderSeekStatus;
00336 
00342 extern FLAC_API const char * const FLAC__StreamDecoderSeekStatusString[];
00343 
00344 
00347 typedef enum {
00348 
00349     FLAC__STREAM_DECODER_TELL_STATUS_OK,
00352     FLAC__STREAM_DECODER_TELL_STATUS_ERROR,
00355     FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED
00358 } FLAC__StreamDecoderTellStatus;
00359 
00365 extern FLAC_API const char * const FLAC__StreamDecoderTellStatusString[];
00366 
00367 
00370 typedef enum {
00371 
00372     FLAC__STREAM_DECODER_LENGTH_STATUS_OK,
00375     FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR,
00378     FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED
00381 } FLAC__StreamDecoderLengthStatus;
00382 
00388 extern FLAC_API const char * const FLAC__StreamDecoderLengthStatusString[];
00389 
00390 
00393 typedef enum {
00394 
00395     FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE,
00398     FLAC__STREAM_DECODER_WRITE_STATUS_ABORT
00401 } FLAC__StreamDecoderWriteStatus;
00402 
00408 extern FLAC_API const char * const FLAC__StreamDecoderWriteStatusString[];
00409 
00410 
00426 typedef enum {
00427 
00428     FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC,
00431     FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER,
00434     FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH,
00437     FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM
00440 } FLAC__StreamDecoderErrorStatus;
00441 
00447 extern FLAC_API const char * const FLAC__StreamDecoderErrorStatusString[];
00448 
00449 
00450 /***********************************************************************
00451  *
00452  * class FLAC__StreamDecoder
00453  *
00454  ***********************************************************************/
00455 
00456 struct FLAC__StreamDecoderProtected;
00457 struct FLAC__StreamDecoderPrivate;
00462 typedef struct {
00463     struct FLAC__StreamDecoderProtected *protected_; /* avoid the C++ keyword 'protected' */
00464     struct FLAC__StreamDecoderPrivate *private_; /* avoid the C++ keyword 'private' */
00465 } FLAC__StreamDecoder;
00466 
00516 typedef FLAC__StreamDecoderReadStatus (*FLAC__StreamDecoderReadCallback)(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
00517 
00551 typedef FLAC__StreamDecoderSeekStatus (*FLAC__StreamDecoderSeekCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
00552 
00589 typedef FLAC__StreamDecoderTellStatus (*FLAC__StreamDecoderTellCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
00590 
00627 typedef FLAC__StreamDecoderLengthStatus (*FLAC__StreamDecoderLengthCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
00628 
00654 typedef FLAC__bool (*FLAC__StreamDecoderEofCallback)(const FLAC__StreamDecoder *decoder, void *client_data);
00655 
00682 typedef FLAC__StreamDecoderWriteStatus (*FLAC__StreamDecoderWriteCallback)(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00683 
00709 typedef void (*FLAC__StreamDecoderMetadataCallback)(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
00710 
00726 typedef void (*FLAC__StreamDecoderErrorCallback)(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
00727 
00728 
00729 /***********************************************************************
00730  *
00731  * Class constructor/destructor
00732  *
00733  ***********************************************************************/
00734 
00742 FLAC_API FLAC__StreamDecoder *FLAC__stream_decoder_new(void);
00743 
00750 FLAC_API void FLAC__stream_decoder_delete(FLAC__StreamDecoder *decoder);
00751 
00752 
00753 /***********************************************************************
00754  *
00755  * Public class method prototypes
00756  *
00757  ***********************************************************************/
00758 
00775 FLAC_API FLAC__bool FLAC__stream_decoder_set_ogg_serial_number(FLAC__StreamDecoder *decoder, long serial_number);
00776 
00797 FLAC_API FLAC__bool FLAC__stream_decoder_set_md5_checking(FLAC__StreamDecoder *decoder, FLAC__bool value);
00798 
00811 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond(FLAC__StreamDecoder *decoder, FLAC__MetadataType type);
00812 
00826 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]);
00827 
00838 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(FLAC__StreamDecoder *decoder);
00839 
00852 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore(FLAC__StreamDecoder *decoder, FLAC__MetadataType type);
00853 
00867 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]);
00868 
00879 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_all(FLAC__StreamDecoder *decoder);
00880 
00889 FLAC_API FLAC__StreamDecoderState FLAC__stream_decoder_get_state(const FLAC__StreamDecoder *decoder);
00890 
00899 FLAC_API const char *FLAC__stream_decoder_get_resolved_state_string(const FLAC__StreamDecoder *decoder);
00900 
00913 FLAC_API FLAC__bool FLAC__stream_decoder_get_md5_checking(const FLAC__StreamDecoder *decoder);
00914 
00925 FLAC_API FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamDecoder *decoder);
00926 
00937 FLAC_API unsigned FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder);
00938 
00949 FLAC_API FLAC__ChannelAssignment FLAC__stream_decoder_get_channel_assignment(const FLAC__StreamDecoder *decoder);
00950 
00961 FLAC_API unsigned FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder);
00962 
00973 FLAC_API unsigned FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder);
00974 
00985 FLAC_API unsigned FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder);
00986 
01006 FLAC_API FLAC__bool FLAC__stream_decoder_get_decode_position(const FLAC__StreamDecoder *decoder, FLAC__uint64 *position);
01007 
01072 FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_stream(
01073     FLAC__StreamDecoder *decoder,
01074     FLAC__StreamDecoderReadCallback read_callback,
01075     FLAC__StreamDecoderSeekCallback seek_callback,
01076     FLAC__StreamDecoderTellCallback tell_callback,
01077     FLAC__StreamDecoderLengthCallback length_callback,
01078     FLAC__StreamDecoderEofCallback eof_callback,
01079     FLAC__StreamDecoderWriteCallback write_callback,
01080     FLAC__StreamDecoderMetadataCallback metadata_callback,
01081     FLAC__StreamDecoderErrorCallback error_callback,
01082     void *client_data
01083 );
01084 
01153 FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_stream(
01154     FLAC__StreamDecoder *decoder,
01155     FLAC__StreamDecoderReadCallback read_callback,
01156     FLAC__StreamDecoderSeekCallback seek_callback,
01157     FLAC__StreamDecoderTellCallback tell_callback,
01158     FLAC__StreamDecoderLengthCallback length_callback,
01159     FLAC__StreamDecoderEofCallback eof_callback,
01160     FLAC__StreamDecoderWriteCallback write_callback,
01161     FLAC__StreamDecoderMetadataCallback metadata_callback,
01162     FLAC__StreamDecoderErrorCallback error_callback,
01163     void *client_data
01164 );
01165 
01203 FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_FILE(
01204     FLAC__StreamDecoder *decoder,
01205     FILE *file,
01206     FLAC__StreamDecoderWriteCallback write_callback,
01207     FLAC__StreamDecoderMetadataCallback metadata_callback,
01208     FLAC__StreamDecoderErrorCallback error_callback,
01209     void *client_data
01210 );
01211 
01253 FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_FILE(
01254     FLAC__StreamDecoder *decoder,
01255     FILE *file,
01256     FLAC__StreamDecoderWriteCallback write_callback,
01257     FLAC__StreamDecoderMetadataCallback metadata_callback,
01258     FLAC__StreamDecoderErrorCallback error_callback,
01259     void *client_data
01260 );
01261 
01295 FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_file(
01296     FLAC__StreamDecoder *decoder,
01297     const char *filename,
01298     FLAC__StreamDecoderWriteCallback write_callback,
01299     FLAC__StreamDecoderMetadataCallback metadata_callback,
01300     FLAC__StreamDecoderErrorCallback error_callback,
01301     void *client_data
01302 );
01303 
01341 FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_file(
01342     FLAC__StreamDecoder *decoder,
01343     const char *filename,
01344     FLAC__StreamDecoderWriteCallback write_callback,
01345     FLAC__StreamDecoderMetadataCallback metadata_callback,
01346     FLAC__StreamDecoderErrorCallback error_callback,
01347     void *client_data
01348 );
01349 
01369 FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder);
01370 
01384 FLAC_API FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder);
01385 
01417 FLAC_API FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder);
01418 
01450 FLAC_API FLAC__bool FLAC__stream_decoder_process_single(FLAC__StreamDecoder *decoder);
01451 
01471 FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_metadata(FLAC__StreamDecoder *decoder);
01472 
01492 FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_stream(FLAC__StreamDecoder *decoder);
01493 
01533 FLAC_API FLAC__bool FLAC__stream_decoder_skip_single_frame(FLAC__StreamDecoder *decoder);
01534 
01551 FLAC_API FLAC__bool FLAC__stream_decoder_seek_absolute(FLAC__StreamDecoder *decoder, FLAC__uint64 sample);
01552 
01553 /* \} */
01554 
01555 #ifdef __cplusplus
01556 }
01557 #endif
01558 
01559 #endif