add MD5 support

This commit is contained in:
Josh Coalson
2001-01-12 23:55:11 +00:00
parent 4397b27181
commit fa37f1c012
8 changed files with 81 additions and 7 deletions

View File

@@ -30,12 +30,16 @@ typedef enum {
FLAC__FILE_DECODER_MEMORY_ALLOCATION_ERROR,
FLAC__FILE_DECODER_SEEK_ERROR,
FLAC__FILE_DECODER_STREAM_ERROR,
FLAC__FILE_DECODER_MD5_ERROR,
FLAC__FILE_DECODER_UNINITIALIZED
} FLAC__FileDecoderState;
extern const char *FLAC__FileDecoderStateString[];
struct FLAC__FileDecoderPrivate;
typedef struct {
/* this field may not change once FLAC__file_decoder_init() is called */
bool check_md5; /* if true, generate MD5 signature of decoded data and compare against signature in the Encoding metadata block */
FLAC__FileDecoderState state; /* must be FLAC__FILE_DECODER_UNINITIALIZED when passed to FLAC__file_decoder_init() */
struct FLAC__FileDecoderPrivate *guts; /* must be 0 when passed to FLAC__file_decoder_init() */
} FLAC__FileDecoder;
@@ -50,7 +54,8 @@ FLAC__FileDecoderState FLAC__file_decoder_init(
void (*error_callback)(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data),
void *client_data
);
void FLAC__file_decoder_finish(FLAC__FileDecoder *decoder);
/* 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 */
bool FLAC__file_decoder_finish(FLAC__FileDecoder *decoder);
bool FLAC__file_decoder_process_whole_file(FLAC__FileDecoder *decoder);
bool FLAC__file_decoder_process_metadata(FLAC__FileDecoder *decoder);
bool FLAC__file_decoder_process_one_frame(FLAC__FileDecoder *decoder);

View File

@@ -66,8 +66,9 @@ typedef enum {
* 3: (number of channels)-1
* 5: (bits per sample)-1
* 36: total samples, 0 => unknown
*128: MD5 digest of the original unencoded audio data
*---- -----------------
* 18 bytes total
* 34 bytes total
*/
typedef struct {
unsigned min_blocksize, max_blocksize;
@@ -76,6 +77,7 @@ typedef struct {
unsigned channels;
unsigned bits_per_sample;
uint64 total_samples;
byte md5sum[16];
} FLAC__StreamMetaData_Encoding;
extern const unsigned FLAC__STREAM_METADATA_ENCODING_MIN_BLOCK_SIZE_LEN; /* = 16 bits */
@@ -86,7 +88,8 @@ extern const unsigned FLAC__STREAM_METADATA_ENCODING_SAMPLE_RATE_LEN; /* = 20 bi
extern const unsigned FLAC__STREAM_METADATA_ENCODING_CHANNELS_LEN; /* = 3 bits */
extern const unsigned FLAC__STREAM_METADATA_ENCODING_BITS_PER_SAMPLE_LEN; /* = 5 bits */
extern const unsigned FLAC__STREAM_METADATA_ENCODING_TOTAL_SAMPLES_LEN; /* = 36 bits */
extern const unsigned FLAC__STREAM_METADATA_ENCODING_LENGTH; /* = 18 bytes */
extern const unsigned FLAC__STREAM_METADATA_ENCODING_MD5SUM_LEN; /* = 128 bits */
extern const unsigned FLAC__STREAM_METADATA_ENCODING_LENGTH; /* = 34 bytes */
/*****************************************************************************
*