mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
add FLAC__metadata_simple_iterator_get_application_id()
This commit is contained in:
@@ -121,6 +121,7 @@
|
||||
<li><b>Added</b> FLAC__metadata_simple_iterator_is_last()</li>
|
||||
<li><b>Added</b> FLAC__metadata_simple_iterator_get_block_offset()</li>
|
||||
<li><b>Added</b> FLAC__metadata_simple_iterator_get_block_length()</li>
|
||||
<li><b>Added</b> FLAC__metadata_simple_iterator_get_application_id()</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
@@ -129,6 +130,7 @@
|
||||
<li><b>Added</b> FLAC::Metadata::SimpleIterator::is_last()</li>
|
||||
<li><b>Added</b> FLAC::Metadata::SimpleIterator::get_block_offset()</li>
|
||||
<li><b>Added</b> FLAC::Metadata::SimpleIterator::get_block_length()</li>
|
||||
<li><b>Added</b> FLAC::Metadata::SimpleIterator::get_application_id()</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -1023,6 +1023,7 @@ namespace FLAC {
|
||||
off_t get_block_offset() const; ///< See FLAC__metadata_simple_iterator_get_block_offset().
|
||||
::FLAC__MetadataType get_block_type() const; ///< See FLAC__metadata_simple_iterator_get_block_type().
|
||||
unsigned get_block_length() const; ///< See FLAC__metadata_simple_iterator_get_block_length().
|
||||
bool get_application_id(FLAC__byte *id); ///< See FLAC__metadata_simple_iterator_get_application_id().
|
||||
Prototype *get_block(); ///< See FLAC__metadata_simple_iterator_get_block().
|
||||
bool set_block(Prototype *block, bool use_padding = true); ///< See FLAC__metadata_simple_iterator_set_block().
|
||||
bool insert_block_after(Prototype *block, bool use_padding = true); ///< See FLAC__metadata_simple_iterator_insert_block_after().
|
||||
|
||||
@@ -472,7 +472,6 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_last(const FLAC__Metadata_
|
||||
* This is the byte offset relative to the beginning of the file of
|
||||
* the current metadata block's header.
|
||||
*/
|
||||
|
||||
FLAC_API off_t FLAC__metadata_simple_iterator_get_block_offset(const FLAC__Metadata_SimpleIterator *iterator);
|
||||
|
||||
/** Get the type of the metadata block at the current position. This
|
||||
@@ -487,7 +486,6 @@ FLAC_API off_t FLAC__metadata_simple_iterator_get_block_offset(const FLAC__Metad
|
||||
* \retval FLAC__MetadataType
|
||||
* The type of the metadata block at the current iterator position.
|
||||
*/
|
||||
|
||||
FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type(const FLAC__Metadata_SimpleIterator *iterator);
|
||||
|
||||
/*@@@@add to tests*/
|
||||
@@ -506,9 +504,34 @@ FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type(const
|
||||
* <a href="http://flac.sourceforge.net/format.html#metadata_block_header">metadata block header</a>,
|
||||
* i.e. the length of the metadata body that follows the header.
|
||||
*/
|
||||
|
||||
FLAC_API unsigned FLAC__metadata_simple_iterator_get_block_length(const FLAC__Metadata_SimpleIterator *iterator);
|
||||
|
||||
/*@@@@add to tests*/
|
||||
/** Get the application ID of the \c APPLICATION block at the current
|
||||
* position. This avoids reading the actual block data which can save
|
||||
* time for large blocks.
|
||||
*
|
||||
* \param iterator A pointer to an existing initialized iterator.
|
||||
* \param id A pointer to a buffer of at least \c 4 bytes where
|
||||
* the ID will be stored.
|
||||
* \assert
|
||||
* \code iterator != NULL \endcode
|
||||
* \code id != NULL \endcode
|
||||
* \a iterator has been successfully initialized with
|
||||
* FLAC__metadata_simple_iterator_init()
|
||||
* \retval FLAC__bool
|
||||
* \c true if the ID was successfully read, else \c false, in which
|
||||
* case you should check FLAC__metadata_simple_iterator_status() to
|
||||
* find out why. If the status is
|
||||
* \c FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT, then the
|
||||
* current metadata block is not an \c APPLICATION block. Otherwise
|
||||
* if the status is
|
||||
* \c FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR or
|
||||
* \c FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR, an I/O error
|
||||
* occurred and the iterator can no longer be used.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_get_application_id(FLAC__Metadata_SimpleIterator *iterator, FLAC__byte *id);
|
||||
|
||||
/** Get the metadata block at the current position. You can modify the
|
||||
* block but must use FLAC__metadata_simple_iterator_set_block() to
|
||||
* write it back to the FLAC file.
|
||||
|
||||
@@ -1363,6 +1363,13 @@ namespace FLAC {
|
||||
return ::FLAC__metadata_simple_iterator_get_block_length(iterator_);
|
||||
}
|
||||
|
||||
//@@@@ add to tests
|
||||
bool SimpleIterator::get_application_id(FLAC__byte *id)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__metadata_simple_iterator_get_application_id(iterator_, id);
|
||||
}
|
||||
|
||||
Prototype *SimpleIterator::get_block()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
|
||||
@@ -609,6 +609,33 @@ FLAC_API unsigned FLAC__metadata_simple_iterator_get_block_length(const FLAC__Me
|
||||
return iterator->length;
|
||||
}
|
||||
|
||||
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_get_application_id(FLAC__Metadata_SimpleIterator *iterator, FLAC__byte *id)
|
||||
{
|
||||
const unsigned id_bytes = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8;
|
||||
|
||||
FLAC__ASSERT(0 != iterator);
|
||||
FLAC__ASSERT(0 != iterator->file);
|
||||
FLAC__ASSERT(0 != id);
|
||||
|
||||
if(iterator->type != FLAC__METADATA_TYPE_APPLICATION) {
|
||||
iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(fread(id, 1, id_bytes, iterator->file) != id_bytes) {
|
||||
iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* back up */
|
||||
if(0 != fseeko(iterator->file, -((int)id_bytes), SEEK_CUR)) {
|
||||
iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
FLAC_API FLAC__StreamMetadata *FLAC__metadata_simple_iterator_get_block(FLAC__Metadata_SimpleIterator *iterator)
|
||||
{
|
||||
FLAC__StreamMetadata *block = FLAC__metadata_object_new(iterator->type);
|
||||
|
||||
Reference in New Issue
Block a user