Commit bf9325f2 authored by Josh Coalson's avatar Josh Coalson
Browse files

add functionality to specify which metadata blocks are parsed and sent back...

add functionality to specify which metadata blocks are parsed and sent back through metadata_callback, and which are ignored
parent ce9459f4
......@@ -105,6 +105,15 @@ FLAC__bool FLAC__file_decoder_set_write_callback(const FLAC__FileDecoder *decode
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));
FLAC__bool FLAC__file_decoder_set_error_callback(const FLAC__FileDecoder *decoder, void (*value)(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data));
FLAC__bool FLAC__file_decoder_set_client_data(const FLAC__FileDecoder *decoder, void *value);
/*
* See the comments for the equivalent functions in stream_decoder.h
*/
FLAC__bool FLAC__file_decoder_set_metadata_respond(const FLAC__FileDecoder *decoder, FLAC__MetaDataType type);
FLAC__bool FLAC__file_decoder_set_metadata_respond_application(const FLAC__FileDecoder *decoder, FLAC__byte id[4]);
FLAC__bool FLAC__file_decoder_set_metadata_respond_all(const FLAC__FileDecoder *decoder);
FLAC__bool FLAC__file_decoder_set_metadata_ignore(const FLAC__FileDecoder *decoder, FLAC__MetaDataType type);
FLAC__bool FLAC__file_decoder_set_metadata_ignore_application(const FLAC__FileDecoder *decoder, FLAC__byte id[4]);
FLAC__bool FLAC__file_decoder_set_metadata_ignore_all(const FLAC__FileDecoder *decoder);
/*
* Various "get" methods
......
......@@ -136,6 +136,15 @@ FLAC__bool FLAC__seekable_stream_decoder_set_write_callback(const FLAC__Seekable
FLAC__bool FLAC__seekable_stream_decoder_set_metadata_callback(const FLAC__SeekableStreamDecoder *decoder, void (*value)(const FLAC__SeekableStreamDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data));
FLAC__bool FLAC__seekable_stream_decoder_set_error_callback(const FLAC__SeekableStreamDecoder *decoder, void (*value)(const FLAC__SeekableStreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data));
FLAC__bool FLAC__seekable_stream_decoder_set_client_data(const FLAC__SeekableStreamDecoder *decoder, void *value);
/*
* See the comments for the equivalent functions in stream_decoder.h
*/
FLAC__bool FLAC__seekable_stream_decoder_set_metadata_respond(const FLAC__SeekableStreamDecoder *decoder, FLAC__MetaDataType type);
FLAC__bool FLAC__seekable_stream_decoder_set_metadata_respond_application(const FLAC__SeekableStreamDecoder *decoder, FLAC__byte id[4]);
FLAC__bool FLAC__seekable_stream_decoder_set_metadata_respond_all(const FLAC__SeekableStreamDecoder *decoder);
FLAC__bool FLAC__seekable_stream_decoder_set_metadata_ignore(const FLAC__SeekableStreamDecoder *decoder, FLAC__MetaDataType type);
FLAC__bool FLAC__seekable_stream_decoder_set_metadata_ignore_application(const FLAC__SeekableStreamDecoder *decoder, FLAC__byte id[4]);
FLAC__bool FLAC__seekable_stream_decoder_set_metadata_ignore_all(const FLAC__SeekableStreamDecoder *decoder);
/*
* Various "get" methods
......
......@@ -123,6 +123,26 @@ FLAC__bool FLAC__stream_decoder_set_write_callback(const FLAC__StreamDecoder *de
FLAC__bool FLAC__stream_decoder_set_metadata_callback(const FLAC__StreamDecoder *decoder, void (*value)(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data));
FLAC__bool FLAC__stream_decoder_set_error_callback(const FLAC__StreamDecoder *decoder, void (*value)(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data));
FLAC__bool FLAC__stream_decoder_set_client_data(const FLAC__StreamDecoder *decoder, void *value);
/*
* These deserve special attention. By default, the decoder only calls the
* metadata_callback for the STREAMINFO block. These functions allow you to
* tell the decoder explicitly which blocks to parse and return via the
* metadata_callback and/or which to skip. Use a _respond_all(), _ignore() ...
* or _ignore_all(), _respond() ... sequence to exactly specify which blocks
* to return. Remember that some metadata blocks can be big so filtering out
* the ones you don't use can reduce the memory requirements of the decoder.
* Also note the special forms _respond/_ignore_application(id) for filtering
* APPLICATION blocks based on the application ID.
*
* STREAMINFO and SEEKTABLE blocks are always parsed and used internally, but
* they still can legally be filtered from the metadata_callback here.
*/
FLAC__bool FLAC__stream_decoder_set_metadata_respond(const FLAC__StreamDecoder *decoder, FLAC__MetaDataType type);
FLAC__bool FLAC__stream_decoder_set_metadata_respond_application(const FLAC__StreamDecoder *decoder, FLAC__byte id[4]);
FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(const FLAC__StreamDecoder *decoder);
FLAC__bool FLAC__stream_decoder_set_metadata_ignore(const FLAC__StreamDecoder *decoder, FLAC__MetaDataType type);
FLAC__bool FLAC__stream_decoder_set_metadata_ignore_application(const FLAC__StreamDecoder *decoder, FLAC__byte id[4]);
FLAC__bool FLAC__stream_decoder_set_metadata_ignore_all(const FLAC__StreamDecoder *decoder);
/*
* Methods to return the current stream decoder state, number
......
......@@ -219,6 +219,9 @@ FLAC__bool FLAC__file_decoder_finish(FLAC__FileDecoder *decoder)
FLAC__bool FLAC__file_decoder_set_md5_checking(const FLAC__FileDecoder *decoder, FLAC__bool value)
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
return false;
decoder->private_->init_values_for_superclass.md5_checking = value;
......@@ -227,6 +230,9 @@ FLAC__bool FLAC__file_decoder_set_md5_checking(const FLAC__FileDecoder *decoder,
FLAC__bool FLAC__file_decoder_set_filename(const FLAC__FileDecoder *decoder, const char *value)
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
FLAC__ASSERT(value != 0);
if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
return false;
......@@ -246,6 +252,9 @@ FLAC__bool FLAC__file_decoder_set_filename(const FLAC__FileDecoder *decoder, con
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))
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
return false;
decoder->private_->write_callback = value;
......@@ -254,6 +263,9 @@ FLAC__bool FLAC__file_decoder_set_write_callback(const FLAC__FileDecoder *decode
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))
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
return false;
decoder->private_->metadata_callback = value;
......@@ -262,6 +274,9 @@ FLAC__bool FLAC__file_decoder_set_metadata_callback(const FLAC__FileDecoder *dec
FLAC__bool FLAC__file_decoder_set_error_callback(const FLAC__FileDecoder *decoder, void (*value)(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data))
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
return false;
decoder->private_->error_callback = value;
......@@ -270,19 +285,87 @@ FLAC__bool FLAC__file_decoder_set_error_callback(const FLAC__FileDecoder *decode
FLAC__bool FLAC__file_decoder_set_client_data(const FLAC__FileDecoder *decoder, void *value)
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
return false;
decoder->private_->client_data = value;
return true;
}
FLAC__bool FLAC__file_decoder_set_metadata_respond(const FLAC__FileDecoder *decoder, FLAC__MetaDataType type)
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
return false;
return FLAC__seekable_stream_decoder_set_metadata_respond(decoder->private_->seekable_stream_decoder, type);
}
FLAC__bool FLAC__file_decoder_set_metadata_respond_application(const FLAC__FileDecoder *decoder, FLAC__byte id[4])
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
return false;
return FLAC__seekable_stream_decoder_set_metadata_respond_application(decoder->private_->seekable_stream_decoder, id);
}
FLAC__bool FLAC__file_decoder_set_metadata_respond_all(const FLAC__FileDecoder *decoder)
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
return false;
return FLAC__seekable_stream_decoder_set_metadata_respond_all(decoder->private_->seekable_stream_decoder);
}
FLAC__bool FLAC__file_decoder_set_metadata_ignore(const FLAC__FileDecoder *decoder, FLAC__MetaDataType type)
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
return false;
return FLAC__seekable_stream_decoder_set_metadata_ignore(decoder->private_->seekable_stream_decoder, type);
}
FLAC__bool FLAC__file_decoder_set_metadata_ignore_application(const FLAC__FileDecoder *decoder, FLAC__byte id[4])
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
return false;
return FLAC__seekable_stream_decoder_set_metadata_ignore_application(decoder->private_->seekable_stream_decoder, id);
}
FLAC__bool FLAC__file_decoder_set_metadata_ignore_all(const FLAC__FileDecoder *decoder)
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
return false;
return FLAC__seekable_stream_decoder_set_metadata_ignore_all(decoder->private_->seekable_stream_decoder);
}
FLAC__FileDecoderState FLAC__file_decoder_get_state(const FLAC__FileDecoder *decoder)
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->protected_ != 0);
return decoder->protected_->state;
}
FLAC__bool FLAC__file_decoder_get_md5_checking(const FLAC__FileDecoder *decoder)
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
return FLAC__seekable_stream_decoder_get_md5_checking(decoder->private_->seekable_stream_decoder);
}
......
......@@ -231,6 +231,8 @@ FLAC__bool FLAC__seekable_stream_decoder_finish(FLAC__SeekableStreamDecoder *dec
FLAC__bool FLAC__seekable_stream_decoder_set_md5_checking(const FLAC__SeekableStreamDecoder *decoder, FLAC__bool value)
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED)
return false;
decoder->protected_->md5_checking = value;
......@@ -239,6 +241,9 @@ FLAC__bool FLAC__seekable_stream_decoder_set_md5_checking(const FLAC__SeekableSt
FLAC__bool FLAC__seekable_stream_decoder_set_read_callback(const FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderReadStatus (*value)(const FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data))
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED)
return false;
decoder->private_->read_callback = value;
......@@ -247,6 +252,9 @@ FLAC__bool FLAC__seekable_stream_decoder_set_read_callback(const FLAC__SeekableS
FLAC__bool FLAC__seekable_stream_decoder_set_seek_callback(const FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderSeekStatus (*value)(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data))
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED)
return false;
decoder->private_->seek_callback = value;
......@@ -255,6 +263,9 @@ FLAC__bool FLAC__seekable_stream_decoder_set_seek_callback(const FLAC__SeekableS
FLAC__bool FLAC__seekable_stream_decoder_set_tell_callback(const FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderTellStatus (*value)(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data))
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED)
return false;
decoder->private_->tell_callback = value;
......@@ -263,6 +274,9 @@ FLAC__bool FLAC__seekable_stream_decoder_set_tell_callback(const FLAC__SeekableS
FLAC__bool FLAC__seekable_stream_decoder_set_length_callback(const FLAC__SeekableStreamDecoder *decoder, FLAC__SeekableStreamDecoderLengthStatus (*value)(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data))
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED)
return false;
decoder->private_->length_callback = value;
......@@ -271,6 +285,9 @@ FLAC__bool FLAC__seekable_stream_decoder_set_length_callback(const FLAC__Seekabl
FLAC__bool FLAC__seekable_stream_decoder_set_eof_callback(const FLAC__SeekableStreamDecoder *decoder, FLAC__bool (*value)(const FLAC__SeekableStreamDecoder *decoder, void *client_data))
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED)
return false;
decoder->private_->eof_callback = value;
......@@ -279,6 +296,9 @@ FLAC__bool FLAC__seekable_stream_decoder_set_eof_callback(const FLAC__SeekableSt
FLAC__bool FLAC__seekable_stream_decoder_set_write_callback(const FLAC__SeekableStreamDecoder *decoder, FLAC__StreamDecoderWriteStatus (*value)(const FLAC__SeekableStreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data))
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED)
return false;
decoder->private_->write_callback = value;
......@@ -287,6 +307,9 @@ FLAC__bool FLAC__seekable_stream_decoder_set_write_callback(const FLAC__Seekable
FLAC__bool FLAC__seekable_stream_decoder_set_metadata_callback(const FLAC__SeekableStreamDecoder *decoder, void (*value)(const FLAC__SeekableStreamDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data))
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED)
return false;
decoder->private_->metadata_callback = value;
......@@ -295,6 +318,9 @@ FLAC__bool FLAC__seekable_stream_decoder_set_metadata_callback(const FLAC__Seeka
FLAC__bool FLAC__seekable_stream_decoder_set_error_callback(const FLAC__SeekableStreamDecoder *decoder, void (*value)(const FLAC__SeekableStreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data))
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED)
return false;
decoder->private_->error_callback = value;
......@@ -303,19 +329,86 @@ FLAC__bool FLAC__seekable_stream_decoder_set_error_callback(const FLAC__Seekable
FLAC__bool FLAC__seekable_stream_decoder_set_client_data(const FLAC__SeekableStreamDecoder *decoder, void *value)
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED)
return false;
decoder->private_->client_data = value;
return true;
}
FLAC__bool FLAC__seekable_stream_decoder_set_metadata_respond(const FLAC__SeekableStreamDecoder *decoder, FLAC__MetaDataType type)
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED)
return false;
return FLAC__stream_decoder_set_metadata_respond(decoder->private_->stream_decoder, type);
}
FLAC__bool FLAC__seekable_stream_decoder_set_metadata_respond_application(const FLAC__SeekableStreamDecoder *decoder, FLAC__byte id[4])
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED)
return false;
return FLAC__stream_decoder_set_metadata_respond_application(decoder->private_->stream_decoder, id);
}
FLAC__bool FLAC__seekable_stream_decoder_set_metadata_respond_all(const FLAC__SeekableStreamDecoder *decoder)
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED)
return false;
return FLAC__stream_decoder_set_metadata_respond_all(decoder->private_->stream_decoder);
}
FLAC__bool FLAC__seekable_stream_decoder_set_metadata_ignore(const FLAC__SeekableStreamDecoder *decoder, FLAC__MetaDataType type)
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED)
return false;
return FLAC__stream_decoder_set_metadata_ignore(decoder->private_->stream_decoder, type);
}
FLAC__bool FLAC__seekable_stream_decoder_set_metadata_ignore_application(const FLAC__SeekableStreamDecoder *decoder, FLAC__byte id[4])
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED)
return false;
return FLAC__stream_decoder_set_metadata_ignore_application(decoder->private_->stream_decoder, id);
}
FLAC__bool FLAC__seekable_stream_decoder_set_metadata_ignore_all(const FLAC__SeekableStreamDecoder *decoder)
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->private_ != 0);
FLAC__ASSERT(decoder->protected_ != 0);
if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED)
return false;
return FLAC__stream_decoder_set_metadata_ignore_all(decoder->private_->stream_decoder);
}
FLAC__SeekableStreamDecoderState FLAC__seekable_stream_decoder_get_state(const FLAC__SeekableStreamDecoder *decoder)
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->protected_ != 0);
return decoder->protected_->state;
}
FLAC__bool FLAC__seekable_stream_decoder_get_md5_checking(const FLAC__SeekableStreamDecoder *decoder)
{
FLAC__ASSERT(decoder != 0);
FLAC__ASSERT(decoder->protected_ != 0);
return decoder->protected_->md5_checking;
}
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment