FLAC
1.4.3
Free Lossless Audio Codec
|
Modules | |
FLAC/metadata.h: metadata level 2 interface | |
Typedefs | |
typedef struct FLAC__Metadata_SimpleIterator | FLAC__Metadata_SimpleIterator |
Variables | |
const char *const | FLAC__Metadata_SimpleIteratorStatusString [] |
The level 1 interface provides read-write access to FLAC file metadata and operates directly on the FLAC file.
The general usage of this interface is:
false
, you should delete the iterator as it may no longer be valid. typedef struct FLAC__Metadata_SimpleIterator FLAC__Metadata_SimpleIterator |
The opaque structure definition for the level 1 iterator type. See the metadata level 1 module for a detailed description.
Status type for FLAC__Metadata_SimpleIterator.
The iterator's current status can be obtained by calling FLAC__metadata_simple_iterator_status().
FLAC__Metadata_SimpleIterator* FLAC__metadata_simple_iterator_new | ( | void | ) |
Create a new iterator instance.
FLAC__Metadata_SimpleIterator* | NULL if there was an error allocating memory, else the new instance. |
void FLAC__metadata_simple_iterator_delete | ( | FLAC__Metadata_SimpleIterator * | iterator | ) |
Free an iterator instance. Deletes the object pointed to by iterator.
iterator | A pointer to an existing iterator. |
FLAC__Metadata_SimpleIteratorStatus FLAC__metadata_simple_iterator_status | ( | FLAC__Metadata_SimpleIterator * | iterator | ) |
Get the current status of the iterator. Call this after a function returns false
to get the reason for the error. Also resets the status to FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK.
iterator | A pointer to an existing iterator. |
FLAC__Metadata_SimpleIteratorStatus | The current status of the iterator. |
FLAC__bool FLAC__metadata_simple_iterator_init | ( | FLAC__Metadata_SimpleIterator * | iterator, |
const char * | filename, | ||
FLAC__bool | read_only, | ||
FLAC__bool | preserve_file_stats | ||
) |
Initialize the iterator to point to the first metadata block in the given FLAC file.
On Windows, filename must be a UTF-8 encoded filename, which libFLAC internally translates to an appropriate representation to use with _wfopen. On all other systems, filename is passed to fopen without any translation.
iterator | A pointer to an existing iterator. |
filename | The path to the FLAC file. |
read_only | If true , the FLAC file will be opened in read-only mode; if false , the FLAC file will be opened for edit even if no edits are performed. |
preserve_file_stats | If true , the owner and modification time will be preserved even if the FLAC file is written to. |
FLAC__bool | false if a memory allocation error occurs, the file can't be opened, or another error occurs, else true . |
FLAC__bool FLAC__metadata_simple_iterator_is_writable | ( | const FLAC__Metadata_SimpleIterator * | iterator | ) |
Returns true
if the FLAC file is writable. If false
, calls to FLAC__metadata_simple_iterator_set_block() and FLAC__metadata_simple_iterator_insert_block_after() will fail.
iterator | A pointer to an existing iterator. |
FLAC__bool | See above. |
FLAC__bool FLAC__metadata_simple_iterator_next | ( | FLAC__Metadata_SimpleIterator * | iterator | ) |
Moves the iterator forward one metadata block, returning false
if already at the end.
iterator | A pointer to an existing initialized iterator. |
FLAC__bool | false if already at the last metadata block of the chain, else true . |
FLAC__bool FLAC__metadata_simple_iterator_prev | ( | FLAC__Metadata_SimpleIterator * | iterator | ) |
Moves the iterator backward one metadata block, returning false
if already at the beginning.
iterator | A pointer to an existing initialized iterator. |
FLAC__bool | false if already at the first metadata block of the chain, else true . |
FLAC__bool FLAC__metadata_simple_iterator_is_last | ( | const FLAC__Metadata_SimpleIterator * | iterator | ) |
Returns a flag telling if the current metadata block is the last.
iterator | A pointer to an existing initialized iterator. |
FLAC__bool | true if the current metadata block is the last in the file, else false . |
off_t FLAC__metadata_simple_iterator_get_block_offset | ( | const FLAC__Metadata_SimpleIterator * | iterator | ) |
Get the offset of the metadata block at the current position. This avoids reading the actual block data which can save time for large blocks.
iterator | A pointer to an existing initialized iterator. |
off_t | The offset of the metadata block at the current iterator position. This is the byte offset relative to the beginning of the file of the current metadata block's header. |
FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type | ( | const FLAC__Metadata_SimpleIterator * | iterator | ) |
Get the type of the metadata block at the current position. This avoids reading the actual block data which can save time for large blocks.
iterator | A pointer to an existing initialized iterator. |
FLAC__MetadataType | The type of the metadata block at the current iterator position. |
uint32_t FLAC__metadata_simple_iterator_get_block_length | ( | const FLAC__Metadata_SimpleIterator * | iterator | ) |
Get the length of the metadata block at the current position. This avoids reading the actual block data which can save time for large blocks.
iterator | A pointer to an existing initialized iterator. |
uint32_t | The length of the metadata block at the current iterator position. The is same length as that in the metadata block header, i.e. the length of the metadata body that follows the header. |
FLAC__bool FLAC__metadata_simple_iterator_get_application_id | ( | FLAC__Metadata_SimpleIterator * | iterator, |
FLAC__byte * | id | ||
) |
Get the application ID of the APPLICATION
block at the current position. This avoids reading the actual block data which can save time for large blocks.
iterator | A pointer to an existing initialized iterator. |
id | A pointer to a buffer of at least 4 bytes where the ID will be stored. |
FLAC__bool | true if the ID was successfully read, else false , in which case you should check FLAC__metadata_simple_iterator_status() to find out why. If the status is FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT , then the current metadata block is not an APPLICATION block. Otherwise if the status is FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR or FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR , an I/O error occurred and the iterator can no longer be used. |
FLAC__StreamMetadata* FLAC__metadata_simple_iterator_get_block | ( | FLAC__Metadata_SimpleIterator * | iterator | ) |
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.
You must call FLAC__metadata_object_delete() on the returned object when you are finished with it.
iterator | A pointer to an existing initialized iterator. |
FLAC__StreamMetadata* | The current metadata block, or NULL if there was a memory allocation error. |
FLAC__bool FLAC__metadata_simple_iterator_set_block | ( | FLAC__Metadata_SimpleIterator * | iterator, |
FLAC__StreamMetadata * | block, | ||
FLAC__bool | use_padding | ||
) |
Write a block back to the FLAC file. This function tries to be as efficient as possible; how the block is actually written is shown by the following:
Existing block is a STREAMINFO block and the new block is a STREAMINFO block: the new block is written in place. Make sure you know what you're doing when changing the values of a STREAMINFO block.
Existing block is a STREAMINFO block and the new block is a not a STREAMINFO block: this is an error since the first block must be a STREAMINFO block. Returns false
without altering the file.
Existing block is not a STREAMINFO block and the new block is a STREAMINFO block: this is an error since there may be only one STREAMINFO block. Returns false
without altering the file.
Existing block and new block are the same length: the existing block will be replaced by the new block, written in place.
Existing block is longer than new block: if use_padding is true
, the existing block will be overwritten in place with the new block followed by a PADDING block, if possible, to make the total size the same as the existing block. Remember that a padding block requires at least four bytes so if the difference in size between the new block and existing block is less than that, the entire file will have to be rewritten, using the new block's exact size. If use_padding is false
, the entire file will be rewritten, replacing the existing block by the new block.
Existing block is shorter than new block: if use_padding is true
, the function will try and expand the new block into the following PADDING block, if it exists and doing so won't shrink the PADDING block to less than 4 bytes. If there is no following PADDING block, or it will shrink to less than 4 bytes, or use_padding is false
, the entire file is rewritten, replacing the existing block with the new block. Note that in this case any following PADDING block is preserved as is.
After writing the block, the iterator will remain in the same place, i.e. pointing to the new block.
iterator | A pointer to an existing initialized iterator. |
block | The block to set. |
use_padding | See above. |
FLAC__bool | true if successful, else false . |
FLAC__bool FLAC__metadata_simple_iterator_insert_block_after | ( | FLAC__Metadata_SimpleIterator * | iterator, |
FLAC__StreamMetadata * | block, | ||
FLAC__bool | use_padding | ||
) |
This is similar to FLAC__metadata_simple_iterator_set_block() except that instead of writing over an existing block, it appends a block after the existing block. use_padding is again used to tell the function to try an expand into following padding in an attempt to avoid rewriting the entire file.
This function will fail and return false
if given a STREAMINFO block.
After writing the block, the iterator will be pointing to the new block.
iterator | A pointer to an existing initialized iterator. |
block | The block to set. |
use_padding | See above. |
FLAC__bool | true if successful, else false . |
FLAC__bool FLAC__metadata_simple_iterator_delete_block | ( | FLAC__Metadata_SimpleIterator * | iterator, |
FLAC__bool | use_padding | ||
) |
Deletes the block at the current position. This will cause the entire FLAC file to be rewritten, unless use_padding is true
, in which case the block will be replaced by an equal-sized PADDING block. The iterator will be left pointing to the block before the one just deleted.
You may not delete the STREAMINFO block.
iterator | A pointer to an existing initialized iterator. |
use_padding | See above. |
FLAC__bool | true if successful, else false . |
|
extern |
Maps a FLAC__Metadata_SimpleIteratorStatus to a C string.
Using a FLAC__Metadata_SimpleIteratorStatus as the index to this array will give the string equivalent. The contents should not be modified.