Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

FLAC/metadata.h: metadata level 2 interface
[FLAC/metadata.h: metadata interfaces]

The level 2 interface provides read-write access to FLAC file metadata; all metadata is read into memory, operated on in memory, and then written to file, which is more efficient than level 1 when editing multiple blocks. More...

Typedefs

typedef FLAC__Metadata_Chain FLAC__Metadata_Chain
typedef FLAC__Metadata_Iterator FLAC__Metadata_Iterator

Enumerations

enum  FLAC__Metadata_ChainStatus {
  FLAC__METADATA_CHAIN_STATUS_OK = 0, FLAC__METADATA_CHAIN_STATUS_ILLEGAL_INPUT, FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE, FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE,
  FLAC__METADATA_CHAIN_STATUS_NOT_WRITABLE, FLAC__METADATA_CHAIN_STATUS_BAD_METADATA, FLAC__METADATA_CHAIN_STATUS_READ_ERROR, FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR,
  FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR, FLAC__METADATA_CHAIN_STATUS_RENAME_ERROR, FLAC__METADATA_CHAIN_STATUS_UNLINK_ERROR, FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR,
  FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR
}

Functions

FLAC__Metadata_ChainFLAC__metadata_chain_new ()
void FLAC__metadata_chain_delete (FLAC__Metadata_Chain *chain)
FLAC__Metadata_ChainStatus FLAC__metadata_chain_status (FLAC__Metadata_Chain *chain)
FLAC__bool FLAC__metadata_chain_read (FLAC__Metadata_Chain *chain, const char *filename)
FLAC__bool FLAC__metadata_chain_write (FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__bool preserve_file_stats)
void FLAC__metadata_chain_merge_padding (FLAC__Metadata_Chain *chain)
void FLAC__metadata_chain_sort_padding (FLAC__Metadata_Chain *chain)
FLAC__Metadata_IteratorFLAC__metadata_iterator_new ()
void FLAC__metadata_iterator_delete (FLAC__Metadata_Iterator *iterator)
void FLAC__metadata_iterator_init (FLAC__Metadata_Iterator *iterator, FLAC__Metadata_Chain *chain)
FLAC__bool FLAC__metadata_iterator_next (FLAC__Metadata_Iterator *iterator)
FLAC__bool FLAC__metadata_iterator_prev (FLAC__Metadata_Iterator *iterator)
FLAC__MetadataType FLAC__metadata_iterator_get_block_type (const FLAC__Metadata_Iterator *iterator)
FLAC__StreamMetadataFLAC__metadata_iterator_get_block (FLAC__Metadata_Iterator *iterator)
FLAC__bool FLAC__metadata_iterator_set_block (FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block)
FLAC__bool FLAC__metadata_iterator_delete_block (FLAC__Metadata_Iterator *iterator, FLAC__bool replace_with_padding)
FLAC__bool FLAC__metadata_iterator_insert_block_before (FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block)
FLAC__bool FLAC__metadata_iterator_insert_block_after (FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block)

Variables

const char *const FLAC__Metadata_ChainStatusString []

Detailed Description

The level 2 interface provides read-write access to FLAC file metadata; all metadata is read into memory, operated on in memory, and then written to file, which is more efficient than level 1 when editing multiple blocks.

The general usage of this interface is:

Note:
Even though the FLAC file is not open while the chain is being manipulated, you must not alter the file externally during this time. The chain assumes the FLAC file will not change between the time of FLAC__metadata_chain_read() and FLAC__metadata_chain_write().
Note:
Do not modify the is_last, length, or type fields of returned FLAC__MetadataType objects. These are managed automatically.
Note:
The metadata objects returned by FLAC__metadata_iterator_get_block() are owned by the chain; do not FLAC__metadata_object_delete() them. In the same way, blocks passed to FLAC__metadata_iterator_set_block() become owned by the chain and they will be deleted when the chain is deleted.

Typedef Documentation

typedef struct FLAC__Metadata_Chain FLAC__Metadata_Chain
 

The opaque structure definition for the level 2 chain type.

typedef struct FLAC__Metadata_Iterator FLAC__Metadata_Iterator
 

The opaque structure definition for the level 2 iterator type.


Enumeration Type Documentation

enum FLAC__Metadata_ChainStatus
 

Enumeration values:
FLAC__METADATA_CHAIN_STATUS_OK  The chain is in the normal OK state
FLAC__METADATA_CHAIN_STATUS_ILLEGAL_INPUT  The data passed into a function violated the function's usage criteria
FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE  The chain could not open the target file
FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE  The chain could not find the FLAC signature at the start of the file
FLAC__METADATA_CHAIN_STATUS_NOT_WRITABLE  The chain tried to write to a file that was not writable
FLAC__METADATA_CHAIN_STATUS_BAD_METADATA  The chain encountered input that does not conform to the FLAC metadata specification
FLAC__METADATA_CHAIN_STATUS_READ_ERROR  The chain encountered an error while reading the FLAC file
FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR  The chain encountered an error while seeking in the FLAC file
FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR  The chain encountered an error while writing the FLAC file
FLAC__METADATA_CHAIN_STATUS_RENAME_ERROR  The chain encountered an error renaming the FLAC file
FLAC__METADATA_CHAIN_STATUS_UNLINK_ERROR  The chain encountered an error removing the temporary file
FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR  Memory allocation failed
FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR  The caller violated an assertion or an unexpected error occurred


Function Documentation

FLAC__Metadata_Chain* FLAC__metadata_chain_new  
 

Create a new chain instance.

Return values:
FLAC__Metadata_Chain  * NULL if there was an error allocating memory, else the new instance.

void FLAC__metadata_chain_delete FLAC__Metadata_Chain   chain
 

Free a chain instance. Deletes the object pointed to by chain.

Parameters:
chain  A pointer to an existing chain.
Assertions:
chain != NULL 

FLAC__Metadata_ChainStatus FLAC__metadata_chain_status FLAC__Metadata_Chain   chain
 

Get the current status of the chain. Call this after a function returns false to get the reason for the error. Also resets the status to FLAC__METADATA_CHAIN_STATUS_OK.

Parameters:
chain  A pointer to an existing chain.
Assertions:
chain != NULL 
Return values:
FLAC__Metadata_ChainStatus  The current status of the chain.

FLAC__bool FLAC__metadata_chain_read FLAC__Metadata_Chain   chain,
const char *    filename
 

Read all metadata from a FLAC file into the chain.

Parameters:
chain  A pointer to an existing chain.
filename  The path to the FLAC file to read.
Assertions:
chain != NULL 
filename != NULL 
Return values:
FLAC__bool  true if a valid list of metadata blocks was read from filename, else false. On failure, check the status with FLAC__metadata_chain_status().

FLAC__bool FLAC__metadata_chain_write FLAC__Metadata_Chain   chain,
FLAC__bool    use_padding,
FLAC__bool    preserve_file_stats
 

Write all metadata out to the FLAC file. This function tries to be as efficient as possible; how the metadata is actually written is shown by the following:

If the current chain is the same size as the existing metadata, the new data is written in place.

If the current chain is longer than the existing metadata, and use_padding is true, and the last block is a PADDING block of sufficient length, the function will truncate the final padding block so that the overall size of the metadata is the same as the existing metadata, and then just rewrite the metadata. Otherwise, if not all of the above conditions are met, the entire FLAC file must be rewritten. If you want to use padding this way it is a good idea to call FLAC__metadata_chain_sort_padding() first so that you have the maximum amount of padding to work with, unless you need to preserve ordering of the PADDING blocks for some reason.

If the current chain is shorter than the existing metadata, and use_padding is true, and the final block is a PADDING block, the padding is extended to make the overall size the same as the existing data. If use_padding is true and the last block is not a PADDING block, a new PADDING block is added to the end of the new data to make it the same size as the existing data (if possible, see the note to FLAC__metadata_simple_iterator_set_block() about the four byte limit) and the new data is written in place. If none of the above apply or use_padding is false, the entire FLAC file is rewritten.

If preserve_file_stats is true, the owner and modification time will be preserved even if the FLAC file is written.

Parameters:
chain  A pointer to an existing chain.
use_padding  See above.
preserve_file_stats  See above.
Assertions:
chain != NULL 
Return values:
FLAC__bool  true if the write succeeded, else false. On failure, check the status with FLAC__metadata_chain_status().

void FLAC__metadata_chain_merge_padding FLAC__Metadata_Chain   chain
 

Merge adjacent PADDING blocks into a single block.

Note:
This function does not write to the FLAC file, it only modifies the chain.
Warning:
Any iterator on the current chain will become invalid after this call. You should delete the iterator and get a new one.
Parameters:
chain  A pointer to an existing chain.
Assertions:
chain != NULL 

void FLAC__metadata_chain_sort_padding FLAC__Metadata_Chain   chain
 

This function will move all PADDING blocks to the end on the metadata, then merge them into a single block.

Note:
This function does not write to the FLAC file, it only modifies the chain.
Warning:
Any iterator on the current chain will become invalid after this call. You should delete the iterator and get a new one.
Parameters:
chain  A pointer to an existing chain.
Assertions:
chain != NULL 

FLAC__Metadata_Iterator* FLAC__metadata_iterator_new  
 

Create a new iterator instance.

Return values:
FLAC__Metadata_Iterator  * NULL if there was an error allocating memory, else the new instance.

void FLAC__metadata_iterator_delete FLAC__Metadata_Iterator   iterator
 

Free an iterator instance. Deletes the object pointed to by iterator.

Parameters:
iterator  A pointer to an existing iterator.
Assertions:
iterator != NULL 

void FLAC__metadata_iterator_init FLAC__Metadata_Iterator   iterator,
FLAC__Metadata_Chain   chain
 

Initialize the iterator to point to the first metadata block in the given chain.

Parameters:
iterator  A pointer to an existing iterator.
chain  A pointer to an existing and initialized (read) chain.
Assertions:
iterator != NULL 
chain != NULL 

FLAC__bool FLAC__metadata_iterator_next FLAC__Metadata_Iterator   iterator
 

