revamp in anticipation of new analysis mode
[platform/upstream/flac.git] / include / FLAC / file_decoder.h
1 /* libFLAC - Free Lossless Audio Coder 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_UNINITIALIZED
35 } FLAC__FileDecoderState;
36 extern const char *FLAC__FileDecoderStateString[];
37
38 struct FLAC__FileDecoderPrivate;
39 typedef struct {
40         /* this field may not change once FLAC__file_decoder_init() is called */
41         bool check_md5; /* if true, generate MD5 signature of decoded data and compare against signature in the Encoding metadata block */
42
43         FLAC__FileDecoderState state; /* must be FLAC__FILE_DECODER_UNINITIALIZED when passed to FLAC__file_decoder_init() */
44         struct FLAC__FileDecoderPrivate *guts; /* must be 0 when passed to FLAC__file_decoder_init() */
45 } FLAC__FileDecoder;
46
47 FLAC__FileDecoder *FLAC__file_decoder_get_new_instance();
48 void FLAC__file_decoder_free_instance(FLAC__FileDecoder *decoder);
49 FLAC__FileDecoderState FLAC__file_decoder_init(
50         FLAC__FileDecoder *decoder,
51         const char *filename,
52         FLAC__StreamDecoderWriteStatus (*write_callback)(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const int32 *buffer[], void *client_data),
53         void (*metadata_callback)(const FLAC__FileDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data),
54         void (*error_callback)(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data),
55         void *client_data
56 );
57 /* only returns false if check_md5 is set AND the stored MD5 sum is non-zero AND the stored MD5 sum and computed MD5 sum do not match */
58 bool FLAC__file_decoder_finish(FLAC__FileDecoder *decoder);
59 bool FLAC__file_decoder_process_whole_file(FLAC__FileDecoder *decoder);
60 bool FLAC__file_decoder_process_metadata(FLAC__FileDecoder *decoder);
61 bool FLAC__file_decoder_process_one_frame(FLAC__FileDecoder *decoder);
62 bool FLAC__file_decoder_process_remaining_frames(FLAC__FileDecoder *decoder);
63 bool FLAC__file_decoder_seek_absolute(FLAC__FileDecoder *decoder, uint64 sample);
64
65 #endif