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
23 #include "stream_decoder.h"
30 /** \file include/FLAC/seekable_stream_decoder.h
33 * This module contains the functions which implement the seekable stream
36 * See the detailed documentation in the
37 * \link flac_seekable_stream_decoder seekable stream decoder \endlink module.
40 /** \defgroup flac_seekable_stream_decoder FLAC/seekable_stream_decoder.h: seekable stream decoder interface
41 * \ingroup flac_decoder
44 * This module contains the functions which implement the seekable stream
47 * The basic usage of this decoder is as follows:
48 * - The program creates an instance of a decoder using
49 * FLAC__seekable_stream_decoder_new().
50 * - The program overrides the default settings and sets callbacks for
51 * reading, writing, seeking, error reporting, and metadata reporting
52 * using FLAC__seekable_stream_decoder_set_*() functions.
53 * - The program initializes the instance to validate the settings and
54 * prepare for decoding using FLAC__seekable_stream_decoder_init().
55 * - The program calls the FLAC__seekable_stream_decoder_process_*()
56 * functions to decode data, which subsequently calls the callbacks.
57 * - The program finishes the decoding with
58 * FLAC__seekable_stream_decoder_finish(), which flushes the input and
59 * output and resets the decoder to the uninitialized state.
60 * - The instance may be used again or deleted with
61 * FLAC__seekable_stream_decoder_delete().
63 * The seekable stream decoder is a wrapper around the
64 * \link flac_stream_decoder stream decoder \endlink which also provides
65 * seeking capability. In addition to the Read/Write/Metadata/Error
66 * callbacks of the stream decoder, the user must also provide the following:
68 * - Seek callback - This function will be called when the decoder wants to
69 * seek to an absolute position in the stream.
70 * - Tell callback - This function will be called when the decoder wants to
71 * know the current absolute position of the stream.
72 * - Length callback - This function will be called when the decoder wants
73 * to know length of the stream. The seeking algorithm currently requires
74 * that the overall stream length be known.
75 * - EOF callback - This function will be called when the decoder wants to
76 * know if it is at the end of the stream. This could be synthesized from
77 * the tell and length callbacks but it may be more expensive that way, so
78 * there is a separate callback for it.
80 * Seeking is exposed through the
81 * FLAC__seekable_stream_decoder_seek_absolute() method. At any point after
82 * the seekable stream decoder has been initialized, the user can call this
83 * function to seek to an exact sample within the stream. Subsequently, the
84 * first time the write callback is called it will be passed a (possibly
85 * partial) block starting at that sample.
87 * The seekable stream decoder also provides MD5 signature checking. If
88 * this is turned on before initialization,
89 * FLAC__seekable_stream_decoder_finish() will report when the decoded MD5
90 * signature does not match the one stored in the STREAMINFO block. MD5
91 * checking is automatically turned off (until the next
92 * FLAC__seekable_stream_decoder_reset()) if there is no signature in the
93 * STREAMINFO block or when a seek is attempted.
95 * Make sure to read the detailed description of the
96 * \link flac_stream_decoder stream decoder module \endlink since the
97 * seekable stream decoder inherits much of its behavior.
100 * The "set" functions may only be called when the decoder is in the
101 * state FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED, i.e. after
102 * FLAC__seekable_stream_decoder_new() or
103 * FLAC__seekable_stream_decoder_finish(), but before
104 * FLAC__seekable_stream_decoder_init(). If this is the case they will
105 * return \c true, otherwise \c false.
108 * FLAC__stream_decoder_finish() resets all settings to the constructor
109 * defaults, including the callbacks.
115 /** State values for a FLAC__SeekableStreamDecoder
117 * The decoder's state can be obtained by calling FLAC__seekable_stream_decoder_get_state().
121 FLAC__SEEKABLE_STREAM_DECODER_OK = 0,
122 /**< The decoder is in the normal OK state. */
124 FLAC__SEEKABLE_STREAM_DECODER_SEEKING,
125 /**< The decoder is in the process of seeking. */
127 FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM,
128 /**< The decoder has reached the end of the stream. */
130 FLAC__SEEKABLE_STREAM_DECODER_MEMORY_ALLOCATION_ERROR,
131 /**< An error occurred allocating memory. */
133 FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR,
134 /**< An error occurred in the underlying stream decoder. */
136 FLAC__SEEKABLE_STREAM_DECODER_READ_ERROR,
137 /**< The read callback returned an error. */
139 FLAC__SEEKABLE_STREAM_DECODER_SEEK_ERROR,
140 /**< An error occurred while seeking or the seek or tell
141 * callback returned an error.
144 FLAC__SEEKABLE_STREAM_DECODER_ALREADY_INITIALIZED,
145 /**< FLAC__seekable_stream_decoder_init() was called when the
146 * decoder was already initialized, usually because
147 * FLAC__seekable_stream_decoder_finish() was not called.
150 FLAC__SEEKABLE_STREAM_DECODER_INVALID_CALLBACK,
151 /**< FLAC__seekable_stream_decoder_init() was called without all
152 * callbacks being set.
155 FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED
156 /**< The decoder is in the uninitialized state. */
158 } FLAC__SeekableStreamDecoderState;
160 /** Maps a FLAC__SeekableStreamDecoderState to a C string.
162 * Using a FLAC__SeekableStreamDecoderState as the index to this array
163 * will give the string equivalent. The contents should not be modified.
165 extern const char * const FLAC__SeekableStreamDecoderStateString[];
168 /** Return values for the FLAC__SeekableStreamDecoder read callback.
172 FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK,
173 /**< The read was OK and decoding can continue. */
175 FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR
176 /**< An unrecoverable error occurred. The decoder will return from the process call. */
178 } FLAC__SeekableStreamDecoderReadStatus;
180 /** Maps a FLAC__SeekableStreamDecoderReadStatus to a C string.
182 * Using a FLAC__SeekableStreamDecoderReadStatus as the index to this array
183 * will give the string equivalent. The contents should not be modified.
185 extern const char * const FLAC__SeekableStreamDecoderReadStatusString[];
188 /** Return values for the FLAC__SeekableStreamDecoder seek callback.
192 FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK,
193 /**< The seek was OK and decoding can continue. */
195 FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR
196 /**< An unrecoverable error occurred. The decoder will return from the process call. */
198 } FLAC__SeekableStreamDecoderSeekStatus;
200 /** Maps a FLAC__SeekableStreamDecoderSeekStatus to a C string.
202 * Using a FLAC__SeekableStreamDecoderSeekStatus as the index to this array
203 * will give the string equivalent. The contents should not be modified.
205 extern const char * const FLAC__SeekableStreamDecoderSeekStatusString[];
208 /** Return values for the FLAC__SeekableStreamDecoder tell callback.
212 FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK,
213 /**< The tell was OK and decoding can continue. */
215 FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR
216 /**< An unrecoverable error occurred. The decoder will return from the process call. */
218 } FLAC__SeekableStreamDecoderTellStatus;
220 /** Maps a FLAC__SeekableStreamDecoderTellStatus to a C string.
222 * Using a FLAC__SeekableStreamDecoderTellStatus as the index to this array
223 * will give the string equivalent. The contents should not be modified.
225 extern const char * const FLAC__SeekableStreamDecoderTellStatusString[];
228 /** Return values for the FLAC__SeekableStreamDecoder length callback.
232 FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK,
233 /**< The length call was OK and decoding can continue. */
235 FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR
236 /**< An unrecoverable error occurred. The decoder will return from the process call. */
238 } FLAC__SeekableStreamDecoderLengthStatus;
240 /** Maps a FLAC__SeekableStreamDecoderLengthStatus to a C string.
242 * Using a FLAC__SeekableStreamDecoderLengthStatus as the index to this array
243 * will give the string equivalent. The contents should not be modified.
245 extern const char * const FLAC__SeekableStreamDecoderLengthStatusString[];
248 /***********************************************************************
250 * class FLAC__SeekableStreamDecoder : public FLAC__StreamDecoder
252 ***********************************************************************/
254 struct FLAC__SeekableStreamDecoderProtected;
255 struct FLAC__SeekableStreamDecoderPrivate;
256 /** The opaque structure definition for the seekable stream decoder type.
258 * \link flac_seekable_stream_decoder seekable stream decoder module \endlink
259 * for a detailed description.
262 struct FLAC__SeekableStreamDecoderProtected *protected_; /* avoid the C++ keyword 'protected' */
263 struct FLAC__SeekableStreamDecoderPrivate *private_; /* avoid the C++ keyword 'private' */
264 } FLAC__SeekableStreamDecoder;
266 /** Signature for the read callback.
267 * See FLAC__seekable_stream_decoder_set_read_callback()
268 * and FLAC__StreamDecoderReadCallback for more info.
270 * \param decoder The decoder instance calling the callback.
271 * \param buffer A pointer to a location for the callee to store
272 * data to be decoded.
273 * \param bytes A pointer to the size of the buffer.
274 * \param client_data The callee's client data set through
275 * FLAC__seekable_stream_decoder_set_client_data().
276 * \retval FLAC__SeekableStreamDecoderReadStatus
277 * The callee's return status.
279 typedef FLAC__SeekableStreamDecoderReadStatus (*FLAC__SeekableStreamDecoderReadCallback)(const FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
281 /** Signature for the seek callback.
282 * See FLAC__seekable_stream_decoder_set_seek_callback() for more info.
284 * \param decoder The decoder instance calling the callback.
285 * \param absolute_byte_offset The offset from the beginning of the stream
287 * \param client_data The callee's client data set through
288 * FLAC__seekable_stream_decoder_set_client_data().
289 * \retval FLAC__SeekableStreamDecoderSeekStatus
290 * The callee's return status.
292 typedef FLAC__SeekableStreamDecoderSeekStatus (*FLAC__SeekableStreamDecoderSeekCallback)(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
294 /** Signature for the tell callback.
295 * See FLAC__seekable_stream_decoder_set_tell_callback() for more info.
297 * \param decoder The decoder instance calling the callback.
298 * \param absolute_byte_offset A pointer to storage for the current offset
299 * from the beginning of the stream.
300 * \param client_data The callee's client data set through
301 * FLAC__seekable_stream_decoder_set_client_data().
302 * \retval FLAC__SeekableStreamDecoderTellStatus
303 * The callee's return status.
305 typedef FLAC__SeekableStreamDecoderTellStatus (*FLAC__SeekableStreamDecoderTellCallback)(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
307 /** Signature for the length callback.
308 * See FLAC__seekable_stream_decoder_set_length_callback() for more info.
310 * \param decoder The decoder instance calling the callback.
311 * \param stream_length A pointer to storage for the length of the stream
313 * \param client_data The callee's client data set through
314 * FLAC__seekable_stream_decoder_set_client_data().
315 * \retval FLAC__SeekableStreamDecoderLengthStatus
316 * The callee's return status.
318 typedef FLAC__SeekableStreamDecoderLengthStatus (*FLAC__SeekableStreamDecoderLengthCallback)(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
320 /** Signature for the EOF callback.
321 * See FLAC__seekable_stream_decoder_set_eof_callback() for more info.
323 * \param decoder The decoder instance calling the callback.
324 * \param client_data The callee's client data set through
325 * FLAC__seekable_stream_decoder_set_client_data().
327 * \c true if the currently at the end of the stream, else \c false.
329 typedef FLAC__bool (*FLAC__SeekableStreamDecoderEofCallback)(const FLAC__SeekableStreamDecoder *decoder, void *client_data);
331 /** Signature for the write callback.
332 * See FLAC__seekable_stream_decoder_set_write_callback()
333 * and FLAC__StreamDecoderWriteCallback for more info.
335 * \param decoder The decoder instance calling the callback.
336 * \param frame The description of the decoded frame.
337 * \param buffer An array of pointers to decoded channels of data.
338 * \param client_data The callee's client data set through
339 * FLAC__seekable_stream_decoder_set_client_data().
340 * \retval FLAC__StreamDecoderWriteStatus
341 * The callee's return status.
343 typedef FLAC__StreamDecoderWriteStatus (*FLAC__SeekableStreamDecoderWriteCallback)(const FLAC__SeekableStreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
345 /** Signature for the metadata callback.
346 * See FLAC__seekable_stream_decoder_set_metadata_callback()
347 * and FLAC__StreamDecoderMetadataCallback for more info.
349 * \param decoder The decoder instance calling the callback.
350 * \param metadata The decoded metadata block.
351 * \param client_data The callee's client data set through
352 * FLAC__seekable_stream_decoder_set_client_data().
354 typedef void (*FLAC__SeekableStreamDecoderMetadataCallback)(const FLAC__SeekableStreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
356 /** Signature for the error callback.
357 * See FLAC__seekable_stream_decoder_set_error_callback()
358 * and FLAC__StreamDecoderErrorCallback for more info.
360 * \param decoder The decoder instance calling the callback.
361 * \param status The error encountered by the decoder.
362 * \param client_data The callee's client data set through
363 * FLAC__seekable_stream_decoder_set_client_data().
365 typedef void (*FLAC__SeekableStreamDecoderErrorCallback)(const FLAC__SeekableStreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
368 /***********************************************************************
370 * Class constructor/destructor
372 ***********************************************************************/
374 /** Create a new seekable stream decoder instance. The instance is created
375 * with default settings; see the individual
376 * FLAC__seekable_stream_decoder_set_*() functions for each setting's
379 * \retval FLAC__SeekableStreamDecoder*
380 * \c NULL if there was an error allocating memory, else the new instance.
382 FLAC__SeekableStreamDecoder *FLAC__seekable_stream_decoder_new();
384 /** Free a decoder instance. Deletes the object pointed to by \a decoder.
386 * \param decoder A pointer to an existing decoder.
388 * \code decoder != NULL \endcode
390 void FLAC__seekable_stream_decoder_delete(FLAC__SeekableStreamDecoder *decoder);
393 /***********************************************************************
395 * Public class method prototypes
397 ***********************************************************************/
399 /** Set the "MD5 signature checking" flag. If \c true, the decoder will
400 * compute the MD5 signature of the unencoded audio data while decoding
401 * and compare it to the signature from the STREAMINFO block, if it
402 * exists, during FLAC__seekable_stream_decoder_finish().
404 * MD5 signature checking will be turned off (until the next
405 * FLAC__seekable_stream_decoder_reset()) if there is no signature in
406 * the STREAMINFO block or when a seek is attempted.
409 * \param decoder A decoder instance to set.
410 * \param value Flag value (see above).
412 * \code decoder != NULL \endcode
414 * \c false if the decoder is already initialized, else \c true.
416 FLAC__bool FLAC__seekable_stream_decoder_set_md5_checking(FLAC__SeekableStreamDecoder *decoder, FLAC__bool value);
418 /** Set the read callback.
419 * This is inherited from FLAC__StreamDecoder; see
420 * FLAC__stream_decoder_set_read_callback().
423 * The callback is mandatory and must be set before initialization.
426 * \param decoder A decoder instance to set.
427 * \param value See above.
429 * \code decoder != NULL \endcode
430 * \code value != NULL \endcode
432 * \c false if the decoder is already initialized, else \c true.
434 FLAC__bool FLAC__seekable_stream_decoder_set_read_callback(FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderReadCallback value);
436 /** Set the seek callback.
437 * The supplied function will be called when the decoder needs to seek
438 * the input stream. The decoder will pass the absolute byte offset
439 * to seek to, 0 meaning the beginning of the stream.
442 * The callback is mandatory and must be set before initialization.
445 * \param decoder A decoder instance to set.
446 * \param value See above.
448 * \code decoder != NULL \endcode
449 * \code value != NULL \endcode
451 * \c false if the decoder is already initialized, else \c true.
453 FLAC__bool FLAC__seekable_stream_decoder_set_seek_callback(FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderSeekCallback value);
455 /** Set the tell callback.
456 * The supplied function will be called when the decoder wants to know
457 * the current position of the stream. The callback should return the
458 * byte offset from the beginning of the stream.
461 * The callback is mandatory and must be set before initialization.
464 * \param decoder A decoder instance to set.
465 * \param value See above.
467 * \code decoder != NULL \endcode
468 * \code value != NULL \endcode
470 * \c false if the decoder is already initialized, else \c true.
472 FLAC__bool FLAC__seekable_stream_decoder_set_tell_callback(FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderTellCallback value);
474 /** Set the length callback.
475 * The supplied function will be called when the decoder wants to know
476 * the total length of the stream in bytes.
479 * The callback is mandatory and must be set before initialization.
482 * \param decoder A decoder instance to set.
483 * \param value See above.
485 * \code decoder != NULL \endcode
486 * \code value != NULL \endcode
488 * \c false if the decoder is already initialized, else \c true.
490 FLAC__bool FLAC__seekable_stream_decoder_set_length_callback(FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderLengthCallback value);
492 /** Set the eof callback.
493 * The supplied function will be called when the decoder needs to know
494 * if the end of the stream has been reached.
497 * The callback is mandatory and must be set before initialization.
500 * \param decoder A decoder instance to set.
501 * \param value See above.
503 * \code decoder != NULL \endcode
504 * \code value != NULL \endcode
506 * \c false if the decoder is already initialized, else \c true.
508 FLAC__bool FLAC__seekable_stream_decoder_set_eof_callback(FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderEofCallback value);
510 /** Set the write callback.
511 * This is inherited from FLAC__StreamDecoder; see
512 * FLAC__stream_decoder_set_write_callback().
515 * The callback is mandatory and must be set before initialization.
518 * \param decoder A decoder instance to set.
519 * \param value See above.
521 * \code decoder != NULL \endcode
522 * \code value != NULL \endcode
524 * \c false if the decoder is already initialized, else \c true.
526 FLAC__bool FLAC__seekable_stream_decoder_set_write_callback(FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderWriteCallback value);
528 /** Set the metadata callback.
529 * This is inherited from FLAC__StreamDecoder; see
530 * FLAC__stream_decoder_set_metadata_callback().
533 * The callback is mandatory and must be set before initialization.
536 * \param decoder A decoder instance to set.
537 * \param value See above.
539 * \code decoder != NULL \endcode
540 * \code value != NULL \endcode
542 * \c false if the decoder is already initialized, else \c true.
544 FLAC__bool FLAC__seekable_stream_decoder_set_metadata_callback(FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderMetadataCallback value);
546 /** Set the error callback.
547 * This is inherited from FLAC__StreamDecoder; see
548 * FLAC__stream_decoder_set_error_callback().
551 * The callback is mandatory and must be set before initialization.
554 * \param decoder A decoder instance to set.
555 * \param value See above.
557 * \code decoder != NULL \endcode
558 * \code value != NULL \endcode
560 * \c false if the decoder is already initialized, else \c true.
562 FLAC__bool FLAC__seekable_stream_decoder_set_error_callback(FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderErrorCallback value);
564 /** Set the client data to be passed back to callbacks.
565 * This value will be supplied to callbacks in their \a client_data
569 * \param decoder A decoder instance to set.
570 * \param value See above.
572 * \code decoder != NULL \endcode
574 * \c false if the decoder is already initialized, else \c true.
576 FLAC__bool FLAC__seekable_stream_decoder_set_client_data(FLAC__SeekableStreamDecoder *decoder, void *value);
578 /** This is inherited from FLAC__StreamDecoder; see
579 * FLAC__stream_decoder_set_metadata_respond().
581 * \default By default, only the \c STREAMINFO block is returned via the
583 * \param decoder A decoder instance to set.
584 * \param type See above.
586 * \code decoder != NULL \endcode
589 * \c false if the decoder is already initialized, else \c true.
591 FLAC__bool FLAC__seekable_stream_decoder_set_metadata_respond(FLAC__SeekableStreamDecoder *decoder, FLAC__MetadataType type);
593 /** This is inherited from FLAC__StreamDecoder; see
594 * FLAC__stream_decoder_set_metadata_respond_application().
596 * \default By default, only the \c STREAMINFO block is returned via the
598 * \param decoder A decoder instance to set.
599 * \param id See above.
601 * \code decoder != NULL \endcode
602 * \code id != NULL \endcode
604 * \c false if the decoder is already initialized, else \c true.
606 FLAC__bool FLAC__seekable_stream_decoder_set_metadata_respond_application(FLAC__SeekableStreamDecoder *decoder, const FLAC__byte id[4]);
608 /** This is inherited from FLAC__StreamDecoder; see
609 * FLAC__stream_decoder_set_metadata_respond_all().
611 * \default By default, only the \c STREAMINFO block is returned via the
613 * \param decoder A decoder instance to set.
615 * \code decoder != NULL \endcode
617 * \c false if the decoder is already initialized, else \c true.
619 FLAC__bool FLAC__seekable_stream_decoder_set_metadata_respond_all(FLAC__SeekableStreamDecoder *decoder);
621 /** This is inherited from FLAC__StreamDecoder; see
622 * FLAC__stream_decoder_set_metadata_ignore().
624 * \default By default, only the \c STREAMINFO block is returned via the
626 * \param decoder A decoder instance to set.
627 * \param type See above.
629 * \code decoder != NULL \endcode
632 * \c false if the decoder is already initialized, else \c true.
634 FLAC__bool FLAC__seekable_stream_decoder_set_metadata_ignore(FLAC__SeekableStreamDecoder *decoder, FLAC__MetadataType type);
636 /** This is inherited from FLAC__StreamDecoder; see
637 * FLAC__stream_decoder_set_metadata_ignore_application().
639 * \default By default, only the \c STREAMINFO block is returned via the
641 * \param decoder A decoder instance to set.
642 * \param id See above.
644 * \code decoder != NULL \endcode
645 * \code id != NULL \endcode
647 * \c false if the decoder is already initialized, else \c true.
649 FLAC__bool FLAC__seekable_stream_decoder_set_metadata_ignore_application(FLAC__SeekableStreamDecoder *decoder, const FLAC__byte id[4]);
651 /** This is inherited from FLAC__StreamDecoder; see
652 * FLAC__stream_decoder_set_metadata_ignore_all().
654 * \default By default, only the \c STREAMINFO block is returned via the
656 * \param decoder A decoder instance to set.
658 * \code decoder != NULL \endcode
660 * \c false if the decoder is already initialized, else \c true.
662 FLAC__bool FLAC__seekable_stream_decoder_set_metadata_ignore_all(FLAC__SeekableStreamDecoder *decoder);
664 /** Get the current decoder state.
666 * \param decoder A decoder instance to query.
668 * \code decoder != NULL \endcode
669 * \retval FLAC__SeekableStreamDecoderState
670 * The current decoder state.
672 FLAC__SeekableStreamDecoderState FLAC__seekable_stream_decoder_get_state(const FLAC__SeekableStreamDecoder *decoder);
674 /** Get the state of the underlying stream decoder.
675 * Useful when the seekable stream decoder state is
676 * \c FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR.
678 * \param decoder A decoder instance to query.
680 * \code decoder != NULL \endcode
681 * \retval FLAC__StreamDecoderState
682 * The stream decoder state.
684 FLAC__StreamDecoderState FLAC__seekable_stream_decoder_get_stream_decoder_state(const FLAC__SeekableStreamDecoder *decoder);
686 /** Get the "MD5 signature checking" flag.
687 * This is the value of the setting, not whether or not the decoder is
688 * currently checking the MD5 (remember, it can be turned off automatically
689 * by a seek). When the decoder is reset the flag will be restored to the
690 * value returned by this function.
692 * \param decoder A decoder instance to query.
694 * \code decoder != NULL \endcode
698 FLAC__bool FLAC__seekable_stream_decoder_get_md5_checking(const FLAC__SeekableStreamDecoder *decoder);
700 /** This is inherited from FLAC__StreamDecoder; see
701 * FLAC__stream_decoder_get_channels().
703 * \param decoder A decoder instance to query.
705 * \code decoder != NULL \endcode
709 unsigned FLAC__seekable_stream_decoder_get_channels(const FLAC__SeekableStreamDecoder *decoder);
711 /** This is inherited from FLAC__StreamDecoder; see
712 * FLAC__stream_decoder_get_channel_assignment().
714 * \param decoder A decoder instance to query.
716 * \code decoder != NULL \endcode
717 * \retval FLAC__ChannelAssignment
720 FLAC__ChannelAssignment FLAC__seekable_stream_decoder_get_channel_assignment(const FLAC__SeekableStreamDecoder *decoder);
722 /** This is inherited from FLAC__StreamDecoder; see
723 * FLAC__stream_decoder_get_bits_per_sample().
725 * \param decoder A decoder instance to query.
727 * \code decoder != NULL \endcode
731 unsigned FLAC__seekable_stream_decoder_get_bits_per_sample(const FLAC__SeekableStreamDecoder *decoder);
733 /** This is inherited from FLAC__StreamDecoder; see
734 * FLAC__stream_decoder_get_sample_rate().
736 * \param decoder A decoder instance to query.
738 * \code decoder != NULL \endcode
742 unsigned FLAC__seekable_stream_decoder_get_sample_rate(const FLAC__SeekableStreamDecoder *decoder);
744 /** This is inherited from FLAC__StreamDecoder; see
745 * FLAC__stream_decoder_get_blocksize().
747 * \param decoder A decoder instance to query.
749 * \code decoder != NULL \endcode
753 unsigned FLAC__seekable_stream_decoder_get_blocksize(const FLAC__SeekableStreamDecoder *decoder);
755 /** Initialize the decoder instance.
756 * Should be called after FLAC__seekable_stream_decoder_new() and
757 * FLAC__seekable_stream_decoder_set_*() but before any of the
758 * FLAC__seekable_stream_decoder_process_*() functions. Will set and return
759 * the decoder state, which will be FLAC__SEEKABLE_STREAM_DECODER_OK
760 * if initialization succeeded.
762 * \param decoder An uninitialized decoder instance.
764 * \code decoder != NULL \endcode
765 * \retval FLAC__SeekableStreamDecoderState
766 * \c FLAC__SEEKABLE_STREAM_DECODER_OK if initialization was
767 * successful; see FLAC__SeekableStreamDecoderState for the meanings
768 * of other return values.
770 FLAC__SeekableStreamDecoderState FLAC__seekable_stream_decoder_init(FLAC__SeekableStreamDecoder *decoder);
772 /** Finish the decoding process.
773 * Flushes the decoding buffer, releases resources, resets the decoder
774 * settings to their defaults, and returns the decoder state to
775 * FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED.
777 * In the event of a prematurely-terminated decode, it is not strictly
778 * necessary to call this immediately before
779 * FLAC__seekable_stream_decoder_delete() but it is good practice to match
780 * every FLAC__seekable_stream_decoder_init() with a
781 * FLAC__seekable_stream_decoder_finish().
783 * \param decoder An uninitialized decoder instance.
785 * \code decoder != NULL \endcode
787 * \c false if MD5 checking is on AND a STREAMINFO block was available
788 * AND the MD5 signature in the STREAMINFO block was non-zero AND the
789 * signature does not match the one computed by the decoder; else
792 FLAC__bool FLAC__seekable_stream_decoder_finish(FLAC__SeekableStreamDecoder *decoder);
794 /** Flush the stream input.
795 * The decoder's input buffer will be cleared and the state set to
796 * \c FLAC__SEEKABLE_STREAM_DECODER_OK. This will also turn off MD5
799 * \param decoder A decoder instance.
801 * \code decoder != NULL \endcode
803 * \c true if successful, else \c false if a memory allocation
804 * or stream decoder error occurs.
806 FLAC__bool FLAC__seekable_stream_decoder_flush(FLAC__SeekableStreamDecoder *decoder);
808 /** Reset the decoding process.
809 * The decoder's input buffer will be cleared and the state set to
810 * \c FLAC__SEEKABLE_STREAM_DECODER_OK. This is similar to
811 * FLAC__seekable_stream_decoder_finish() except that the settings are
812 * preserved; there is no need to call FLAC__seekable_stream_decoder_init()
813 * before decoding again. MD5 checking will be restored to its original
816 * \param decoder A decoder instance.
818 * \code decoder != NULL \endcode
820 * \c true if successful, else \c false if a memory allocation
821 * or stream decoder error occurs.
823 FLAC__bool FLAC__seekable_stream_decoder_reset(FLAC__SeekableStreamDecoder *decoder);
825 /** This is inherited from FLAC__StreamDecoder; see
826 * FLAC__stream_decoder_process_single().
828 * \param decoder A decoder instance.
830 * \code decoder != NULL \endcode
834 FLAC__bool FLAC__seekable_stream_decoder_process_single(FLAC__SeekableStreamDecoder *decoder);
836 /** This is inherited from FLAC__StreamDecoder; see
837 * FLAC__stream_decoder_process_until_end_of_metadata().
839 * \param decoder A decoder instance.
841 * \code decoder != NULL \endcode
845 FLAC__bool FLAC__seekable_stream_decoder_process_until_end_of_metadata(FLAC__SeekableStreamDecoder *decoder);
847 /** This is inherited from FLAC__StreamDecoder; see
848 * FLAC__stream_decoder_process_until_end_of_stream().
850 * \param decoder A decoder instance.
852 * \code decoder != NULL \endcode
856 FLAC__bool FLAC__seekable_stream_decoder_process_until_end_of_stream(FLAC__SeekableStreamDecoder *decoder);
858 /** Flush the input and seek to an absolute sample.
859 * Decoding will resume at the given sample. Note that because of
860 * this, the next write callback may contain a partial block.
862 * \param decoder A decoder instance.
863 * \param sample The target sample number to seek to.
865 * \code decoder != NULL \endcode
867 * \c true if successful, else \c false.
869 FLAC__bool FLAC__seekable_stream_decoder_seek_absolute(FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 sample);