annotate win64-mingw/include/FLAC/stream_decoder.h @ 42:2cd0e3b3e1fd

Current fftw source
author Chris Cannam
date Tue, 18 Oct 2016 13:40:26 +0100
parents 05254799ed10
children
rev   line source
Chris@34 1 /* libFLAC - Free Lossless Audio Codec library
Chris@34 2 * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
Chris@34 3 *
Chris@34 4 * Redistribution and use in source and binary forms, with or without
Chris@34 5 * modification, are permitted provided that the following conditions
Chris@34 6 * are met:
Chris@34 7 *
Chris@34 8 * - Redistributions of source code must retain the above copyright
Chris@34 9 * notice, this list of conditions and the following disclaimer.
Chris@34 10 *
Chris@34 11 * - Redistributions in binary form must reproduce the above copyright
Chris@34 12 * notice, this list of conditions and the following disclaimer in the
Chris@34 13 * documentation and/or other materials provided with the distribution.
Chris@34 14 *
Chris@34 15 * - Neither the name of the Xiph.org Foundation nor the names of its
Chris@34 16 * contributors may be used to endorse or promote products derived from
Chris@34 17 * this software without specific prior written permission.
Chris@34 18 *
Chris@34 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Chris@34 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Chris@34 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Chris@34 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
Chris@34 23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
Chris@34 24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
Chris@34 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
Chris@34 26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
Chris@34 27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
Chris@34 28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Chris@34 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Chris@34 30 */
Chris@34 31
Chris@34 32 #ifndef FLAC__STREAM_DECODER_H
Chris@34 33 #define FLAC__STREAM_DECODER_H
Chris@34 34
Chris@34 35 #include <stdio.h> /* for FILE */
Chris@34 36 #include "export.h"
Chris@34 37 #include "format.h"
Chris@34 38
Chris@34 39 #ifdef __cplusplus
Chris@34 40 extern "C" {
Chris@34 41 #endif
Chris@34 42
Chris@34 43
Chris@34 44 /** \file include/FLAC/stream_decoder.h
Chris@34 45 *
Chris@34 46 * \brief
Chris@34 47 * This module contains the functions which implement the stream
Chris@34 48 * decoder.
Chris@34 49 *
Chris@34 50 * See the detailed documentation in the
Chris@34 51 * \link flac_stream_decoder stream decoder \endlink module.
Chris@34 52 */
Chris@34 53
Chris@34 54 /** \defgroup flac_decoder FLAC/ \*_decoder.h: decoder interfaces
Chris@34 55 * \ingroup flac
Chris@34 56 *
Chris@34 57 * \brief
Chris@34 58 * This module describes the decoder layers provided by libFLAC.
Chris@34 59 *
Chris@34 60 * The stream decoder can be used to decode complete streams either from
Chris@34 61 * the client via callbacks, or directly from a file, depending on how
Chris@34 62 * it is initialized. When decoding via callbacks, the client provides
Chris@34 63 * callbacks for reading FLAC data and writing decoded samples, and
Chris@34 64 * handling metadata and errors. If the client also supplies seek-related
Chris@34 65 * callback, the decoder function for sample-accurate seeking within the
Chris@34 66 * FLAC input is also available. When decoding from a file, the client
Chris@34 67 * needs only supply a filename or open \c FILE* and write/metadata/error
Chris@34 68 * callbacks; the rest of the callbacks are supplied internally. For more
Chris@34 69 * info see the \link flac_stream_decoder stream decoder \endlink module.
Chris@34 70 */
Chris@34 71
Chris@34 72 /** \defgroup flac_stream_decoder FLAC/stream_decoder.h: stream decoder interface
Chris@34 73 * \ingroup flac_decoder
Chris@34 74 *
Chris@34 75 * \brief
Chris@34 76 * This module contains the functions which implement the stream
Chris@34 77 * decoder.
Chris@34 78 *
Chris@34 79 * The stream decoder can decode native FLAC, and optionally Ogg FLAC
Chris@34 80 * (check FLAC_API_SUPPORTS_OGG_FLAC) streams and files.
Chris@34 81 *
Chris@34 82 * The basic usage of this decoder is as follows:
Chris@34 83 * - The program creates an instance of a decoder using
Chris@34 84 * FLAC__stream_decoder_new().
Chris@34 85 * - The program overrides the default settings using
Chris@34 86 * FLAC__stream_decoder_set_*() functions.
Chris@34 87 * - The program initializes the instance to validate the settings and
Chris@34 88 * prepare for decoding using
Chris@34 89 * - FLAC__stream_decoder_init_stream() or FLAC__stream_decoder_init_FILE()
Chris@34 90 * or FLAC__stream_decoder_init_file() for native FLAC,
Chris@34 91 * - FLAC__stream_decoder_init_ogg_stream() or FLAC__stream_decoder_init_ogg_FILE()
Chris@34 92 * or FLAC__stream_decoder_init_ogg_file() for Ogg FLAC
Chris@34 93 * - The program calls the FLAC__stream_decoder_process_*() functions
Chris@34 94 * to decode data, which subsequently calls the callbacks.
Chris@34 95 * - The program finishes the decoding with FLAC__stream_decoder_finish(),
Chris@34 96 * which flushes the input and output and resets the decoder to the
Chris@34 97 * uninitialized state.
Chris@34 98 * - The instance may be used again or deleted with
Chris@34 99 * FLAC__stream_decoder_delete().
Chris@34 100 *
Chris@34 101 * In more detail, the program will create a new instance by calling
Chris@34 102 * FLAC__stream_decoder_new(), then call FLAC__stream_decoder_set_*()
Chris@34 103 * functions to override the default decoder options, and call
Chris@34 104 * one of the FLAC__stream_decoder_init_*() functions.
Chris@34 105 *
Chris@34 106 * There are three initialization functions for native FLAC, one for
Chris@34 107 * setting up the decoder to decode FLAC data from the client via
Chris@34 108 * callbacks, and two for decoding directly from a FLAC file.
Chris@34 109 *
Chris@34 110 * For decoding via callbacks, use FLAC__stream_decoder_init_stream().
Chris@34 111 * You must also supply several callbacks for handling I/O. Some (like
Chris@34 112 * seeking) are optional, depending on the capabilities of the input.
Chris@34 113 *
Chris@34 114 * For decoding directly from a file, use FLAC__stream_decoder_init_FILE()
Chris@34 115 * or FLAC__stream_decoder_init_file(). Then you must only supply an open
Chris@34 116 * \c FILE* or filename and fewer callbacks; the decoder will handle
Chris@34 117 * the other callbacks internally.
Chris@34 118 *
Chris@34 119 * There are three similarly-named init functions for decoding from Ogg
Chris@34 120 * FLAC streams. Check \c FLAC_API_SUPPORTS_OGG_FLAC to find out if the
Chris@34 121 * library has been built with Ogg support.
Chris@34 122 *
Chris@34 123 * Once the decoder is initialized, your program will call one of several
Chris@34 124 * functions to start the decoding process:
Chris@34 125 *
Chris@34 126 * - FLAC__stream_decoder_process_single() - Tells the decoder to process at
Chris@34 127 * most one metadata block or audio frame and return, calling either the
Chris@34 128 * metadata callback or write callback, respectively, once. If the decoder
Chris@34 129 * loses sync it will return with only the error callback being called.
Chris@34 130 * - FLAC__stream_decoder_process_until_end_of_metadata() - Tells the decoder
Chris@34 131 * to process the stream from the current location and stop upon reaching
Chris@34 132 * the first audio frame. The client will get one metadata, write, or error
Chris@34 133 * callback per metadata block, audio frame, or sync error, respectively.
Chris@34 134 * - FLAC__stream_decoder_process_until_end_of_stream() - Tells the decoder
Chris@34 135 * to process the stream from the current location until the read callback
Chris@34 136 * returns FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM or
Chris@34 137 * FLAC__STREAM_DECODER_READ_STATUS_ABORT. The client will get one metadata,
Chris@34 138 * write, or error callback per metadata block, audio frame, or sync error,
Chris@34 139 * respectively.
Chris@34 140 *
Chris@34 141 * When the decoder has finished decoding (normally or through an abort),
Chris@34 142 * the instance is finished by calling FLAC__stream_decoder_finish(), which
Chris@34 143 * ensures the decoder is in the correct state and frees memory. Then the
Chris@34 144 * instance may be deleted with FLAC__stream_decoder_delete() or initialized
Chris@34 145 * again to decode another stream.
Chris@34 146 *
Chris@34 147 * Seeking is exposed through the FLAC__stream_decoder_seek_absolute() method.
Chris@34 148 * At any point after the stream decoder has been initialized, the client can
Chris@34 149 * call this function to seek to an exact sample within the stream.
Chris@34 150 * Subsequently, the first time the write callback is called it will be
Chris@34 151 * passed a (possibly partial) block starting at that sample.
Chris@34 152 *
Chris@34 153 * If the client cannot seek via the callback interface provided, but still
Chris@34 154 * has another way of seeking, it can flush the decoder using
Chris@34 155 * FLAC__stream_decoder_flush() and start feeding data from the new position
Chris@34 156 * through the read callback.
Chris@34 157 *
Chris@34 158 * The stream decoder also provides MD5 signature checking. If this is
Chris@34 159 * turned on before initialization, FLAC__stream_decoder_finish() will
Chris@34 160 * report when the decoded MD5 signature does not match the one stored
Chris@34 161 * in the STREAMINFO block. MD5 checking is automatically turned off
Chris@34 162 * (until the next FLAC__stream_decoder_reset()) if there is no signature
Chris@34 163 * in the STREAMINFO block or when a seek is attempted.
Chris@34 164 *
Chris@34 165 * The FLAC__stream_decoder_set_metadata_*() functions deserve special
Chris@34 166 * attention. By default, the decoder only calls the metadata_callback for
Chris@34 167 * the STREAMINFO block. These functions allow you to tell the decoder
Chris@34 168 * explicitly which blocks to parse and return via the metadata_callback
Chris@34 169 * and/or which to skip. Use a FLAC__stream_decoder_set_metadata_respond_all(),
Chris@34 170 * FLAC__stream_decoder_set_metadata_ignore() ... or FLAC__stream_decoder_set_metadata_ignore_all(),
Chris@34 171 * FLAC__stream_decoder_set_metadata_respond() ... sequence to exactly specify
Chris@34 172 * which blocks to return. Remember that metadata blocks can potentially
Chris@34 173 * be big (for example, cover art) so filtering out the ones you don't
Chris@34 174 * use can reduce the memory requirements of the decoder. Also note the
Chris@34 175 * special forms FLAC__stream_decoder_set_metadata_respond_application(id)
Chris@34 176 * and FLAC__stream_decoder_set_metadata_ignore_application(id) for
Chris@34 177 * filtering APPLICATION blocks based on the application ID.
Chris@34 178 *
Chris@34 179 * STREAMINFO and SEEKTABLE blocks are always parsed and used internally, but
Chris@34 180 * they still can legally be filtered from the metadata_callback.
Chris@34 181 *
Chris@34 182 * \note
Chris@34 183 * The "set" functions may only be called when the decoder is in the
Chris@34 184 * state FLAC__STREAM_DECODER_UNINITIALIZED, i.e. after
Chris@34 185 * FLAC__stream_decoder_new() or FLAC__stream_decoder_finish(), but
Chris@34 186 * before FLAC__stream_decoder_init_*(). If this is the case they will
Chris@34 187 * return \c true, otherwise \c false.
Chris@34 188 *
Chris@34 189 * \note
Chris@34 190 * FLAC__stream_decoder_finish() resets all settings to the constructor
Chris@34 191 * defaults, including the callbacks.
Chris@34 192 *
Chris@34 193 * \{
Chris@34 194 */
Chris@34 195
Chris@34 196
Chris@34 197 /** State values for a FLAC__StreamDecoder
Chris@34 198 *
Chris@34 199 * The decoder's state can be obtained by calling FLAC__stream_decoder_get_state().
Chris@34 200 */
Chris@34 201 typedef enum {
Chris@34 202
Chris@34 203 FLAC__STREAM_DECODER_SEARCH_FOR_METADATA = 0,
Chris@34 204 /**< The decoder is ready to search for metadata. */
Chris@34 205
Chris@34 206 FLAC__STREAM_DECODER_READ_METADATA,
Chris@34 207 /**< The decoder is ready to or is in the process of reading metadata. */
Chris@34 208
Chris@34 209 FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC,
Chris@34 210 /**< The decoder is ready to or is in the process of searching for the
Chris@34 211 * frame sync code.
Chris@34 212 */
Chris@34 213
Chris@34 214 FLAC__STREAM_DECODER_READ_FRAME,
Chris@34 215 /**< The decoder is ready to or is in the process of reading a frame. */
Chris@34 216
Chris@34 217 FLAC__STREAM_DECODER_END_OF_STREAM,
Chris@34 218 /**< The decoder has reached the end of the stream. */
Chris@34 219
Chris@34 220 FLAC__STREAM_DECODER_OGG_ERROR,
Chris@34 221 /**< An error occurred in the underlying Ogg layer. */
Chris@34 222
Chris@34 223 FLAC__STREAM_DECODER_SEEK_ERROR,
Chris@34 224 /**< An error occurred while seeking. The decoder must be flushed
Chris@34 225 * with FLAC__stream_decoder_flush() or reset with
Chris@34 226 * FLAC__stream_decoder_reset() before decoding can continue.
Chris@34 227 */
Chris@34 228
Chris@34 229 FLAC__STREAM_DECODER_ABORTED,
Chris@34 230 /**< The decoder was aborted by the read callback. */
Chris@34 231
Chris@34 232 FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR,
Chris@34 233 /**< An error occurred allocating memory. The decoder is in an invalid
Chris@34 234 * state and can no longer be used.
Chris@34 235 */
Chris@34 236
Chris@34 237 FLAC__STREAM_DECODER_UNINITIALIZED
Chris@34 238 /**< The decoder is in the uninitialized state; one of the
Chris@34 239 * FLAC__stream_decoder_init_*() functions must be called before samples
Chris@34 240 * can be processed.
Chris@34 241 */
Chris@34 242
Chris@34 243 } FLAC__StreamDecoderState;
Chris@34 244
Chris@34 245 /** Maps a FLAC__StreamDecoderState to a C string.
Chris@34 246 *
Chris@34 247 * Using a FLAC__StreamDecoderState as the index to this array
Chris@34 248 * will give the string equivalent. The contents should not be modified.
Chris@34 249 */
Chris@34 250 extern FLAC_API const char * const FLAC__StreamDecoderStateString[];
Chris@34 251
Chris@34 252
Chris@34 253 /** Possible return values for the FLAC__stream_decoder_init_*() functions.
Chris@34 254 */
Chris@34 255 typedef enum {
Chris@34 256
Chris@34 257 FLAC__STREAM_DECODER_INIT_STATUS_OK = 0,
Chris@34 258 /**< Initialization was successful. */
Chris@34 259
Chris@34 260 FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER,
Chris@34 261 /**< The library was not compiled with support for the given container
Chris@34 262 * format.
Chris@34 263 */
Chris@34 264
Chris@34 265 FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS,
Chris@34 266 /**< A required callback was not supplied. */
Chris@34 267
Chris@34 268 FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR,
Chris@34 269 /**< An error occurred allocating memory. */
Chris@34 270
Chris@34 271 FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE,
Chris@34 272 /**< fopen() failed in FLAC__stream_decoder_init_file() or
Chris@34 273 * FLAC__stream_decoder_init_ogg_file(). */
Chris@34 274
Chris@34 275 FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED
Chris@34 276 /**< FLAC__stream_decoder_init_*() was called when the decoder was
Chris@34 277 * already initialized, usually because
Chris@34 278 * FLAC__stream_decoder_finish() was not called.
Chris@34 279 */
Chris@34 280
Chris@34 281 } FLAC__StreamDecoderInitStatus;
Chris@34 282
Chris@34 283 /** Maps a FLAC__StreamDecoderInitStatus to a C string.
Chris@34 284 *
Chris@34 285 * Using a FLAC__StreamDecoderInitStatus as the index to this array
Chris@34 286 * will give the string equivalent. The contents should not be modified.
Chris@34 287 */
Chris@34 288 extern FLAC_API const char * const FLAC__StreamDecoderInitStatusString[];
Chris@34 289
Chris@34 290
Chris@34 291 /** Return values for the FLAC__StreamDecoder read callback.
Chris@34 292 */
Chris@34 293 typedef enum {
Chris@34 294
Chris@34 295 FLAC__STREAM_DECODER_READ_STATUS_CONTINUE,
Chris@34 296 /**< The read was OK and decoding can continue. */
Chris@34 297
Chris@34 298 FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM,
Chris@34 299 /**< The read was attempted while at the end of the stream. Note that
Chris@34 300 * the client must only return this value when the read callback was
Chris@34 301 * called when already at the end of the stream. Otherwise, if the read
Chris@34 302 * itself moves to the end of the stream, the client should still return
Chris@34 303 * the data and \c FLAC__STREAM_DECODER_READ_STATUS_CONTINUE, and then on
Chris@34 304 * the next read callback it should return
Chris@34 305 * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM with a byte count
Chris@34 306 * of \c 0.
Chris@34 307 */
Chris@34 308
Chris@34 309 FLAC__STREAM_DECODER_READ_STATUS_ABORT
Chris@34 310 /**< An unrecoverable error occurred. The decoder will return from the process call. */
Chris@34 311
Chris@34 312 } FLAC__StreamDecoderReadStatus;
Chris@34 313
Chris@34 314 /** Maps a FLAC__StreamDecoderReadStatus to a C string.
Chris@34 315 *
Chris@34 316 * Using a FLAC__StreamDecoderReadStatus as the index to this array
Chris@34 317 * will give the string equivalent. The contents should not be modified.
Chris@34 318 */
Chris@34 319 extern FLAC_API const char * const FLAC__StreamDecoderReadStatusString[];
Chris@34 320
Chris@34 321
Chris@34 322 /** Return values for the FLAC__StreamDecoder seek callback.
Chris@34 323 */
Chris@34 324 typedef enum {
Chris@34 325
Chris@34 326 FLAC__STREAM_DECODER_SEEK_STATUS_OK,
Chris@34 327 /**< The seek was OK and decoding can continue. */
Chris@34 328
Chris@34 329 FLAC__STREAM_DECODER_SEEK_STATUS_ERROR,
Chris@34 330 /**< An unrecoverable error occurred. The decoder will return from the process call. */
Chris@34 331
Chris@34 332 FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED
Chris@34 333 /**< Client does not support seeking. */
Chris@34 334
Chris@34 335 } FLAC__StreamDecoderSeekStatus;
Chris@34 336
Chris@34 337 /** Maps a FLAC__StreamDecoderSeekStatus to a C string.
Chris@34 338 *
Chris@34 339 * Using a FLAC__StreamDecoderSeekStatus as the index to this array
Chris@34 340 * will give the string equivalent. The contents should not be modified.
Chris@34 341 */
Chris@34 342 extern FLAC_API const char * const FLAC__StreamDecoderSeekStatusString[];
Chris@34 343
Chris@34 344
Chris@34 345 /** Return values for the FLAC__StreamDecoder tell callback.
Chris@34 346 */
Chris@34 347 typedef enum {
Chris@34 348
Chris@34 349 FLAC__STREAM_DECODER_TELL_STATUS_OK,
Chris@34 350 /**< The tell was OK and decoding can continue. */
Chris@34 351
Chris@34 352 FLAC__STREAM_DECODER_TELL_STATUS_ERROR,
Chris@34 353 /**< An unrecoverable error occurred. The decoder will return from the process call. */
Chris@34 354
Chris@34 355 FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED
Chris@34 356 /**< Client does not support telling the position. */
Chris@34 357
Chris@34 358 } FLAC__StreamDecoderTellStatus;
Chris@34 359
Chris@34 360 /** Maps a FLAC__StreamDecoderTellStatus to a C string.
Chris@34 361 *
Chris@34 362 * Using a FLAC__StreamDecoderTellStatus as the index to this array
Chris@34 363 * will give the string equivalent. The contents should not be modified.
Chris@34 364 */
Chris@34 365 extern FLAC_API const char * const FLAC__StreamDecoderTellStatusString[];
Chris@34 366
Chris@34 367
Chris@34 368 /** Return values for the FLAC__StreamDecoder length callback.
Chris@34 369 */
Chris@34 370 typedef enum {
Chris@34 371
Chris@34 372 FLAC__STREAM_DECODER_LENGTH_STATUS_OK,
Chris@34 373 /**< The length call was OK and decoding can continue. */
Chris@34 374
Chris@34 375 FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR,
Chris@34 376 /**< An unrecoverable error occurred. The decoder will return from the process call. */
Chris@34 377
Chris@34 378 FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED
Chris@34 379 /**< Client does not support reporting the length. */
Chris@34 380
Chris@34 381 } FLAC__StreamDecoderLengthStatus;
Chris@34 382
Chris@34 383 /** Maps a FLAC__StreamDecoderLengthStatus to a C string.
Chris@34 384 *
Chris@34 385 * Using a FLAC__StreamDecoderLengthStatus as the index to this array
Chris@34 386 * will give the string equivalent. The contents should not be modified.
Chris@34 387 */
Chris@34 388 extern FLAC_API const char * const FLAC__StreamDecoderLengthStatusString[];
Chris@34 389
Chris@34 390
Chris@34 391 /** Return values for the FLAC__StreamDecoder write callback.
Chris@34 392 */
Chris@34 393 typedef enum {
Chris@34 394
Chris@34 395 FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE,
Chris@34 396 /**< The write was OK and decoding can continue. */
Chris@34 397
Chris@34 398 FLAC__STREAM_DECODER_WRITE_STATUS_ABORT
Chris@34 399 /**< An unrecoverable error occurred. The decoder will return from the process call. */
Chris@34 400
Chris@34 401 } FLAC__StreamDecoderWriteStatus;
Chris@34 402
Chris@34 403 /** Maps a FLAC__StreamDecoderWriteStatus to a C string.
Chris@34 404 *
Chris@34 405 * Using a FLAC__StreamDecoderWriteStatus as the index to this array
Chris@34 406 * will give the string equivalent. The contents should not be modified.
Chris@34 407 */
Chris@34 408 extern FLAC_API const char * const FLAC__StreamDecoderWriteStatusString[];
Chris@34 409
Chris@34 410
Chris@34 411 /** Possible values passed back to the FLAC__StreamDecoder error callback.
Chris@34 412 * \c FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC is the generic catch-
Chris@34 413 * all. The rest could be caused by bad sync (false synchronization on
Chris@34 414 * data that is not the start of a frame) or corrupted data. The error
Chris@34 415 * itself is the decoder's best guess at what happened assuming a correct
Chris@34 416 * sync. For example \c FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER
Chris@34 417 * could be caused by a correct sync on the start of a frame, but some
Chris@34 418 * data in the frame header was corrupted. Or it could be the result of
Chris@34 419 * syncing on a point the stream that looked like the starting of a frame
Chris@34 420 * but was not. \c FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM
Chris@34 421 * could be because the decoder encountered a valid frame made by a future
Chris@34 422 * version of the encoder which it cannot parse, or because of a false
Chris@34 423 * sync making it appear as though an encountered frame was generated by
Chris@34 424 * a future encoder.
Chris@34 425 */
Chris@34 426 typedef enum {
Chris@34 427
Chris@34 428 FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC,
Chris@34 429 /**< An error in the stream caused the decoder to lose synchronization. */
Chris@34 430
Chris@34 431 FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER,
Chris@34 432 /**< The decoder encountered a corrupted frame header. */
Chris@34 433
Chris@34 434 FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH,
Chris@34 435 /**< The frame's data did not match the CRC in the footer. */
Chris@34 436
Chris@34 437 FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM
Chris@34 438 /**< The decoder encountered reserved fields in use in the stream. */
Chris@34 439
Chris@34 440 } FLAC__StreamDecoderErrorStatus;
Chris@34 441
Chris@34 442 /** Maps a FLAC__StreamDecoderErrorStatus to a C string.
Chris@34 443 *
Chris@34 444 * Using a FLAC__StreamDecoderErrorStatus as the index to this array
Chris@34 445 * will give the string equivalent. The contents should not be modified.
Chris@34 446 */
Chris@34 447 extern FLAC_API const char * const FLAC__StreamDecoderErrorStatusString[];
Chris@34 448
Chris@34 449
Chris@34 450 /***********************************************************************
Chris@34 451 *
Chris@34 452 * class FLAC__StreamDecoder
Chris@34 453 *
Chris@34 454 ***********************************************************************/
Chris@34 455
Chris@34 456 struct FLAC__StreamDecoderProtected;
Chris@34 457 struct FLAC__StreamDecoderPrivate;
Chris@34 458 /** The opaque structure definition for the stream decoder type.
Chris@34 459 * See the \link flac_stream_decoder stream decoder module \endlink
Chris@34 460 * for a detailed description.
Chris@34 461 */
Chris@34 462 typedef struct {
Chris@34 463 struct FLAC__StreamDecoderProtected *protected_; /* avoid the C++ keyword 'protected' */
Chris@34 464 struct FLAC__StreamDecoderPrivate *private_; /* avoid the C++ keyword 'private' */
Chris@34 465 } FLAC__StreamDecoder;
Chris@34 466
Chris@34 467 /** Signature for the read callback.
Chris@34 468 *
Chris@34 469 * A function pointer matching this signature must be passed to
Chris@34 470 * FLAC__stream_decoder_init*_stream(). The supplied function will be
Chris@34 471 * called when the decoder needs more input data. The address of the
Chris@34 472 * buffer to be filled is supplied, along with the number of bytes the
Chris@34 473 * buffer can hold. The callback may choose to supply less data and
Chris@34 474 * modify the byte count but must be careful not to overflow the buffer.
Chris@34 475 * The callback then returns a status code chosen from
Chris@34 476 * FLAC__StreamDecoderReadStatus.
Chris@34 477 *
Chris@34 478 * Here is an example of a read callback for stdio streams:
Chris@34 479 * \code
Chris@34 480 * FLAC__StreamDecoderReadStatus read_cb(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
Chris@34 481 * {
Chris@34 482 * FILE *file = ((MyClientData*)client_data)->file;
Chris@34 483 * if(*bytes > 0) {
Chris@34 484 * *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, file);
Chris@34 485 * if(ferror(file))
Chris@34 486 * return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
Chris@34 487 * else if(*bytes == 0)
Chris@34 488 * return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
Chris@34 489 * else
Chris@34 490 * return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
Chris@34 491 * }
Chris@34 492 * else
Chris@34 493 * return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
Chris@34 494 * }
Chris@34 495 * \endcode
Chris@34 496 *
Chris@34 497 * \note In general, FLAC__StreamDecoder functions which change the
Chris@34 498 * state should not be called on the \a decoder while in the callback.
Chris@34 499 *
Chris@34 500 * \param decoder The decoder instance calling the callback.
Chris@34 501 * \param buffer A pointer to a location for the callee to store
Chris@34 502 * data to be decoded.
Chris@34 503 * \param bytes A pointer to the size of the buffer. On entry
Chris@34 504 * to the callback, it contains the maximum number
Chris@34 505 * of bytes that may be stored in \a buffer. The
Chris@34 506 * callee must set it to the actual number of bytes
Chris@34 507 * stored (0 in case of error or end-of-stream) before
Chris@34 508 * returning.
Chris@34 509 * \param client_data The callee's client data set through
Chris@34 510 * FLAC__stream_decoder_init_*().
Chris@34 511 * \retval FLAC__StreamDecoderReadStatus
Chris@34 512 * The callee's return status. Note that the callback should return
Chris@34 513 * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM if and only if
Chris@34 514 * zero bytes were read and there is no more data to be read.
Chris@34 515 */
Chris@34 516 typedef FLAC__StreamDecoderReadStatus (*FLAC__StreamDecoderReadCallback)(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
Chris@34 517
Chris@34 518 /** Signature for the seek callback.
Chris@34 519 *
Chris@34 520 * A function pointer matching this signature may be passed to
Chris@34 521 * FLAC__stream_decoder_init*_stream(). The supplied function will be
Chris@34 522 * called when the decoder needs to seek the input stream. The decoder
Chris@34 523 * will pass the absolute byte offset to seek to, 0 meaning the
Chris@34 524 * beginning of the stream.
Chris@34 525 *
Chris@34 526 * Here is an example of a seek callback for stdio streams:
Chris@34 527 * \code
Chris@34 528 * FLAC__StreamDecoderSeekStatus seek_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data)
Chris@34 529 * {
Chris@34 530 * FILE *file = ((MyClientData*)client_data)->file;
Chris@34 531 * if(file == stdin)
Chris@34 532 * return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED;
Chris@34 533 * else if(fseeko(file, (off_t)absolute_byte_offset, SEEK_SET) < 0)
Chris@34 534 * return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
Chris@34 535 * else
Chris@34 536 * return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
Chris@34 537 * }
Chris@34 538 * \endcode
Chris@34 539 *
Chris@34 540 * \note In general, FLAC__StreamDecoder functions which change the
Chris@34 541 * state should not be called on the \a decoder while in the callback.
Chris@34 542 *
Chris@34 543 * \param decoder The decoder instance calling the callback.
Chris@34 544 * \param absolute_byte_offset The offset from the beginning of the stream
Chris@34 545 * to seek to.
Chris@34 546 * \param client_data The callee's client data set through
Chris@34 547 * FLAC__stream_decoder_init_*().
Chris@34 548 * \retval FLAC__StreamDecoderSeekStatus
Chris@34 549 * The callee's return status.
Chris@34 550 */
Chris@34 551 typedef FLAC__StreamDecoderSeekStatus (*FLAC__StreamDecoderSeekCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
Chris@34 552
Chris@34 553 /** Signature for the tell callback.
Chris@34 554 *
Chris@34 555 * A function pointer matching this signature may be passed to
Chris@34 556 * FLAC__stream_decoder_init*_stream(). The supplied function will be
Chris@34 557 * called when the decoder wants to know the current position of the
Chris@34 558 * stream. The callback should return the byte offset from the
Chris@34 559 * beginning of the stream.
Chris@34 560 *
Chris@34 561 * Here is an example of a tell callback for stdio streams:
Chris@34 562 * \code
Chris@34 563 * FLAC__StreamDecoderTellStatus tell_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data)
Chris@34 564 * {
Chris@34 565 * FILE *file = ((MyClientData*)client_data)->file;
Chris@34 566 * off_t pos;
Chris@34 567 * if(file == stdin)
Chris@34 568 * return FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED;
Chris@34 569 * else if((pos = ftello(file)) < 0)
Chris@34 570 * return FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
Chris@34 571 * else {
Chris@34 572 * *absolute_byte_offset = (FLAC__uint64)pos;
Chris@34 573 * return FLAC__STREAM_DECODER_TELL_STATUS_OK;
Chris@34 574 * }
Chris@34 575 * }
Chris@34 576 * \endcode
Chris@34 577 *
Chris@34 578 * \note In general, FLAC__StreamDecoder functions which change the
Chris@34 579 * state should not be called on the \a decoder while in the callback.
Chris@34 580 *
Chris@34 581 * \param decoder The decoder instance calling the callback.
Chris@34 582 * \param absolute_byte_offset A pointer to storage for the current offset
Chris@34 583 * from the beginning of the stream.
Chris@34 584 * \param client_data The callee's client data set through
Chris@34 585 * FLAC__stream_decoder_init_*().
Chris@34 586 * \retval FLAC__StreamDecoderTellStatus
Chris@34 587 * The callee's return status.
Chris@34 588 */
Chris@34 589 typedef FLAC__StreamDecoderTellStatus (*FLAC__StreamDecoderTellCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
Chris@34 590
Chris@34 591 /** Signature for the length callback.
Chris@34 592 *
Chris@34 593 * A function pointer matching this signature may be passed to
Chris@34 594 * FLAC__stream_decoder_init*_stream(). The supplied function will be
Chris@34 595 * called when the decoder wants to know the total length of the stream
Chris@34 596 * in bytes.
Chris@34 597 *
Chris@34 598 * Here is an example of a length callback for stdio streams:
Chris@34 599 * \code
Chris@34 600 * FLAC__StreamDecoderLengthStatus length_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data)
Chris@34 601 * {
Chris@34 602 * FILE *file = ((MyClientData*)client_data)->file;
Chris@34 603 * struct stat filestats;
Chris@34 604 *
Chris@34 605 * if(file == stdin)
Chris@34 606 * return FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED;
Chris@34 607 * else if(fstat(fileno(file), &filestats) != 0)
Chris@34 608 * return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
Chris@34 609 * else {
Chris@34 610 * *stream_length = (FLAC__uint64)filestats.st_size;
Chris@34 611 * return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
Chris@34 612 * }
Chris@34 613 * }
Chris@34 614 * \endcode
Chris@34 615 *
Chris@34 616 * \note In general, FLAC__StreamDecoder functions which change the
Chris@34 617 * state should not be called on the \a decoder while in the callback.
Chris@34 618 *
Chris@34 619 * \param decoder The decoder instance calling the callback.
Chris@34 620 * \param stream_length A pointer to storage for the length of the stream
Chris@34 621 * in bytes.
Chris@34 622 * \param client_data The callee's client data set through
Chris@34 623 * FLAC__stream_decoder_init_*().
Chris@34 624 * \retval FLAC__StreamDecoderLengthStatus
Chris@34 625 * The callee's return status.
Chris@34 626 */
Chris@34 627 typedef FLAC__StreamDecoderLengthStatus (*FLAC__StreamDecoderLengthCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
Chris@34 628
Chris@34 629 /** Signature for the EOF callback.
Chris@34 630 *
Chris@34 631 * A function pointer matching this signature may be passed to
Chris@34 632 * FLAC__stream_decoder_init*_stream(). The supplied function will be
Chris@34 633 * called when the decoder needs to know if the end of the stream has
Chris@34 634 * been reached.
Chris@34 635 *
Chris@34 636 * Here is an example of a EOF callback for stdio streams:
Chris@34 637 * FLAC__bool eof_cb(const FLAC__StreamDecoder *decoder, void *client_data)
Chris@34 638 * \code
Chris@34 639 * {
Chris@34 640 * FILE *file = ((MyClientData*)client_data)->file;
Chris@34 641 * return feof(file)? true : false;
Chris@34 642 * }
Chris@34 643 * \endcode
Chris@34 644 *
Chris@34 645 * \note In general, FLAC__StreamDecoder functions which change the
Chris@34 646 * state should not be called on the \a decoder while in the callback.
Chris@34 647 *
Chris@34 648 * \param decoder The decoder instance calling the callback.
Chris@34 649 * \param client_data The callee's client data set through
Chris@34 650 * FLAC__stream_decoder_init_*().
Chris@34 651 * \retval FLAC__bool
Chris@34 652 * \c true if the currently at the end of the stream, else \c false.
Chris@34 653 */
Chris@34 654 typedef FLAC__bool (*FLAC__StreamDecoderEofCallback)(const FLAC__StreamDecoder *decoder, void *client_data);
Chris@34 655
Chris@34 656 /** Signature for the write callback.
Chris@34 657 *
Chris@34 658 * A function pointer matching this signature must be passed to one of
Chris@34 659 * the FLAC__stream_decoder_init_*() functions.
Chris@34 660 * The supplied function will be called when the decoder has decoded a
Chris@34 661 * single audio frame. The decoder will pass the frame metadata as well
Chris@34 662 * as an array of pointers (one for each channel) pointing to the
Chris@34 663 * decoded audio.
Chris@34 664 *
Chris@34 665 * \note In general, FLAC__StreamDecoder functions which change the
Chris@34 666 * state should not be called on the \a decoder while in the callback.
Chris@34 667 *
Chris@34 668 * \param decoder The decoder instance calling the callback.
Chris@34 669 * \param frame The description of the decoded frame. See
Chris@34 670 * FLAC__Frame.
Chris@34 671 * \param buffer An array of pointers to decoded channels of data.
Chris@34 672 * Each pointer will point to an array of signed
Chris@34 673 * samples of length \a frame->header.blocksize.
Chris@34 674 * Channels will be ordered according to the FLAC
Chris@34 675 * specification; see the documentation for the
Chris@34 676 * <A HREF="../format.html#frame_header">frame header</A>.
Chris@34 677 * \param client_data The callee's client data set through
Chris@34 678 * FLAC__stream_decoder_init_*().
Chris@34 679 * \retval FLAC__StreamDecoderWriteStatus
Chris@34 680 * The callee's return status.
Chris@34 681 */
Chris@34 682 typedef FLAC__StreamDecoderWriteStatus (*FLAC__StreamDecoderWriteCallback)(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
Chris@34 683
Chris@34 684 /** Signature for the metadata callback.
Chris@34 685 *
Chris@34 686 * A function pointer matching this signature must be passed to one of
Chris@34 687 * the FLAC__stream_decoder_init_*() functions.
Chris@34 688 * The supplied function will be called when the decoder has decoded a
Chris@34 689 * metadata block. In a valid FLAC file there will always be one
Chris@34 690 * \c STREAMINFO block, followed by zero or more other metadata blocks.
Chris@34 691 * These will be supplied by the decoder in the same order as they
Chris@34 692 * appear in the stream and always before the first audio frame (i.e.
Chris@34 693 * write callback). The metadata block that is passed in must not be
Chris@34 694 * modified, and it doesn't live beyond the callback, so you should make
Chris@34 695 * a copy of it with FLAC__metadata_object_clone() if you will need it
Chris@34 696 * elsewhere. Since metadata blocks can potentially be large, by
Chris@34 697 * default the decoder only calls the metadata callback for the
Chris@34 698 * \c STREAMINFO block; you can instruct the decoder to pass or filter
Chris@34 699 * other blocks with FLAC__stream_decoder_set_metadata_*() calls.
Chris@34 700 *
Chris@34 701 * \note In general, FLAC__StreamDecoder functions which change the
Chris@34 702 * state should not be called on the \a decoder while in the callback.
Chris@34 703 *
Chris@34 704 * \param decoder The decoder instance calling the callback.
Chris@34 705 * \param metadata The decoded metadata block.
Chris@34 706 * \param client_data The callee's client data set through
Chris@34 707 * FLAC__stream_decoder_init_*().
Chris@34 708 */
Chris@34 709 typedef void (*FLAC__StreamDecoderMetadataCallback)(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
Chris@34 710
Chris@34 711 /** Signature for the error callback.
Chris@34 712 *
Chris@34 713 * A function pointer matching this signature must be passed to one of
Chris@34 714 * the FLAC__stream_decoder_init_*() functions.
Chris@34 715 * The supplied function will be called whenever an error occurs during
Chris@34 716 * decoding.
Chris@34 717 *
Chris@34 718 * \note In general, FLAC__StreamDecoder functions which change the
Chris@34 719 * state should not be called on the \a decoder while in the callback.
Chris@34 720 *
Chris@34 721 * \param decoder The decoder instance calling the callback.
Chris@34 722 * \param status The error encountered by the decoder.
Chris@34 723 * \param client_data The callee's client data set through
Chris@34 724 * FLAC__stream_decoder_init_*().
Chris@34 725 */
Chris@34 726 typedef void (*FLAC__StreamDecoderErrorCallback)(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
Chris@34 727
Chris@34 728
Chris@34 729 /***********************************************************************
Chris@34 730 *
Chris@34 731 * Class constructor/destructor
Chris@34 732 *
Chris@34 733 ***********************************************************************/
Chris@34 734
Chris@34 735 /** Create a new stream decoder instance. The instance is created with
Chris@34 736 * default settings; see the individual FLAC__stream_decoder_set_*()
Chris@34 737 * functions for each setting's default.
Chris@34 738 *
Chris@34 739 * \retval FLAC__StreamDecoder*
Chris@34 740 * \c NULL if there was an error allocating memory, else the new instance.
Chris@34 741 */
Chris@34 742 FLAC_API FLAC__StreamDecoder *FLAC__stream_decoder_new(void);
Chris@34 743
Chris@34 744 /** Free a decoder instance. Deletes the object pointed to by \a decoder.
Chris@34 745 *
Chris@34 746 * \param decoder A pointer to an existing decoder.
Chris@34 747 * \assert
Chris@34 748 * \code decoder != NULL \endcode
Chris@34 749 */
Chris@34 750 FLAC_API void FLAC__stream_decoder_delete(FLAC__StreamDecoder *decoder);
Chris@34 751
Chris@34 752
Chris@34 753 /***********************************************************************
Chris@34 754 *
Chris@34 755 * Public class method prototypes
Chris@34 756 *
Chris@34 757 ***********************************************************************/
Chris@34 758
Chris@34 759 /** Set the serial number for the FLAC stream within the Ogg container.
Chris@34 760 * The default behavior is to use the serial number of the first Ogg
Chris@34 761 * page. Setting a serial number here will explicitly specify which
Chris@34 762 * stream is to be decoded.
Chris@34 763 *
Chris@34 764 * \note
Chris@34 765 * This does not need to be set for native FLAC decoding.
Chris@34 766 *
Chris@34 767 * \default \c use serial number of first page
Chris@34 768 * \param decoder A decoder instance to set.
Chris@34 769 * \param serial_number See above.
Chris@34 770 * \assert
Chris@34 771 * \code decoder != NULL \endcode
Chris@34 772 * \retval FLAC__bool
Chris@34 773 * \c false if the decoder is already initialized, else \c true.
Chris@34 774 */
Chris@34 775 FLAC_API FLAC__bool FLAC__stream_decoder_set_ogg_serial_number(FLAC__StreamDecoder *decoder, long serial_number);
Chris@34 776
Chris@34 777 /** Set the "MD5 signature checking" flag. If \c true, the decoder will
Chris@34 778 * compute the MD5 signature of the unencoded audio data while decoding
Chris@34 779 * and compare it to the signature from the STREAMINFO block, if it
Chris@34 780 * exists, during FLAC__stream_decoder_finish().
Chris@34 781 *
Chris@34 782 * MD5 signature checking will be turned off (until the next
Chris@34 783 * FLAC__stream_decoder_reset()) if there is no signature in the
Chris@34 784 * STREAMINFO block or when a seek is attempted.
Chris@34 785 *
Chris@34 786 * Clients that do not use the MD5 check should leave this off to speed
Chris@34 787 * up decoding.
Chris@34 788 *
Chris@34 789 * \default \c false
Chris@34 790 * \param decoder A decoder instance to set.
Chris@34 791 * \param value Flag value (see above).
Chris@34 792 * \assert
Chris@34 793 * \code decoder != NULL \endcode
Chris@34 794 * \retval FLAC__bool
Chris@34 795 * \c false if the decoder is already initialized, else \c true.
Chris@34 796 */
Chris@34 797 FLAC_API FLAC__bool FLAC__stream_decoder_set_md5_checking(FLAC__StreamDecoder *decoder, FLAC__bool value);
Chris@34 798
Chris@34 799 /** Direct the decoder to pass on all metadata blocks of type \a type.
Chris@34 800 *
Chris@34 801 * \default By default, only the \c STREAMINFO block is returned via the
Chris@34 802 * metadata callback.
Chris@34 803 * \param decoder A decoder instance to set.
Chris@34 804 * \param type See above.
Chris@34 805 * \assert
Chris@34 806 * \code decoder != NULL \endcode
Chris@34 807 * \a type is valid
Chris@34 808 * \retval FLAC__bool
Chris@34 809 * \c false if the decoder is already initialized, else \c true.
Chris@34 810 */
Chris@34 811 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond(FLAC__StreamDecoder *decoder, FLAC__MetadataType type);
Chris@34 812
Chris@34 813 /** Direct the decoder to pass on all APPLICATION metadata blocks of the
Chris@34 814 * given \a id.
Chris@34 815 *
Chris@34 816 * \default By default, only the \c STREAMINFO block is returned via the
Chris@34 817 * metadata callback.
Chris@34 818 * \param decoder A decoder instance to set.
Chris@34 819 * \param id See above.
Chris@34 820 * \assert
Chris@34 821 * \code decoder != NULL \endcode
Chris@34 822 * \code id != NULL \endcode
Chris@34 823 * \retval FLAC__bool
Chris@34 824 * \c false if the decoder is already initialized, else \c true.
Chris@34 825 */
Chris@34 826 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]);
Chris@34 827
Chris@34 828 /** Direct the decoder to pass on all metadata blocks of any type.
Chris@34 829 *
Chris@34 830 * \default By default, only the \c STREAMINFO block is returned via the
Chris@34 831 * metadata callback.
Chris@34 832 * \param decoder A decoder instance to set.
Chris@34 833 * \assert
Chris@34 834 * \code decoder != NULL \endcode
Chris@34 835 * \retval FLAC__bool
Chris@34 836 * \c false if the decoder is already initialized, else \c true.
Chris@34 837 */
Chris@34 838 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(FLAC__StreamDecoder *decoder);
Chris@34 839
Chris@34 840 /** Direct the decoder to filter out all metadata blocks of type \a type.
Chris@34 841 *
Chris@34 842 * \default By default, only the \c STREAMINFO block is returned via the
Chris@34 843 * metadata callback.
Chris@34 844 * \param decoder A decoder instance to set.
Chris@34 845 * \param type See above.
Chris@34 846 * \assert
Chris@34 847 * \code decoder != NULL \endcode
Chris@34 848 * \a type is valid
Chris@34 849 * \retval FLAC__bool
Chris@34 850 * \c false if the decoder is already initialized, else \c true.
Chris@34 851 */
Chris@34 852 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore(FLAC__StreamDecoder *decoder, FLAC__MetadataType type);
Chris@34 853
Chris@34 854 /** Direct the decoder to filter out all APPLICATION metadata blocks of
Chris@34 855 * the given \a id.
Chris@34 856 *
Chris@34 857 * \default By default, only the \c STREAMINFO block is returned via the
Chris@34 858 * metadata callback.
Chris@34 859 * \param decoder A decoder instance to set.
Chris@34 860 * \param id See above.
Chris@34 861 * \assert
Chris@34 862 * \code decoder != NULL \endcode
Chris@34 863 * \code id != NULL \endcode
Chris@34 864 * \retval FLAC__bool
Chris@34 865 * \c false if the decoder is already initialized, else \c true.
Chris@34 866 */
Chris@34 867 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]);
Chris@34 868
Chris@34 869 /** Direct the decoder to filter out all metadata blocks of any type.
Chris@34 870 *
Chris@34 871 * \default By default, only the \c STREAMINFO block is returned via the
Chris@34 872 * metadata callback.
Chris@34 873 * \param decoder A decoder instance to set.
Chris@34 874 * \assert
Chris@34 875 * \code decoder != NULL \endcode
Chris@34 876 * \retval FLAC__bool
Chris@34 877 * \c false if the decoder is already initialized, else \c true.
Chris@34 878 */
Chris@34 879 FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_all(FLAC__StreamDecoder *decoder);
Chris@34 880
Chris@34 881 /** Get the current decoder state.
Chris@34 882 *
Chris@34 883 * \param decoder A decoder instance to query.
Chris@34 884 * \assert
Chris@34 885 * \code decoder != NULL \endcode
Chris@34 886 * \retval FLAC__StreamDecoderState
Chris@34 887 * The current decoder state.
Chris@34 888 */
Chris@34 889 FLAC_API FLAC__StreamDecoderState FLAC__stream_decoder_get_state(const FLAC__StreamDecoder *decoder);
Chris@34 890
Chris@34 891 /** Get the current decoder state as a C string.
Chris@34 892 *
Chris@34 893 * \param decoder A decoder instance to query.
Chris@34 894 * \assert
Chris@34 895 * \code decoder != NULL \endcode
Chris@34 896 * \retval const char *
Chris@34 897 * The decoder state as a C string. Do not modify the contents.
Chris@34 898 */
Chris@34 899 FLAC_API const char *FLAC__stream_decoder_get_resolved_state_string(const FLAC__StreamDecoder *decoder);
Chris@34 900
Chris@34 901 /** Get the "MD5 signature checking" flag.
Chris@34 902 * This is the value of the setting, not whether or not the decoder is
Chris@34 903 * currently checking the MD5 (remember, it can be turned off automatically
Chris@34 904 * by a seek). When the decoder is reset the flag will be restored to the
Chris@34 905 * value returned by this function.
Chris@34 906 *
Chris@34 907 * \param decoder A decoder instance to query.
Chris@34 908 * \assert
Chris@34 909 * \code decoder != NULL \endcode
Chris@34 910 * \retval FLAC__bool
Chris@34 911 * See above.
Chris@34 912 */
Chris@34 913 FLAC_API FLAC__bool FLAC__stream_decoder_get_md5_checking(const FLAC__StreamDecoder *decoder);
Chris@34 914
Chris@34 915 /** Get the total number of samples in the stream being decoded.
Chris@34 916 * Will only be valid after decoding has started and will contain the
Chris@34 917 * value from the \c STREAMINFO block. A value of \c 0 means "unknown".
Chris@34 918 *
Chris@34 919 * \param decoder A decoder instance to query.
Chris@34 920 * \assert
Chris@34 921 * \code decoder != NULL \endcode
Chris@34 922 * \retval unsigned
Chris@34 923 * See above.
Chris@34 924 */
Chris@34 925 FLAC_API FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamDecoder *decoder);
Chris@34 926
Chris@34 927 /** Get the current number of channels in the stream being decoded.
Chris@34 928 * Will only be valid after decoding has started and will contain the
Chris@34 929 * value from the most recently decoded frame header.
Chris@34 930 *
Chris@34 931 * \param decoder A decoder instance to query.
Chris@34 932 * \assert
Chris@34 933 * \code decoder != NULL \endcode
Chris@34 934 * \retval unsigned
Chris@34 935 * See above.
Chris@34 936 */
Chris@34 937 FLAC_API unsigned FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder);
Chris@34 938
Chris@34 939 /** Get the current channel assignment in the stream being decoded.
Chris@34 940 * Will only be valid after decoding has started and will contain the
Chris@34 941 * value from the most recently decoded frame header.
Chris@34 942 *
Chris@34 943 * \param decoder A decoder instance to query.
Chris@34 944 * \assert
Chris@34 945 * \code decoder != NULL \endcode
Chris@34 946 * \retval FLAC__ChannelAssignment
Chris@34 947 * See above.
Chris@34 948 */
Chris@34 949 FLAC_API FLAC__ChannelAssignment FLAC__stream_decoder_get_channel_assignment(const FLAC__StreamDecoder *decoder);
Chris@34 950
Chris@34 951 /** Get the current sample resolution in the stream being decoded.
Chris@34 952 * Will only be valid after decoding has started and will contain the
Chris@34 953 * value from the most recently decoded frame header.
Chris@34 954 *
Chris@34 955 * \param decoder A decoder instance to query.
Chris@34 956 * \assert
Chris@34 957 * \code decoder != NULL \endcode
Chris@34 958 * \retval unsigned
Chris@34 959 * See above.
Chris@34 960 */
Chris@34 961 FLAC_API unsigned FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder);
Chris@34 962
Chris@34 963 /** Get the current sample rate in Hz of the stream being decoded.
Chris@34 964 * Will only be valid after decoding has started and will contain the
Chris@34 965 * value from the most recently decoded frame header.
Chris@34 966 *
Chris@34 967 * \param decoder A decoder instance to query.
Chris@34 968 * \assert
Chris@34 969 * \code decoder != NULL \endcode
Chris@34 970 * \retval unsigned
Chris@34 971 * See above.
Chris@34 972 */
Chris@34 973 FLAC_API unsigned FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder);
Chris@34 974
Chris@34 975 /** Get the current blocksize of the stream being decoded.
Chris@34 976 * Will only be valid after decoding has started and will contain the
Chris@34 977 * value from the most recently decoded frame header.
Chris@34 978 *
Chris@34 979 * \param decoder A decoder instance to query.
Chris@34 980 * \assert
Chris@34 981 * \code decoder != NULL \endcode
Chris@34 982 * \retval unsigned
Chris@34 983 * See above.
Chris@34 984 */
Chris@34 985 FLAC_API unsigned FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder);
Chris@34 986
Chris@34 987 /** Returns the decoder's current read position within the stream.
Chris@34 988 * The position is the byte offset from the start of the stream.
Chris@34 989 * Bytes before this position have been fully decoded. Note that
Chris@34 990 * there may still be undecoded bytes in the decoder's read FIFO.
Chris@34 991 * The returned position is correct even after a seek.
Chris@34 992 *
Chris@34 993 * \warning This function currently only works for native FLAC,
Chris@34 994 * not Ogg FLAC streams.
Chris@34 995 *
Chris@34 996 * \param decoder A decoder instance to query.
Chris@34 997 * \param position Address at which to return the desired position.
Chris@34 998 * \assert
Chris@34 999 * \code decoder != NULL \endcode
Chris@34 1000 * \code position != NULL \endcode
Chris@34 1001 * \retval FLAC__bool
Chris@34 1002 * \c true if successful, \c false if the stream is not native FLAC,
Chris@34 1003 * or there was an error from the 'tell' callback or it returned
Chris@34 1004 * \c FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED.
Chris@34 1005 */
Chris@34 1006 FLAC_API FLAC__bool FLAC__stream_decoder_get_decode_position(const FLAC__StreamDecoder *decoder, FLAC__uint64 *position);
Chris@34 1007
Chris@34 1008 /** Initialize the decoder instance to decode native FLAC streams.
Chris@34 1009 *
Chris@34 1010 * This flavor of initialization sets up the decoder to decode from a
Chris@34 1011 * native FLAC stream. I/O is performed via callbacks to the client.
Chris@34 1012 * For decoding from a plain file via filename or open FILE*,
Chris@34 1013 * FLAC__stream_decoder_init_file() and FLAC__stream_decoder_init_FILE()
Chris@34 1014 * provide a simpler interface.
Chris@34 1015 *
Chris@34 1016 * This function should be called after FLAC__stream_decoder_new() and
Chris@34 1017 * FLAC__stream_decoder_set_*() but before any of the
Chris@34 1018 * FLAC__stream_decoder_process_*() functions. Will set and return the
Chris@34 1019 * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
Chris@34 1020 * if initialization succeeded.
Chris@34 1021 *
Chris@34 1022 * \param decoder An uninitialized decoder instance.
Chris@34 1023 * \param read_callback See FLAC__StreamDecoderReadCallback. This
Chris@34 1024 * pointer must not be \c NULL.
Chris@34 1025 * \param seek_callback See FLAC__StreamDecoderSeekCallback. This
Chris@34 1026 * pointer may be \c NULL if seeking is not
Chris@34 1027 * supported. If \a seek_callback is not \c NULL then a
Chris@34 1028 * \a tell_callback, \a length_callback, and \a eof_callback must also be supplied.
Chris@34 1029 * Alternatively, a dummy seek callback that just
Chris@34 1030 * returns \c FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED
Chris@34 1031 * may also be supplied, all though this is slightly
Chris@34 1032 * less efficient for the decoder.
Chris@34 1033 * \param tell_callback See FLAC__StreamDecoderTellCallback. This
Chris@34 1034 * pointer may be \c NULL if not supported by the client. If
Chris@34 1035 * \a seek_callback is not \c NULL then a
Chris@34 1036 * \a tell_callback must also be supplied.
Chris@34 1037 * Alternatively, a dummy tell callback that just
Chris@34 1038 * returns \c FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED
Chris@34 1039 * may also be supplied, all though this is slightly
Chris@34 1040 * less efficient for the decoder.
Chris@34 1041 * \param length_callback See FLAC__StreamDecoderLengthCallback. This
Chris@34 1042 * pointer may be \c NULL if not supported by the client. If
Chris@34 1043 * \a seek_callback is not \c NULL then a
Chris@34 1044 * \a length_callback must also be supplied.
Chris@34 1045 * Alternatively, a dummy length callback that just
Chris@34 1046 * returns \c FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED
Chris@34 1047 * may also be supplied, all though this is slightly
Chris@34 1048 * less efficient for the decoder.
Chris@34 1049 * \param eof_callback See FLAC__StreamDecoderEofCallback. This
Chris@34 1050 * pointer may be \c NULL if not supported by the client. If
Chris@34 1051 * \a seek_callback is not \c NULL then a
Chris@34 1052 * \a eof_callback must also be supplied.
Chris@34 1053 * Alternatively, a dummy length callback that just
Chris@34 1054 * returns \c false
Chris@34 1055 * may also be supplied, all though this is slightly
Chris@34 1056 * less efficient for the decoder.
Chris@34 1057 * \param write_callback See FLAC__StreamDecoderWriteCallback. This
Chris@34 1058 * pointer must not be \c NULL.
Chris@34 1059 * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
Chris@34 1060 * pointer may be \c NULL if the callback is not
Chris@34 1061 * desired.
Chris@34 1062 * \param error_callback See FLAC__StreamDecoderErrorCallback. This
Chris@34 1063 * pointer must not be \c NULL.
Chris@34 1064 * \param client_data This value will be supplied to callbacks in their
Chris@34 1065 * \a client_data argument.
Chris@34 1066 * \assert
Chris@34 1067 * \code decoder != NULL \endcode
Chris@34 1068 * \retval FLAC__StreamDecoderInitStatus
Chris@34 1069 * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
Chris@34 1070 * see FLAC__StreamDecoderInitStatus for the meanings of other return values.
Chris@34 1071 */
Chris@34 1072 FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_stream(
Chris@34 1073 FLAC__StreamDecoder *decoder,
Chris@34 1074 FLAC__StreamDecoderReadCallback read_callback,
Chris@34 1075 FLAC__StreamDecoderSeekCallback seek_callback,
Chris@34 1076 FLAC__StreamDecoderTellCallback tell_callback,
Chris@34 1077 FLAC__StreamDecoderLengthCallback length_callback,
Chris@34 1078 FLAC__StreamDecoderEofCallback eof_callback,
Chris@34 1079 FLAC__StreamDecoderWriteCallback write_callback,
Chris@34 1080 FLAC__StreamDecoderMetadataCallback metadata_callback,
Chris@34 1081 FLAC__StreamDecoderErrorCallback error_callback,
Chris@34 1082 void *client_data
Chris@34 1083 );
Chris@34 1084
Chris@34 1085 /** Initialize the decoder instance to decode Ogg FLAC streams.
Chris@34 1086 *
Chris@34 1087 * This flavor of initialization sets up the decoder to decode from a
Chris@34 1088 * FLAC stream in an Ogg container. I/O is performed via callbacks to the
Chris@34 1089 * client. For decoding from a plain file via filename or open FILE*,
Chris@34 1090 * FLAC__stream_decoder_init_ogg_file() and FLAC__stream_decoder_init_ogg_FILE()
Chris@34 1091 * provide a simpler interface.
Chris@34 1092 *
Chris@34 1093 * This function should be called after FLAC__stream_decoder_new() and
Chris@34 1094 * FLAC__stream_decoder_set_*() but before any of the
Chris@34 1095 * FLAC__stream_decoder_process_*() functions. Will set and return the
Chris@34 1096 * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
Chris@34 1097 * if initialization succeeded.
Chris@34 1098 *
Chris@34 1099 * \note Support for Ogg FLAC in the library is optional. If this
Chris@34 1100 * library has been built without support for Ogg FLAC, this function
Chris@34 1101 * will return \c FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER.
Chris@34 1102 *
Chris@34 1103 * \param decoder An uninitialized decoder instance.
Chris@34 1104 * \param read_callback See FLAC__StreamDecoderReadCallback. This
Chris@34 1105 * pointer must not be \c NULL.
Chris@34 1106 * \param seek_callback See FLAC__StreamDecoderSeekCallback. This
Chris@34 1107 * pointer may be \c NULL if seeking is not
Chris@34 1108 * supported. If \a seek_callback is not \c NULL then a
Chris@34 1109 * \a tell_callback, \a length_callback, and \a eof_callback must also be supplied.
Chris@34 1110 * Alternatively, a dummy seek callback that just
Chris@34 1111 * returns \c FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED
Chris@34 1112 * may also be supplied, all though this is slightly
Chris@34 1113 * less efficient for the decoder.
Chris@34 1114 * \param tell_callback See FLAC__StreamDecoderTellCallback. This
Chris@34 1115 * pointer may be \c NULL if not supported by the client. If
Chris@34 1116 * \a seek_callback is not \c NULL then a
Chris@34 1117 * \a tell_callback must also be supplied.
Chris@34 1118 * Alternatively, a dummy tell callback that just
Chris@34 1119 * returns \c FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED
Chris@34 1120 * may also be supplied, all though this is slightly
Chris@34 1121 * less efficient for the decoder.
Chris@34 1122 * \param length_callback See FLAC__StreamDecoderLengthCallback. This
Chris@34 1123 * pointer may be \c NULL if not supported by the client. If
Chris@34 1124 * \a seek_callback is not \c NULL then a
Chris@34 1125 * \a length_callback must also be supplied.
Chris@34 1126 * Alternatively, a dummy length callback that just
Chris@34 1127 * returns \c FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED
Chris@34 1128 * may also be supplied, all though this is slightly
Chris@34 1129 * less efficient for the decoder.
Chris@34 1130 * \param eof_callback See FLAC__StreamDecoderEofCallback. This
Chris@34 1131 * pointer may be \c NULL if not supported by the client. If
Chris@34 1132 * \a seek_callback is not \c NULL then a
Chris@34 1133 * \a eof_callback must also be supplied.
Chris@34 1134 * Alternatively, a dummy length callback that just
Chris@34 1135 * returns \c false
Chris@34 1136 * may also be supplied, all though this is slightly
Chris@34 1137 * less efficient for the decoder.
Chris@34 1138 * \param write_callback See FLAC__StreamDecoderWriteCallback. This
Chris@34 1139 * pointer must not be \c NULL.
Chris@34 1140 * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
Chris@34 1141 * pointer may be \c NULL if the callback is not
Chris@34 1142 * desired.
Chris@34 1143 * \param error_callback See FLAC__StreamDecoderErrorCallback. This
Chris@34 1144 * pointer must not be \c NULL.
Chris@34 1145 * \param client_data This value will be supplied to callbacks in their
Chris@34 1146 * \a client_data argument.
Chris@34 1147 * \assert
Chris@34 1148 * \code decoder != NULL \endcode
Chris@34 1149 * \retval FLAC__StreamDecoderInitStatus
Chris@34 1150 * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
Chris@34 1151 * see FLAC__StreamDecoderInitStatus for the meanings of other return values.
Chris@34 1152 */
Chris@34 1153 FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_stream(
Chris@34 1154 FLAC__StreamDecoder *decoder,
Chris@34 1155 FLAC__StreamDecoderReadCallback read_callback,
Chris@34 1156 FLAC__StreamDecoderSeekCallback seek_callback,
Chris@34 1157 FLAC__StreamDecoderTellCallback tell_callback,
Chris@34 1158 FLAC__StreamDecoderLengthCallback length_callback,
Chris@34 1159 FLAC__StreamDecoderEofCallback eof_callback,
Chris@34 1160 FLAC__StreamDecoderWriteCallback write_callback,
Chris@34 1161 FLAC__StreamDecoderMetadataCallback metadata_callback,
Chris@34 1162 FLAC__StreamDecoderErrorCallback error_callback,
Chris@34 1163 void *client_data
Chris@34 1164 );
Chris@34 1165
Chris@34 1166 /** Initialize the decoder instance to decode native FLAC files.
Chris@34 1167 *
Chris@34 1168 * This flavor of initialization sets up the decoder to decode from a
Chris@34 1169 * plain native FLAC file. For non-stdio streams, you must use
Chris@34 1170 * FLAC__stream_decoder_init_stream() and provide callbacks for the I/O.
Chris@34 1171 *
Chris@34 1172 * This function should be called after FLAC__stream_decoder_new() and
Chris@34 1173 * FLAC__stream_decoder_set_*() but before any of the
Chris@34 1174 * FLAC__stream_decoder_process_*() functions. Will set and return the
Chris@34 1175 * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
Chris@34 1176 * if initialization succeeded.
Chris@34 1177 *
Chris@34 1178 * \param decoder An uninitialized decoder instance.
Chris@34 1179 * \param file An open FLAC file. The file should have been
Chris@34 1180 * opened with mode \c "rb" and rewound. The file
Chris@34 1181 * becomes owned by the decoder and should not be
Chris@34 1182 * manipulated by the client while decoding.
Chris@34 1183 * Unless \a file is \c stdin, it will be closed
Chris@34 1184 * when FLAC__stream_decoder_finish() is called.
Chris@34 1185 * Note however that seeking will not work when
Chris@34 1186 * decoding from \c stdout since it is not seekable.
Chris@34 1187 * \param write_callback See FLAC__StreamDecoderWriteCallback. This
Chris@34 1188 * pointer must not be \c NULL.
Chris@34 1189 * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
Chris@34 1190 * pointer may be \c NULL if the callback is not
Chris@34 1191 * desired.
Chris@34 1192 * \param error_callback See FLAC__StreamDecoderErrorCallback. This
Chris@34 1193 * pointer must not be \c NULL.
Chris@34 1194 * \param client_data This value will be supplied to callbacks in their
Chris@34 1195 * \a client_data argument.
Chris@34 1196 * \assert
Chris@34 1197 * \code decoder != NULL \endcode
Chris@34 1198 * \code file != NULL \endcode
Chris@34 1199 * \retval FLAC__StreamDecoderInitStatus
Chris@34 1200 * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
Chris@34 1201 * see FLAC__StreamDecoderInitStatus for the meanings of other return values.
Chris@34 1202 */
Chris@34 1203 FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_FILE(
Chris@34 1204 FLAC__StreamDecoder *decoder,
Chris@34 1205 FILE *file,
Chris@34 1206 FLAC__StreamDecoderWriteCallback write_callback,
Chris@34 1207 FLAC__StreamDecoderMetadataCallback metadata_callback,
Chris@34 1208 FLAC__StreamDecoderErrorCallback error_callback,
Chris@34 1209 void *client_data
Chris@34 1210 );
Chris@34 1211
Chris@34 1212 /** Initialize the decoder instance to decode Ogg FLAC files.
Chris@34 1213 *
Chris@34 1214 * This flavor of initialization sets up the decoder to decode from a
Chris@34 1215 * plain Ogg FLAC file. For non-stdio streams, you must use
Chris@34 1216 * FLAC__stream_decoder_init_ogg_stream() and provide callbacks for the I/O.
Chris@34 1217 *
Chris@34 1218 * This function should be called after FLAC__stream_decoder_new() and
Chris@34 1219 * FLAC__stream_decoder_set_*() but before any of the
Chris@34 1220 * FLAC__stream_decoder_process_*() functions. Will set and return the
Chris@34 1221 * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
Chris@34 1222 * if initialization succeeded.
Chris@34 1223 *
Chris@34 1224 * \note Support for Ogg FLAC in the library is optional. If this
Chris@34 1225 * library has been built without support for Ogg FLAC, this function
Chris@34 1226 * will return \c FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER.
Chris@34 1227 *
Chris@34 1228 * \param decoder An uninitialized decoder instance.
Chris@34 1229 * \param file An open FLAC file. The file should have been
Chris@34 1230 * opened with mode \c "rb" and rewound. The file
Chris@34 1231 * becomes owned by the decoder and should not be
Chris@34 1232 * manipulated by the client while decoding.
Chris@34 1233 * Unless \a file is \c stdin, it will be closed
Chris@34 1234 * when FLAC__stream_decoder_finish() is called.
Chris@34 1235 * Note however that seeking will not work when
Chris@34 1236 * decoding from \c stdout since it is not seekable.
Chris@34 1237 * \param write_callback See FLAC__StreamDecoderWriteCallback. This
Chris@34 1238 * pointer must not be \c NULL.
Chris@34 1239 * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
Chris@34 1240 * pointer may be \c NULL if the callback is not
Chris@34 1241 * desired.
Chris@34 1242 * \param error_callback See FLAC__StreamDecoderErrorCallback. This
Chris@34 1243 * pointer must not be \c NULL.
Chris@34 1244 * \param client_data This value will be supplied to callbacks in their
Chris@34 1245 * \a client_data argument.
Chris@34 1246 * \assert
Chris@34 1247 * \code decoder != NULL \endcode
Chris@34 1248 * \code file != NULL \endcode
Chris@34 1249 * \retval FLAC__StreamDecoderInitStatus
Chris@34 1250 * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
Chris@34 1251 * see FLAC__StreamDecoderInitStatus for the meanings of other return values.
Chris@34 1252 */
Chris@34 1253 FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_FILE(
Chris@34 1254 FLAC__StreamDecoder *decoder,
Chris@34 1255 FILE *file,
Chris@34 1256 FLAC__StreamDecoderWriteCallback write_callback,
Chris@34 1257 FLAC__StreamDecoderMetadataCallback metadata_callback,
Chris@34 1258 FLAC__StreamDecoderErrorCallback error_callback,
Chris@34 1259 void *client_data
Chris@34 1260 );
Chris@34 1261
Chris@34 1262 /** Initialize the decoder instance to decode native FLAC files.
Chris@34 1263 *
Chris@34 1264 * This flavor of initialization sets up the decoder to decode from a plain
Chris@34 1265 * native FLAC file. If POSIX fopen() semantics are not sufficient, (for
Chris@34 1266 * example, with Unicode filenames on Windows), you must use
Chris@34 1267 * FLAC__stream_decoder_init_FILE(), or FLAC__stream_decoder_init_stream()
Chris@34 1268 * and provide callbacks for the I/O.
Chris@34 1269 *
Chris@34 1270 * This function should be called after FLAC__stream_decoder_new() and
Chris@34 1271 * FLAC__stream_decoder_set_*() but before any of the
Chris@34 1272 * FLAC__stream_decoder_process_*() functions. Will set and return the
Chris@34 1273 * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
Chris@34 1274 * if initialization succeeded.
Chris@34 1275 *
Chris@34 1276 * \param decoder An uninitialized decoder instance.
Chris@34 1277 * \param filename The name of the file to decode from. The file will
Chris@34 1278 * be opened with fopen(). Use \c NULL to decode from
Chris@34 1279 * \c stdin. Note that \c stdin is not seekable.
Chris@34 1280 * \param write_callback See FLAC__StreamDecoderWriteCallback. This
Chris@34 1281 * pointer must not be \c NULL.
Chris@34 1282 * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
Chris@34 1283 * pointer may be \c NULL if the callback is not
Chris@34 1284 * desired.
Chris@34 1285 * \param error_callback See FLAC__StreamDecoderErrorCallback. This
Chris@34 1286 * pointer must not be \c NULL.
Chris@34 1287 * \param client_data This value will be supplied to callbacks in their
Chris@34 1288 * \a client_data argument.
Chris@34 1289 * \assert
Chris@34 1290 * \code decoder != NULL \endcode
Chris@34 1291 * \retval FLAC__StreamDecoderInitStatus
Chris@34 1292 * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
Chris@34 1293 * see FLAC__StreamDecoderInitStatus for the meanings of other return values.
Chris@34 1294 */
Chris@34 1295 FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_file(
Chris@34 1296 FLAC__StreamDecoder *decoder,
Chris@34 1297 const char *filename,
Chris@34 1298 FLAC__StreamDecoderWriteCallback write_callback,
Chris@34 1299 FLAC__StreamDecoderMetadataCallback metadata_callback,
Chris@34 1300 FLAC__StreamDecoderErrorCallback error_callback,
Chris@34 1301 void *client_data
Chris@34 1302 );
Chris@34 1303
Chris@34 1304 /** Initialize the decoder instance to decode Ogg FLAC files.
Chris@34 1305 *
Chris@34 1306 * This flavor of initialization sets up the decoder to decode from a plain
Chris@34 1307 * Ogg FLAC file. If POSIX fopen() semantics are not sufficient, (for
Chris@34 1308 * example, with Unicode filenames on Windows), you must use
Chris@34 1309 * FLAC__stream_decoder_init_ogg_FILE(), or FLAC__stream_decoder_init_ogg_stream()
Chris@34 1310 * and provide callbacks for the I/O.
Chris@34 1311 *
Chris@34 1312 * This function should be called after FLAC__stream_decoder_new() and
Chris@34 1313 * FLAC__stream_decoder_set_*() but before any of the
Chris@34 1314 * FLAC__stream_decoder_process_*() functions. Will set and return the
Chris@34 1315 * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
Chris@34 1316 * if initialization succeeded.
Chris@34 1317 *
Chris@34 1318 * \note Support for Ogg FLAC in the library is optional. If this
Chris@34 1319 * library has been built without support for Ogg FLAC, this function
Chris@34 1320 * will return \c FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER.
Chris@34 1321 *
Chris@34 1322 * \param decoder An uninitialized decoder instance.
Chris@34 1323 * \param filename The name of the file to decode from. The file will
Chris@34 1324 * be opened with fopen(). Use \c NULL to decode from
Chris@34 1325 * \c stdin. Note that \c stdin is not seekable.
Chris@34 1326 * \param write_callback See FLAC__StreamDecoderWriteCallback. This
Chris@34 1327 * pointer must not be \c NULL.
Chris@34 1328 * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
Chris@34 1329 * pointer may be \c NULL if the callback is not
Chris@34 1330 * desired.
Chris@34 1331 * \param error_callback See FLAC__StreamDecoderErrorCallback. This
Chris@34 1332 * pointer must not be \c NULL.
Chris@34 1333 * \param client_data This value will be supplied to callbacks in their
Chris@34 1334 * \a client_data argument.
Chris@34 1335 * \assert
Chris@34 1336 * \code decoder != NULL \endcode
Chris@34 1337 * \retval FLAC__StreamDecoderInitStatus
Chris@34 1338 * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
Chris@34 1339 * see FLAC__StreamDecoderInitStatus for the meanings of other return values.
Chris@34 1340 */
Chris@34 1341 FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_file(
Chris@34 1342 FLAC__StreamDecoder *decoder,
Chris@34 1343 const char *filename,
Chris@34 1344 FLAC__StreamDecoderWriteCallback write_callback,
Chris@34 1345 FLAC__StreamDecoderMetadataCallback metadata_callback,
Chris@34 1346 FLAC__StreamDecoderErrorCallback error_callback,
Chris@34 1347 void *client_data
Chris@34 1348 );
Chris@34 1349
Chris@34 1350 /** Finish the decoding process.
Chris@34 1351 * Flushes the decoding buffer, releases resources, resets the decoder
Chris@34 1352 * settings to their defaults, and returns the decoder state to
Chris@34 1353 * FLAC__STREAM_DECODER_UNINITIALIZED.
Chris@34 1354 *
Chris@34 1355 * In the event of a prematurely-terminated decode, it is not strictly
Chris@34 1356 * necessary to call this immediately before FLAC__stream_decoder_delete()
Chris@34 1357 * but it is good practice to match every FLAC__stream_decoder_init_*()
Chris@34 1358 * with a FLAC__stream_decoder_finish().
Chris@34 1359 *
Chris@34 1360 * \param decoder An uninitialized decoder instance.
Chris@34 1361 * \assert
Chris@34 1362 * \code decoder != NULL \endcode
Chris@34 1363 * \retval FLAC__bool
Chris@34 1364 * \c false if MD5 checking is on AND a STREAMINFO block was available
Chris@34 1365 * AND the MD5 signature in the STREAMINFO block was non-zero AND the
Chris@34 1366 * signature does not match the one computed by the decoder; else
Chris@34 1367 * \c true.
Chris@34 1368 */
Chris@34 1369 FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder);
Chris@34 1370
Chris@34 1371 /** Flush the stream input.
Chris@34 1372 * The decoder's input buffer will be cleared and the state set to
Chris@34 1373 * \c FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC. This will also turn
Chris@34 1374 * off MD5 checking.
Chris@34 1375 *
Chris@34 1376 * \param decoder A decoder instance.
Chris@34 1377 * \assert
Chris@34 1378 * \code decoder != NULL \endcode
Chris@34 1379 * \retval FLAC__bool
Chris@34 1380 * \c true if successful, else \c false if a memory allocation
Chris@34 1381 * error occurs (in which case the state will be set to
Chris@34 1382 * \c FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR).
Chris@34 1383 */
Chris@34 1384 FLAC_API FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder);
Chris@34 1385
Chris@34 1386 /** Reset the decoding process.
Chris@34 1387 * The decoder's input buffer will be cleared and the state set to
Chris@34 1388 * \c FLAC__STREAM_DECODER_SEARCH_FOR_METADATA. This is similar to
Chris@34 1389 * FLAC__stream_decoder_finish() except that the settings are
Chris@34 1390 * preserved; there is no need to call FLAC__stream_decoder_init_*()
Chris@34 1391 * before decoding again. MD5 checking will be restored to its original
Chris@34 1392 * setting.
Chris@34 1393 *
Chris@34 1394 * If the decoder is seekable, or was initialized with
Chris@34 1395 * FLAC__stream_decoder_init*_FILE() or FLAC__stream_decoder_init*_file(),
Chris@34 1396 * the decoder will also attempt to seek to the beginning of the file.
Chris@34 1397 * If this rewind fails, this function will return \c false. It follows
Chris@34 1398 * that FLAC__stream_decoder_reset() cannot be used when decoding from
Chris@34 1399 * \c stdin.
Chris@34 1400 *
Chris@34 1401 * If the decoder was initialized with FLAC__stream_encoder_init*_stream()
Chris@34 1402 * and is not seekable (i.e. no seek callback was provided or the seek
Chris@34 1403 * callback returns \c FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED), it
Chris@34 1404 * is the duty of the client to start feeding data from the beginning of
Chris@34 1405 * the stream on the next FLAC__stream_decoder_process() or
Chris@34 1406 * FLAC__stream_decoder_process_interleaved() call.
Chris@34 1407 *
Chris@34 1408 * \param decoder A decoder instance.
Chris@34 1409 * \assert
Chris@34 1410 * \code decoder != NULL \endcode
Chris@34 1411 * \retval FLAC__bool
Chris@34 1412 * \c true if successful, else \c false if a memory allocation occurs
Chris@34 1413 * (in which case the state will be set to
Chris@34 1414 * \c FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR) or a seek error
Chris@34 1415 * occurs (the state will be unchanged).
Chris@34 1416 */
Chris@34 1417 FLAC_API FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder);
Chris@34 1418
Chris@34 1419 /** Decode one metadata block or audio frame.
Chris@34 1420 * This version instructs the decoder to decode a either a single metadata
Chris@34 1421 * block or a single frame and stop, unless the callbacks return a fatal
Chris@34 1422 * error or the read callback returns
Chris@34 1423 * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM.
Chris@34 1424 *
Chris@34 1425 * As the decoder needs more input it will call the read callback.
Chris@34 1426 * Depending on what was decoded, the metadata or write callback will be
Chris@34 1427 * called with the decoded metadata block or audio frame.
Chris@34 1428 *
Chris@34 1429 * Unless there is a fatal read error or end of stream, this function
Chris@34 1430 * will return once one whole frame is decoded. In other words, if the
Chris@34 1431 * stream is not synchronized or points to a corrupt frame header, the
Chris@34 1432 * decoder will continue to try and resync until it gets to a valid
Chris@34 1433 * frame, then decode one frame, then return. If the decoder points to
Chris@34 1434 * a frame whose frame CRC in the frame footer does not match the
Chris@34 1435 * computed frame CRC, this function will issue a
Chris@34 1436 * FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH error to the
Chris@34 1437 * error callback, and return, having decoded one complete, although
Chris@34 1438 * corrupt, frame. (Such corrupted frames are sent as silence of the
Chris@34 1439 * correct length to the write callback.)
Chris@34 1440 *
Chris@34 1441 * \param decoder An initialized decoder instance.
Chris@34 1442 * \assert
Chris@34 1443 * \code decoder != NULL \endcode
Chris@34 1444 * \retval FLAC__bool
Chris@34 1445 * \c false if any fatal read, write, or memory allocation error
Chris@34 1446 * occurred (meaning decoding must stop), else \c true; for more
Chris@34 1447 * information about the decoder, check the decoder state with
Chris@34 1448 * FLAC__stream_decoder_get_state().
Chris@34 1449 */
Chris@34 1450 FLAC_API FLAC__bool FLAC__stream_decoder_process_single(FLAC__StreamDecoder *decoder);
Chris@34 1451
Chris@34 1452 /** Decode until the end of the metadata.
Chris@34 1453 * This version instructs the decoder to decode from the current position
Chris@34 1454 * and continue until all the metadata has been read, or until the
Chris@34 1455 * callbacks return a fatal error or the read callback returns
Chris@34 1456 * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM.
Chris@34 1457 *
Chris@34 1458 * As the decoder needs more input it will call the read callback.
Chris@34 1459 * As each metadata block is decoded, the metadata callback will be called
Chris@34 1460 * with the decoded metadata.
Chris@34 1461 *
Chris@34 1462 * \param decoder An initialized decoder instance.
Chris@34 1463 * \assert
Chris@34 1464 * \code decoder != NULL \endcode
Chris@34 1465 * \retval FLAC__bool
Chris@34 1466 * \c false if any fatal read, write, or memory allocation error
Chris@34 1467 * occurred (meaning decoding must stop), else \c true; for more
Chris@34 1468 * information about the decoder, check the decoder state with
Chris@34 1469 * FLAC__stream_decoder_get_state().
Chris@34 1470 */
Chris@34 1471 FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_metadata(FLAC__StreamDecoder *decoder);
Chris@34 1472
Chris@34 1473 /** Decode until the end of the stream.
Chris@34 1474 * This version instructs the decoder to decode from the current position
Chris@34 1475 * and continue until the end of stream (the read callback returns
Chris@34 1476 * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM), or until the
Chris@34 1477 * callbacks return a fatal error.
Chris@34 1478 *
Chris@34 1479 * As the decoder needs more input it will call the read callback.
Chris@34 1480 * As each metadata block and frame is decoded, the metadata or write
Chris@34 1481 * callback will be called with the decoded metadata or frame.
Chris@34 1482 *
Chris@34 1483 * \param decoder An initialized decoder instance.
Chris@34 1484 * \assert
Chris@34 1485 * \code decoder != NULL \endcode
Chris@34 1486 * \retval FLAC__bool
Chris@34 1487 * \c false if any fatal read, write, or memory allocation error
Chris@34 1488 * occurred (meaning decoding must stop), else \c true; for more
Chris@34 1489 * information about the decoder, check the decoder state with
Chris@34 1490 * FLAC__stream_decoder_get_state().
Chris@34 1491 */
Chris@34 1492 FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_stream(FLAC__StreamDecoder *decoder);
Chris@34 1493
Chris@34 1494 /** Skip one audio frame.
Chris@34 1495 * This version instructs the decoder to 'skip' a single frame and stop,
Chris@34 1496 * unless the callbacks return a fatal error or the read callback returns
Chris@34 1497 * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM.
Chris@34 1498 *
Chris@34 1499 * The decoding flow is the same as what occurs when
Chris@34 1500 * FLAC__stream_decoder_process_single() is called to process an audio
Chris@34 1501 * frame, except that this function does not decode the parsed data into
Chris@34 1502 * PCM or call the write callback. The integrity of the frame is still
Chris@34 1503 * checked the same way as in the other process functions.
Chris@34 1504 *
Chris@34 1505 * This function will return once one whole frame is skipped, in the
Chris@34 1506 * same way that FLAC__stream_decoder_process_single() will return once
Chris@34 1507 * one whole frame is decoded.
Chris@34 1508 *
Chris@34 1509 * This function can be used in more quickly determining FLAC frame
Chris@34 1510 * boundaries when decoding of the actual data is not needed, for
Chris@34 1511 * example when an application is separating a FLAC stream into frames
Chris@34 1512 * for editing or storing in a container. To do this, the application
Chris@34 1513 * can use FLAC__stream_decoder_skip_single_frame() to quickly advance
Chris@34 1514 * to the next frame, then use
Chris@34 1515 * FLAC__stream_decoder_get_decode_position() to find the new frame
Chris@34 1516 * boundary.
Chris@34 1517 *
Chris@34 1518 * This function should only be called when the stream has advanced
Chris@34 1519 * past all the metadata, otherwise it will return \c false.
Chris@34 1520 *
Chris@34 1521 * \param decoder An initialized decoder instance not in a metadata
Chris@34 1522 * state.
Chris@34 1523 * \assert
Chris@34 1524 * \code decoder != NULL \endcode
Chris@34 1525 * \retval FLAC__bool
Chris@34 1526 * \c false if any fatal read, write, or memory allocation error
Chris@34 1527 * occurred (meaning decoding must stop), or if the decoder
Chris@34 1528 * is in the FLAC__STREAM_DECODER_SEARCH_FOR_METADATA or
Chris@34 1529 * FLAC__STREAM_DECODER_READ_METADATA state, else \c true; for more
Chris@34 1530 * information about the decoder, check the decoder state with
Chris@34 1531 * FLAC__stream_decoder_get_state().
Chris@34 1532 */
Chris@34 1533 FLAC_API FLAC__bool FLAC__stream_decoder_skip_single_frame(FLAC__StreamDecoder *decoder);
Chris@34 1534
Chris@34 1535 /** Flush the input and seek to an absolute sample.
Chris@34 1536 * Decoding will resume at the given sample. Note that because of
Chris@34 1537 * this, the next write callback may contain a partial block. The
Chris@34 1538 * client must support seeking the input or this function will fail
Chris@34 1539 * and return \c false. Furthermore, if the decoder state is
Chris@34 1540 * \c FLAC__STREAM_DECODER_SEEK_ERROR, then the decoder must be flushed
Chris@34 1541 * with FLAC__stream_decoder_flush() or reset with
Chris@34 1542 * FLAC__stream_decoder_reset() before decoding can continue.
Chris@34 1543 *
Chris@34 1544 * \param decoder A decoder instance.
Chris@34 1545 * \param sample The target sample number to seek to.
Chris@34 1546 * \assert
Chris@34 1547 * \code decoder != NULL \endcode
Chris@34 1548 * \retval FLAC__bool
Chris@34 1549 * \c true if successful, else \c false.
Chris@34 1550 */
Chris@34 1551 FLAC_API FLAC__bool FLAC__stream_decoder_seek_absolute(FLAC__StreamDecoder *decoder, FLAC__uint64 sample);
Chris@34 1552
Chris@34 1553 /* \} */
Chris@34 1554
Chris@34 1555 #ifdef __cplusplus
Chris@34 1556 }
Chris@34 1557 #endif
Chris@34 1558
Chris@34 1559 #endif