⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 seekable_stream_decoder.h

📁 这是著名的TCPMP播放器在WINDWOWS,和WINCE下编译通过的源程序.笔者对其中的LIBMAD库做了针对ARM MPU的优化. 并增加了词幕功能.
💻 H
📖 第 1 页 / 共 3 页
字号:
/* libFLAC - Free Lossless Audio Codec library
 * Copyright (C) 2000,2001,2002,2003,2004,2005  Josh Coalson
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * - Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *
 * - Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 *
 * - Neither the name of the Xiph.org Foundation nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef FLAC__SEEKABLE_STREAM_DECODER_H
#define FLAC__SEEKABLE_STREAM_DECODER_H

#include "export.h"
#include "stream_decoder.h"

#ifdef __cplusplus
extern "C" {
#endif


/** \file include/FLAC/seekable_stream_decoder.h
 *
 *  \brief
 *  This module contains the functions which implement the seekable stream
 *  decoder.
 *
 *  See the detailed documentation in the
 *  \link flac_seekable_stream_decoder seekable stream decoder \endlink module.
 */

/** \defgroup flac_seekable_stream_decoder FLAC/seekable_stream_decoder.h: seekable stream decoder interface
 *  \ingroup flac_decoder
 *
 *  \brief
 *  This module contains the functions which implement the seekable stream
 *  decoder.
 *
 * The basic usage of this decoder is as follows:
 * - The program creates an instance of a decoder using
 *   FLAC__seekable_stream_decoder_new().
 * - The program overrides the default settings and sets callbacks for
 *   reading, writing, seeking, error reporting, and metadata reporting
 *   using FLAC__seekable_stream_decoder_set_*() functions.
 * - The program initializes the instance to validate the settings and
 *   prepare for decoding using FLAC__seekable_stream_decoder_init().
 * - The program calls the FLAC__seekable_stream_decoder_process_*()
 *   functions to decode data, which subsequently calls the callbacks.
 * - The program finishes the decoding with
 *   FLAC__seekable_stream_decoder_finish(), which flushes the input and
 *   output and resets the decoder to the uninitialized state.
 * - The instance may be used again or deleted with
 *   FLAC__seekable_stream_decoder_delete().
 *
 * The seekable stream decoder is a wrapper around the
 * \link flac_stream_decoder stream decoder \endlink which also provides
 * seeking capability.  In addition to the Read/Write/Metadata/Error
 * callbacks of the stream decoder, the user must also provide the following:
 *
 * - Seek callback - This function will be called when the decoder wants to
 *   seek to an absolute position in the stream.
 * - Tell callback - This function will be called when the decoder wants to
 *   know the current absolute position of the stream.
 * - Length callback - This function will be called when the decoder wants
 *   to know length of the stream.  The seeking algorithm currently requires
 *   that the overall stream length be known.
 * - EOF callback - This function will be called when the decoder wants to
 *   know if it is at the end of the stream.  This could be synthesized from
 *   the tell and length callbacks but it may be more expensive that way, so
 *   there is a separate callback for it.
 *
 * Seeking is exposed through the
 * FLAC__seekable_stream_decoder_seek_absolute() method.  At any point after
 * the seekable stream decoder has been initialized, the user can call this
 * function to seek to an exact sample within the stream.  Subsequently, the
 * first time the write callback is called it will be passed a (possibly
 * partial) block starting at that sample.
 *
 * The seekable stream decoder also provides MD5 signature checking.  If
 * this is turned on before initialization,
 * FLAC__seekable_stream_decoder_finish() will report when the decoded MD5
 * signature does not match the one stored in the STREAMINFO block.  MD5
 * checking is automatically turned off (until the next
 * FLAC__seekable_stream_decoder_reset()) if there is no signature in the
 * STREAMINFO block or when a seek is attempted.
 *
 * Make sure to read the detailed description of the
 * \link flac_stream_decoder stream decoder module \endlink since the
 * seekable stream decoder inherits much of its behavior.
 *
 * \note
 * The "set" functions may only be called when the decoder is in the
 * state FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED, i.e. after
 * FLAC__seekable_stream_decoder_new() or
 * FLAC__seekable_stream_decoder_finish(), but before
 * FLAC__seekable_stream_decoder_init().  If this is the case they will
 * return \c true, otherwise \c false.
 *
 * \note
 * FLAC__stream_decoder_finish() resets all settings to the constructor
 * defaults, including the callbacks.
 *
 * \{
 */


/** State values for a FLAC__SeekableStreamDecoder
 *
 *  The decoder's state can be obtained by calling FLAC__seekable_stream_decoder_get_state().
 */
typedef enum {

	FLAC__SEEKABLE_STREAM_DECODER_OK = 0,
	/**< The decoder is in the normal OK state. */

	FLAC__SEEKABLE_STREAM_DECODER_SEEKING,
	/**< The decoder is in the process of seeking. */

	FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM,
	/**< The decoder has reached the end of the stream. */

	FLAC__SEEKABLE_STREAM_DECODER_MEMORY_ALLOCATION_ERROR,
	/**< An error occurred allocating memory. */

	FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR,
	/**< An error occurred in the underlying stream decoder. */

	FLAC__SEEKABLE_STREAM_DECODER_READ_ERROR,
	/**< The read callback returned an error. */

	FLAC__SEEKABLE_STREAM_DECODER_SEEK_ERROR,
	/**< An error occurred while seeking or the seek or tell
	 * callback returned an error.
	 */

	FLAC__SEEKABLE_STREAM_DECODER_ALREADY_INITIALIZED,
	/**< FLAC__seekable_stream_decoder_init() was called when the
	 * decoder was already initialized, usually because
	 * FLAC__seekable_stream_decoder_finish() was not called.
	 */

	FLAC__SEEKABLE_STREAM_DECODER_INVALID_CALLBACK,
	/**< FLAC__seekable_stream_decoder_init() was called without all
	 * callbacks being set.
	 */

	FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED
	/**< The decoder is in the uninitialized state. */

} FLAC__SeekableStreamDecoderState;

