Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /* libFLAC - Free Lossless Audio Codec library
  2.  * Copyright (C) 2000,2001  Josh Coalson
  3.  *
  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.
  8.  *
  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.
  13.  *
  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.
  18.  */
  19.  
  20. #ifndef FLAC__FILE_DECODER_H
  21. #define FLAC__FILE_DECODER_H
  22.  
  23. #include "stream_decoder.h"
  24.  
  25. typedef enum {
  26.     FLAC__FILE_DECODER_OK = 0,
  27.         FLAC__FILE_DECODER_SEEKING,
  28.         FLAC__FILE_DECODER_END_OF_FILE,
  29.     FLAC__FILE_DECODER_ERROR_OPENING_FILE,
  30.     FLAC__FILE_DECODER_MEMORY_ALLOCATION_ERROR,
  31.         FLAC__FILE_DECODER_SEEK_ERROR,
  32.         FLAC__FILE_DECODER_STREAM_ERROR,
  33.         FLAC__FILE_DECODER_MD5_ERROR,
  34.         FLAC__FILE_DECODER_STREAM_DECODER_ERROR,
  35.     FLAC__FILE_DECODER_ALREADY_INITIALIZED,
  36.     FLAC__FILE_DECODER_INVALID_CALLBACK,
  37.     FLAC__FILE_DECODER_UNINITIALIZED
  38. } FLAC__FileDecoderState;
  39. extern const char *FLAC__FileDecoderStateString[];
  40.  
  41. /***********************************************************************
  42.  *
  43.  * class FLAC__FileDecoder : public FLAC__StreamDecoder
  44.  *
  45.  ***********************************************************************/
  46.  
  47. struct FLAC__FileDecoderProtected;
  48. struct FLAC__FileDecoderPrivate;
  49. typedef struct {
  50.         struct FLAC__FileDecoderProtected *protected;
  51.         struct FLAC__FileDecoderPrivate *private;
  52. } FLAC__FileDecoder;
  53.  
  54. /***********************************************************************
  55.  *
  56.  * Class constructor/destructor
  57.  *
  58.  ***********************************************************************/
  59.  
  60. /*
  61.  * Any parameters that are not set before FLAC__file_decoder_init()
  62.  * will take on the defaults from the constructor, shown below.
  63.  * For more on what the parameters mean, see the documentation.
  64.  *
  65.  * FLAC__bool  md5_checking                   (DEFAULT: false) MD5 checking will be turned off if a seek is requested
  66.  *           (*write_callback)()              (DEFAULT: NULL ) The callbacks are the only values that MUST be set before FLAC__file_decoder_init()
  67.  *           (*metadata_callback)()           (DEFAULT: NULL )
  68.  *           (*error_callback)()              (DEFAULT: NULL )
  69.  * void*       client_data                    (DEFAULT: NULL ) passed back through the callbacks
  70.  */
  71. FLAC__FileDecoder *FLAC__file_decoder_new();
  72. void FLAC__file_decoder_delete(FLAC__FileDecoder *);
  73.  
  74. /***********************************************************************
  75.  *
  76.  * Public class method prototypes
  77.  *
  78.  ***********************************************************************/
  79.  
  80. /*
  81.  * Various "set" methods.  These may only be called when the decoder
  82.  * is in the state FLAC__FILE_DECODER_UNINITIALIZED, i.e. after
  83.  * FLAC__file_decoder_new() or FLAC__file_decoder_finish(), but
  84.  * before FLAC__file_decoder_init().  If this is the case they will
  85.  * return true, otherwise false.
  86.  *
  87.  * NOTE that these functions do not validate the values as many are
  88.  * interdependent.  The FLAC__file_decoder_init() function will do
  89.  * this, so make sure to pay attention to the state returned by
  90.  * FLAC__file_decoder_init().
  91.  *
  92.  * Any parameters that are not set before FLAC__file_decoder_init()
  93.  * will take on the defaults from the constructor.  NOTE that
  94.  * FLAC__file_decoder_flush() or FLAC__file_decoder_reset() do
  95.  * NOT reset the values to the constructor defaults.
  96.  */
  97. FLAC__bool FLAC__file_decoder_set_md5_checking(const FLAC__FileDecoder *decoder, FLAC__bool value);
  98. FLAC__bool FLAC__file_decoder_set_filename(const FLAC__FileDecoder *decoder, const char *value);
  99. FLAC__bool FLAC__file_decoder_set_write_callback(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderWriteStatus (*value)(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data));
  100. FLAC__bool FLAC__file_decoder_set_metadata_callback(const FLAC__FileDecoder *decoder, void (*value)(const FLAC__FileDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data));
  101. FLAC__bool FLAC__file_decoder_set_error_callback(const FLAC__FileDecoder *decoder, void (*value)(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data));
  102. FLAC__bool FLAC__file_decoder_set_client_data(const FLAC__FileDecoder *decoder, void *value);
  103.  
  104. /*
  105.  * Various "get" methods
  106.  */
  107. FLAC__FileDecoderState FLAC__file_decoder_get_state(const FLAC__FileDecoder *decoder);
  108. FLAC__bool FLAC__file_decoder_get_md5_checking(const FLAC__FileDecoder *decoder);
  109.  
  110. /*
  111.  * Initialize the instance; should be called after construction and
  112.  * 'set' calls but before any of the 'process' or 'seek' calls.  Will
  113.  * set and return the decoder state, which will be FLAC__FILE_DECODER_OK
  114.  * if initializationsucceeded.
  115.  */
  116. FLAC__FileDecoderState FLAC__file_decoder_init(FLAC__FileDecoder *decoder);
  117.  
  118. /*
  119.  * Flush the decoding buffer, release resources, and return the decoder
  120.  * state to FLAC__FILE_DECODER_UNINITIALIZED.  Only returns false if
  121.  * md5_checking is set AND the stored MD5 sum is non-zero AND the stored
  122.  * MD5 sum and computed MD5 sum do not match.
  123.  */
  124. FLAC__bool FLAC__file_decoder_finish(FLAC__FileDecoder *decoder);
  125.  
  126. /*
  127.  * Methods for decoding the data
  128.  */
  129. FLAC__bool FLAC__file_decoder_process_whole_file(FLAC__FileDecoder *decoder);
  130. FLAC__bool FLAC__file_decoder_process_metadata(FLAC__FileDecoder *decoder);
  131. FLAC__bool FLAC__file_decoder_process_one_frame(FLAC__FileDecoder *decoder);
  132. FLAC__bool FLAC__file_decoder_process_remaining_frames(FLAC__FileDecoder *decoder);
  133.  
  134. FLAC__bool FLAC__file_decoder_seek_absolute(FLAC__FileDecoder *decoder, FLAC__uint64 sample);
  135.  
  136. #endif
  137.