FLAC  1.5.0
FreeLosslessAudioCodec
stream_decoder.h
Go to the documentation of this file.
1 /* libFLAC - Free Lossless Audio Codec library
2  * Copyright (C) 2000-2009 Josh Coalson
3  * Copyright (C) 2011-2025 Xiph.Org Foundation
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * - Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * - Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * - Neither the name of the Xiph.org Foundation nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef FLAC__STREAM_DECODER_H
34 #define FLAC__STREAM_DECODER_H
35 
36 #include <stdio.h> /* for FILE */
37 #include "export.h"
38 #include "format.h"
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 
202 typedef enum {
203 
253 
259 extern FLAC_API const char * const FLAC__StreamDecoderStateString[];
260 
261 
264 typedef enum {
265 
291 
297 extern FLAC_API const char * const FLAC__StreamDecoderInitStatusString[];
298 
299 
302 typedef enum {
303 
327 
333 extern FLAC_API const char * const FLAC__StreamDecoderReadStatusString[];
334 
335 
338 typedef enum {
339 
350 
356 extern FLAC_API const char * const FLAC__StreamDecoderSeekStatusString[];
357 
358 
361 typedef enum {
362 
373 
379 extern FLAC_API const char * const FLAC__StreamDecoderTellStatusString[];
380 
381 
384 typedef enum {
385 
396 
402 extern FLAC_API const char * const FLAC__StreamDecoderLengthStatusString[];
403 
404 
407 typedef enum {
408 
416 
422 extern FLAC_API const char * const FLAC__StreamDecoderWriteStatusString[];
423 
424 
444 typedef enum {
445 
474 
480 extern FLAC_API const char * const FLAC__StreamDecoderErrorStatusString[];
481 
482 
483 /***********************************************************************
484  *
485  * class FLAC__StreamDecoder
486  *
487  ***********************************************************************/
488 
489 struct FLAC__StreamDecoderProtected;
490 struct FLAC__StreamDecoderPrivate;
495 typedef struct {
496  struct FLAC__StreamDecoderProtected *protected_; /* avoid the C++ keyword 'protected' */
497  struct FLAC__StreamDecoderPrivate *private_; /* avoid the C++ keyword 'private' */
499 
549 typedef FLAC__StreamDecoderReadStatus (*FLAC__StreamDecoderReadCallback)(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
550 
584 typedef FLAC__StreamDecoderSeekStatus (*FLAC__StreamDecoderSeekCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
585 
622 typedef FLAC__StreamDecoderTellStatus (*FLAC__StreamDecoderTellCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
623 
660 typedef FLAC__StreamDecoderLengthStatus (*FLAC__StreamDecoderLengthCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
661 
687 typedef FLAC__bool (*FLAC__StreamDecoderEofCallback)(const FLAC__StreamDecoder *decoder, void *client_data);
688 
715 typedef FLAC__StreamDecoderWriteStatus (*FLAC__StreamDecoderWriteCallback)(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
716 
742 typedef void (*FLAC__StreamDecoderMetadataCallback)(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
743 
759 typedef void (*FLAC__StreamDecoderErrorCallback)(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
760 
761 
762 /***********************************************************************
763  *
764  * Class constructor/destructor
765  *
766  ***********************************************************************/
767 
776 
784 
785 
786 /***********************************************************************
787  *
788  * Public class method prototypes
789  *
790  ***********************************************************************/
791 
808 FLAC_API FLAC__bool FLAC__stream_decoder_set_ogg_serial_number(FLAC__StreamDecoder *decoder, long serial_number);
809 
836 
857 FLAC_API FLAC__bool FLAC__stream_decoder_set_md5_checking(FLAC__StreamDecoder *decoder, FLAC__bool value);
858 
872 
886 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]);
887 
899 
913 
927 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]);
928 
940 
950 
960 
971 
985 
997 
1023 
1035 
1047 
1059 
1071 
1083 
1103 FLAC_API FLAC__bool FLAC__stream_decoder_get_decode_position(const FLAC__StreamDecoder *decoder, FLAC__uint64 *position);
1104 
1114 
1115 #define FLAC__STREAM_DECODER_GET_LINK_LENGTHS_INVALID -1
1116 #define FLAC__STREAM_DECODER_GET_LINK_LENGTHS_NOT_INDEXED -2
1117 #define FLAC__STREAM_DECODER_GET_LINK_LENGTHS_MEMORY_ALLOCATION_ERROR -3
1118 
1150 FLAC_API int32_t FLAC__stream_decoder_get_link_lengths(FLAC__StreamDecoder *decoder, FLAC__uint64 **link_lengths);
1151 
1217  FLAC__StreamDecoder *decoder,
1218  FLAC__StreamDecoderReadCallback read_callback,
1219  FLAC__StreamDecoderSeekCallback seek_callback,
1220  FLAC__StreamDecoderTellCallback tell_callback,
1221  FLAC__StreamDecoderLengthCallback length_callback,
1222  FLAC__StreamDecoderEofCallback eof_callback,
1223  FLAC__StreamDecoderWriteCallback write_callback,
1224  FLAC__StreamDecoderMetadataCallback metadata_callback,
1225  FLAC__StreamDecoderErrorCallback error_callback,
1226  void *client_data
1227 );
1228 
1298  FLAC__StreamDecoder *decoder,
1299  FLAC__StreamDecoderReadCallback read_callback,
1300  FLAC__StreamDecoderSeekCallback seek_callback,
1301  FLAC__StreamDecoderTellCallback tell_callback,
1302  FLAC__StreamDecoderLengthCallback length_callback,
1303  FLAC__StreamDecoderEofCallback eof_callback,
1304  FLAC__StreamDecoderWriteCallback write_callback,
1305  FLAC__StreamDecoderMetadataCallback metadata_callback,
1306  FLAC__StreamDecoderErrorCallback error_callback,
1307  void *client_data
1308 );
1309 
1348  FLAC__StreamDecoder *decoder,
1349  FILE *file,
1350  FLAC__StreamDecoderWriteCallback write_callback,
1351  FLAC__StreamDecoderMetadataCallback metadata_callback,
1352  FLAC__StreamDecoderErrorCallback error_callback,
1353  void *client_data
1354 );
1355 
1398  FLAC__StreamDecoder *decoder,
1399  FILE *file,
1400  FLAC__StreamDecoderWriteCallback write_callback,
1401  FLAC__StreamDecoderMetadataCallback metadata_callback,
1402  FLAC__StreamDecoderErrorCallback error_callback,
1403  void *client_data
1404 );
1405 
1444  FLAC__StreamDecoder *decoder,
1445  const char *filename,
1446  FLAC__StreamDecoderWriteCallback write_callback,
1447  FLAC__StreamDecoderMetadataCallback metadata_callback,
1448  FLAC__StreamDecoderErrorCallback error_callback,
1449  void *client_data
1450 );
1451 
1494  FLAC__StreamDecoder *decoder,
1495  const char *filename,
1496  FLAC__StreamDecoderWriteCallback write_callback,
1497  FLAC__StreamDecoderMetadataCallback metadata_callback,
1498  FLAC__StreamDecoderErrorCallback error_callback,
1499  void *client_data
1500 );
1501 
1522 
1539 
1554 
1586 
1619 
1640 
1665 
1686 
1727 
1755 
1780 FLAC_API FLAC__bool FLAC__stream_decoder_seek_absolute(FLAC__StreamDecoder *decoder, FLAC__uint64 sample);
1781 
1782 /* \} */
1783 
1784 #ifdef __cplusplus
1785 }
1786 #endif
1787 
1788 #endif
uint32_t FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder)
Definition: stream_decoder.h:366
Definition: stream_decoder.h:369
const char * FLAC__stream_decoder_get_resolved_state_string(const FLAC__StreamDecoder *decoder)
Definition: stream_decoder.h:215
FLAC__bool FLAC__stream_decoder_get_decode_position(const FLAC__StreamDecoder *decoder, FLAC__uint64 *position)
Definition: stream_decoder.h:307
FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(FLAC__StreamDecoder *decoder)
Definition: stream_decoder.h:210
Definition: stream_decoder.h:204
FLAC__ChannelAssignment FLAC__stream_decoder_get_channel_assignment(const FLAC__StreamDecoder *decoder)
This module contains #defines and symbols for exporting function calls, and providing version informa...
FLAC__bool FLAC__stream_decoder_process_until_end_of_link(FLAC__StreamDecoder *decoder)
const char *const FLAC__StreamDecoderSeekStatusString[]
FLAC__StreamDecoderWriteStatus(* FLAC__StreamDecoderWriteCallback)(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *const buffer[], void *client_data)
Definition: stream_decoder.h:715
FLAC__StreamDecoderLengthStatus(* FLAC__StreamDecoderLengthCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data)
Definition: stream_decoder.h:660
FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_stream(FLAC__StreamDecoder *decoder, FLAC__StreamDecoderReadCallback read_callback, FLAC__StreamDecoderSeekCallback seek_callback, FLAC__StreamDecoderTellCallback tell_callback, FLAC__StreamDecoderLengthCallback length_callback, FLAC__StreamDecoderEofCallback eof_callback, FLAC__StreamDecoderWriteCallback write_callback, FLAC__StreamDecoderMetadataCallback metadata_callback, FLAC__StreamDecoderErrorCallback error_callback, void *client_data)
Definition: stream_decoder.h:346
FLAC__bool FLAC__stream_decoder_get_decode_chained_stream(const FLAC__StreamDecoder *decoder)
Definition: stream_decoder.h:446
void(* FLAC__StreamDecoderErrorCallback)(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
Definition: stream_decoder.h:759
FLAC__bool FLAC__stream_decoder_set_metadata_respond(FLAC__StreamDecoder *decoder, FLAC__MetadataType type)
FLAC__StreamDecoderTellStatus
Definition: stream_decoder.h:361
Definition: stream_decoder.h:412
const char *const FLAC__StreamDecoderStateString[]
Definition: stream_decoder.h:461
Definition: stream_decoder.h:230
Definition: stream_decoder.h:218
FLAC__StreamDecoderErrorStatus
Definition: stream_decoder.h:444
Definition: stream_decoder.h:495
FLAC__bool(* FLAC__StreamDecoderEofCallback)(const FLAC__StreamDecoder *decoder, void *client_data)
Definition: stream_decoder.h:687
Definition: stream_decoder.h:304
FLAC__bool FLAC__stream_decoder_set_metadata_ignore(FLAC__StreamDecoder *decoder, FLAC__MetadataType type)
const char *const FLAC__StreamDecoderReadStatusString[]
FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder)
const char *const FLAC__StreamDecoderInitStatusString[]
This module contains structure definitions for the representation of FLAC format components in memory...
FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_stream(FLAC__StreamDecoder *decoder, FLAC__StreamDecoderReadCallback read_callback, FLAC__StreamDecoderSeekCallback seek_callback, FLAC__StreamDecoderTellCallback tell_callback, FLAC__StreamDecoderLengthCallback length_callback, FLAC__StreamDecoderEofCallback eof_callback, FLAC__StreamDecoderWriteCallback write_callback, FLAC__StreamDecoderMetadataCallback metadata_callback, FLAC__StreamDecoderErrorCallback error_callback, void *client_data)
FLAC__bool FLAC__stream_decoder_process_single(FLAC__StreamDecoder *decoder)
FLAC__bool FLAC__stream_decoder_process_until_end_of_stream(FLAC__StreamDecoder *decoder)
FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_FILE(FLAC__StreamDecoder *decoder, FILE *file, FLAC__StreamDecoderWriteCallback write_callback, FLAC__StreamDecoderMetadataCallback metadata_callback, FLAC__StreamDecoderErrorCallback error_callback, void *client_data)
Definition: stream_decoder.h:409
Definition: stream_decoder.h:266
FLAC__bool FLAC__stream_decoder_skip_single_frame(FLAC__StreamDecoder *decoder)
FLAC__bool FLAC__stream_decoder_set_decode_chained_stream(FLAC__StreamDecoder *decoder, FLAC__bool value)
const char *const FLAC__StreamDecoderErrorStatusString[]
FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_file(FLAC__StreamDecoder *decoder, const char *filename, FLAC__StreamDecoderWriteCallback write_callback, FLAC__StreamDecoderMetadataCallback metadata_callback, FLAC__StreamDecoderErrorCallback error_callback, void *client_data)
FLAC__StreamDecoderInitStatus
Definition: stream_decoder.h:264
FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_file(FLAC__StreamDecoder *decoder, const char *filename, FLAC__StreamDecoderWriteCallback write_callback, FLAC__StreamDecoderMetadataCallback metadata_callback, FLAC__StreamDecoderErrorCallback error_callback, void *client_data)
FLAC__StreamDecoderWriteStatus
Definition: stream_decoder.h:407
Definition: stream_decoder.h:244
Definition: stream_decoder.h:207
Definition: format.h:480
Definition: stream_decoder.h:343
void(* FLAC__StreamDecoderMetadataCallback)(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
Definition: stream_decoder.h:742
Definition: format.h:841
const char *const FLAC__StreamDecoderWriteStatusString[]
const char *const FLAC__StreamDecoderTellStatusString[]
FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamDecoder *decoder)
FLAC__bool FLAC__stream_decoder_finish_link(FLAC__StreamDecoder *decoder)
Definition: stream_decoder.h:392
FLAC__bool FLAC__stream_decoder_seek_absolute(FLAC__StreamDecoder *decoder, FLAC__uint64 sample)
Definition: stream_decoder.h:224
uint32_t FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder)
#define FLAC_API
Definition: export.h:91
void FLAC__stream_decoder_delete(FLAC__StreamDecoder *decoder)
FLAC__StreamDecoderSeekStatus(* FLAC__StreamDecoderSeekCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data)
Definition: stream_decoder.h:584
FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder)
FLAC__bool FLAC__stream_decoder_set_md5_checking(FLAC__StreamDecoder *decoder, FLAC__bool value)
FLAC__bool FLAC__stream_decoder_set_ogg_serial_number(FLAC__StreamDecoder *decoder, long serial_number)
FLAC__MetadataType
Definition: format.h:496
Definition: stream_decoder.h:233
FLAC__bool FLAC__stream_decoder_set_metadata_ignore_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4])
Definition: stream_decoder.h:466
FLAC__bool FLAC__stream_decoder_get_md5_checking(const FLAC__StreamDecoder *decoder)
FLAC__StreamDecoderState FLAC__stream_decoder_get_state(const FLAC__StreamDecoder *decoder)
FLAC__StreamDecoderReadStatus
Definition: stream_decoder.h:302
FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_FILE(FLAC__StreamDecoder *decoder, FILE *file, FLAC__StreamDecoderWriteCallback write_callback, FLAC__StreamDecoderMetadataCallback metadata_callback, FLAC__StreamDecoderErrorCallback error_callback, void *client_data)
Definition: stream_decoder.h:449
FLAC__bool FLAC__stream_decoder_set_metadata_respond_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4])
FLAC__bool FLAC__stream_decoder_process_until_end_of_metadata(FLAC__StreamDecoder *decoder)
FLAC__StreamDecoderState
Definition: stream_decoder.h:202
const void * FLAC__stream_decoder_get_client_data(FLAC__StreamDecoder *decoder)
Definition: stream_decoder.h:386
FLAC__StreamDecoderLengthStatus
Definition: stream_decoder.h:384
FLAC__ChannelAssignment
Definition: format.h:388
FLAC__bool FLAC__stream_decoder_skip_single_link(FLAC__StreamDecoder *decoder)
Definition: stream_decoder.h:340
Definition: stream_decoder.h:238
Definition: stream_decoder.h:321
const char *const FLAC__StreamDecoderLengthStatusString[]
FLAC__StreamDecoderReadStatus(* FLAC__StreamDecoderReadCallback)(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
Definition: stream_decoder.h:549
FLAC__StreamDecoderTellStatus(* FLAC__StreamDecoderTellCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data)
Definition: stream_decoder.h:622
uint32_t FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder)
uint32_t FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder)
FLAC__bool FLAC__stream_decoder_set_metadata_ignore_all(FLAC__StreamDecoder *decoder)
FLAC__uint64 FLAC__stream_decoder_find_total_samples(FLAC__StreamDecoder *decoder)
FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder)
Definition: stream_decoder.h:389
Definition: stream_decoder.h:221
int32_t FLAC__stream_decoder_get_link_lengths(FLAC__StreamDecoder *decoder, FLAC__uint64 **link_lengths)
Definition: stream_decoder.h:318
FLAC__StreamDecoderSeekStatus
Definition: stream_decoder.h:338
Definition: stream_decoder.h:458
FLAC__StreamDecoder * FLAC__stream_decoder_new(void)
Definition: stream_decoder.h:363

Copyright (c) 2000-2009 Josh Coalson Copyright (c) 2011-2025 Xiph.Org Foundation