Moves the iterator forward one metadata block, returning false if already at the end.

Parameters:
iterator  A pointer to an existing initialized iterator.
Assertions:
iterator != NULL 
iterator has been successfully initialized with FLAC__metadata_iterator_init()
Return values:
FLAC__bool  false if already at the last metadata block of the chain, else true.

FLAC__bool FLAC__metadata_iterator_prev FLAC__Metadata_Iterator   iterator
 

Moves the iterator backward one metadata block, returning false if already at the beginning.

Parameters:
iterator  A pointer to an existing initialized iterator.
Assertions:
iterator != NULL 
iterator has been successfully initialized with FLAC__metadata_iterator_init()
Return values:
FLAC__bool  false if already at the first metadata block of the chain, else true.

FLAC__MetadataType FLAC__metadata_iterator_get_block_type const FLAC__Metadata_Iterator   iterator
 

Get the type of the metadata block at the current position.

Parameters:
iterator  A pointer to an existing initialized iterator.
Assertions:
iterator != NULL 
iterator has been successfully initialized with FLAC__metadata_iterator_init()
Return values:
FLAC__MetadataType  The type of the metadata block at the current iterator position.

FLAC__StreamMetadata* FLAC__metadata_iterator_get_block FLAC__Metadata_Iterator   iterator
 

Get the metadata block at the current position. You can modify the block in place but must write the chain before the changes are reflected to the FLAC file. You do not need to call FLAC__metadata_iterator_set_block() to reflect the changes; the pointer returned by FLAC__metadata_iterator_get_block() points directly into the chain.

Warning:
Do not call FLAC__metadata_object_delete() on the returned object; to delete a block use FLAC__metadata_iterator_delete_block().
Parameters:
iterator  A pointer to an existing initialized iterator.
Assertions:
iterator != NULL 
iterator has been successfully initialized with FLAC__metadata_iterator_init()
Return values:
FLAC__StreamMetadata  * The current metadata block.

FLAC__bool FLAC__metadata_iterator_set_block FLAC__Metadata_Iterator   iterator,
FLAC__StreamMetadata   block
 

Set the metadata block at the current position, replacing the existing block. The new block passed in becomes owned by the chain and it will be deleted when the chain is deleted.

Parameters:
iterator  A pointer to an existing initialized iterator.
block  A pointer to a metadata block.
Assertions:
iterator != NULL 
iterator has been successfully initialized with FLAC__metadata_iterator_init()
block != NULL 
Return values:
FLAC__bool  false if the conditions in the above description are not met, or a memory allocation error occurs, otherwise true.

FLAC__bool FLAC__metadata_iterator_delete_block FLAC__Metadata_Iterator   iterator,
FLAC__bool    replace_with_padding
 

Removes the current block from the chain. If replace_with_padding is true, the block will instead be replaced with a padding block of equal size. You can not delete the STREAMINFO block. The iterator will be left pointing to the block before the one just "deleted", even if replace_with_padding is true.

Parameters:
iterator  A pointer to an existing initialized iterator.
replace_with_padding  See above.
Assertions:
iterator != NULL 
iterator has been successfully initialized with FLAC__metadata_iterator_init()
Return values:
FLAC__bool  false if the conditions in the above description are not met, otherwise true.

FLAC__bool FLAC__metadata_iterator_insert_block_before FLAC__Metadata_Iterator   iterator,
FLAC__StreamMetadata   block
 

Insert a new block before the current block. You cannot insert a block before the first STREAMINFO block. You cannot insert a STREAMINFO block as there can be only one, the one that already exists at the head when you read in a chain. The chain takes ownership of the new block and it will be deleted when the chain is deleted. The iterator will be left pointing to the new block.

Parameters:
iterator  A pointer to an existing initialized iterator.
block  A pointer to a metadata block to insert.
Assertions:
iterator != NULL 
iterator has been successfully initialized with FLAC__metadata_iterator_init()
Return values:
FLAC__bool  false if the conditions in the above description are not met, or a memory allocation error occurs, otherwise true.

FLAC__bool FLAC__metadata_iterator_insert_block_after FLAC__Metadata_Iterator   iterator,
FLAC__StreamMetadata   block
 

Insert a new block after the current block. You cannot insert a STREAMINFO block as there can be only one, the one that already exists at the head when you read in a chain. The chain takes ownership of the new block and it will be deleted when the chain is deleted. The iterator will be left pointing to the new block.

Parameters:
iterator  A pointer to an existing initialized iterator.
block  A pointer to a metadata block to insert.
Assertions:
iterator != NULL 
iterator has been successfully initialized with FLAC__metadata_iterator_init()
Return values:
FLAC__bool  false if the conditions in the above description are not met, or a memory allocation error occurs, otherwise true.


Variable Documentation

const char* const FLAC__Metadata_ChainStatusString[]
 

Maps a FLAC__Metadata_ChainStatus to a C string.

Using a FLAC__Metadata_ChainStatus as the index to this array will give the string equivalent. The contents should not be modified.


Generated on Sat Jan 25 10:44:54 2003 for FLAC by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002