1 /* libFLAC - Free Lossless Audio Codec library
2 * Copyright (C) 2000,2001,2002 Josh Coalson
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef FLAC__SEEKABLE_STREAM_DECODER_H
21 #define FLAC__SEEKABLE_STREAM_DECODER_H
24 #include "stream_decoder.h"
31 /** \file include/FLAC/seekable_stream_decoder.h
34 * This module contains the functions which implement the seekable stream
37 * See the detailed documentation in the
38 * \link flac_seekable_stream_decoder seekable stream decoder \endlink module.
41 /** \defgroup flac_seekable_stream_decoder FLAC/seekable_stream_decoder.h: seekable stream decoder interface
42 * \ingroup flac_decoder
45 * This module contains the functions which implement the seekable stream
48 * The basic usage of this decoder is as follows:
49 * - The program creates an instance of a decoder using
50 * FLAC__seekable_stream_decoder_new().
51 * - The program overrides the default settings and sets callbacks for
52 * reading, writing, seeking, error reporting, and metadata reporting
53 * using FLAC__seekable_stream_decoder_set_*() functions.
54 * - The program initializes the instance to validate the settings and
55 * prepare for decoding using FLAC__seekable_stream_decoder_init().
56 * - The program calls the FLAC__seekable_stream_decoder_process_*()
57 * functions to decode data, which subsequently calls the callbacks.
58 * - The program finishes the decoding with
59 * FLAC__seekable_stream_decoder_finish(), which flushes the input and
60 * output and resets the decoder to the uninitialized state.
61 * - The instance may be used again or deleted with
62 * FLAC__seekable_stream_decoder_delete().
64 * The seekable stream decoder is a wrapper around the
65 * \link flac_stream_decoder stream decoder \endlink which also provides
66 * seeking capability. In addition to the Read/Write/Metadata/Error
67 * callbacks of the stream decoder, the user must also provide the following:
69 * - Seek callback - This function will be called when the decoder wants to
70 * seek to an absolute position in the stream.
71 * - Tell callback - This function will be called when the decoder wants to
72 * know the current absolute position of the stream.
73 * - Length callback - This function will be called when the decoder wants
74 * to know length of the stream. The seeking algorithm currently requires
75 * that the overall stream length be known.
76 * - EOF callback - This function will be called when the decoder wants to
77 * know if it is at the end of the stream. This could be synthesized from
78 * the tell and length callbacks but it may be more expensive that way, so
79 * there is a separate callback for it.
81 * Seeking is exposed through the
82 * FLAC__seekable_stream_decoder_seek_absolute() method. At any point after
83 * the seekable stream decoder has been initialized, the user can call this
84 * function to seek to an exact sample within the stream. Subsequently, the
85 * first time the write callback is called it will be passed a (possibly
86 * partial) block starting at that sample.
88 * The seekable stream decoder also provides MD5 signature checking. If
89 * this is turned on before initialization,
90 * FLAC__seekable_stream_decoder_finish() will report when the decoded MD5
91 * signature does not match the one stored in the STREAMINFO block. MD5
92 * checking is automatically turned off (until the next
93 * FLAC__seekable_stream_decoder_reset()) if there is no signature in the
94 * STREAMINFO block or when a seek is attempted.
96 * Make sure to read the detailed description of the
97 * \link flac_stream_decoder stream decoder module \endlink since the
98 * seekable stream decoder inherits much of its behavior.
101 * The "set" functions may only be called when the decoder is in the
102 * state FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED, i.e. after
103 * FLAC__seekable_stream_decoder_new() or
104 * FLAC__seekable_stream_decoder_finish(), but before
105 * FLAC__seekable_stream_decoder_init(). If this is the case they will
106 * return \c true, otherwise \c false.
109 * FLAC__stream_decoder_finish() resets all settings to the constructor
110 * defaults, including the callbacks.
116 /** State values for a FLAC__SeekableStreamDecoder
118 * The decoder's state can be obtained by calling FLAC__seekable_stream_decoder_get_state().
122 FLAC__SEEKABLE_STREAM_DECODER_OK = 0,
123 /**< The decoder is in the normal OK state. */
125 FLAC__SEEKABLE_STREAM_DECODER_SEEKING,
126 /**< The decoder is in the process of seeking. */
128 FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM,
129 /**< The decoder has reached the end of the stream. */
131 FLAC__SEEKABLE_STREAM_DECODER_MEMORY_ALLOCATION_ERROR,
132 /**< An error occurred allocating memory. */
134 FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR,
135 /**< An error occurred in the underlying stream decoder. */
137 FLAC__SEEKABLE_STREAM_DECODER_READ_ERROR,
138 /**< The read callback returned an error. */
140 FLAC__SEEKABLE_STREAM_DECODER_SEEK_ERROR,
141 /**< An error occurred while seeking or the seek or tell
142 * callback returned an error.
145 FLAC__SEEKABLE_STREAM_DECODER_ALREADY_INITIALIZED,
146 /**< FLAC__seekable_stream_decoder_init() was called when the
147 * decoder was already initialized, usually because
148 * FLAC__seekable_stream_decoder_finish() was not called.
151 FLAC__SEEKABLE_STREAM_DECODER_INVALID_CALLBACK,
152 /**< FLAC__seekable_stream_decoder_init() was called without all
153 * callbacks being set.
156 FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED
157 /**< The decoder is in the uninitialized state. */
159 } FLAC__SeekableStreamDecoderState;
161 /** Maps a FLAC__SeekableStreamDecoderState to a C string.
163 * Using a FLAC__SeekableStreamDecoderState as the index to this array
164 * will give the string equivalent. The contents should not be modified.
166 extern FLAC_API const char * const FLAC__SeekableStreamDecoderStateString[];
169 /** Return values for the FLAC__SeekableStreamDecoder read callback.
173 FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK,
174 /**< The read was OK and decoding can continue. */
176 FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR
177 /**< An unrecoverable error occurred. The decoder will return from the process call. */
179 } FLAC__SeekableStreamDecoderReadStatus;
181 /** Maps a FLAC__SeekableStreamDecoderReadStatus to a C string.
183 * Using a FLAC__SeekableStreamDecoderReadStatus as the index to this array
184 * will give the string equivalent. The contents should not be modified.
186 extern FLAC_API const char * const FLAC__SeekableStreamDecoderReadStatusString[];
189 /** Return values for the FLAC__SeekableStreamDecoder seek callback.
193 FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK,
194 /**< The seek was OK and decoding can continue. */
196 FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR
197 /**< An unrecoverable error occurred. The decoder will return from the process call. */
199 } FLAC__SeekableStreamDecoderSeekStatus;
201 /** Maps a FLAC__SeekableStreamDecoderSeekStatus to a C string.
203 * Using a FLAC__SeekableStreamDecoderSeekStatus as the index to this array
204 * will give the string equivalent. The contents should not be modified.
206 extern FLAC_API const char * const FLAC__SeekableStreamDecoderSeekStatusString[];
209 /** Return values for the FLAC__SeekableStreamDecoder tell callback.
213 FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK,
214 /**< The tell was OK and decoding can continue. */
216 FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR
217 /**< An unrecoverable error occurred. The decoder will return from the process call. */
219 } FLAC__SeekableStreamDecoderTellStatus;
221 /** Maps a FLAC__SeekableStreamDecoderTellStatus to a C string.
223 * Using a FLAC__SeekableStreamDecoderTellStatus as the index to this array
224 * will give the string equivalent. The contents should not be modified.
226 extern FLAC_API const char * const FLAC__SeekableStreamDecoderTellStatusString[];
229 /** Return values for the FLAC__SeekableStreamDecoder length callback.
233 FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK,
234 /**< The length call was OK and decoding can continue. */
236 FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR
237 /**< An unrecoverable error occurred. The decoder will return from the process call. */
239 } FLAC__SeekableStreamDecoderLengthStatus;
241 /** Maps a FLAC__SeekableStreamDecoderLengthStatus to a C string.
243 * Using a FLAC__SeekableStreamDecoderLengthStatus as the index to this array
244 * will give the string equivalent. The contents should not be modified.
246 extern FLAC_API const char * const FLAC__SeekableStreamDecoderLengthStatusString[];
249 /***********************************************************************
251 * class FLAC__SeekableStreamDecoder : public FLAC__StreamDecoder
253 ***********************************************************************/
255 struct FLAC__SeekableStreamDecoderProtected;
256 struct FLAC__SeekableStreamDecoderPrivate;
257 /** The opaque structure definition for the seekable stream decoder type.
259 * \link flac_seekable_stream_decoder seekable stream decoder module \endlink
260 * for a detailed description.
263 struct FLAC__SeekableStreamDecoderProtected *protected_; /* avoid the C++ keyword 'protected' */
264 struct FLAC__SeekableStreamDecoderPrivate *private_; /* avoid the C++ keyword 'private' */
265 } FLAC__SeekableStreamDecoder;
267 /** Signature for the read callback.
268 * See FLAC__seekable_stream_decoder_set_read_callback()
269 * and FLAC__StreamDecoderReadCallback for more info.
271 * \param decoder The decoder instance calling the callback.
272 * \param buffer A pointer to a location for the callee to store
273 * data to be decoded.
274 * \param bytes A pointer to the size of the buffer.
275 * \param client_data The callee's client data set through
276 * FLAC__seekable_stream_decoder_set_client_data().
277 * \retval FLAC__SeekableStreamDecoderReadStatus
278 * The callee's return status.
280 typedef FLAC__SeekableStreamDecoderReadStatus (*FLAC__SeekableStreamDecoderReadCallback)(const FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
282 /** Signature for the seek callback.
283 * See FLAC__seekable_stream_decoder_set_seek_callback() for more info.
285 * \param decoder The decoder instance calling the callback.
286 * \param absolute_byte_offset The offset from the beginning of the stream
288 * \param client_data The callee's client data set through
289 * FLAC__seekable_stream_decoder_set_client_data().
290 * \retval FLAC__SeekableStreamDecoderSeekStatus
291 * The callee's return status.
293 typedef FLAC__SeekableStreamDecoderSeekStatus (*FLAC__SeekableStreamDecoderSeekCallback)(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
295 /** Signature for the tell callback.
296 * See FLAC__seekable_stream_decoder_set_tell_callback() for more info.
298 * \param decoder The decoder instance calling the callback.
299 * \param absolute_byte_offset A pointer to storage for the current offset
300 * from the beginning of the stream.
301 * \param client_data The callee's client data set through
302 * FLAC__seekable_stream_decoder_set_client_data().
303 * \retval FLAC__SeekableStreamDecoderTellStatus
304 * The callee's return status.
306 typedef FLAC__SeekableStreamDecoderTellStatus (*FLAC__SeekableStreamDecoderTellCallback)(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
308 /** Signature for the length callback.
309 * See FLAC__seekable_stream_decoder_set_length_callback() for more info.
311 * \param decoder The decoder instance calling the callback.
312 * \param stream_length A pointer to storage for the length of the stream
314 * \param client_data The callee's client data set through
315 * FLAC__seekable_stream_decoder_set_client_data().
316 * \retval FLAC__SeekableStreamDecoderLengthStatus
317 * The callee's return status.
319 typedef FLAC__SeekableStreamDecoderLengthStatus (*FLAC__SeekableStreamDecoderLengthCallback)(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
321 /** Signature for the EOF callback.
322 * See FLAC__seekable_stream_decoder_set_eof_callback() for more info.
324 * \param decoder The decoder instance calling the callback.
325 * \param client_data The callee's client data set through
326 * FLAC__seekable_stream_decoder_set_client_data().
328 * \c true if the currently at the end of the stream, else \c false.
330 typedef FLAC__bool (*FLAC__SeekableStreamDecoderEofCallback)(const FLAC__SeekableStreamDecoder *decoder, void *client_data);
332 /** Signature for the write callback.
333 * See FLAC__seekable_stream_decoder_set_write_callback()
334 * and FLAC__StreamDecoderWriteCallback for more info.
336 * \param decoder The decoder instance calling the callback.
337 * \param frame The description of the decoded frame.
338 * \param buffer An array of pointers to decoded channels of data.
339 * \param client_data The callee's client data set through
340 * FLAC__seekable_stream_decoder_set_client_data().
341 * \retval FLAC__StreamDecoderWriteStatus
342 * The callee's return status.
344 typedef FLAC__StreamDecoderWriteStatus (*FLAC__SeekableStreamDecoderWriteCallback)(const FLAC__SeekableStreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
346 /** Signature for the metadata callback.
347 * See FLAC__seekable_stream_decoder_set_metadata_callback()
348 * and FLAC__StreamDecoderMetadataCallback for more info.
350 * \param decoder The decoder instance calling the callback.
351 * \param metadata The decoded metadata block.
352 * \param client_data The callee's client data set through
353 * FLAC__seekable_stream_decoder_set_client_data().
355 typedef void (*FLAC__SeekableStreamDecoderMetadataCallback)(const FLAC__SeekableStreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
357 /** Signature for the error callback.
358 * See FLAC__seekable_stream_decoder_set_error_callback()
359 * and FLAC__StreamDecoderErrorCallback for more info.
361 * \param decoder The decoder instance calling the callback.
362 * \param status The error encountered by the decoder.
363 * \param client_data The callee's client data set through
364 * FLAC__seekable_stream_decoder_set_client_data().
366 typedef void (*FLAC__SeekableStreamDecoderErrorCallback)(const FLAC__SeekableStreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
369 /***********************************************************************
371 * Class constructor/destructor
373 ***********************************************************************/
375 /** Create a new seekable stream decoder instance. The instance is created
376 * with default settings; see the individual
377 * FLAC__seekable_stream_decoder_set_*() functions for each setting's
380 * \retval FLAC__SeekableStreamDecoder*
381 * \c NULL if there was an error allocating memory, else the new instance.
383 FLAC_API FLAC__SeekableStreamDecoder *FLAC__seekable_stream_decoder_new();
385 /** Free a decoder instance. Deletes the object pointed to by \a decoder.
387 * \param decoder A pointer to an existing decoder.
389 * \code decoder != NULL \endcode
391 FLAC_API void FLAC__seekable_stream_decoder_delete(FLAC__SeekableStreamDecoder *decoder);
394 /***********************************************************************
396 * Public class method prototypes
398 ***********************************************************************/
400 /** Set the "MD5 signature checking" flag. If \c true, the decoder will
401 * compute the MD5 signature of the unencoded audio data while decoding
402 * and compare it to the signature from the STREAMINFO block, if it
403 * exists, during FLAC__seekable_stream_decoder_finish().
405 * MD5 signature checking will be turned off (until the next
406 * FLAC__seekable_stream_decoder_reset()) if there is no signature in
407 * the STREAMINFO block or when a seek is attempted.
410 * \param decoder A decoder instance to set.
411 * \param value Flag value (see above).
413 * \code decoder != NULL \endcode
415 * \c false if the decoder is already initialized, else \c true.
417 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_set_md5_checking(FLAC__SeekableStreamDecoder *decoder, FLAC__bool value);
419 /** Set the read callback.
420 * This is inherited from FLAC__StreamDecoder; see
421 * FLAC__stream_decoder_set_read_callback().
424 * The callback is mandatory and must be set before initialization.
427 * \param decoder A decoder instance to set.
428 * \param value See above.
430 * \code decoder != NULL \endcode
431 * \code value != NULL \endcode
433 * \c false if the decoder is already initialized, else \c true.
435 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_set_read_callback(FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderReadCallback value);
437 /** Set the seek callback.
438 * The supplied function will be called when the decoder needs to seek
439 * the input stream. The decoder will pass the absolute byte offset
440 * to seek to, 0 meaning the beginning of the stream.
443 * The callback is mandatory and must be set before initialization.
446 * \param decoder A decoder instance to set.
447 * \param value See above.
449 * \code decoder != NULL \endcode
450 * \code value != NULL \endcode
452 * \c false if the decoder is already initialized, else \c true.
454 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_set_seek_callback(FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderSeekCallback value);
456 /** Set the tell callback.
457 * The supplied function will be called when the decoder wants to know
458 * the current position of the stream. The callback should return the
459 * byte offset from the beginning of the stream.
462 * The callback is mandatory and must be set before initialization.
465 * \param decoder A decoder instance to set.
466 * \param value See above.
468 * \code decoder != NULL \endcode
469 * \code value != NULL \endcode
471 * \c false if the decoder is already initialized, else \c true.
473 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_set_tell_callback(FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderTellCallback value);
475 /** Set the length callback.
476 * The supplied function will be called when the decoder wants to know
477 * the total length of the stream in bytes.
480 * The callback is mandatory and must be set before initialization.
483 * \param decoder A decoder instance to set.
484 * \param value See above.
486 * \code decoder != NULL \endcode
487 * \code value != NULL \endcode
489 * \c false if the decoder is already initialized, else \c true.
491 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_set_length_callback(FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderLengthCallback value);
493 /** Set the eof callback.
494 * The supplied function will be called when the decoder needs to know
495 * if the end of the stream has been reached.
498 * The callback is mandatory and must be set before initialization.
501 * \param decoder A decoder instance to set.
502 * \param value See above.
504 * \code decoder != NULL \endcode
505 * \code value != NULL \endcode
507 * \c false if the decoder is already initialized, else \c true.
509 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_set_eof_callback(FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderEofCallback value);
511 /** Set the write callback.
512 * This is inherited from FLAC__StreamDecoder; see
513 * FLAC__stream_decoder_set_write_callback().
516 * The callback is mandatory and must be set before initialization.
519 * \param decoder A decoder instance to set.
520 * \param value See above.
522 * \code decoder != NULL \endcode
523 * \code value != NULL \endcode
525 * \c false if the decoder is already initialized, else \c true.
527 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_set_write_callback(FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderWriteCallback value);
529 /** Set the metadata callback.
530 * This is inherited from FLAC__StreamDecoder; see
531 * FLAC__stream_decoder_set_metadata_callback().
534 * The callback is mandatory and must be set before initialization.
537 * \param decoder A decoder instance to set.
538 * \param value See above.
540 * \code decoder != NULL \endcode
541 * \code value != NULL \endcode
543 * \c false if the decoder is already initialized, else \c true.
545 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_set_metadata_callback(FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderMetadataCallback value);
547 /** Set the error callback.
548 * This is inherited from FLAC__StreamDecoder; see
549 * FLAC__stream_decoder_set_error_callback().
552 * The callback is mandatory and must be set before initialization.
555 * \param decoder A decoder instance to set.
556 * \param value See above.
558 * \code decoder != NULL \endcode
559 * \code value != NULL \endcode
561 * \c false if the decoder is already initialized, else \c true.
563 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_set_error_callback(FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderErrorCallback value);
565 /** Set the client data to be passed back to callbacks.
566 * This value will be supplied to callbacks in their \a client_data
570 * \param decoder A decoder instance to set.
571 * \param value See above.
573 * \code decoder != NULL \endcode
575 * \c false if the decoder is already initialized, else \c true.
577 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_set_client_data(FLAC__SeekableStreamDecoder *decoder, void *value);
579 /** This is inherited from FLAC__StreamDecoder; see
580 * FLAC__stream_decoder_set_metadata_respond().
582 * \default By default, only the \c STREAMINFO block is returned via the
584 * \param decoder A decoder instance to set.
585 * \param type See above.
587 * \code decoder != NULL \endcode
590 * \c false if the decoder is already initialized, else \c true.
592 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_set_metadata_respond(FLAC__SeekableStreamDecoder *decoder, FLAC__MetadataType type);
594 /** This is inherited from FLAC__StreamDecoder; see
595 * FLAC__stream_decoder_set_metadata_respond_application().
597 * \default By default, only the \c STREAMINFO block is returned via the
599 * \param decoder A decoder instance to set.
600 * \param id See above.
602 * \code decoder != NULL \endcode
603 * \code id != NULL \endcode
605 * \c false if the decoder is already initialized, else \c true.
607 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_set_metadata_respond_application(FLAC__SeekableStreamDecoder *decoder, const FLAC__byte id[4]);
609 /** This is inherited from FLAC__StreamDecoder; see
610 * FLAC__stream_decoder_set_metadata_respond_all().
612 * \default By default, only the \c STREAMINFO block is returned via the
614 * \param decoder A decoder instance to set.
616 * \code decoder != NULL \endcode
618 * \c false if the decoder is already initialized, else \c true.
620 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_set_metadata_respond_all(FLAC__SeekableStreamDecoder *decoder);
622 /** This is inherited from FLAC__StreamDecoder; see
623 * FLAC__stream_decoder_set_metadata_ignore().
625 * \default By default, only the \c STREAMINFO block is returned via the
627 * \param decoder A decoder instance to set.
628 * \param type See above.
630 * \code decoder != NULL \endcode
633 * \c false if the decoder is already initialized, else \c true.
635 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_set_metadata_ignore(FLAC__SeekableStreamDecoder *decoder, FLAC__MetadataType type);
637 /** This is inherited from FLAC__StreamDecoder; see
638 * FLAC__stream_decoder_set_metadata_ignore_application().
640 * \default By default, only the \c STREAMINFO block is returned via the
642 * \param decoder A decoder instance to set.
643 * \param id See above.
645 * \code decoder != NULL \endcode
646 * \code id != NULL \endcode
648 * \c false if the decoder is already initialized, else \c true.
650 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_set_metadata_ignore_application(FLAC__SeekableStreamDecoder *decoder, const FLAC__byte id[4]);
652 /** This is inherited from FLAC__StreamDecoder; see
653 * FLAC__stream_decoder_set_metadata_ignore_all().
655 * \default By default, only the \c STREAMINFO block is returned via the
657 * \param decoder A decoder instance to set.
659 * \code decoder != NULL \endcode
661 * \c false if the decoder is already initialized, else \c true.
663 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_set_metadata_ignore_all(FLAC__SeekableStreamDecoder *decoder);
665 /** Get the current decoder state.
667 * \param decoder A decoder instance to query.
669 * \code decoder != NULL \endcode
670 * \retval FLAC__SeekableStreamDecoderState
671 * The current decoder state.
673 FLAC_API FLAC__SeekableStreamDecoderState FLAC__seekable_stream_decoder_get_state(const FLAC__SeekableStreamDecoder *decoder);
675 /** Get the state of the underlying stream decoder.
676 * Useful when the seekable stream decoder state is
677 * \c FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR.
679 * \param decoder A decoder instance to query.
681 * \code decoder != NULL \endcode
682 * \retval FLAC__StreamDecoderState
683 * The stream decoder state.
685 FLAC_API FLAC__StreamDecoderState FLAC__seekable_stream_decoder_get_stream_decoder_state(const FLAC__SeekableStreamDecoder *decoder);
687 /** Get the "MD5 signature checking" flag.
688 * This is the value of the setting, not whether or not the decoder is
689 * currently checking the MD5 (remember, it can be turned off automatically
690 * by a seek). When the decoder is reset the flag will be restored to the
691 * value returned by this function.
693 * \param decoder A decoder instance to query.
695 * \code decoder != NULL \endcode
699 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_get_md5_checking(const FLAC__SeekableStreamDecoder *decoder);
701 /** This is inherited from FLAC__StreamDecoder; see
702 * FLAC__stream_decoder_get_channels().
704 * \param decoder A decoder instance to query.
706 * \code decoder != NULL \endcode
710 FLAC_API unsigned FLAC__seekable_stream_decoder_get_channels(const FLAC__SeekableStreamDecoder *decoder);
712 /** This is inherited from FLAC__StreamDecoder; see
713 * FLAC__stream_decoder_get_channel_assignment().
715 * \param decoder A decoder instance to query.
717 * \code decoder != NULL \endcode
718 * \retval FLAC__ChannelAssignment
721 FLAC_API FLAC__ChannelAssignment FLAC__seekable_stream_decoder_get_channel_assignment(const FLAC__SeekableStreamDecoder *decoder);
723 /** This is inherited from FLAC__StreamDecoder; see
724 * FLAC__stream_decoder_get_bits_per_sample().
726 * \param decoder A decoder instance to query.
728 * \code decoder != NULL \endcode
732 FLAC_API unsigned FLAC__seekable_stream_decoder_get_bits_per_sample(const FLAC__SeekableStreamDecoder *decoder);
734 /** This is inherited from FLAC__StreamDecoder; see
735 * FLAC__stream_decoder_get_sample_rate().
737 * \param decoder A decoder instance to query.
739 * \code decoder != NULL \endcode
743 FLAC_API unsigned FLAC__seekable_stream_decoder_get_sample_rate(const FLAC__SeekableStreamDecoder *decoder);
745 /** This is inherited from FLAC__StreamDecoder; see
746 * FLAC__stream_decoder_get_blocksize().
748 * \param decoder A decoder instance to query.
750 * \code decoder != NULL \endcode
754 FLAC_API unsigned FLAC__seekable_stream_decoder_get_blocksize(const FLAC__SeekableStreamDecoder *decoder);
756 /** Initialize the decoder instance.
757 * Should be called after FLAC__seekable_stream_decoder_new() and
758 * FLAC__seekable_stream_decoder_set_*() but before any of the
759 * FLAC__seekable_stream_decoder_process_*() functions. Will set and return
760 * the decoder state, which will be FLAC__SEEKABLE_STREAM_DECODER_OK
761 * if initialization succeeded.
763 * \param decoder An uninitialized decoder instance.
765 * \code decoder != NULL \endcode
766 * \retval FLAC__SeekableStreamDecoderState
767 * \c FLAC__SEEKABLE_STREAM_DECODER_OK if initialization was
768 * successful; see FLAC__SeekableStreamDecoderState for the meanings
769 * of other return values.
771 FLAC_API FLAC__SeekableStreamDecoderState FLAC__seekable_stream_decoder_init(FLAC__SeekableStreamDecoder *decoder);
773 /** Finish the decoding process.
774 * Flushes the decoding buffer, releases resources, resets the decoder
775 * settings to their defaults, and returns the decoder state to
776 * FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED.
778 * In the event of a prematurely-terminated decode, it is not strictly
779 * necessary to call this immediately before
780 * FLAC__seekable_stream_decoder_delete() but it is good practice to match
781 * every FLAC__seekable_stream_decoder_init() with a
782 * FLAC__seekable_stream_decoder_finish().
784 * \param decoder An uninitialized decoder instance.
786 * \code decoder != NULL \endcode
788 * \c false if MD5 checking is on AND a STREAMINFO block was available
789 * AND the MD5 signature in the STREAMINFO block was non-zero AND the
790 * signature does not match the one computed by the decoder; else
793 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_finish(FLAC__SeekableStreamDecoder *decoder);
795 /** Flush the stream input.
796 * The decoder's input buffer will be cleared and the state set to
797 * \c FLAC__SEEKABLE_STREAM_DECODER_OK. This will also turn off MD5
800 * \param decoder A decoder instance.
802 * \code decoder != NULL \endcode
804 * \c true if successful, else \c false if a memory allocation
805 * or stream decoder error occurs.
807 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_flush(FLAC__SeekableStreamDecoder *decoder);
809 /** Reset the decoding process.
810 * The decoder's input buffer will be cleared and the state set to
811 * \c FLAC__SEEKABLE_STREAM_DECODER_OK. This is similar to
812 * FLAC__seekable_stream_decoder_finish() except that the settings are
813 * preserved; there is no need to call FLAC__seekable_stream_decoder_init()
814 * before decoding again. MD5 checking will be restored to its original
817 * \param decoder A decoder instance.
819 * \code decoder != NULL \endcode
821 * \c true if successful, else \c false if a memory allocation
822 * or stream decoder error occurs.
824 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_reset(FLAC__SeekableStreamDecoder *decoder);
826 /** This is inherited from FLAC__StreamDecoder; see
827 * FLAC__stream_decoder_process_single().
829 * \param decoder A decoder instance.
831 * \code decoder != NULL \endcode
835 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_process_single(FLAC__SeekableStreamDecoder *decoder);
837 /** This is inherited from FLAC__StreamDecoder; see
838 * FLAC__stream_decoder_process_until_end_of_metadata().
840 * \param decoder A decoder instance.
842 * \code decoder != NULL \endcode
846 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_process_until_end_of_metadata(FLAC__SeekableStreamDecoder *decoder);
848 /** This is inherited from FLAC__StreamDecoder; see
849 * FLAC__stream_decoder_process_until_end_of_stream().
851 * \param decoder A decoder instance.
853 * \code decoder != NULL \endcode
857 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_process_until_end_of_stream(FLAC__SeekableStreamDecoder *decoder);
859 /** Flush the input and seek to an absolute sample.
860 * Decoding will resume at the given sample. Note that because of
861 * this, the next write callback may contain a partial block.
863 * \param decoder A decoder instance.
864 * \param sample The target sample number to seek to.
866 * \code decoder != NULL \endcode
868 * \c true if successful, else \c false.
870 FLAC_API FLAC__bool FLAC__seekable_stream_decoder_seek_absolute(FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 sample);