/** Maps a FLAC__SeekableStreamDecoderState to a C string.
 *
 *  Using a FLAC__SeekableStreamDecoderState as the index to this array
 *  will give the string equivalent.  The contents should not be modified.
 */
extern FLAC_API const char * const FLAC__SeekableStreamDecoderStateString[];


/** Return values for the FLAC__SeekableStreamDecoder read callback.
 */
typedef enum {

	FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK,
	/**< The read was OK and decoding can continue. */

	FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR
	/**< An unrecoverable error occurred.  The decoder will return from the process call. */

} FLAC__SeekableStreamDecoderReadStatus;

/** Maps a FLAC__SeekableStreamDecoderReadStatus to a C string.
 *
 *  Using a FLAC__SeekableStreamDecoderReadStatus as the index to this array
 *  will give the string equivalent.  The contents should not be modified.
 */
extern FLAC_API const char * const FLAC__SeekableStreamDecoderReadStatusString[];


/** Return values for the FLAC__SeekableStreamDecoder seek callback.
 */
typedef enum {

	FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK,
	/**< The seek was OK and decoding can continue. */

	FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR
	/**< An unrecoverable error occurred.  The decoder will return from the process call. */

} FLAC__SeekableStreamDecoderSeekStatus;

/** Maps a FLAC__SeekableStreamDecoderSeekStatus to a C string.
 *
 *  Using a FLAC__SeekableStreamDecoderSeekStatus as the index to this array
 *  will give the string equivalent.  The contents should not be modified.
 */
extern FLAC_API const char * const FLAC__SeekableStreamDecoderSeekStatusString[];


/** Return values for the FLAC__SeekableStreamDecoder tell callback.
 */
typedef enum {

	FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK,
	/**< The tell was OK and decoding can continue. */

	FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR
	/**< An unrecoverable error occurred.  The decoder will return from the process call. */

} FLAC__SeekableStreamDecoderTellStatus;

/** Maps a FLAC__SeekableStreamDecoderTellStatus to a C string.
 *
 *  Using a FLAC__SeekableStreamDecoderTellStatus as the index to this array
 *  will give the string equivalent.  The contents should not be modified.
 */
extern FLAC_API const char * const FLAC__SeekableStreamDecoderTellStatusString[];


/** Return values for the FLAC__SeekableStreamDecoder length callback.
 */
typedef enum {

	FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK,
	/**< The length call was OK and decoding can continue. */

	FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR
	/**< An unrecoverable error occurred.  The decoder will return from the process call. */

} FLAC__SeekableStreamDecoderLengthStatus;

/** Maps a FLAC__SeekableStreamDecoderLengthStatus to a C string.
 *
 *  Using a FLAC__SeekableStreamDecoderLengthStatus as the index to this array
 *  will give the string equivalent.  The contents should not be modified.
 */
extern FLAC_API const char * const FLAC__SeekableStreamDecoderLengthStatusString[];


/***********************************************************************
 *
 * class FLAC__SeekableStreamDecoder : public FLAC__StreamDecoder
 *
 ***********************************************************************/

struct FLAC__SeekableStreamDecoderProtected;
struct FLAC__SeekableStreamDecoderPrivate;
/** The opaque structure definition for the seekable stream decoder type.
 *  See the
 *  \link flac_seekable_stream_decoder seekable stream decoder module \endlink
 *  for a detailed description.
 */
typedef struct {
	struct FLAC__SeekableStreamDecoderProtected *protected_; /* avoid the C++ keyword 'protected' */
	struct FLAC__SeekableStreamDecoderPrivate *private_; /* avoid the C++ keyword 'private' */
} FLAC__SeekableStreamDecoder;

/** Signature for the read callback.
 *  See FLAC__seekable_stream_decoder_set_read_callback()
 *  and FLAC__StreamDecoderReadCallback for more info.
 *
 * \param  decoder  The decoder instance calling the callback.
 * \param  buffer   A pointer to a location for the callee to store
 *                  data to be decoded.
 * \param  bytes    A pointer to the size of the buffer.
 * \param  client_data  The callee's client data set through
 *                      FLAC__seekable_stream_decoder_set_client_data().
 * \retval FLAC__SeekableStreamDecoderReadStatus
 *    The callee's return status.
 */
typedef FLAC__SeekableStreamDecoderReadStatus (*FLAC__SeekableStreamDecoderReadCallback)(const FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);

/** Signature for the seek callback.
 *  See FLAC__seekable_stream_decoder_set_seek_callback() for more info.
 *
 * \param  decoder  The decoder instance calling the callback.
 * \param  absolute_byte_offset  The offset from the beginning of the stream
 *                               to seek to.
 * \param  client_data  The callee's client data set through
 *                      FLAC__seekable_stream_decoder_set_client_data().
 * \retval FLAC__SeekableStreamDecoderSeekStatus
 *    The callee's return status.
 */
typedef FLAC__SeekableStreamDecoderSeekStatus (*FLAC__SeekableStreamDecoderSeekCallback)(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);

/** Signature for the tell callback.
 *  See FLAC__seekable_stream_decoder_set_tell_callback() for more info.
 *
 * \param  decoder  The decoder instance calling the callback.
 * \param  absolute_byte_offset  A pointer to storage for the current offset

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -