1*600f14f4SXin Li /* libFLAC - Free Lossless Audio Codec library 2*600f14f4SXin Li * Copyright (C) 2001-2009 Josh Coalson 3*600f14f4SXin Li * Copyright (C) 2011-2023 Xiph.Org Foundation 4*600f14f4SXin Li * 5*600f14f4SXin Li * Redistribution and use in source and binary forms, with or without 6*600f14f4SXin Li * modification, are permitted provided that the following conditions 7*600f14f4SXin Li * are met: 8*600f14f4SXin Li * 9*600f14f4SXin Li * - Redistributions of source code must retain the above copyright 10*600f14f4SXin Li * notice, this list of conditions and the following disclaimer. 11*600f14f4SXin Li * 12*600f14f4SXin Li * - Redistributions in binary form must reproduce the above copyright 13*600f14f4SXin Li * notice, this list of conditions and the following disclaimer in the 14*600f14f4SXin Li * documentation and/or other materials provided with the distribution. 15*600f14f4SXin Li * 16*600f14f4SXin Li * - Neither the name of the Xiph.org Foundation nor the names of its 17*600f14f4SXin Li * contributors may be used to endorse or promote products derived from 18*600f14f4SXin Li * this software without specific prior written permission. 19*600f14f4SXin Li * 20*600f14f4SXin Li * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21*600f14f4SXin Li * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22*600f14f4SXin Li * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23*600f14f4SXin Li * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 24*600f14f4SXin Li * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25*600f14f4SXin Li * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26*600f14f4SXin Li * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27*600f14f4SXin Li * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28*600f14f4SXin Li * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29*600f14f4SXin Li * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30*600f14f4SXin Li * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31*600f14f4SXin Li */ 32*600f14f4SXin Li 33*600f14f4SXin Li #ifndef FLAC__METADATA_H 34*600f14f4SXin Li #define FLAC__METADATA_H 35*600f14f4SXin Li 36*600f14f4SXin Li #include <sys/types.h> /* for off_t */ 37*600f14f4SXin Li #include "export.h" 38*600f14f4SXin Li #include "callback.h" 39*600f14f4SXin Li #include "format.h" 40*600f14f4SXin Li 41*600f14f4SXin Li /* -------------------------------------------------------------------- 42*600f14f4SXin Li (For an example of how all these routines are used, see the source 43*600f14f4SXin Li code for the unit tests in src/test_libFLAC/metadata_*.c, or 44*600f14f4SXin Li metaflac in src/metaflac/) 45*600f14f4SXin Li ------------------------------------------------------------------*/ 46*600f14f4SXin Li 47*600f14f4SXin Li /** \file include/FLAC/metadata.h 48*600f14f4SXin Li * 49*600f14f4SXin Li * \brief 50*600f14f4SXin Li * This module provides functions for creating and manipulating FLAC 51*600f14f4SXin Li * metadata blocks in memory, and three progressively more powerful 52*600f14f4SXin Li * interfaces for traversing and editing metadata in FLAC files. 53*600f14f4SXin Li * 54*600f14f4SXin Li * See the detailed documentation for each interface in the 55*600f14f4SXin Li * \link flac_metadata metadata \endlink module. 56*600f14f4SXin Li */ 57*600f14f4SXin Li 58*600f14f4SXin Li /** \defgroup flac_metadata FLAC/metadata.h: metadata interfaces 59*600f14f4SXin Li * \ingroup flac 60*600f14f4SXin Li * 61*600f14f4SXin Li * \brief 62*600f14f4SXin Li * This module provides functions for creating and manipulating FLAC 63*600f14f4SXin Li * metadata blocks in memory, and three progressively more powerful 64*600f14f4SXin Li * interfaces for traversing and editing metadata in native FLAC files. 65*600f14f4SXin Li * Note that currently only the Chain interface (level 2) supports Ogg 66*600f14f4SXin Li * FLAC files, and it is read-only i.e. no writing back changed 67*600f14f4SXin Li * metadata to file. 68*600f14f4SXin Li * 69*600f14f4SXin Li * There are three metadata interfaces of increasing complexity: 70*600f14f4SXin Li * 71*600f14f4SXin Li * Level 0: 72*600f14f4SXin Li * Read-only access to the STREAMINFO, VORBIS_COMMENT, CUESHEET, and 73*600f14f4SXin Li * PICTURE blocks. 74*600f14f4SXin Li * 75*600f14f4SXin Li * Level 1: 76*600f14f4SXin Li * Read-write access to all metadata blocks. This level is write- 77*600f14f4SXin Li * efficient in most cases (more on this below), and uses less memory 78*600f14f4SXin Li * than level 2. 79*600f14f4SXin Li * 80*600f14f4SXin Li * Level 2: 81*600f14f4SXin Li * Read-write access to all metadata blocks. This level is write- 82*600f14f4SXin Li * efficient in all cases, but uses more memory since all metadata for 83*600f14f4SXin Li * the whole file is read into memory and manipulated before writing 84*600f14f4SXin Li * out again. 85*600f14f4SXin Li * 86*600f14f4SXin Li * What do we mean by efficient? Since FLAC metadata appears at the 87*600f14f4SXin Li * beginning of the file, when writing metadata back to a FLAC file 88*600f14f4SXin Li * it is possible to grow or shrink the metadata such that the entire 89*600f14f4SXin Li * file must be rewritten. However, if the size remains the same during 90*600f14f4SXin Li * changes or PADDING blocks are utilized, only the metadata needs to be 91*600f14f4SXin Li * overwritten, which is much faster. 92*600f14f4SXin Li * 93*600f14f4SXin Li * Efficient means the whole file is rewritten at most one time, and only 94*600f14f4SXin Li * when necessary. Level 1 is not efficient only in the case that you 95*600f14f4SXin Li * cause more than one metadata block to grow or shrink beyond what can 96*600f14f4SXin Li * be accommodated by padding. In this case you should probably use level 97*600f14f4SXin Li * 2, which allows you to edit all the metadata for a file in memory and 98*600f14f4SXin Li * write it out all at once. 99*600f14f4SXin Li * 100*600f14f4SXin Li * All levels know how to skip over and not disturb an ID3v2 tag at the 101*600f14f4SXin Li * front of the file. 102*600f14f4SXin Li * 103*600f14f4SXin Li * All levels access files via their filenames. In addition, level 2 104*600f14f4SXin Li * has additional alternative read and write functions that take an I/O 105*600f14f4SXin Li * handle and callbacks, for situations where access by filename is not 106*600f14f4SXin Li * possible. 107*600f14f4SXin Li * 108*600f14f4SXin Li * In addition to the three interfaces, this module defines functions for 109*600f14f4SXin Li * creating and manipulating various metadata objects in memory. As we see 110*600f14f4SXin Li * from the Format module, FLAC metadata blocks in memory are very primitive 111*600f14f4SXin Li * structures for storing information in an efficient way. Reading 112*600f14f4SXin Li * information from the structures is easy but creating or modifying them 113*600f14f4SXin Li * directly is more complex. The metadata object routines here facilitate 114*600f14f4SXin Li * this by taking care of the consistency and memory management drudgery. 115*600f14f4SXin Li * 116*600f14f4SXin Li * Unless you will be using the level 1 or 2 interfaces to modify existing 117*600f14f4SXin Li * metadata however, you will not probably not need these. 118*600f14f4SXin Li * 119*600f14f4SXin Li * From a dependency standpoint, none of the encoders or decoders require 120*600f14f4SXin Li * the metadata module. This is so that embedded users can strip out the 121*600f14f4SXin Li * metadata module from libFLAC to reduce the size and complexity. 122*600f14f4SXin Li */ 123*600f14f4SXin Li 124*600f14f4SXin Li #ifdef __cplusplus 125*600f14f4SXin Li extern "C" { 126*600f14f4SXin Li #endif 127*600f14f4SXin Li 128*600f14f4SXin Li 129*600f14f4SXin Li /** \defgroup flac_metadata_level0 FLAC/metadata.h: metadata level 0 interface 130*600f14f4SXin Li * \ingroup flac_metadata 131*600f14f4SXin Li * 132*600f14f4SXin Li * \brief 133*600f14f4SXin Li * The level 0 interface consists of individual routines to read the 134*600f14f4SXin Li * STREAMINFO, VORBIS_COMMENT, CUESHEET, and PICTURE blocks, requiring 135*600f14f4SXin Li * only a filename. 136*600f14f4SXin Li * 137*600f14f4SXin Li * On Windows, filename must be a UTF-8 encoded filename, which libFLAC 138*600f14f4SXin Li * internally translates to an appropriate representation to use with 139*600f14f4SXin Li * _wfopen. On all other systems, filename is passed to fopen without 140*600f14f4SXin Li * any translation. 141*600f14f4SXin Li * 142*600f14f4SXin Li * They try to skip any ID3v2 tag at the head of the file. 143*600f14f4SXin Li * 144*600f14f4SXin Li * \{ 145*600f14f4SXin Li */ 146*600f14f4SXin Li 147*600f14f4SXin Li /** Read the STREAMINFO metadata block of the given FLAC file. This function 148*600f14f4SXin Li * will try to skip any ID3v2 tag at the head of the file. 149*600f14f4SXin Li * 150*600f14f4SXin Li * \param filename The path to the FLAC file to read. 151*600f14f4SXin Li * \param streaminfo A pointer to space for the STREAMINFO block. Since 152*600f14f4SXin Li * FLAC__StreamMetadata is a simple structure with no 153*600f14f4SXin Li * memory allocation involved, you pass the address of 154*600f14f4SXin Li * an existing structure. It need not be initialized. 155*600f14f4SXin Li * \assert 156*600f14f4SXin Li * \code filename != NULL \endcode 157*600f14f4SXin Li * \code streaminfo != NULL \endcode 158*600f14f4SXin Li * \retval FLAC__bool 159*600f14f4SXin Li * \c true if a valid STREAMINFO block was read from \a filename. Returns 160*600f14f4SXin Li * \c false if there was a memory allocation error, a file decoder error, 161*600f14f4SXin Li * or the file contained no STREAMINFO block. (A memory allocation error 162*600f14f4SXin Li * is possible because this function must set up a file decoder.) 163*600f14f4SXin Li */ 164*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_get_streaminfo(const char *filename, FLAC__StreamMetadata *streaminfo); 165*600f14f4SXin Li 166*600f14f4SXin Li /** Read the VORBIS_COMMENT metadata block of the given FLAC file. This 167*600f14f4SXin Li * function will try to skip any ID3v2 tag at the head of the file. 168*600f14f4SXin Li * 169*600f14f4SXin Li * \param filename The path to the FLAC file to read. 170*600f14f4SXin Li * \param tags The address where the returned pointer will be 171*600f14f4SXin Li * stored. The \a tags object must be deleted by 172*600f14f4SXin Li * the caller using FLAC__metadata_object_delete(). 173*600f14f4SXin Li * \assert 174*600f14f4SXin Li * \code filename != NULL \endcode 175*600f14f4SXin Li * \code tags != NULL \endcode 176*600f14f4SXin Li * \retval FLAC__bool 177*600f14f4SXin Li * \c true if a valid VORBIS_COMMENT block was read from \a filename, 178*600f14f4SXin Li * and \a *tags will be set to the address of the metadata structure. 179*600f14f4SXin Li * Returns \c false if there was a memory allocation error, a file 180*600f14f4SXin Li * decoder error, or the file contained no VORBIS_COMMENT block, and 181*600f14f4SXin Li * \a *tags will be set to \c NULL. 182*600f14f4SXin Li */ 183*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_get_tags(const char *filename, FLAC__StreamMetadata **tags); 184*600f14f4SXin Li 185*600f14f4SXin Li /** Read the CUESHEET metadata block of the given FLAC file. This 186*600f14f4SXin Li * function will try to skip any ID3v2 tag at the head of the file. 187*600f14f4SXin Li * 188*600f14f4SXin Li * \param filename The path to the FLAC file to read. 189*600f14f4SXin Li * \param cuesheet The address where the returned pointer will be 190*600f14f4SXin Li * stored. The \a cuesheet object must be deleted by 191*600f14f4SXin Li * the caller using FLAC__metadata_object_delete(). 192*600f14f4SXin Li * \assert 193*600f14f4SXin Li * \code filename != NULL \endcode 194*600f14f4SXin Li * \code cuesheet != NULL \endcode 195*600f14f4SXin Li * \retval FLAC__bool 196*600f14f4SXin Li * \c true if a valid CUESHEET block was read from \a filename, 197*600f14f4SXin Li * and \a *cuesheet will be set to the address of the metadata 198*600f14f4SXin Li * structure. Returns \c false if there was a memory allocation 199*600f14f4SXin Li * error, a file decoder error, or the file contained no CUESHEET 200*600f14f4SXin Li * block, and \a *cuesheet will be set to \c NULL. 201*600f14f4SXin Li */ 202*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_get_cuesheet(const char *filename, FLAC__StreamMetadata **cuesheet); 203*600f14f4SXin Li 204*600f14f4SXin Li /** Read a PICTURE metadata block of the given FLAC file. This 205*600f14f4SXin Li * function will try to skip any ID3v2 tag at the head of the file. 206*600f14f4SXin Li * Since there can be more than one PICTURE block in a file, this 207*600f14f4SXin Li * function takes a number of parameters that act as constraints to 208*600f14f4SXin Li * the search. The PICTURE block with the largest area matching all 209*600f14f4SXin Li * the constraints will be returned, or \a *picture will be set to 210*600f14f4SXin Li * \c NULL if there was no such block. 211*600f14f4SXin Li * 212*600f14f4SXin Li * \param filename The path to the FLAC file to read. 213*600f14f4SXin Li * \param picture The address where the returned pointer will be 214*600f14f4SXin Li * stored. The \a picture object must be deleted by 215*600f14f4SXin Li * the caller using FLAC__metadata_object_delete(). 216*600f14f4SXin Li * \param type The desired picture type. Use \c -1 to mean 217*600f14f4SXin Li * "any type". 218*600f14f4SXin Li * \param mime_type The desired MIME type, e.g. "image/jpeg". The 219*600f14f4SXin Li * string will be matched exactly. Use \c NULL to 220*600f14f4SXin Li * mean "any MIME type". 221*600f14f4SXin Li * \param description The desired description. The string will be 222*600f14f4SXin Li * matched exactly. Use \c NULL to mean "any 223*600f14f4SXin Li * description". 224*600f14f4SXin Li * \param max_width The maximum width in pixels desired. Use 225*600f14f4SXin Li * \c (uint32_t)(-1) to mean "any width". 226*600f14f4SXin Li * \param max_height The maximum height in pixels desired. Use 227*600f14f4SXin Li * \c (uint32_t)(-1) to mean "any height". 228*600f14f4SXin Li * \param max_depth The maximum color depth in bits-per-pixel desired. 229*600f14f4SXin Li * Use \c (uint32_t)(-1) to mean "any depth". 230*600f14f4SXin Li * \param max_colors The maximum number of colors desired. Use 231*600f14f4SXin Li * \c (uint32_t)(-1) to mean "any number of colors". 232*600f14f4SXin Li * \assert 233*600f14f4SXin Li * \code filename != NULL \endcode 234*600f14f4SXin Li * \code picture != NULL \endcode 235*600f14f4SXin Li * \retval FLAC__bool 236*600f14f4SXin Li * \c true if a valid PICTURE block was read from \a filename, 237*600f14f4SXin Li * and \a *picture will be set to the address of the metadata 238*600f14f4SXin Li * structure. Returns \c false if there was a memory allocation 239*600f14f4SXin Li * error, a file decoder error, or the file contained no PICTURE 240*600f14f4SXin Li * block, and \a *picture will be set to \c NULL. 241*600f14f4SXin Li */ 242*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_get_picture(const char *filename, FLAC__StreamMetadata **picture, FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, uint32_t max_width, uint32_t max_height, uint32_t max_depth, uint32_t max_colors); 243*600f14f4SXin Li 244*600f14f4SXin Li /* \} */ 245*600f14f4SXin Li 246*600f14f4SXin Li 247*600f14f4SXin Li /** \defgroup flac_metadata_level1 FLAC/metadata.h: metadata level 1 interface 248*600f14f4SXin Li * \ingroup flac_metadata 249*600f14f4SXin Li * 250*600f14f4SXin Li * \brief 251*600f14f4SXin Li * The level 1 interface provides read-write access to FLAC file metadata and 252*600f14f4SXin Li * operates directly on the FLAC file. 253*600f14f4SXin Li * 254*600f14f4SXin Li * The general usage of this interface is: 255*600f14f4SXin Li * 256*600f14f4SXin Li * - Create an iterator using FLAC__metadata_simple_iterator_new() 257*600f14f4SXin Li * - Attach it to a file using FLAC__metadata_simple_iterator_init() and check 258*600f14f4SXin Li * the exit code. Call FLAC__metadata_simple_iterator_is_writable() to 259*600f14f4SXin Li * see if the file is writable, or only read access is allowed. 260*600f14f4SXin Li * - Use FLAC__metadata_simple_iterator_next() and 261*600f14f4SXin Li * FLAC__metadata_simple_iterator_prev() to traverse the blocks. 262*600f14f4SXin Li * This is does not read the actual blocks themselves. 263*600f14f4SXin Li * FLAC__metadata_simple_iterator_next() is relatively fast. 264*600f14f4SXin Li * FLAC__metadata_simple_iterator_prev() is slower since it needs to search 265*600f14f4SXin Li * forward from the front of the file. 266*600f14f4SXin Li * - Use FLAC__metadata_simple_iterator_get_block_type() or 267*600f14f4SXin Li * FLAC__metadata_simple_iterator_get_block() to access the actual data at 268*600f14f4SXin Li * the current iterator position. The returned object is yours to modify 269*600f14f4SXin Li * and free. 270*600f14f4SXin Li * - Use FLAC__metadata_simple_iterator_set_block() to write a modified block 271*600f14f4SXin Li * back. You must have write permission to the original file. Make sure to 272*600f14f4SXin Li * read the whole comment to FLAC__metadata_simple_iterator_set_block() 273*600f14f4SXin Li * below. 274*600f14f4SXin Li * - Use FLAC__metadata_simple_iterator_insert_block_after() to add new blocks. 275*600f14f4SXin Li * Use the object creation functions from 276*600f14f4SXin Li * \link flac_metadata_object here \endlink to generate new objects. 277*600f14f4SXin Li * - Use FLAC__metadata_simple_iterator_delete_block() to remove the block 278*600f14f4SXin Li * currently referred to by the iterator, or replace it with padding. 279*600f14f4SXin Li * - Destroy the iterator with FLAC__metadata_simple_iterator_delete() when 280*600f14f4SXin Li * finished. 281*600f14f4SXin Li * 282*600f14f4SXin Li * \note 283*600f14f4SXin Li * The FLAC file remains open the whole time between 284*600f14f4SXin Li * FLAC__metadata_simple_iterator_init() and 285*600f14f4SXin Li * FLAC__metadata_simple_iterator_delete(), so make sure you are not altering 286*600f14f4SXin Li * the file during this time. 287*600f14f4SXin Li * 288*600f14f4SXin Li * \note 289*600f14f4SXin Li * Do not modify the \a is_last, \a length, or \a type fields of returned 290*600f14f4SXin Li * FLAC__StreamMetadata objects. These are managed automatically. 291*600f14f4SXin Li * 292*600f14f4SXin Li * \note 293*600f14f4SXin Li * If any of the modification functions 294*600f14f4SXin Li * (FLAC__metadata_simple_iterator_set_block(), 295*600f14f4SXin Li * FLAC__metadata_simple_iterator_delete_block(), 296*600f14f4SXin Li * FLAC__metadata_simple_iterator_insert_block_after(), etc.) return \c false, 297*600f14f4SXin Li * you should delete the iterator as it may no longer be valid. 298*600f14f4SXin Li * 299*600f14f4SXin Li * \{ 300*600f14f4SXin Li */ 301*600f14f4SXin Li 302*600f14f4SXin Li struct FLAC__Metadata_SimpleIterator; 303*600f14f4SXin Li /** The opaque structure definition for the level 1 iterator type. 304*600f14f4SXin Li * See the 305*600f14f4SXin Li * \link flac_metadata_level1 metadata level 1 module \endlink 306*600f14f4SXin Li * for a detailed description. 307*600f14f4SXin Li */ 308*600f14f4SXin Li typedef struct FLAC__Metadata_SimpleIterator FLAC__Metadata_SimpleIterator; 309*600f14f4SXin Li 310*600f14f4SXin Li /** Status type for FLAC__Metadata_SimpleIterator. 311*600f14f4SXin Li * 312*600f14f4SXin Li * The iterator's current status can be obtained by calling FLAC__metadata_simple_iterator_status(). 313*600f14f4SXin Li */ 314*600f14f4SXin Li typedef enum { 315*600f14f4SXin Li 316*600f14f4SXin Li FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK = 0, 317*600f14f4SXin Li /**< The iterator is in the normal OK state */ 318*600f14f4SXin Li 319*600f14f4SXin Li FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT, 320*600f14f4SXin Li /**< The data passed into a function violated the function's usage criteria */ 321*600f14f4SXin Li 322*600f14f4SXin Li FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE, 323*600f14f4SXin Li /**< The iterator could not open the target file */ 324*600f14f4SXin Li 325*600f14f4SXin Li FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_A_FLAC_FILE, 326*600f14f4SXin Li /**< The iterator could not find the FLAC signature at the start of the file */ 327*600f14f4SXin Li 328*600f14f4SXin Li FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_WRITABLE, 329*600f14f4SXin Li /**< The iterator tried to write to a file that was not writable */ 330*600f14f4SXin Li 331*600f14f4SXin Li FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA, 332*600f14f4SXin Li /**< The iterator encountered input that does not conform to the FLAC metadata specification */ 333*600f14f4SXin Li 334*600f14f4SXin Li FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR, 335*600f14f4SXin Li /**< The iterator encountered an error while reading the FLAC file */ 336*600f14f4SXin Li 337*600f14f4SXin Li FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR, 338*600f14f4SXin Li /**< The iterator encountered an error while seeking in the FLAC file */ 339*600f14f4SXin Li 340*600f14f4SXin Li FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR, 341*600f14f4SXin Li /**< The iterator encountered an error while writing the FLAC file */ 342*600f14f4SXin Li 343*600f14f4SXin Li FLAC__METADATA_SIMPLE_ITERATOR_STATUS_RENAME_ERROR, 344*600f14f4SXin Li /**< The iterator encountered an error renaming the FLAC file */ 345*600f14f4SXin Li 346*600f14f4SXin Li FLAC__METADATA_SIMPLE_ITERATOR_STATUS_UNLINK_ERROR, 347*600f14f4SXin Li /**< The iterator encountered an error removing the temporary file */ 348*600f14f4SXin Li 349*600f14f4SXin Li FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR, 350*600f14f4SXin Li /**< Memory allocation failed */ 351*600f14f4SXin Li 352*600f14f4SXin Li FLAC__METADATA_SIMPLE_ITERATOR_STATUS_INTERNAL_ERROR 353*600f14f4SXin Li /**< The caller violated an assertion or an unexpected error occurred */ 354*600f14f4SXin Li 355*600f14f4SXin Li } FLAC__Metadata_SimpleIteratorStatus; 356*600f14f4SXin Li 357*600f14f4SXin Li /** Maps a FLAC__Metadata_SimpleIteratorStatus to a C string. 358*600f14f4SXin Li * 359*600f14f4SXin Li * Using a FLAC__Metadata_SimpleIteratorStatus as the index to this array 360*600f14f4SXin Li * will give the string equivalent. The contents should not be modified. 361*600f14f4SXin Li */ 362*600f14f4SXin Li extern FLAC_API const char * const FLAC__Metadata_SimpleIteratorStatusString[]; 363*600f14f4SXin Li 364*600f14f4SXin Li 365*600f14f4SXin Li /** Create a new iterator instance. 366*600f14f4SXin Li * 367*600f14f4SXin Li * \retval FLAC__Metadata_SimpleIterator* 368*600f14f4SXin Li * \c NULL if there was an error allocating memory, else the new instance. 369*600f14f4SXin Li */ 370*600f14f4SXin Li FLAC_API FLAC__Metadata_SimpleIterator *FLAC__metadata_simple_iterator_new(void); 371*600f14f4SXin Li 372*600f14f4SXin Li /** Free an iterator instance. Deletes the object pointed to by \a iterator. 373*600f14f4SXin Li * 374*600f14f4SXin Li * \param iterator A pointer to an existing iterator. 375*600f14f4SXin Li * \assert 376*600f14f4SXin Li * \code iterator != NULL \endcode 377*600f14f4SXin Li */ 378*600f14f4SXin Li FLAC_API void FLAC__metadata_simple_iterator_delete(FLAC__Metadata_SimpleIterator *iterator); 379*600f14f4SXin Li 380*600f14f4SXin Li /** Get the current status of the iterator. Call this after a function 381*600f14f4SXin Li * returns \c false to get the reason for the error. Also resets the status 382*600f14f4SXin Li * to FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK. 383*600f14f4SXin Li * 384*600f14f4SXin Li * \param iterator A pointer to an existing iterator. 385*600f14f4SXin Li * \assert 386*600f14f4SXin Li * \code iterator != NULL \endcode 387*600f14f4SXin Li * \retval FLAC__Metadata_SimpleIteratorStatus 388*600f14f4SXin Li * The current status of the iterator. 389*600f14f4SXin Li */ 390*600f14f4SXin Li FLAC_API FLAC__Metadata_SimpleIteratorStatus FLAC__metadata_simple_iterator_status(FLAC__Metadata_SimpleIterator *iterator); 391*600f14f4SXin Li 392*600f14f4SXin Li /** Initialize the iterator to point to the first metadata block in the 393*600f14f4SXin Li * given FLAC file. 394*600f14f4SXin Li * 395*600f14f4SXin Li * On Windows, filename must be a UTF-8 encoded filename, which libFLAC 396*600f14f4SXin Li * internally translates to an appropriate representation to use with 397*600f14f4SXin Li * _wfopen. On all other systems, filename is passed to fopen without 398*600f14f4SXin Li * any translation. 399*600f14f4SXin Li * 400*600f14f4SXin Li * \param iterator A pointer to an existing iterator. 401*600f14f4SXin Li * \param filename The path to the FLAC file. 402*600f14f4SXin Li * \param read_only If \c true, the FLAC file will be opened 403*600f14f4SXin Li * in read-only mode; if \c false, the FLAC 404*600f14f4SXin Li * file will be opened for edit even if no 405*600f14f4SXin Li * edits are performed. 406*600f14f4SXin Li * \param preserve_file_stats If \c true, the owner and modification 407*600f14f4SXin Li * time will be preserved even if the FLAC 408*600f14f4SXin Li * file is written to. 409*600f14f4SXin Li * \assert 410*600f14f4SXin Li * \code iterator != NULL \endcode 411*600f14f4SXin Li * \code filename != NULL \endcode 412*600f14f4SXin Li * \retval FLAC__bool 413*600f14f4SXin Li * \c false if a memory allocation error occurs, the file can't be 414*600f14f4SXin Li * opened, or another error occurs, else \c true. 415*600f14f4SXin Li */ 416*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_simple_iterator_init(FLAC__Metadata_SimpleIterator *iterator, const char *filename, FLAC__bool read_only, FLAC__bool preserve_file_stats); 417*600f14f4SXin Li 418*600f14f4SXin Li /** Returns \c true if the FLAC file is writable. If \c false, calls to 419*600f14f4SXin Li * FLAC__metadata_simple_iterator_set_block() and 420*600f14f4SXin Li * FLAC__metadata_simple_iterator_insert_block_after() will fail. 421*600f14f4SXin Li * 422*600f14f4SXin Li * \param iterator A pointer to an existing iterator. 423*600f14f4SXin Li * \assert 424*600f14f4SXin Li * \code iterator != NULL \endcode 425*600f14f4SXin Li * \retval FLAC__bool 426*600f14f4SXin Li * See above. 427*600f14f4SXin Li */ 428*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_writable(const FLAC__Metadata_SimpleIterator *iterator); 429*600f14f4SXin Li 430*600f14f4SXin Li /** Moves the iterator forward one metadata block, returning \c false if 431*600f14f4SXin Li * already at the end. 432*600f14f4SXin Li * 433*600f14f4SXin Li * \param iterator A pointer to an existing initialized iterator. 434*600f14f4SXin Li * \assert 435*600f14f4SXin Li * \code iterator != NULL \endcode 436*600f14f4SXin Li * \a iterator has been successfully initialized with 437*600f14f4SXin Li * FLAC__metadata_simple_iterator_init() 438*600f14f4SXin Li * \retval FLAC__bool 439*600f14f4SXin Li * \c false if already at the last metadata block of the chain, else 440*600f14f4SXin Li * \c true. 441*600f14f4SXin Li */ 442*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_simple_iterator_next(FLAC__Metadata_SimpleIterator *iterator); 443*600f14f4SXin Li 444*600f14f4SXin Li /** Moves the iterator backward one metadata block, returning \c false if 445*600f14f4SXin Li * already at the beginning. 446*600f14f4SXin Li * 447*600f14f4SXin Li * \param iterator A pointer to an existing initialized iterator. 448*600f14f4SXin Li * \assert 449*600f14f4SXin Li * \code iterator != NULL \endcode 450*600f14f4SXin Li * \a iterator has been successfully initialized with 451*600f14f4SXin Li * FLAC__metadata_simple_iterator_init() 452*600f14f4SXin Li * \retval FLAC__bool 453*600f14f4SXin Li * \c false if already at the first metadata block of the chain, else 454*600f14f4SXin Li * \c true. 455*600f14f4SXin Li */ 456*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_simple_iterator_prev(FLAC__Metadata_SimpleIterator *iterator); 457*600f14f4SXin Li 458*600f14f4SXin Li /** Returns a flag telling if the current metadata block is the last. 459*600f14f4SXin Li * 460*600f14f4SXin Li * \param iterator A pointer to an existing initialized iterator. 461*600f14f4SXin Li * \assert 462*600f14f4SXin Li * \code iterator != NULL \endcode 463*600f14f4SXin Li * \a iterator has been successfully initialized with 464*600f14f4SXin Li * FLAC__metadata_simple_iterator_init() 465*600f14f4SXin Li * \retval FLAC__bool 466*600f14f4SXin Li * \c true if the current metadata block is the last in the file, 467*600f14f4SXin Li * else \c false. 468*600f14f4SXin Li */ 469*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_last(const FLAC__Metadata_SimpleIterator *iterator); 470*600f14f4SXin Li 471*600f14f4SXin Li /** Get the offset of the metadata block at the current position. This 472*600f14f4SXin Li * avoids reading the actual block data which can save time for large 473*600f14f4SXin Li * blocks. 474*600f14f4SXin Li * 475*600f14f4SXin Li * \param iterator A pointer to an existing initialized iterator. 476*600f14f4SXin Li * \assert 477*600f14f4SXin Li * \code iterator != NULL \endcode 478*600f14f4SXin Li * \a iterator has been successfully initialized with 479*600f14f4SXin Li * FLAC__metadata_simple_iterator_init() 480*600f14f4SXin Li * \retval off_t 481*600f14f4SXin Li * The offset of the metadata block at the current iterator position. 482*600f14f4SXin Li * This is the byte offset relative to the beginning of the file of 483*600f14f4SXin Li * the current metadata block's header. 484*600f14f4SXin Li */ 485*600f14f4SXin Li FLAC_API off_t FLAC__metadata_simple_iterator_get_block_offset(const FLAC__Metadata_SimpleIterator *iterator); 486*600f14f4SXin Li 487*600f14f4SXin Li /** Get the type of the metadata block at the current position. This 488*600f14f4SXin Li * avoids reading the actual block data which can save time for large 489*600f14f4SXin Li * blocks. 490*600f14f4SXin Li * 491*600f14f4SXin Li * \param iterator A pointer to an existing initialized iterator. 492*600f14f4SXin Li * \assert 493*600f14f4SXin Li * \code iterator != NULL \endcode 494*600f14f4SXin Li * \a iterator has been successfully initialized with 495*600f14f4SXin Li * FLAC__metadata_simple_iterator_init() 496*600f14f4SXin Li * \retval FLAC__MetadataType 497*600f14f4SXin Li * The type of the metadata block at the current iterator position. 498*600f14f4SXin Li */ 499*600f14f4SXin Li FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type(const FLAC__Metadata_SimpleIterator *iterator); 500*600f14f4SXin Li 501*600f14f4SXin Li /** Get the length of the metadata block at the current position. This 502*600f14f4SXin Li * avoids reading the actual block data which can save time for large 503*600f14f4SXin Li * blocks. 504*600f14f4SXin Li * 505*600f14f4SXin Li * \param iterator A pointer to an existing initialized iterator. 506*600f14f4SXin Li * \assert 507*600f14f4SXin Li * \code iterator != NULL \endcode 508*600f14f4SXin Li * \a iterator has been successfully initialized with 509*600f14f4SXin Li * FLAC__metadata_simple_iterator_init() 510*600f14f4SXin Li * \retval uint32_t 511*600f14f4SXin Li * The length of the metadata block at the current iterator position. 512*600f14f4SXin Li * The is same length as that in the 513*600f14f4SXin Li * <a href="http://xiph.org/flhttps://xiph.org/flac/format.html#metadata_block_header">metadata block header</a>, 514*600f14f4SXin Li * i.e. the length of the metadata body that follows the header. 515*600f14f4SXin Li */ 516*600f14f4SXin Li FLAC_API uint32_t FLAC__metadata_simple_iterator_get_block_length(const FLAC__Metadata_SimpleIterator *iterator); 517*600f14f4SXin Li 518*600f14f4SXin Li /** Get the application ID of the \c APPLICATION block at the current 519*600f14f4SXin Li * position. This avoids reading the actual block data which can save 520*600f14f4SXin Li * time for large blocks. 521*600f14f4SXin Li * 522*600f14f4SXin Li * \param iterator A pointer to an existing initialized iterator. 523*600f14f4SXin Li * \param id A pointer to a buffer of at least \c 4 bytes where 524*600f14f4SXin Li * the ID will be stored. 525*600f14f4SXin Li * \assert 526*600f14f4SXin Li * \code iterator != NULL \endcode 527*600f14f4SXin Li * \code id != NULL \endcode 528*600f14f4SXin Li * \a iterator has been successfully initialized with 529*600f14f4SXin Li * FLAC__metadata_simple_iterator_init() 530*600f14f4SXin Li * \retval FLAC__bool 531*600f14f4SXin Li * \c true if the ID was successfully read, else \c false, in which 532*600f14f4SXin Li * case you should check FLAC__metadata_simple_iterator_status() to 533*600f14f4SXin Li * find out why. If the status is 534*600f14f4SXin Li * \c FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT, then the 535*600f14f4SXin Li * current metadata block is not an \c APPLICATION block. Otherwise 536*600f14f4SXin Li * if the status is 537*600f14f4SXin Li * \c FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR or 538*600f14f4SXin Li * \c FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR, an I/O error 539*600f14f4SXin Li * occurred and the iterator can no longer be used. 540*600f14f4SXin Li */ 541*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_simple_iterator_get_application_id(FLAC__Metadata_SimpleIterator *iterator, FLAC__byte *id); 542*600f14f4SXin Li 543*600f14f4SXin Li /** Get the metadata block at the current position. You can modify the 544*600f14f4SXin Li * block but must use FLAC__metadata_simple_iterator_set_block() to 545*600f14f4SXin Li * write it back to the FLAC file. 546*600f14f4SXin Li * 547*600f14f4SXin Li * You must call FLAC__metadata_object_delete() on the returned object 548*600f14f4SXin Li * when you are finished with it. 549*600f14f4SXin Li * 550*600f14f4SXin Li * \param iterator A pointer to an existing initialized iterator. 551*600f14f4SXin Li * \assert 552*600f14f4SXin Li * \code iterator != NULL \endcode 553*600f14f4SXin Li * \a iterator has been successfully initialized with 554*600f14f4SXin Li * FLAC__metadata_simple_iterator_init() 555*600f14f4SXin Li * \retval FLAC__StreamMetadata* 556*600f14f4SXin Li * The current metadata block, or \c NULL if there was a memory 557*600f14f4SXin Li * allocation error. 558*600f14f4SXin Li */ 559*600f14f4SXin Li FLAC_API FLAC__StreamMetadata *FLAC__metadata_simple_iterator_get_block(FLAC__Metadata_SimpleIterator *iterator); 560*600f14f4SXin Li 561*600f14f4SXin Li /** Write a block back to the FLAC file. This function tries to be 562*600f14f4SXin Li * as efficient as possible; how the block is actually written is 563*600f14f4SXin Li * shown by the following: 564*600f14f4SXin Li * 565*600f14f4SXin Li * Existing block is a STREAMINFO block and the new block is a 566*600f14f4SXin Li * STREAMINFO block: the new block is written in place. Make sure 567*600f14f4SXin Li * you know what you're doing when changing the values of a 568*600f14f4SXin Li * STREAMINFO block. 569*600f14f4SXin Li * 570*600f14f4SXin Li * Existing block is a STREAMINFO block and the new block is a 571*600f14f4SXin Li * not a STREAMINFO block: this is an error since the first block 572*600f14f4SXin Li * must be a STREAMINFO block. Returns \c false without altering the 573*600f14f4SXin Li * file. 574*600f14f4SXin Li * 575*600f14f4SXin Li * Existing block is not a STREAMINFO block and the new block is a 576*600f14f4SXin Li * STREAMINFO block: this is an error since there may be only one 577*600f14f4SXin Li * STREAMINFO block. Returns \c false without altering the file. 578*600f14f4SXin Li * 579*600f14f4SXin Li * Existing block and new block are the same length: the existing 580*600f14f4SXin Li * block will be replaced by the new block, written in place. 581*600f14f4SXin Li * 582*600f14f4SXin Li * Existing block is longer than new block: if use_padding is \c true, 583*600f14f4SXin Li * the existing block will be overwritten in place with the new 584*600f14f4SXin Li * block followed by a PADDING block, if possible, to make the total 585*600f14f4SXin Li * size the same as the existing block. Remember that a padding 586*600f14f4SXin Li * block requires at least four bytes so if the difference in size 587*600f14f4SXin Li * between the new block and existing block is less than that, the 588*600f14f4SXin Li * entire file will have to be rewritten, using the new block's 589*600f14f4SXin Li * exact size. If use_padding is \c false, the entire file will be 590*600f14f4SXin Li * rewritten, replacing the existing block by the new block. 591*600f14f4SXin Li * 592*600f14f4SXin Li * Existing block is shorter than new block: if use_padding is \c true, 593*600f14f4SXin Li * the function will try and expand the new block into the following 594*600f14f4SXin Li * PADDING block, if it exists and doing so won't shrink the PADDING 595*600f14f4SXin Li * block to less than 4 bytes. If there is no following PADDING 596*600f14f4SXin Li * block, or it will shrink to less than 4 bytes, or use_padding is 597*600f14f4SXin Li * \c false, the entire file is rewritten, replacing the existing block 598*600f14f4SXin Li * with the new block. Note that in this case any following PADDING 599*600f14f4SXin Li * block is preserved as is. 600*600f14f4SXin Li * 601*600f14f4SXin Li * After writing the block, the iterator will remain in the same 602*600f14f4SXin Li * place, i.e. pointing to the new block. 603*600f14f4SXin Li * 604*600f14f4SXin Li * \param iterator A pointer to an existing initialized iterator. 605*600f14f4SXin Li * \param block The block to set. 606*600f14f4SXin Li * \param use_padding See above. 607*600f14f4SXin Li * \assert 608*600f14f4SXin Li * \code iterator != NULL \endcode 609*600f14f4SXin Li * \a iterator has been successfully initialized with 610*600f14f4SXin Li * FLAC__metadata_simple_iterator_init() 611*600f14f4SXin Li * \code block != NULL \endcode 612*600f14f4SXin Li * \retval FLAC__bool 613*600f14f4SXin Li * \c true if successful, else \c false. 614*600f14f4SXin Li */ 615*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding); 616*600f14f4SXin Li 617*600f14f4SXin Li /** This is similar to FLAC__metadata_simple_iterator_set_block() 618*600f14f4SXin Li * except that instead of writing over an existing block, it appends 619*600f14f4SXin Li * a block after the existing block. \a use_padding is again used to 620*600f14f4SXin Li * tell the function to try an expand into following padding in an 621*600f14f4SXin Li * attempt to avoid rewriting the entire file. 622*600f14f4SXin Li * 623*600f14f4SXin Li * This function will fail and return \c false if given a STREAMINFO 624*600f14f4SXin Li * block. 625*600f14f4SXin Li * 626*600f14f4SXin Li * After writing the block, the iterator will be pointing to the 627*600f14f4SXin Li * new block. 628*600f14f4SXin Li * 629*600f14f4SXin Li * \param iterator A pointer to an existing initialized iterator. 630*600f14f4SXin Li * \param block The block to set. 631*600f14f4SXin Li * \param use_padding See above. 632*600f14f4SXin Li * \assert 633*600f14f4SXin Li * \code iterator != NULL \endcode 634*600f14f4SXin Li * \a iterator has been successfully initialized with 635*600f14f4SXin Li * FLAC__metadata_simple_iterator_init() 636*600f14f4SXin Li * \code block != NULL \endcode 637*600f14f4SXin Li * \retval FLAC__bool 638*600f14f4SXin Li * \c true if successful, else \c false. 639*600f14f4SXin Li */ 640*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_simple_iterator_insert_block_after(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding); 641*600f14f4SXin Li 642*600f14f4SXin Li /** Deletes the block at the current position. This will cause the 643*600f14f4SXin Li * entire FLAC file to be rewritten, unless \a use_padding is \c true, 644*600f14f4SXin Li * in which case the block will be replaced by an equal-sized PADDING 645*600f14f4SXin Li * block. The iterator will be left pointing to the block before the 646*600f14f4SXin Li * one just deleted. 647*600f14f4SXin Li * 648*600f14f4SXin Li * You may not delete the STREAMINFO block. 649*600f14f4SXin Li * 650*600f14f4SXin Li * \param iterator A pointer to an existing initialized iterator. 651*600f14f4SXin Li * \param use_padding See above. 652*600f14f4SXin Li * \assert 653*600f14f4SXin Li * \code iterator != NULL \endcode 654*600f14f4SXin Li * \a iterator has been successfully initialized with 655*600f14f4SXin Li * FLAC__metadata_simple_iterator_init() 656*600f14f4SXin Li * \retval FLAC__bool 657*600f14f4SXin Li * \c true if successful, else \c false. 658*600f14f4SXin Li */ 659*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_simple_iterator_delete_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__bool use_padding); 660*600f14f4SXin Li 661*600f14f4SXin Li /* \} */ 662*600f14f4SXin Li 663*600f14f4SXin Li 664*600f14f4SXin Li /** \defgroup flac_metadata_level2 FLAC/metadata.h: metadata level 2 interface 665*600f14f4SXin Li * \ingroup flac_metadata 666*600f14f4SXin Li * 667*600f14f4SXin Li * \brief 668*600f14f4SXin Li * The level 2 interface provides read-write access to FLAC file metadata; 669*600f14f4SXin Li * all metadata is read into memory, operated on in memory, and then written 670*600f14f4SXin Li * to file, which is more efficient than level 1 when editing multiple blocks. 671*600f14f4SXin Li * 672*600f14f4SXin Li * Currently Ogg FLAC is supported for read only, via 673*600f14f4SXin Li * FLAC__metadata_chain_read_ogg() but a subsequent 674*600f14f4SXin Li * FLAC__metadata_chain_write() will fail. 675*600f14f4SXin Li * 676*600f14f4SXin Li * The general usage of this interface is: 677*600f14f4SXin Li * 678*600f14f4SXin Li * - Create a new chain using FLAC__metadata_chain_new(). A chain is a 679*600f14f4SXin Li * linked list of FLAC metadata blocks. 680*600f14f4SXin Li * - Read all metadata into the chain from a FLAC file using 681*600f14f4SXin Li * FLAC__metadata_chain_read() or FLAC__metadata_chain_read_ogg() and 682*600f14f4SXin Li * check the status. 683*600f14f4SXin Li * - Optionally, consolidate the padding using 684*600f14f4SXin Li * FLAC__metadata_chain_merge_padding() or 685*600f14f4SXin Li * FLAC__metadata_chain_sort_padding(). 686*600f14f4SXin Li * - Create a new iterator using FLAC__metadata_iterator_new() 687*600f14f4SXin Li * - Initialize the iterator to point to the first element in the chain 688*600f14f4SXin Li * using FLAC__metadata_iterator_init() 689*600f14f4SXin Li * - Traverse the chain using FLAC__metadata_iterator_next and 690*600f14f4SXin Li * FLAC__metadata_iterator_prev(). 691*600f14f4SXin Li * - Get a block for reading or modification using 692*600f14f4SXin Li * FLAC__metadata_iterator_get_block(). The pointer to the object 693*600f14f4SXin Li * inside the chain is returned, so the block is yours to modify. 694*600f14f4SXin Li * Changes will be reflected in the FLAC file when you write the 695*600f14f4SXin Li * chain. You can also add and delete blocks (see functions below). 696*600f14f4SXin Li * - When done, write out the chain using FLAC__metadata_chain_write(). 697*600f14f4SXin Li * Make sure to read the whole comment to the function below. 698*600f14f4SXin Li * - Delete the chain using FLAC__metadata_chain_delete(). 699*600f14f4SXin Li * 700*600f14f4SXin Li * \note 701*600f14f4SXin Li * Even though the FLAC file is not open while the chain is being 702*600f14f4SXin Li * manipulated, you must not alter the file externally during 703*600f14f4SXin Li * this time. The chain assumes the FLAC file will not change 704*600f14f4SXin Li * between the time of FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg() 705*600f14f4SXin Li * and FLAC__metadata_chain_write(). 706*600f14f4SXin Li * 707*600f14f4SXin Li * \note 708*600f14f4SXin Li * Do not modify the is_last, length, or type fields of returned 709*600f14f4SXin Li * FLAC__StreamMetadata objects. These are managed automatically. 710*600f14f4SXin Li * 711*600f14f4SXin Li * \note 712*600f14f4SXin Li * The metadata objects returned by FLAC__metadata_iterator_get_block() 713*600f14f4SXin Li * are owned by the chain; do not FLAC__metadata_object_delete() them. 714*600f14f4SXin Li * In the same way, blocks passed to FLAC__metadata_iterator_set_block() 715*600f14f4SXin Li * become owned by the chain and they will be deleted when the chain is 716*600f14f4SXin Li * deleted. 717*600f14f4SXin Li * 718*600f14f4SXin Li * \{ 719*600f14f4SXin Li */ 720*600f14f4SXin Li 721*600f14f4SXin Li struct FLAC__Metadata_Chain; 722*600f14f4SXin Li /** The opaque structure definition for the level 2 chain type. 723*600f14f4SXin Li */ 724*600f14f4SXin Li typedef struct FLAC__Metadata_Chain FLAC__Metadata_Chain; 725*600f14f4SXin Li 726*600f14f4SXin Li struct FLAC__Metadata_Iterator; 727*600f14f4SXin Li /** The opaque structure definition for the level 2 iterator type. 728*600f14f4SXin Li */ 729*600f14f4SXin Li typedef struct FLAC__Metadata_Iterator FLAC__Metadata_Iterator; 730*600f14f4SXin Li 731*600f14f4SXin Li typedef enum { 732*600f14f4SXin Li FLAC__METADATA_CHAIN_STATUS_OK = 0, 733*600f14f4SXin Li /**< The chain is in the normal OK state */ 734*600f14f4SXin Li 735*600f14f4SXin Li FLAC__METADATA_CHAIN_STATUS_ILLEGAL_INPUT, 736*600f14f4SXin Li /**< The data passed into a function violated the function's usage criteria */ 737*600f14f4SXin Li 738*600f14f4SXin Li FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE, 739*600f14f4SXin Li /**< The chain could not open the target file */ 740*600f14f4SXin Li 741*600f14f4SXin Li FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE, 742*600f14f4SXin Li /**< The chain could not find the FLAC signature at the start of the file */ 743*600f14f4SXin Li 744*600f14f4SXin Li FLAC__METADATA_CHAIN_STATUS_NOT_WRITABLE, 745*600f14f4SXin Li /**< The chain tried to write to a file that was not writable */ 746*600f14f4SXin Li 747*600f14f4SXin Li FLAC__METADATA_CHAIN_STATUS_BAD_METADATA, 748*600f14f4SXin Li /**< The chain encountered input that does not conform to the FLAC metadata specification */ 749*600f14f4SXin Li 750*600f14f4SXin Li FLAC__METADATA_CHAIN_STATUS_READ_ERROR, 751*600f14f4SXin Li /**< The chain encountered an error while reading the FLAC file */ 752*600f14f4SXin Li 753*600f14f4SXin Li FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR, 754*600f14f4SXin Li /**< The chain encountered an error while seeking in the FLAC file */ 755*600f14f4SXin Li 756*600f14f4SXin Li FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR, 757*600f14f4SXin Li /**< The chain encountered an error while writing the FLAC file */ 758*600f14f4SXin Li 759*600f14f4SXin Li FLAC__METADATA_CHAIN_STATUS_RENAME_ERROR, 760*600f14f4SXin Li /**< The chain encountered an error renaming the FLAC file */ 761*600f14f4SXin Li 762*600f14f4SXin Li FLAC__METADATA_CHAIN_STATUS_UNLINK_ERROR, 763*600f14f4SXin Li /**< The chain encountered an error removing the temporary file */ 764*600f14f4SXin Li 765*600f14f4SXin Li FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR, 766*600f14f4SXin Li /**< Memory allocation failed */ 767*600f14f4SXin Li 768*600f14f4SXin Li FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR, 769*600f14f4SXin Li /**< The caller violated an assertion or an unexpected error occurred */ 770*600f14f4SXin Li 771*600f14f4SXin Li FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS, 772*600f14f4SXin Li /**< One or more of the required callbacks was NULL */ 773*600f14f4SXin Li 774*600f14f4SXin Li FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH, 775*600f14f4SXin Li /**< FLAC__metadata_chain_write() was called on a chain read by 776*600f14f4SXin Li * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(), 777*600f14f4SXin Li * or 778*600f14f4SXin Li * FLAC__metadata_chain_write_with_callbacks()/FLAC__metadata_chain_write_with_callbacks_and_tempfile() 779*600f14f4SXin Li * was called on a chain read by 780*600f14f4SXin Li * FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg(). 781*600f14f4SXin Li * Matching read/write methods must always be used. */ 782*600f14f4SXin Li 783*600f14f4SXin Li FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL 784*600f14f4SXin Li /**< FLAC__metadata_chain_write_with_callbacks() was called when the 785*600f14f4SXin Li * chain write requires a tempfile; use 786*600f14f4SXin Li * FLAC__metadata_chain_write_with_callbacks_and_tempfile() instead. 787*600f14f4SXin Li * Or, FLAC__metadata_chain_write_with_callbacks_and_tempfile() was 788*600f14f4SXin Li * called when the chain write does not require a tempfile; use 789*600f14f4SXin Li * FLAC__metadata_chain_write_with_callbacks() instead. 790*600f14f4SXin Li * Always check FLAC__metadata_chain_check_if_tempfile_needed() 791*600f14f4SXin Li * before writing via callbacks. */ 792*600f14f4SXin Li 793*600f14f4SXin Li } FLAC__Metadata_ChainStatus; 794*600f14f4SXin Li 795*600f14f4SXin Li /** Maps a FLAC__Metadata_ChainStatus to a C string. 796*600f14f4SXin Li * 797*600f14f4SXin Li * Using a FLAC__Metadata_ChainStatus as the index to this array 798*600f14f4SXin Li * will give the string equivalent. The contents should not be modified. 799*600f14f4SXin Li */ 800*600f14f4SXin Li extern FLAC_API const char * const FLAC__Metadata_ChainStatusString[]; 801*600f14f4SXin Li 802*600f14f4SXin Li /*********** FLAC__Metadata_Chain ***********/ 803*600f14f4SXin Li 804*600f14f4SXin Li /** Create a new chain instance. 805*600f14f4SXin Li * 806*600f14f4SXin Li * \retval FLAC__Metadata_Chain* 807*600f14f4SXin Li * \c NULL if there was an error allocating memory, else the new instance. 808*600f14f4SXin Li */ 809*600f14f4SXin Li FLAC_API FLAC__Metadata_Chain *FLAC__metadata_chain_new(void); 810*600f14f4SXin Li 811*600f14f4SXin Li /** Free a chain instance. Deletes the object pointed to by \a chain. 812*600f14f4SXin Li * 813*600f14f4SXin Li * \param chain A pointer to an existing chain. 814*600f14f4SXin Li * \assert 815*600f14f4SXin Li * \code chain != NULL \endcode 816*600f14f4SXin Li */ 817*600f14f4SXin Li FLAC_API void FLAC__metadata_chain_delete(FLAC__Metadata_Chain *chain); 818*600f14f4SXin Li 819*600f14f4SXin Li /** Get the current status of the chain. Call this after a function 820*600f14f4SXin Li * returns \c false to get the reason for the error. Also resets the 821*600f14f4SXin Li * status to FLAC__METADATA_CHAIN_STATUS_OK. 822*600f14f4SXin Li * 823*600f14f4SXin Li * \param chain A pointer to an existing chain. 824*600f14f4SXin Li * \assert 825*600f14f4SXin Li * \code chain != NULL \endcode 826*600f14f4SXin Li * \retval FLAC__Metadata_ChainStatus 827*600f14f4SXin Li * The current status of the chain. 828*600f14f4SXin Li */ 829*600f14f4SXin Li FLAC_API FLAC__Metadata_ChainStatus FLAC__metadata_chain_status(FLAC__Metadata_Chain *chain); 830*600f14f4SXin Li 831*600f14f4SXin Li /** Read all metadata from a FLAC file into the chain. 832*600f14f4SXin Li * 833*600f14f4SXin Li * On Windows, filename must be a UTF-8 encoded filename, which libFLAC 834*600f14f4SXin Li * internally translates to an appropriate representation to use with 835*600f14f4SXin Li * _wfopen. On all other systems, filename is passed to fopen without 836*600f14f4SXin Li * any translation. 837*600f14f4SXin Li * 838*600f14f4SXin Li * \param chain A pointer to an existing chain. 839*600f14f4SXin Li * \param filename The path to the FLAC file to read. 840*600f14f4SXin Li * \assert 841*600f14f4SXin Li * \code chain != NULL \endcode 842*600f14f4SXin Li * \code filename != NULL \endcode 843*600f14f4SXin Li * \retval FLAC__bool 844*600f14f4SXin Li * \c true if a valid list of metadata blocks was read from 845*600f14f4SXin Li * \a filename, else \c false. On failure, check the status with 846*600f14f4SXin Li * FLAC__metadata_chain_status(). 847*600f14f4SXin Li */ 848*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_chain_read(FLAC__Metadata_Chain *chain, const char *filename); 849*600f14f4SXin Li 850*600f14f4SXin Li /** Read all metadata from an Ogg FLAC file into the chain. 851*600f14f4SXin Li * 852*600f14f4SXin Li * On Windows, filename must be a UTF-8 encoded filename, which libFLAC 853*600f14f4SXin Li * internally translates to an appropriate representation to use with 854*600f14f4SXin Li * _wfopen. On all other systems, filename is passed to fopen without 855*600f14f4SXin Li * any translation. 856*600f14f4SXin Li * 857*600f14f4SXin Li * \note Ogg FLAC metadata data writing is not supported yet and 858*600f14f4SXin Li * FLAC__metadata_chain_write() will fail. 859*600f14f4SXin Li * 860*600f14f4SXin Li * \param chain A pointer to an existing chain. 861*600f14f4SXin Li * \param filename The path to the Ogg FLAC file to read. 862*600f14f4SXin Li * \assert 863*600f14f4SXin Li * \code chain != NULL \endcode 864*600f14f4SXin Li * \code filename != NULL \endcode 865*600f14f4SXin Li * \retval FLAC__bool 866*600f14f4SXin Li * \c true if a valid list of metadata blocks was read from 867*600f14f4SXin Li * \a filename, else \c false. On failure, check the status with 868*600f14f4SXin Li * FLAC__metadata_chain_status(). 869*600f14f4SXin Li */ 870*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_chain_read_ogg(FLAC__Metadata_Chain *chain, const char *filename); 871*600f14f4SXin Li 872*600f14f4SXin Li /** Read all metadata from a FLAC stream into the chain via I/O callbacks. 873*600f14f4SXin Li * 874*600f14f4SXin Li * The \a handle need only be open for reading, but must be seekable. 875*600f14f4SXin Li * The equivalent minimum stdio fopen() file mode is \c "r" (or \c "rb" 876*600f14f4SXin Li * for Windows). 877*600f14f4SXin Li * 878*600f14f4SXin Li * \param chain A pointer to an existing chain. 879*600f14f4SXin Li * \param handle The I/O handle of the FLAC stream to read. The 880*600f14f4SXin Li * handle will NOT be closed after the metadata is read; 881*600f14f4SXin Li * that is the duty of the caller. 882*600f14f4SXin Li * \param callbacks 883*600f14f4SXin Li * A set of callbacks to use for I/O. The mandatory 884*600f14f4SXin Li * callbacks are \a read, \a seek, and \a tell. 885*600f14f4SXin Li * \assert 886*600f14f4SXin Li * \code chain != NULL \endcode 887*600f14f4SXin Li * \retval FLAC__bool 888*600f14f4SXin Li * \c true if a valid list of metadata blocks was read from 889*600f14f4SXin Li * \a handle, else \c false. On failure, check the status with 890*600f14f4SXin Li * FLAC__metadata_chain_status(). 891*600f14f4SXin Li */ 892*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_chain_read_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks); 893*600f14f4SXin Li 894*600f14f4SXin Li /** Read all metadata from an Ogg FLAC stream into the chain via I/O callbacks. 895*600f14f4SXin Li * 896*600f14f4SXin Li * The \a handle need only be open for reading, but must be seekable. 897*600f14f4SXin Li * The equivalent minimum stdio fopen() file mode is \c "r" (or \c "rb" 898*600f14f4SXin Li * for Windows). 899*600f14f4SXin Li * 900*600f14f4SXin Li * \note Ogg FLAC metadata data writing is not supported yet and 901*600f14f4SXin Li * FLAC__metadata_chain_write() will fail. 902*600f14f4SXin Li * 903*600f14f4SXin Li * \param chain A pointer to an existing chain. 904*600f14f4SXin Li * \param handle The I/O handle of the Ogg FLAC stream to read. The 905*600f14f4SXin Li * handle will NOT be closed after the metadata is read; 906*600f14f4SXin Li * that is the duty of the caller. 907*600f14f4SXin Li * \param callbacks 908*600f14f4SXin Li * A set of callbacks to use for I/O. The mandatory 909*600f14f4SXin Li * callbacks are \a read, \a seek, and \a tell. 910*600f14f4SXin Li * \assert 911*600f14f4SXin Li * \code chain != NULL \endcode 912*600f14f4SXin Li * \retval FLAC__bool 913*600f14f4SXin Li * \c true if a valid list of metadata blocks was read from 914*600f14f4SXin Li * \a handle, else \c false. On failure, check the status with 915*600f14f4SXin Li * FLAC__metadata_chain_status(). 916*600f14f4SXin Li */ 917*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_chain_read_ogg_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks); 918*600f14f4SXin Li 919*600f14f4SXin Li /** Checks if writing the given chain would require the use of a 920*600f14f4SXin Li * temporary file, or if it could be written in place. 921*600f14f4SXin Li * 922*600f14f4SXin Li * Under certain conditions, padding can be utilized so that writing 923*600f14f4SXin Li * edited metadata back to the FLAC file does not require rewriting the 924*600f14f4SXin Li * entire file. If rewriting is required, then a temporary workfile is 925*600f14f4SXin Li * required. When writing metadata using callbacks, you must check 926*600f14f4SXin Li * this function to know whether to call 927*600f14f4SXin Li * FLAC__metadata_chain_write_with_callbacks() or 928*600f14f4SXin Li * FLAC__metadata_chain_write_with_callbacks_and_tempfile(). When 929*600f14f4SXin Li * writing with FLAC__metadata_chain_write(), the temporary file is 930*600f14f4SXin Li * handled internally. 931*600f14f4SXin Li * 932*600f14f4SXin Li * \param chain A pointer to an existing chain. 933*600f14f4SXin Li * \param use_padding 934*600f14f4SXin Li * Whether or not padding will be allowed to be used 935*600f14f4SXin Li * during the write. The value of \a use_padding given 936*600f14f4SXin Li * here must match the value later passed to 937*600f14f4SXin Li * FLAC__metadata_chain_write_with_callbacks() or 938*600f14f4SXin Li * FLAC__metadata_chain_write_with_callbacks_with_tempfile(). 939*600f14f4SXin Li * \assert 940*600f14f4SXin Li * \code chain != NULL \endcode 941*600f14f4SXin Li * \retval FLAC__bool 942*600f14f4SXin Li * \c true if writing the current chain would require a tempfile, or 943*600f14f4SXin Li * \c false if metadata can be written in place. 944*600f14f4SXin Li */ 945*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata_Chain *chain, FLAC__bool use_padding); 946*600f14f4SXin Li 947*600f14f4SXin Li /** Write all metadata out to the FLAC file. This function tries to be as 948*600f14f4SXin Li * efficient as possible; how the metadata is actually written is shown by 949*600f14f4SXin Li * the following: 950*600f14f4SXin Li * 951*600f14f4SXin Li * If the current chain is the same size as the existing metadata, the new 952*600f14f4SXin Li * data is written in place. 953*600f14f4SXin Li * 954*600f14f4SXin Li * If the current chain is longer than the existing metadata, and 955*600f14f4SXin Li * \a use_padding is \c true, and the last block is a PADDING block of 956*600f14f4SXin Li * sufficient length, the function will truncate the final padding block 957*600f14f4SXin Li * so that the overall size of the metadata is the same as the existing 958*600f14f4SXin Li * metadata, and then just rewrite the metadata. Otherwise, if not all of 959*600f14f4SXin Li * the above conditions are met, the entire FLAC file must be rewritten. 960*600f14f4SXin Li * If you want to use padding this way it is a good idea to call 961*600f14f4SXin Li * FLAC__metadata_chain_sort_padding() first so that you have the maximum 962*600f14f4SXin Li * amount of padding to work with, unless you need to preserve ordering 963*600f14f4SXin Li * of the PADDING blocks for some reason. 964*600f14f4SXin Li * 965*600f14f4SXin Li * If the current chain is shorter than the existing metadata, and 966*600f14f4SXin Li * \a use_padding is \c true, and the final block is a PADDING block, the padding 967*600f14f4SXin Li * is extended to make the overall size the same as the existing data. If 968*600f14f4SXin Li * \a use_padding is \c true and the last block is not a PADDING block, a new 969*600f14f4SXin Li * PADDING block is added to the end of the new data to make it the same 970*600f14f4SXin Li * size as the existing data (if possible, see the note to 971*600f14f4SXin Li * FLAC__metadata_simple_iterator_set_block() about the four byte limit) 972*600f14f4SXin Li * and the new data is written in place. If none of the above apply or 973*600f14f4SXin Li * \a use_padding is \c false, the entire FLAC file is rewritten. 974*600f14f4SXin Li * 975*600f14f4SXin Li * If \a preserve_file_stats is \c true, the owner and modification time will 976*600f14f4SXin Li * be preserved even if the FLAC file is written. 977*600f14f4SXin Li * 978*600f14f4SXin Li * For this write function to be used, the chain must have been read with 979*600f14f4SXin Li * FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg(), not 980*600f14f4SXin Li * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(). 981*600f14f4SXin Li * 982*600f14f4SXin Li * \param chain A pointer to an existing chain. 983*600f14f4SXin Li * \param use_padding See above. 984*600f14f4SXin Li * \param preserve_file_stats See above. 985*600f14f4SXin Li * \assert 986*600f14f4SXin Li * \code chain != NULL \endcode 987*600f14f4SXin Li * \retval FLAC__bool 988*600f14f4SXin Li * \c true if the write succeeded, else \c false. On failure, 989*600f14f4SXin Li * check the status with FLAC__metadata_chain_status(). 990*600f14f4SXin Li */ 991*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_chain_write(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__bool preserve_file_stats); 992*600f14f4SXin Li 993*600f14f4SXin Li /** Write all metadata out to a FLAC stream via callbacks. 994*600f14f4SXin Li * 995*600f14f4SXin Li * (See FLAC__metadata_chain_write() for the details on how padding is 996*600f14f4SXin Li * used to write metadata in place if possible.) 997*600f14f4SXin Li * 998*600f14f4SXin Li * The \a handle must be open for updating and be seekable. The 999*600f14f4SXin Li * equivalent minimum stdio fopen() file mode is \c "r+" (or \c "r+b" 1000*600f14f4SXin Li * for Windows). 1001*600f14f4SXin Li * 1002*600f14f4SXin Li * For this write function to be used, the chain must have been read with 1003*600f14f4SXin Li * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(), 1004*600f14f4SXin Li * not FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg(). 1005*600f14f4SXin Li * Also, FLAC__metadata_chain_check_if_tempfile_needed() must have returned 1006*600f14f4SXin Li * \c false. 1007*600f14f4SXin Li * 1008*600f14f4SXin Li * \param chain A pointer to an existing chain. 1009*600f14f4SXin Li * \param use_padding See FLAC__metadata_chain_write() 1010*600f14f4SXin Li * \param handle The I/O handle of the FLAC stream to write. The 1011*600f14f4SXin Li * handle will NOT be closed after the metadata is 1012*600f14f4SXin Li * written; that is the duty of the caller. 1013*600f14f4SXin Li * \param callbacks A set of callbacks to use for I/O. The mandatory 1014*600f14f4SXin Li * callbacks are \a write and \a seek. 1015*600f14f4SXin Li * \assert 1016*600f14f4SXin Li * \code chain != NULL \endcode 1017*600f14f4SXin Li * \retval FLAC__bool 1018*600f14f4SXin Li * \c true if the write succeeded, else \c false. On failure, 1019*600f14f4SXin Li * check the status with FLAC__metadata_chain_status(). 1020*600f14f4SXin Li */ 1021*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks); 1022*600f14f4SXin Li 1023*600f14f4SXin Li /** Write all metadata out to a FLAC stream via callbacks. 1024*600f14f4SXin Li * 1025*600f14f4SXin Li * (See FLAC__metadata_chain_write() for the details on how padding is 1026*600f14f4SXin Li * used to write metadata in place if possible.) 1027*600f14f4SXin Li * 1028*600f14f4SXin Li * This version of the write-with-callbacks function must be used when 1029*600f14f4SXin Li * FLAC__metadata_chain_check_if_tempfile_needed() returns true. In 1030*600f14f4SXin Li * this function, you must supply an I/O handle corresponding to the 1031*600f14f4SXin Li * FLAC file to edit, and a temporary handle to which the new FLAC 1032*600f14f4SXin Li * file will be written. It is the caller's job to move this temporary 1033*600f14f4SXin Li * FLAC file on top of the original FLAC file to complete the metadata 1034*600f14f4SXin Li * edit. 1035*600f14f4SXin Li * 1036*600f14f4SXin Li * The \a handle must be open for reading and be seekable. The 1037*600f14f4SXin Li * equivalent minimum stdio fopen() file mode is \c "r" (or \c "rb" 1038*600f14f4SXin Li * for Windows). 1039*600f14f4SXin Li * 1040*600f14f4SXin Li * The \a temp_handle must be open for writing. The 1041*600f14f4SXin Li * equivalent minimum stdio fopen() file mode is \c "w" (or \c "wb" 1042*600f14f4SXin Li * for Windows). It should be an empty stream, or at least positioned 1043*600f14f4SXin Li * at the start-of-file (in which case it is the caller's duty to 1044*600f14f4SXin Li * truncate it on return). 1045*600f14f4SXin Li * 1046*600f14f4SXin Li * For this write function to be used, the chain must have been read with 1047*600f14f4SXin Li * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(), 1048*600f14f4SXin Li * not FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg(). 1049*600f14f4SXin Li * Also, FLAC__metadata_chain_check_if_tempfile_needed() must have returned 1050*600f14f4SXin Li * \c true. 1051*600f14f4SXin Li * 1052*600f14f4SXin Li * \param chain A pointer to an existing chain. 1053*600f14f4SXin Li * \param use_padding See FLAC__metadata_chain_write() 1054*600f14f4SXin Li * \param handle The I/O handle of the original FLAC stream to read. 1055*600f14f4SXin Li * The handle will NOT be closed after the metadata is 1056*600f14f4SXin Li * written; that is the duty of the caller. 1057*600f14f4SXin Li * \param callbacks A set of callbacks to use for I/O on \a handle. 1058*600f14f4SXin Li * The mandatory callbacks are \a read, \a seek, and 1059*600f14f4SXin Li * \a eof. 1060*600f14f4SXin Li * \param temp_handle The I/O handle of the FLAC stream to write. The 1061*600f14f4SXin Li * handle will NOT be closed after the metadata is 1062*600f14f4SXin Li * written; that is the duty of the caller. 1063*600f14f4SXin Li * \param temp_callbacks 1064*600f14f4SXin Li * A set of callbacks to use for I/O on temp_handle. 1065*600f14f4SXin Li * The only mandatory callback is \a write. 1066*600f14f4SXin Li * \assert 1067*600f14f4SXin Li * \code chain != NULL \endcode 1068*600f14f4SXin Li * \retval FLAC__bool 1069*600f14f4SXin Li * \c true if the write succeeded, else \c false. On failure, 1070*600f14f4SXin Li * check the status with FLAC__metadata_chain_status(). 1071*600f14f4SXin Li */ 1072*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks_and_tempfile(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks, FLAC__IOHandle temp_handle, FLAC__IOCallbacks temp_callbacks); 1073*600f14f4SXin Li 1074*600f14f4SXin Li /** Merge adjacent PADDING blocks into a single block. 1075*600f14f4SXin Li * 1076*600f14f4SXin Li * \note This function does not write to the FLAC file, it only 1077*600f14f4SXin Li * modifies the chain. 1078*600f14f4SXin Li * 1079*600f14f4SXin Li * \warning Any iterator on the current chain will become invalid after this 1080*600f14f4SXin Li * call. You should delete the iterator and get a new one. 1081*600f14f4SXin Li * 1082*600f14f4SXin Li * \param chain A pointer to an existing chain. 1083*600f14f4SXin Li * \assert 1084*600f14f4SXin Li * \code chain != NULL \endcode 1085*600f14f4SXin Li */ 1086*600f14f4SXin Li FLAC_API void FLAC__metadata_chain_merge_padding(FLAC__Metadata_Chain *chain); 1087*600f14f4SXin Li 1088*600f14f4SXin Li /** This function will move all PADDING blocks to the end on the metadata, 1089*600f14f4SXin Li * then merge them into a single block. 1090*600f14f4SXin Li * 1091*600f14f4SXin Li * \note This function does not write to the FLAC file, it only 1092*600f14f4SXin Li * modifies the chain. 1093*600f14f4SXin Li * 1094*600f14f4SXin Li * \warning Any iterator on the current chain will become invalid after this 1095*600f14f4SXin Li * call. You should delete the iterator and get a new one. 1096*600f14f4SXin Li * 1097*600f14f4SXin Li * \param chain A pointer to an existing chain. 1098*600f14f4SXin Li * \assert 1099*600f14f4SXin Li * \code chain != NULL \endcode 1100*600f14f4SXin Li */ 1101*600f14f4SXin Li FLAC_API void FLAC__metadata_chain_sort_padding(FLAC__Metadata_Chain *chain); 1102*600f14f4SXin Li 1103*600f14f4SXin Li 1104*600f14f4SXin Li /*********** FLAC__Metadata_Iterator ***********/ 1105*600f14f4SXin Li 1106*600f14f4SXin Li /** Create a new iterator instance. 1107*600f14f4SXin Li * 1108*600f14f4SXin Li * \retval FLAC__Metadata_Iterator* 1109*600f14f4SXin Li * \c NULL if there was an error allocating memory, else the new instance. 1110*600f14f4SXin Li */ 1111*600f14f4SXin Li FLAC_API FLAC__Metadata_Iterator *FLAC__metadata_iterator_new(void); 1112*600f14f4SXin Li 1113*600f14f4SXin Li /** Free an iterator instance. Deletes the object pointed to by \a iterator. 1114*600f14f4SXin Li * 1115*600f14f4SXin Li * \param iterator A pointer to an existing iterator. 1116*600f14f4SXin Li * \assert 1117*600f14f4SXin Li * \code iterator != NULL \endcode 1118*600f14f4SXin Li */ 1119*600f14f4SXin Li FLAC_API void FLAC__metadata_iterator_delete(FLAC__Metadata_Iterator *iterator); 1120*600f14f4SXin Li 1121*600f14f4SXin Li /** Initialize the iterator to point to the first metadata block in the 1122*600f14f4SXin Li * given chain. 1123*600f14f4SXin Li * 1124*600f14f4SXin Li * \param iterator A pointer to an existing iterator. 1125*600f14f4SXin Li * \param chain A pointer to an existing and initialized (read) chain. 1126*600f14f4SXin Li * \assert 1127*600f14f4SXin Li * \code iterator != NULL \endcode 1128*600f14f4SXin Li * \code chain != NULL \endcode 1129*600f14f4SXin Li */ 1130*600f14f4SXin Li FLAC_API void FLAC__metadata_iterator_init(FLAC__Metadata_Iterator *iterator, FLAC__Metadata_Chain *chain); 1131*600f14f4SXin Li 1132*600f14f4SXin Li /** Moves the iterator forward one metadata block, returning \c false if 1133*600f14f4SXin Li * already at the end. 1134*600f14f4SXin Li * 1135*600f14f4SXin Li * \param iterator A pointer to an existing initialized iterator. 1136*600f14f4SXin Li * \assert 1137*600f14f4SXin Li * \code iterator != NULL \endcode 1138*600f14f4SXin Li * \a iterator has been successfully initialized with 1139*600f14f4SXin Li * FLAC__metadata_iterator_init() 1140*600f14f4SXin Li * \retval FLAC__bool 1141*600f14f4SXin Li * \c false if already at the last metadata block of the chain, else 1142*600f14f4SXin Li * \c true. 1143*600f14f4SXin Li */ 1144*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_iterator_next(FLAC__Metadata_Iterator *iterator); 1145*600f14f4SXin Li 1146*600f14f4SXin Li /** Moves the iterator backward one metadata block, returning \c false if 1147*600f14f4SXin Li * already at the beginning. 1148*600f14f4SXin Li * 1149*600f14f4SXin Li * \param iterator A pointer to an existing initialized iterator. 1150*600f14f4SXin Li * \assert 1151*600f14f4SXin Li * \code iterator != NULL \endcode 1152*600f14f4SXin Li * \a iterator has been successfully initialized with 1153*600f14f4SXin Li * FLAC__metadata_iterator_init() 1154*600f14f4SXin Li * \retval FLAC__bool 1155*600f14f4SXin Li * \c false if already at the first metadata block of the chain, else 1156*600f14f4SXin Li * \c true. 1157*600f14f4SXin Li */ 1158*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_iterator_prev(FLAC__Metadata_Iterator *iterator); 1159*600f14f4SXin Li 1160*600f14f4SXin Li /** Get the type of the metadata block at the current position. 1161*600f14f4SXin Li * 1162*600f14f4SXin Li * \param iterator A pointer to an existing initialized iterator. 1163*600f14f4SXin Li * \assert 1164*600f14f4SXin Li * \code iterator != NULL \endcode 1165*600f14f4SXin Li * \a iterator has been successfully initialized with 1166*600f14f4SXin Li * FLAC__metadata_iterator_init() 1167*600f14f4SXin Li * \retval FLAC__MetadataType 1168*600f14f4SXin Li * The type of the metadata block at the current iterator position. 1169*600f14f4SXin Li */ 1170*600f14f4SXin Li FLAC_API FLAC__MetadataType FLAC__metadata_iterator_get_block_type(const FLAC__Metadata_Iterator *iterator); 1171*600f14f4SXin Li 1172*600f14f4SXin Li /** Get the metadata block at the current position. You can modify 1173*600f14f4SXin Li * the block in place but must write the chain before the changes 1174*600f14f4SXin Li * are reflected to the FLAC file. You do not need to call 1175*600f14f4SXin Li * FLAC__metadata_iterator_set_block() to reflect the changes; 1176*600f14f4SXin Li * the pointer returned by FLAC__metadata_iterator_get_block() 1177*600f14f4SXin Li * points directly into the chain. 1178*600f14f4SXin Li * 1179*600f14f4SXin Li * \warning 1180*600f14f4SXin Li * Do not call FLAC__metadata_object_delete() on the returned object; 1181*600f14f4SXin Li * to delete a block use FLAC__metadata_iterator_delete_block(). 1182*600f14f4SXin Li * 1183*600f14f4SXin Li * \param iterator A pointer to an existing initialized iterator. 1184*600f14f4SXin Li * \assert 1185*600f14f4SXin Li * \code iterator != NULL \endcode 1186*600f14f4SXin Li * \a iterator has been successfully initialized with 1187*600f14f4SXin Li * FLAC__metadata_iterator_init() 1188*600f14f4SXin Li * \retval FLAC__StreamMetadata* 1189*600f14f4SXin Li * The current metadata block. 1190*600f14f4SXin Li */ 1191*600f14f4SXin Li FLAC_API FLAC__StreamMetadata *FLAC__metadata_iterator_get_block(FLAC__Metadata_Iterator *iterator); 1192*600f14f4SXin Li 1193*600f14f4SXin Li /** Set the metadata block at the current position, replacing the existing 1194*600f14f4SXin Li * block. The new block passed in becomes owned by the chain and it will be 1195*600f14f4SXin Li * deleted when the chain is deleted. 1196*600f14f4SXin Li * 1197*600f14f4SXin Li * \param iterator A pointer to an existing initialized iterator. 1198*600f14f4SXin Li * \param block A pointer to a metadata block. 1199*600f14f4SXin Li * \assert 1200*600f14f4SXin Li * \code iterator != NULL \endcode 1201*600f14f4SXin Li * \a iterator has been successfully initialized with 1202*600f14f4SXin Li * FLAC__metadata_iterator_init() 1203*600f14f4SXin Li * \code block != NULL \endcode 1204*600f14f4SXin Li * \retval FLAC__bool 1205*600f14f4SXin Li * \c false if the conditions in the above description are not met, or 1206*600f14f4SXin Li * a memory allocation error occurs, otherwise \c true. 1207*600f14f4SXin Li */ 1208*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_iterator_set_block(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block); 1209*600f14f4SXin Li 1210*600f14f4SXin Li /** Removes the current block from the chain. If \a replace_with_padding is 1211*600f14f4SXin Li * \c true, the block will instead be replaced with a padding block of equal 1212*600f14f4SXin Li * size. You can not delete the STREAMINFO block. The iterator will be 1213*600f14f4SXin Li * left pointing to the block before the one just "deleted", even if 1214*600f14f4SXin Li * \a replace_with_padding is \c true. 1215*600f14f4SXin Li * 1216*600f14f4SXin Li * \param iterator A pointer to an existing initialized iterator. 1217*600f14f4SXin Li * \param replace_with_padding See above. 1218*600f14f4SXin Li * \assert 1219*600f14f4SXin Li * \code iterator != NULL \endcode 1220*600f14f4SXin Li * \a iterator has been successfully initialized with 1221*600f14f4SXin Li * FLAC__metadata_iterator_init() 1222*600f14f4SXin Li * \retval FLAC__bool 1223*600f14f4SXin Li * \c false if the conditions in the above description are not met, 1224*600f14f4SXin Li * otherwise \c true. 1225*600f14f4SXin Li */ 1226*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_iterator_delete_block(FLAC__Metadata_Iterator *iterator, FLAC__bool replace_with_padding); 1227*600f14f4SXin Li 1228*600f14f4SXin Li /** Insert a new block before the current block. You cannot insert a block 1229*600f14f4SXin Li * before the first STREAMINFO block. You cannot insert a STREAMINFO block 1230*600f14f4SXin Li * as there can be only one, the one that already exists at the head when you 1231*600f14f4SXin Li * read in a chain. The chain takes ownership of the new block and it will be 1232*600f14f4SXin Li * deleted when the chain is deleted. The iterator will be left pointing to 1233*600f14f4SXin Li * the new block. 1234*600f14f4SXin Li * 1235*600f14f4SXin Li * \param iterator A pointer to an existing initialized iterator. 1236*600f14f4SXin Li * \param block A pointer to a metadata block to insert. 1237*600f14f4SXin Li * \assert 1238*600f14f4SXin Li * \code iterator != NULL \endcode 1239*600f14f4SXin Li * \a iterator has been successfully initialized with 1240*600f14f4SXin Li * FLAC__metadata_iterator_init() 1241*600f14f4SXin Li * \retval FLAC__bool 1242*600f14f4SXin Li * \c false if the conditions in the above description are not met, or 1243*600f14f4SXin Li * a memory allocation error occurs, otherwise \c true. 1244*600f14f4SXin Li */ 1245*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_iterator_insert_block_before(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block); 1246*600f14f4SXin Li 1247*600f14f4SXin Li /** Insert a new block after the current block. You cannot insert a STREAMINFO 1248*600f14f4SXin Li * block as there can be only one, the one that already exists at the head when 1249*600f14f4SXin Li * you read in a chain. The chain takes ownership of the new block and it will 1250*600f14f4SXin Li * be deleted when the chain is deleted. The iterator will be left pointing to 1251*600f14f4SXin Li * the new block. 1252*600f14f4SXin Li * 1253*600f14f4SXin Li * \param iterator A pointer to an existing initialized iterator. 1254*600f14f4SXin Li * \param block A pointer to a metadata block to insert. 1255*600f14f4SXin Li * \assert 1256*600f14f4SXin Li * \code iterator != NULL \endcode 1257*600f14f4SXin Li * \a iterator has been successfully initialized with 1258*600f14f4SXin Li * FLAC__metadata_iterator_init() 1259*600f14f4SXin Li * \retval FLAC__bool 1260*600f14f4SXin Li * \c false if the conditions in the above description are not met, or 1261*600f14f4SXin Li * a memory allocation error occurs, otherwise \c true. 1262*600f14f4SXin Li */ 1263*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_iterator_insert_block_after(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block); 1264*600f14f4SXin Li 1265*600f14f4SXin Li /* \} */ 1266*600f14f4SXin Li 1267*600f14f4SXin Li 1268*600f14f4SXin Li /** \defgroup flac_metadata_object FLAC/metadata.h: metadata object methods 1269*600f14f4SXin Li * \ingroup flac_metadata 1270*600f14f4SXin Li * 1271*600f14f4SXin Li * \brief 1272*600f14f4SXin Li * This module contains methods for manipulating FLAC metadata objects. 1273*600f14f4SXin Li * 1274*600f14f4SXin Li * Since many are variable length we have to be careful about the memory 1275*600f14f4SXin Li * management. We decree that all pointers to data in the object are 1276*600f14f4SXin Li * owned by the object and memory-managed by the object. 1277*600f14f4SXin Li * 1278*600f14f4SXin Li * Use the FLAC__metadata_object_new() and FLAC__metadata_object_delete() 1279*600f14f4SXin Li * functions to create all instances. When using the 1280*600f14f4SXin Li * FLAC__metadata_object_set_*() functions to set pointers to data, set 1281*600f14f4SXin Li * \a copy to \c true to have the function make it's own copy of the data, or 1282*600f14f4SXin Li * to \c false to give the object ownership of your data. In the latter case 1283*600f14f4SXin Li * your pointer must be freeable by free() and will be free()d when the object 1284*600f14f4SXin Li * is FLAC__metadata_object_delete()d. It is legal to pass a null pointer as 1285*600f14f4SXin Li * the data pointer to a FLAC__metadata_object_set_*() function as long as 1286*600f14f4SXin Li * the length argument is 0 and the \a copy argument is \c false. 1287*600f14f4SXin Li * 1288*600f14f4SXin Li * The FLAC__metadata_object_new() and FLAC__metadata_object_clone() function 1289*600f14f4SXin Li * will return \c NULL in the case of a memory allocation error, otherwise a new 1290*600f14f4SXin Li * object. The FLAC__metadata_object_set_*() functions return \c false in the 1291*600f14f4SXin Li * case of a memory allocation error. 1292*600f14f4SXin Li * 1293*600f14f4SXin Li * We don't have the convenience of C++ here, so note that the library relies 1294*600f14f4SXin Li * on you to keep the types straight. In other words, if you pass, for 1295*600f14f4SXin Li * example, a FLAC__StreamMetadata* that represents a STREAMINFO block to 1296*600f14f4SXin Li * FLAC__metadata_object_application_set_data(), you will get an assertion 1297*600f14f4SXin Li * failure. 1298*600f14f4SXin Li * 1299*600f14f4SXin Li * For convenience the FLAC__metadata_object_vorbiscomment_*() functions 1300*600f14f4SXin Li * maintain a trailing NUL on each Vorbis comment entry. This is not counted 1301*600f14f4SXin Li * toward the length or stored in the stream, but it can make working with plain 1302*600f14f4SXin Li * comments (those that don't contain embedded-NULs in the value) easier. 1303*600f14f4SXin Li * Entries passed into these functions have trailing NULs added if missing, and 1304*600f14f4SXin Li * returned entries are guaranteed to have a trailing NUL. 1305*600f14f4SXin Li * 1306*600f14f4SXin Li * The FLAC__metadata_object_vorbiscomment_*() functions that take a Vorbis 1307*600f14f4SXin Li * comment entry/name/value will first validate that it complies with the Vorbis 1308*600f14f4SXin Li * comment specification and return false if it does not. 1309*600f14f4SXin Li * 1310*600f14f4SXin Li * There is no need to recalculate the length field on metadata blocks you 1311*600f14f4SXin Li * have modified. They will be calculated automatically before they are 1312*600f14f4SXin Li * written back to a file. 1313*600f14f4SXin Li * 1314*600f14f4SXin Li * \{ 1315*600f14f4SXin Li */ 1316*600f14f4SXin Li 1317*600f14f4SXin Li 1318*600f14f4SXin Li /** Create a new metadata object instance of the given type. 1319*600f14f4SXin Li * 1320*600f14f4SXin Li * The object will be "empty"; i.e. values and data pointers will be \c 0, 1321*600f14f4SXin Li * with the exception of FLAC__METADATA_TYPE_VORBIS_COMMENT, which will have 1322*600f14f4SXin Li * the vendor string set (but zero comments). 1323*600f14f4SXin Li * 1324*600f14f4SXin Li * Do not pass in a value greater than or equal to 1325*600f14f4SXin Li * \a FLAC__METADATA_TYPE_UNDEFINED unless you really know what you're 1326*600f14f4SXin Li * doing. 1327*600f14f4SXin Li * 1328*600f14f4SXin Li * \param type Type of object to create 1329*600f14f4SXin Li * \retval FLAC__StreamMetadata* 1330*600f14f4SXin Li * \c NULL if there was an error allocating memory or the type code is 1331*600f14f4SXin Li * greater than FLAC__MAX_METADATA_TYPE_CODE, else the new instance. 1332*600f14f4SXin Li */ 1333*600f14f4SXin Li FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_new(FLAC__MetadataType type); 1334*600f14f4SXin Li 1335*600f14f4SXin Li /** Create a copy of an existing metadata object. 1336*600f14f4SXin Li * 1337*600f14f4SXin Li * The copy is a "deep" copy, i.e. dynamically allocated data within the 1338*600f14f4SXin Li * object is also copied. The caller takes ownership of the new block and 1339*600f14f4SXin Li * is responsible for freeing it with FLAC__metadata_object_delete(). 1340*600f14f4SXin Li * 1341*600f14f4SXin Li * \param object Pointer to object to copy. 1342*600f14f4SXin Li * \assert 1343*600f14f4SXin Li * \code object != NULL \endcode 1344*600f14f4SXin Li * \retval FLAC__StreamMetadata* 1345*600f14f4SXin Li * \c NULL if there was an error allocating memory, else the new instance. 1346*600f14f4SXin Li */ 1347*600f14f4SXin Li FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_clone(const FLAC__StreamMetadata *object); 1348*600f14f4SXin Li 1349*600f14f4SXin Li /** Free a metadata object. Deletes the object pointed to by \a object. 1350*600f14f4SXin Li * 1351*600f14f4SXin Li * The delete is a "deep" delete, i.e. dynamically allocated data within the 1352*600f14f4SXin Li * object is also deleted. 1353*600f14f4SXin Li * 1354*600f14f4SXin Li * \param object A pointer to an existing object. 1355*600f14f4SXin Li * \assert 1356*600f14f4SXin Li * \code object != NULL \endcode 1357*600f14f4SXin Li */ 1358*600f14f4SXin Li FLAC_API void FLAC__metadata_object_delete(FLAC__StreamMetadata *object); 1359*600f14f4SXin Li 1360*600f14f4SXin Li /** Compares two metadata objects. 1361*600f14f4SXin Li * 1362*600f14f4SXin Li * The compare is "deep", i.e. dynamically allocated data within the 1363*600f14f4SXin Li * object is also compared. 1364*600f14f4SXin Li * 1365*600f14f4SXin Li * \param block1 A pointer to an existing object. 1366*600f14f4SXin Li * \param block2 A pointer to an existing object. 1367*600f14f4SXin Li * \assert 1368*600f14f4SXin Li * \code block1 != NULL \endcode 1369*600f14f4SXin Li * \code block2 != NULL \endcode 1370*600f14f4SXin Li * \retval FLAC__bool 1371*600f14f4SXin Li * \c true if objects are identical, else \c false. 1372*600f14f4SXin Li */ 1373*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_is_equal(const FLAC__StreamMetadata *block1, const FLAC__StreamMetadata *block2); 1374*600f14f4SXin Li 1375*600f14f4SXin Li /** Sets the application data of an APPLICATION block. 1376*600f14f4SXin Li * 1377*600f14f4SXin Li * If \a copy is \c true, a copy of the data is stored; otherwise, the object 1378*600f14f4SXin Li * takes ownership of the pointer. The existing data will be freed if this 1379*600f14f4SXin Li * function is successful, otherwise the original data will remain if \a copy 1380*600f14f4SXin Li * is \c true and malloc() fails. 1381*600f14f4SXin Li * 1382*600f14f4SXin Li * \note It is safe to pass a const pointer to \a data if \a copy is \c true. 1383*600f14f4SXin Li * 1384*600f14f4SXin Li * \param object A pointer to an existing APPLICATION object. 1385*600f14f4SXin Li * \param data A pointer to the data to set. 1386*600f14f4SXin Li * \param length The length of \a data in bytes. 1387*600f14f4SXin Li * \param copy See above. 1388*600f14f4SXin Li * \assert 1389*600f14f4SXin Li * \code object != NULL \endcode 1390*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_APPLICATION \endcode 1391*600f14f4SXin Li * \code (data != NULL && length > 0) || 1392*600f14f4SXin Li * (data == NULL && length == 0 && copy == false) \endcode 1393*600f14f4SXin Li * \retval FLAC__bool 1394*600f14f4SXin Li * \c false if \a copy is \c true and malloc() fails, else \c true. 1395*600f14f4SXin Li */ 1396*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_application_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, uint32_t length, FLAC__bool copy); 1397*600f14f4SXin Li 1398*600f14f4SXin Li /** Resize the seekpoint array. 1399*600f14f4SXin Li * 1400*600f14f4SXin Li * If the size shrinks, elements will truncated; if it grows, new placeholder 1401*600f14f4SXin Li * points will be added to the end. If this function returns false, the 1402*600f14f4SXin Li * object is left untouched. 1403*600f14f4SXin Li * 1404*600f14f4SXin Li * \param object A pointer to an existing SEEKTABLE object. 1405*600f14f4SXin Li * \param new_num_points The desired length of the array; may be \c 0. 1406*600f14f4SXin Li * \assert 1407*600f14f4SXin Li * \code object != NULL \endcode 1408*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode 1409*600f14f4SXin Li * \code (object->data.seek_table.points == NULL && object->data.seek_table.num_points == 0) || 1410*600f14f4SXin Li * (object->data.seek_table.points != NULL && object->data.seek_table.num_points > 0) \endcode 1411*600f14f4SXin Li * \retval FLAC__bool 1412*600f14f4SXin Li * \c false if memory allocation error, else \c true. 1413*600f14f4SXin Li */ 1414*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_seektable_resize_points(FLAC__StreamMetadata *object, uint32_t new_num_points); 1415*600f14f4SXin Li 1416*600f14f4SXin Li /** Set a seekpoint in a seektable. 1417*600f14f4SXin Li * 1418*600f14f4SXin Li * \param object A pointer to an existing SEEKTABLE object. 1419*600f14f4SXin Li * \param point_num Index into seekpoint array to set. 1420*600f14f4SXin Li * \param point The point to set. 1421*600f14f4SXin Li * \assert 1422*600f14f4SXin Li * \code object != NULL \endcode 1423*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode 1424*600f14f4SXin Li * \code object->data.seek_table.num_points > point_num \endcode 1425*600f14f4SXin Li */ 1426*600f14f4SXin Li FLAC_API void FLAC__metadata_object_seektable_set_point(FLAC__StreamMetadata *object, uint32_t point_num, FLAC__StreamMetadata_SeekPoint point); 1427*600f14f4SXin Li 1428*600f14f4SXin Li /** Insert a seekpoint into a seektable. 1429*600f14f4SXin Li * 1430*600f14f4SXin Li * \param object A pointer to an existing SEEKTABLE object. 1431*600f14f4SXin Li * \param point_num Index into seekpoint array to set. 1432*600f14f4SXin Li * \param point The point to set. 1433*600f14f4SXin Li * \assert 1434*600f14f4SXin Li * \code object != NULL \endcode 1435*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode 1436*600f14f4SXin Li * \code object->data.seek_table.num_points >= point_num \endcode 1437*600f14f4SXin Li * \retval FLAC__bool 1438*600f14f4SXin Li * \c false if memory allocation error, else \c true. 1439*600f14f4SXin Li */ 1440*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_seektable_insert_point(FLAC__StreamMetadata *object, uint32_t point_num, FLAC__StreamMetadata_SeekPoint point); 1441*600f14f4SXin Li 1442*600f14f4SXin Li /** Delete a seekpoint from a seektable. 1443*600f14f4SXin Li * 1444*600f14f4SXin Li * \param object A pointer to an existing SEEKTABLE object. 1445*600f14f4SXin Li * \param point_num Index into seekpoint array to set. 1446*600f14f4SXin Li * \assert 1447*600f14f4SXin Li * \code object != NULL \endcode 1448*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode 1449*600f14f4SXin Li * \code object->data.seek_table.num_points > point_num \endcode 1450*600f14f4SXin Li * \retval FLAC__bool 1451*600f14f4SXin Li * \c false if memory allocation error, else \c true. 1452*600f14f4SXin Li */ 1453*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_seektable_delete_point(FLAC__StreamMetadata *object, uint32_t point_num); 1454*600f14f4SXin Li 1455*600f14f4SXin Li /** Check a seektable to see if it conforms to the FLAC specification. 1456*600f14f4SXin Li * See the format specification for limits on the contents of the 1457*600f14f4SXin Li * seektable. 1458*600f14f4SXin Li * 1459*600f14f4SXin Li * \param object A pointer to an existing SEEKTABLE object. 1460*600f14f4SXin Li * \assert 1461*600f14f4SXin Li * \code object != NULL \endcode 1462*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode 1463*600f14f4SXin Li * \retval FLAC__bool 1464*600f14f4SXin Li * \c false if seek table is illegal, else \c true. 1465*600f14f4SXin Li */ 1466*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_seektable_is_legal(const FLAC__StreamMetadata *object); 1467*600f14f4SXin Li 1468*600f14f4SXin Li /** Append a number of placeholder points to the end of a seek table. 1469*600f14f4SXin Li * 1470*600f14f4SXin Li * \note 1471*600f14f4SXin Li * As with the other ..._seektable_template_... functions, you should 1472*600f14f4SXin Li * call FLAC__metadata_object_seektable_template_sort() when finished 1473*600f14f4SXin Li * to make the seek table legal. 1474*600f14f4SXin Li * 1475*600f14f4SXin Li * \param object A pointer to an existing SEEKTABLE object. 1476*600f14f4SXin Li * \param num The number of placeholder points to append. 1477*600f14f4SXin Li * \assert 1478*600f14f4SXin Li * \code object != NULL \endcode 1479*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode 1480*600f14f4SXin Li * \retval FLAC__bool 1481*600f14f4SXin Li * \c false if memory allocation fails, else \c true. 1482*600f14f4SXin Li */ 1483*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_placeholders(FLAC__StreamMetadata *object, uint32_t num); 1484*600f14f4SXin Li 1485*600f14f4SXin Li /** Append a specific seek point template to the end of a seek table. 1486*600f14f4SXin Li * 1487*600f14f4SXin Li * \note 1488*600f14f4SXin Li * As with the other ..._seektable_template_... functions, you should 1489*600f14f4SXin Li * call FLAC__metadata_object_seektable_template_sort() when finished 1490*600f14f4SXin Li * to make the seek table legal. 1491*600f14f4SXin Li * 1492*600f14f4SXin Li * \param object A pointer to an existing SEEKTABLE object. 1493*600f14f4SXin Li * \param sample_number The sample number of the seek point template. 1494*600f14f4SXin Li * \assert 1495*600f14f4SXin Li * \code object != NULL \endcode 1496*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode 1497*600f14f4SXin Li * \retval FLAC__bool 1498*600f14f4SXin Li * \c false if memory allocation fails, else \c true. 1499*600f14f4SXin Li */ 1500*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_point(FLAC__StreamMetadata *object, FLAC__uint64 sample_number); 1501*600f14f4SXin Li 1502*600f14f4SXin Li /** Append specific seek point templates to the end of a seek table. 1503*600f14f4SXin Li * 1504*600f14f4SXin Li * \note 1505*600f14f4SXin Li * As with the other ..._seektable_template_... functions, you should 1506*600f14f4SXin Li * call FLAC__metadata_object_seektable_template_sort() when finished 1507*600f14f4SXin Li * to make the seek table legal. 1508*600f14f4SXin Li * 1509*600f14f4SXin Li * \param object A pointer to an existing SEEKTABLE object. 1510*600f14f4SXin Li * \param sample_numbers An array of sample numbers for the seek points. 1511*600f14f4SXin Li * \param num The number of seek point templates to append. 1512*600f14f4SXin Li * \assert 1513*600f14f4SXin Li * \code object != NULL \endcode 1514*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode 1515*600f14f4SXin Li * \retval FLAC__bool 1516*600f14f4SXin Li * \c false if memory allocation fails, else \c true. 1517*600f14f4SXin Li */ 1518*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_points(FLAC__StreamMetadata *object, FLAC__uint64 sample_numbers[], uint32_t num); 1519*600f14f4SXin Li 1520*600f14f4SXin Li /** Append a set of evenly-spaced seek point templates to the end of a 1521*600f14f4SXin Li * seek table. 1522*600f14f4SXin Li * 1523*600f14f4SXin Li * \note 1524*600f14f4SXin Li * As with the other ..._seektable_template_... functions, you should 1525*600f14f4SXin Li * call FLAC__metadata_object_seektable_template_sort() when finished 1526*600f14f4SXin Li * to make the seek table legal. 1527*600f14f4SXin Li * 1528*600f14f4SXin Li * \param object A pointer to an existing SEEKTABLE object. 1529*600f14f4SXin Li * \param num The number of placeholder points to append. 1530*600f14f4SXin Li * \param total_samples The total number of samples to be encoded; 1531*600f14f4SXin Li * the seekpoints will be spaced approximately 1532*600f14f4SXin Li * \a total_samples / \a num samples apart. 1533*600f14f4SXin Li * \assert 1534*600f14f4SXin Li * \code object != NULL \endcode 1535*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode 1536*600f14f4SXin Li * \code total_samples > 0 \endcode 1537*600f14f4SXin Li * \retval FLAC__bool 1538*600f14f4SXin Li * \c false if memory allocation fails, else \c true. 1539*600f14f4SXin Li */ 1540*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points(FLAC__StreamMetadata *object, uint32_t num, FLAC__uint64 total_samples); 1541*600f14f4SXin Li 1542*600f14f4SXin Li /** Append a set of evenly-spaced seek point templates to the end of a 1543*600f14f4SXin Li * seek table. 1544*600f14f4SXin Li * 1545*600f14f4SXin Li * \note 1546*600f14f4SXin Li * As with the other ..._seektable_template_... functions, you should 1547*600f14f4SXin Li * call FLAC__metadata_object_seektable_template_sort() when finished 1548*600f14f4SXin Li * to make the seek table legal. 1549*600f14f4SXin Li * 1550*600f14f4SXin Li * \param object A pointer to an existing SEEKTABLE object. 1551*600f14f4SXin Li * \param samples The number of samples apart to space the placeholder 1552*600f14f4SXin Li * points. The first point will be at sample \c 0, the 1553*600f14f4SXin Li * second at sample \a samples, then 2*\a samples, and 1554*600f14f4SXin Li * so on. As long as \a samples and \a total_samples 1555*600f14f4SXin Li * are greater than \c 0, there will always be at least 1556*600f14f4SXin Li * one seekpoint at sample \c 0. 1557*600f14f4SXin Li * \param total_samples The total number of samples to be encoded; 1558*600f14f4SXin Li * the seekpoints will be spaced 1559*600f14f4SXin Li * \a samples samples apart. 1560*600f14f4SXin Li * \assert 1561*600f14f4SXin Li * \code object != NULL \endcode 1562*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode 1563*600f14f4SXin Li * \code samples > 0 \endcode 1564*600f14f4SXin Li * \code total_samples > 0 \endcode 1565*600f14f4SXin Li * \retval FLAC__bool 1566*600f14f4SXin Li * \c false if memory allocation fails, else \c true. 1567*600f14f4SXin Li */ 1568*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(FLAC__StreamMetadata *object, uint32_t samples, FLAC__uint64 total_samples); 1569*600f14f4SXin Li 1570*600f14f4SXin Li /** Sort a seek table's seek points according to the format specification, 1571*600f14f4SXin Li * removing duplicates. 1572*600f14f4SXin Li * 1573*600f14f4SXin Li * \param object A pointer to a seek table to be sorted. 1574*600f14f4SXin Li * \param compact If \c false, behaves like FLAC__format_seektable_sort(). 1575*600f14f4SXin Li * If \c true, duplicates are deleted and the seek table is 1576*600f14f4SXin Li * shrunk appropriately; the number of placeholder points 1577*600f14f4SXin Li * present in the seek table will be the same after the call 1578*600f14f4SXin Li * as before. 1579*600f14f4SXin Li * \assert 1580*600f14f4SXin Li * \code object != NULL \endcode 1581*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode 1582*600f14f4SXin Li * \retval FLAC__bool 1583*600f14f4SXin Li * \c false if realloc() fails, else \c true. 1584*600f14f4SXin Li */ 1585*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_sort(FLAC__StreamMetadata *object, FLAC__bool compact); 1586*600f14f4SXin Li 1587*600f14f4SXin Li /** Sets the vendor string in a VORBIS_COMMENT block. 1588*600f14f4SXin Li * 1589*600f14f4SXin Li * For convenience, a trailing NUL is added to the entry if it doesn't have 1590*600f14f4SXin Li * one already. 1591*600f14f4SXin Li * 1592*600f14f4SXin Li * If \a copy is \c true, a copy of the entry is stored; otherwise, the object 1593*600f14f4SXin Li * takes ownership of the \c entry.entry pointer. 1594*600f14f4SXin Li * 1595*600f14f4SXin Li * \note If this function returns \c false, the caller still owns the 1596*600f14f4SXin Li * pointer. 1597*600f14f4SXin Li * 1598*600f14f4SXin Li * \param object A pointer to an existing VORBIS_COMMENT object. 1599*600f14f4SXin Li * \param entry The entry to set the vendor string to. 1600*600f14f4SXin Li * \param copy See above. 1601*600f14f4SXin Li * \assert 1602*600f14f4SXin Li * \code object != NULL \endcode 1603*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode 1604*600f14f4SXin Li * \code (entry.entry != NULL && entry.length > 0) || 1605*600f14f4SXin Li * (entry.entry == NULL && entry.length == 0) \endcode 1606*600f14f4SXin Li * \retval FLAC__bool 1607*600f14f4SXin Li * \c false if memory allocation fails or \a entry does not comply with the 1608*600f14f4SXin Li * Vorbis comment specification, else \c true. 1609*600f14f4SXin Li */ 1610*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_vendor_string(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy); 1611*600f14f4SXin Li 1612*600f14f4SXin Li /** Resize the comment array. 1613*600f14f4SXin Li * 1614*600f14f4SXin Li * If the size shrinks, elements will truncated; if it grows, new empty 1615*600f14f4SXin Li * fields will be added to the end. If this function returns false, the 1616*600f14f4SXin Li * object is left untouched. 1617*600f14f4SXin Li * 1618*600f14f4SXin Li * \param object A pointer to an existing VORBIS_COMMENT object. 1619*600f14f4SXin Li * \param new_num_comments The desired length of the array; may be \c 0. 1620*600f14f4SXin Li * \assert 1621*600f14f4SXin Li * \code object != NULL \endcode 1622*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode 1623*600f14f4SXin Li * \code (object->data.vorbis_comment.comments == NULL && object->data.vorbis_comment.num_comments == 0) || 1624*600f14f4SXin Li * (object->data.vorbis_comment.comments != NULL && object->data.vorbis_comment.num_comments > 0) \endcode 1625*600f14f4SXin Li * \retval FLAC__bool 1626*600f14f4SXin Li * \c false if memory allocation fails, else \c true. 1627*600f14f4SXin Li */ 1628*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__StreamMetadata *object, uint32_t new_num_comments); 1629*600f14f4SXin Li 1630*600f14f4SXin Li /** Sets a comment in a VORBIS_COMMENT block. 1631*600f14f4SXin Li * 1632*600f14f4SXin Li * For convenience, a trailing NUL is added to the entry if it doesn't have 1633*600f14f4SXin Li * one already. 1634*600f14f4SXin Li * 1635*600f14f4SXin Li * If \a copy is \c true, a copy of the entry is stored; otherwise, the object 1636*600f14f4SXin Li * takes ownership of the \c entry.entry pointer. 1637*600f14f4SXin Li * 1638*600f14f4SXin Li * \note If this function returns \c false, the caller still owns the 1639*600f14f4SXin Li * pointer. 1640*600f14f4SXin Li * 1641*600f14f4SXin Li * \param object A pointer to an existing VORBIS_COMMENT object. 1642*600f14f4SXin Li * \param comment_num Index into comment array to set. 1643*600f14f4SXin Li * \param entry The entry to set the comment to. 1644*600f14f4SXin Li * \param copy See above. 1645*600f14f4SXin Li * \assert 1646*600f14f4SXin Li * \code object != NULL \endcode 1647*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode 1648*600f14f4SXin Li * \code comment_num < object->data.vorbis_comment.num_comments \endcode 1649*600f14f4SXin Li * \code (entry.entry != NULL && entry.length > 0) || 1650*600f14f4SXin Li * (entry.entry == NULL && entry.length == 0) \endcode 1651*600f14f4SXin Li * \retval FLAC__bool 1652*600f14f4SXin Li * \c false if memory allocation fails or \a entry does not comply with the 1653*600f14f4SXin Li * Vorbis comment specification, else \c true. 1654*600f14f4SXin Li */ 1655*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_comment(FLAC__StreamMetadata *object, uint32_t comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy); 1656*600f14f4SXin Li 1657*600f14f4SXin Li /** Insert a comment in a VORBIS_COMMENT block at the given index. 1658*600f14f4SXin Li * 1659*600f14f4SXin Li * For convenience, a trailing NUL is added to the entry if it doesn't have 1660*600f14f4SXin Li * one already. 1661*600f14f4SXin Li * 1662*600f14f4SXin Li * If \a copy is \c true, a copy of the entry is stored; otherwise, the object 1663*600f14f4SXin Li * takes ownership of the \c entry.entry pointer. 1664*600f14f4SXin Li * 1665*600f14f4SXin Li * \note If this function returns \c false, the caller still owns the 1666*600f14f4SXin Li * pointer. 1667*600f14f4SXin Li * 1668*600f14f4SXin Li * \param object A pointer to an existing VORBIS_COMMENT object. 1669*600f14f4SXin Li * \param comment_num The index at which to insert the comment. The comments 1670*600f14f4SXin Li * at and after \a comment_num move right one position. 1671*600f14f4SXin Li * To append a comment to the end, set \a comment_num to 1672*600f14f4SXin Li * \c object->data.vorbis_comment.num_comments . 1673*600f14f4SXin Li * \param entry The comment to insert. 1674*600f14f4SXin Li * \param copy See above. 1675*600f14f4SXin Li * \assert 1676*600f14f4SXin Li * \code object != NULL \endcode 1677*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode 1678*600f14f4SXin Li * \code object->data.vorbis_comment.num_comments >= comment_num \endcode 1679*600f14f4SXin Li * \code (entry.entry != NULL && entry.length > 0) || 1680*600f14f4SXin Li * (entry.entry == NULL && entry.length == 0 && copy == false) \endcode 1681*600f14f4SXin Li * \retval FLAC__bool 1682*600f14f4SXin Li * \c false if memory allocation fails or \a entry does not comply with the 1683*600f14f4SXin Li * Vorbis comment specification, else \c true. 1684*600f14f4SXin Li */ 1685*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_insert_comment(FLAC__StreamMetadata *object, uint32_t comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy); 1686*600f14f4SXin Li 1687*600f14f4SXin Li /** Appends a comment to a VORBIS_COMMENT block. 1688*600f14f4SXin Li * 1689*600f14f4SXin Li * For convenience, a trailing NUL is added to the entry if it doesn't have 1690*600f14f4SXin Li * one already. 1691*600f14f4SXin Li * 1692*600f14f4SXin Li * If \a copy is \c true, a copy of the entry is stored; otherwise, the object 1693*600f14f4SXin Li * takes ownership of the \c entry.entry pointer. 1694*600f14f4SXin Li * 1695*600f14f4SXin Li * \note If this function returns \c false, the caller still owns the 1696*600f14f4SXin Li * pointer. 1697*600f14f4SXin Li * 1698*600f14f4SXin Li * \param object A pointer to an existing VORBIS_COMMENT object. 1699*600f14f4SXin Li * \param entry The comment to insert. 1700*600f14f4SXin Li * \param copy See above. 1701*600f14f4SXin Li * \assert 1702*600f14f4SXin Li * \code object != NULL \endcode 1703*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode 1704*600f14f4SXin Li * \code (entry.entry != NULL && entry.length > 0) || 1705*600f14f4SXin Li * (entry.entry == NULL && entry.length == 0 && copy == false) \endcode 1706*600f14f4SXin Li * \retval FLAC__bool 1707*600f14f4SXin Li * \c false if memory allocation fails or \a entry does not comply with the 1708*600f14f4SXin Li * Vorbis comment specification, else \c true. 1709*600f14f4SXin Li */ 1710*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_append_comment(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy); 1711*600f14f4SXin Li 1712*600f14f4SXin Li /** Replaces comments in a VORBIS_COMMENT block with a new one. 1713*600f14f4SXin Li * 1714*600f14f4SXin Li * For convenience, a trailing NUL is added to the entry if it doesn't have 1715*600f14f4SXin Li * one already. 1716*600f14f4SXin Li * 1717*600f14f4SXin Li * Depending on the value of \a all, either all or just the first comment 1718*600f14f4SXin Li * whose field name(s) match the given entry's name will be replaced by the 1719*600f14f4SXin Li * given entry. If no comments match, \a entry will simply be appended. 1720*600f14f4SXin Li * 1721*600f14f4SXin Li * If \a copy is \c true, a copy of the entry is stored; otherwise, the object 1722*600f14f4SXin Li * takes ownership of the \c entry.entry pointer. 1723*600f14f4SXin Li * 1724*600f14f4SXin Li * \note If this function returns \c false, the caller still owns the 1725*600f14f4SXin Li * pointer. 1726*600f14f4SXin Li * 1727*600f14f4SXin Li * \param object A pointer to an existing VORBIS_COMMENT object. 1728*600f14f4SXin Li * \param entry The comment to insert. 1729*600f14f4SXin Li * \param all If \c true, all comments whose field name matches 1730*600f14f4SXin Li * \a entry's field name will be removed, and \a entry will 1731*600f14f4SXin Li * be inserted at the position of the first matching 1732*600f14f4SXin Li * comment. If \c false, only the first comment whose 1733*600f14f4SXin Li * field name matches \a entry's field name will be 1734*600f14f4SXin Li * replaced with \a entry. 1735*600f14f4SXin Li * \param copy See above. 1736*600f14f4SXin Li * \assert 1737*600f14f4SXin Li * \code object != NULL \endcode 1738*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode 1739*600f14f4SXin Li * \code (entry.entry != NULL && entry.length > 0) || 1740*600f14f4SXin Li * (entry.entry == NULL && entry.length == 0 && copy == false) \endcode 1741*600f14f4SXin Li * \retval FLAC__bool 1742*600f14f4SXin Li * \c false if memory allocation fails or \a entry does not comply with the 1743*600f14f4SXin Li * Vorbis comment specification, else \c true. 1744*600f14f4SXin Li */ 1745*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_replace_comment(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool all, FLAC__bool copy); 1746*600f14f4SXin Li 1747*600f14f4SXin Li /** Delete a comment in a VORBIS_COMMENT block at the given index. 1748*600f14f4SXin Li * 1749*600f14f4SXin Li * \param object A pointer to an existing VORBIS_COMMENT object. 1750*600f14f4SXin Li * \param comment_num The index of the comment to delete. 1751*600f14f4SXin Li * \assert 1752*600f14f4SXin Li * \code object != NULL \endcode 1753*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode 1754*600f14f4SXin Li * \code object->data.vorbis_comment.num_comments > comment_num \endcode 1755*600f14f4SXin Li * \retval FLAC__bool 1756*600f14f4SXin Li * \c false if realloc() fails, else \c true. 1757*600f14f4SXin Li */ 1758*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_delete_comment(FLAC__StreamMetadata *object, uint32_t comment_num); 1759*600f14f4SXin Li 1760*600f14f4SXin Li /** Creates a Vorbis comment entry from NUL-terminated name and value strings. 1761*600f14f4SXin Li * 1762*600f14f4SXin Li * On return, the filled-in \a entry->entry pointer will point to malloc()ed 1763*600f14f4SXin Li * memory and shall be owned by the caller. For convenience the entry will 1764*600f14f4SXin Li * have a terminating NUL. 1765*600f14f4SXin Li * 1766*600f14f4SXin Li * \param entry A pointer to a Vorbis comment entry. The entry's 1767*600f14f4SXin Li * \c entry pointer should not point to allocated 1768*600f14f4SXin Li * memory as it will be overwritten. 1769*600f14f4SXin Li * \param field_name The field name in ASCII, \c NUL terminated. 1770*600f14f4SXin Li * \param field_value The field value in UTF-8, \c NUL terminated. 1771*600f14f4SXin Li * \assert 1772*600f14f4SXin Li * \code entry != NULL \endcode 1773*600f14f4SXin Li * \code field_name != NULL \endcode 1774*600f14f4SXin Li * \code field_value != NULL \endcode 1775*600f14f4SXin Li * \retval FLAC__bool 1776*600f14f4SXin Li * \c false if malloc() fails, or if \a field_name or \a field_value does 1777*600f14f4SXin Li * not comply with the Vorbis comment specification, else \c true. 1778*600f14f4SXin Li */ 1779*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(FLAC__StreamMetadata_VorbisComment_Entry *entry, const char *field_name, const char *field_value); 1780*600f14f4SXin Li 1781*600f14f4SXin Li /** Splits a Vorbis comment entry into NUL-terminated name and value strings. 1782*600f14f4SXin Li * 1783*600f14f4SXin Li * The returned pointers to name and value will be allocated by malloc() 1784*600f14f4SXin Li * and shall be owned by the caller. 1785*600f14f4SXin Li * 1786*600f14f4SXin Li * \param entry An existing Vorbis comment entry. 1787*600f14f4SXin Li * \param field_name The address of where the returned pointer to the 1788*600f14f4SXin Li * field name will be stored. 1789*600f14f4SXin Li * \param field_value The address of where the returned pointer to the 1790*600f14f4SXin Li * field value will be stored. 1791*600f14f4SXin Li * \assert 1792*600f14f4SXin Li * \code (entry.entry != NULL && entry.length > 0) \endcode 1793*600f14f4SXin Li * \code memchr(entry.entry, '=', entry.length) != NULL \endcode 1794*600f14f4SXin Li * \code field_name != NULL \endcode 1795*600f14f4SXin Li * \code field_value != NULL \endcode 1796*600f14f4SXin Li * \retval FLAC__bool 1797*600f14f4SXin Li * \c false if memory allocation fails or \a entry does not comply with the 1798*600f14f4SXin Li * Vorbis comment specification, else \c true. 1799*600f14f4SXin Li */ 1800*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair(const FLAC__StreamMetadata_VorbisComment_Entry entry, char **field_name, char **field_value); 1801*600f14f4SXin Li 1802*600f14f4SXin Li /** Check if the given Vorbis comment entry's field name matches the given 1803*600f14f4SXin Li * field name. 1804*600f14f4SXin Li * 1805*600f14f4SXin Li * \param entry An existing Vorbis comment entry. 1806*600f14f4SXin Li * \param field_name The field name to check. 1807*600f14f4SXin Li * \param field_name_length The length of \a field_name, not including the 1808*600f14f4SXin Li * terminating \c NUL. 1809*600f14f4SXin Li * \assert 1810*600f14f4SXin Li * \code (entry.entry != NULL && entry.length > 0) \endcode 1811*600f14f4SXin Li * \retval FLAC__bool 1812*600f14f4SXin Li * \c true if the field names match, else \c false 1813*600f14f4SXin Li */ 1814*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_matches(const FLAC__StreamMetadata_VorbisComment_Entry entry, const char *field_name, uint32_t field_name_length); 1815*600f14f4SXin Li 1816*600f14f4SXin Li /** Find a Vorbis comment with the given field name. 1817*600f14f4SXin Li * 1818*600f14f4SXin Li * The search begins at entry number \a offset; use an offset of 0 to 1819*600f14f4SXin Li * search from the beginning of the comment array. 1820*600f14f4SXin Li * 1821*600f14f4SXin Li * \param object A pointer to an existing VORBIS_COMMENT object. 1822*600f14f4SXin Li * \param offset The offset into the comment array from where to start 1823*600f14f4SXin Li * the search. 1824*600f14f4SXin Li * \param field_name The field name of the comment to find. 1825*600f14f4SXin Li * \assert 1826*600f14f4SXin Li * \code object != NULL \endcode 1827*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode 1828*600f14f4SXin Li * \code field_name != NULL \endcode 1829*600f14f4SXin Li * \retval int 1830*600f14f4SXin Li * The offset in the comment array of the first comment whose field 1831*600f14f4SXin Li * name matches \a field_name, or \c -1 if no match was found. 1832*600f14f4SXin Li */ 1833*600f14f4SXin Li FLAC_API int FLAC__metadata_object_vorbiscomment_find_entry_from(const FLAC__StreamMetadata *object, uint32_t offset, const char *field_name); 1834*600f14f4SXin Li 1835*600f14f4SXin Li /** Remove first Vorbis comment matching the given field name. 1836*600f14f4SXin Li * 1837*600f14f4SXin Li * \param object A pointer to an existing VORBIS_COMMENT object. 1838*600f14f4SXin Li * \param field_name The field name of comment to delete. 1839*600f14f4SXin Li * \assert 1840*600f14f4SXin Li * \code object != NULL \endcode 1841*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode 1842*600f14f4SXin Li * \retval int 1843*600f14f4SXin Li * \c -1 for memory allocation error, \c 0 for no matching entries, 1844*600f14f4SXin Li * \c 1 for one matching entry deleted. 1845*600f14f4SXin Li */ 1846*600f14f4SXin Li FLAC_API int FLAC__metadata_object_vorbiscomment_remove_entry_matching(FLAC__StreamMetadata *object, const char *field_name); 1847*600f14f4SXin Li 1848*600f14f4SXin Li /** Remove all Vorbis comments matching the given field name. 1849*600f14f4SXin Li * 1850*600f14f4SXin Li * \param object A pointer to an existing VORBIS_COMMENT object. 1851*600f14f4SXin Li * \param field_name The field name of comments to delete. 1852*600f14f4SXin Li * \assert 1853*600f14f4SXin Li * \code object != NULL \endcode 1854*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode 1855*600f14f4SXin Li * \retval int 1856*600f14f4SXin Li * \c -1 for memory allocation error, \c 0 for no matching entries, 1857*600f14f4SXin Li * else the number of matching entries deleted. 1858*600f14f4SXin Li */ 1859*600f14f4SXin Li FLAC_API int FLAC__metadata_object_vorbiscomment_remove_entries_matching(FLAC__StreamMetadata *object, const char *field_name); 1860*600f14f4SXin Li 1861*600f14f4SXin Li /** Create a new CUESHEET track instance. 1862*600f14f4SXin Li * 1863*600f14f4SXin Li * The object will be "empty"; i.e. values and data pointers will be \c 0. 1864*600f14f4SXin Li * 1865*600f14f4SXin Li * \retval FLAC__StreamMetadata_CueSheet_Track* 1866*600f14f4SXin Li * \c NULL if there was an error allocating memory, else the new instance. 1867*600f14f4SXin Li */ 1868*600f14f4SXin Li FLAC_API FLAC__StreamMetadata_CueSheet_Track *FLAC__metadata_object_cuesheet_track_new(void); 1869*600f14f4SXin Li 1870*600f14f4SXin Li /** Create a copy of an existing CUESHEET track object. 1871*600f14f4SXin Li * 1872*600f14f4SXin Li * The copy is a "deep" copy, i.e. dynamically allocated data within the 1873*600f14f4SXin Li * object is also copied. The caller takes ownership of the new object and 1874*600f14f4SXin Li * is responsible for freeing it with 1875*600f14f4SXin Li * FLAC__metadata_object_cuesheet_track_delete(). 1876*600f14f4SXin Li * 1877*600f14f4SXin Li * \param object Pointer to object to copy. 1878*600f14f4SXin Li * \assert 1879*600f14f4SXin Li * \code object != NULL \endcode 1880*600f14f4SXin Li * \retval FLAC__StreamMetadata_CueSheet_Track* 1881*600f14f4SXin Li * \c NULL if there was an error allocating memory, else the new instance. 1882*600f14f4SXin Li */ 1883*600f14f4SXin Li FLAC_API FLAC__StreamMetadata_CueSheet_Track *FLAC__metadata_object_cuesheet_track_clone(const FLAC__StreamMetadata_CueSheet_Track *object); 1884*600f14f4SXin Li 1885*600f14f4SXin Li /** Delete a CUESHEET track object 1886*600f14f4SXin Li * 1887*600f14f4SXin Li * \param object A pointer to an existing CUESHEET track object. 1888*600f14f4SXin Li * \assert 1889*600f14f4SXin Li * \code object != NULL \endcode 1890*600f14f4SXin Li */ 1891*600f14f4SXin Li FLAC_API void FLAC__metadata_object_cuesheet_track_delete(FLAC__StreamMetadata_CueSheet_Track *object); 1892*600f14f4SXin Li 1893*600f14f4SXin Li /** Resize a track's index point array. 1894*600f14f4SXin Li * 1895*600f14f4SXin Li * If the size shrinks, elements will truncated; if it grows, new blank 1896*600f14f4SXin Li * indices will be added to the end. If this function returns false, the 1897*600f14f4SXin Li * track object is left untouched. 1898*600f14f4SXin Li * 1899*600f14f4SXin Li * \param object A pointer to an existing CUESHEET object. 1900*600f14f4SXin Li * \param track_num The index of the track to modify. NOTE: this is not 1901*600f14f4SXin Li * necessarily the same as the track's \a number field. 1902*600f14f4SXin Li * \param new_num_indices The desired length of the array; may be \c 0. 1903*600f14f4SXin Li * \assert 1904*600f14f4SXin Li * \code object != NULL \endcode 1905*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode 1906*600f14f4SXin Li * \code object->data.cue_sheet.num_tracks > track_num \endcode 1907*600f14f4SXin Li * \code (object->data.cue_sheet.tracks[track_num].indices == NULL && object->data.cue_sheet.tracks[track_num].num_indices == 0) || 1908*600f14f4SXin Li * (object->data.cue_sheet.tracks[track_num].indices != NULL && object->data.cue_sheet.tracks[track_num].num_indices > 0) \endcode 1909*600f14f4SXin Li * \retval FLAC__bool 1910*600f14f4SXin Li * \c false if memory allocation error, else \c true. 1911*600f14f4SXin Li */ 1912*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_resize_indices(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t new_num_indices); 1913*600f14f4SXin Li 1914*600f14f4SXin Li /** Insert an index point in a CUESHEET track at the given index. 1915*600f14f4SXin Li * 1916*600f14f4SXin Li * \param object A pointer to an existing CUESHEET object. 1917*600f14f4SXin Li * \param track_num The index of the track to modify. NOTE: this is not 1918*600f14f4SXin Li * necessarily the same as the track's \a number field. 1919*600f14f4SXin Li * \param index_num The index into the track's index array at which to 1920*600f14f4SXin Li * insert the index point. NOTE: this is not necessarily 1921*600f14f4SXin Li * the same as the index point's \a number field. The 1922*600f14f4SXin Li * indices at and after \a index_num move right one 1923*600f14f4SXin Li * position. To append an index point to the end, set 1924*600f14f4SXin Li * \a index_num to 1925*600f14f4SXin Li * \c object->data.cue_sheet.tracks[track_num].num_indices . 1926*600f14f4SXin Li * \param index The index point to insert. 1927*600f14f4SXin Li * \assert 1928*600f14f4SXin Li * \code object != NULL \endcode 1929*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode 1930*600f14f4SXin Li * \code object->data.cue_sheet.num_tracks > track_num \endcode 1931*600f14f4SXin Li * \code object->data.cue_sheet.tracks[track_num].num_indices >= index_num \endcode 1932*600f14f4SXin Li * \retval FLAC__bool 1933*600f14f4SXin Li * \c false if realloc() fails, else \c true. 1934*600f14f4SXin Li */ 1935*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_index(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t index_num, FLAC__StreamMetadata_CueSheet_Index index); 1936*600f14f4SXin Li 1937*600f14f4SXin Li /** Insert a blank index point in a CUESHEET track at the given index. 1938*600f14f4SXin Li * 1939*600f14f4SXin Li * A blank index point is one in which all field values are zero. 1940*600f14f4SXin Li * 1941*600f14f4SXin Li * \param object A pointer to an existing CUESHEET object. 1942*600f14f4SXin Li * \param track_num The index of the track to modify. NOTE: this is not 1943*600f14f4SXin Li * necessarily the same as the track's \a number field. 1944*600f14f4SXin Li * \param index_num The index into the track's index array at which to 1945*600f14f4SXin Li * insert the index point. NOTE: this is not necessarily 1946*600f14f4SXin Li * the same as the index point's \a number field. The 1947*600f14f4SXin Li * indices at and after \a index_num move right one 1948*600f14f4SXin Li * position. To append an index point to the end, set 1949*600f14f4SXin Li * \a index_num to 1950*600f14f4SXin Li * \c object->data.cue_sheet.tracks[track_num].num_indices . 1951*600f14f4SXin Li * \assert 1952*600f14f4SXin Li * \code object != NULL \endcode 1953*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode 1954*600f14f4SXin Li * \code object->data.cue_sheet.num_tracks > track_num \endcode 1955*600f14f4SXin Li * \code object->data.cue_sheet.tracks[track_num].num_indices >= index_num \endcode 1956*600f14f4SXin Li * \retval FLAC__bool 1957*600f14f4SXin Li * \c false if realloc() fails, else \c true. 1958*600f14f4SXin Li */ 1959*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_blank_index(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t index_num); 1960*600f14f4SXin Li 1961*600f14f4SXin Li /** Delete an index point in a CUESHEET track at the given index. 1962*600f14f4SXin Li * 1963*600f14f4SXin Li * \param object A pointer to an existing CUESHEET object. 1964*600f14f4SXin Li * \param track_num The index into the track array of the track to 1965*600f14f4SXin Li * modify. NOTE: this is not necessarily the same 1966*600f14f4SXin Li * as the track's \a number field. 1967*600f14f4SXin Li * \param index_num The index into the track's index array of the index 1968*600f14f4SXin Li * to delete. NOTE: this is not necessarily the same 1969*600f14f4SXin Li * as the index's \a number field. 1970*600f14f4SXin Li * \assert 1971*600f14f4SXin Li * \code object != NULL \endcode 1972*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode 1973*600f14f4SXin Li * \code object->data.cue_sheet.num_tracks > track_num \endcode 1974*600f14f4SXin Li * \code object->data.cue_sheet.tracks[track_num].num_indices > index_num \endcode 1975*600f14f4SXin Li * \retval FLAC__bool 1976*600f14f4SXin Li * \c false if realloc() fails, else \c true. 1977*600f14f4SXin Li */ 1978*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_delete_index(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t index_num); 1979*600f14f4SXin Li 1980*600f14f4SXin Li /** Resize the track array. 1981*600f14f4SXin Li * 1982*600f14f4SXin Li * If the size shrinks, elements will truncated; if it grows, new blank 1983*600f14f4SXin Li * tracks will be added to the end. If this function returns false, the 1984*600f14f4SXin Li * object is left untouched. 1985*600f14f4SXin Li * 1986*600f14f4SXin Li * \param object A pointer to an existing CUESHEET object. 1987*600f14f4SXin Li * \param new_num_tracks The desired length of the array; may be \c 0. 1988*600f14f4SXin Li * \assert 1989*600f14f4SXin Li * \code object != NULL \endcode 1990*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode 1991*600f14f4SXin Li * \code (object->data.cue_sheet.tracks == NULL && object->data.cue_sheet.num_tracks == 0) || 1992*600f14f4SXin Li * (object->data.cue_sheet.tracks != NULL && object->data.cue_sheet.num_tracks > 0) \endcode 1993*600f14f4SXin Li * \retval FLAC__bool 1994*600f14f4SXin Li * \c false if memory allocation error, else \c true. 1995*600f14f4SXin Li */ 1996*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_resize_tracks(FLAC__StreamMetadata *object, uint32_t new_num_tracks); 1997*600f14f4SXin Li 1998*600f14f4SXin Li /** Sets a track in a CUESHEET block. 1999*600f14f4SXin Li * 2000*600f14f4SXin Li * If \a copy is \c true, a copy of the track is stored; otherwise, the object 2001*600f14f4SXin Li * takes ownership of the \a track pointer. 2002*600f14f4SXin Li * 2003*600f14f4SXin Li * \param object A pointer to an existing CUESHEET object. 2004*600f14f4SXin Li * \param track_num Index into track array to set. NOTE: this is not 2005*600f14f4SXin Li * necessarily the same as the track's \a number field. 2006*600f14f4SXin Li * \param track The track to set the track to. You may safely pass in 2007*600f14f4SXin Li * a const pointer if \a copy is \c true. 2008*600f14f4SXin Li * \param copy See above. 2009*600f14f4SXin Li * \assert 2010*600f14f4SXin Li * \code object != NULL \endcode 2011*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode 2012*600f14f4SXin Li * \code track_num < object->data.cue_sheet.num_tracks \endcode 2013*600f14f4SXin Li * \code (track->indices != NULL && track->num_indices > 0) || 2014*600f14f4SXin Li * (track->indices == NULL && track->num_indices == 0) \endcode 2015*600f14f4SXin Li * \retval FLAC__bool 2016*600f14f4SXin Li * \c false if \a copy is \c true and malloc() fails, else \c true. 2017*600f14f4SXin Li */ 2018*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_set_track(FLAC__StreamMetadata *object, uint32_t track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy); 2019*600f14f4SXin Li 2020*600f14f4SXin Li /** Insert a track in a CUESHEET block at the given index. 2021*600f14f4SXin Li * 2022*600f14f4SXin Li * If \a copy is \c true, a copy of the track is stored; otherwise, the object 2023*600f14f4SXin Li * takes ownership of the \a track pointer. 2024*600f14f4SXin Li * 2025*600f14f4SXin Li * \param object A pointer to an existing CUESHEET object. 2026*600f14f4SXin Li * \param track_num The index at which to insert the track. NOTE: this 2027*600f14f4SXin Li * is not necessarily the same as the track's \a number 2028*600f14f4SXin Li * field. The tracks at and after \a track_num move right 2029*600f14f4SXin Li * one position. To append a track to the end, set 2030*600f14f4SXin Li * \a track_num to \c object->data.cue_sheet.num_tracks . 2031*600f14f4SXin Li * \param track The track to insert. You may safely pass in a const 2032*600f14f4SXin Li * pointer if \a copy is \c true. 2033*600f14f4SXin Li * \param copy See above. 2034*600f14f4SXin Li * \assert 2035*600f14f4SXin Li * \code object != NULL \endcode 2036*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode 2037*600f14f4SXin Li * \code object->data.cue_sheet.num_tracks >= track_num \endcode 2038*600f14f4SXin Li * \retval FLAC__bool 2039*600f14f4SXin Li * \c false if \a copy is \c true and malloc() fails, else \c true. 2040*600f14f4SXin Li */ 2041*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_track(FLAC__StreamMetadata *object, uint32_t track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy); 2042*600f14f4SXin Li 2043*600f14f4SXin Li /** Insert a blank track in a CUESHEET block at the given index. 2044*600f14f4SXin Li * 2045*600f14f4SXin Li * A blank track is one in which all field values are zero. 2046*600f14f4SXin Li * 2047*600f14f4SXin Li * \param object A pointer to an existing CUESHEET object. 2048*600f14f4SXin Li * \param track_num The index at which to insert the track. NOTE: this 2049*600f14f4SXin Li * is not necessarily the same as the track's \a number 2050*600f14f4SXin Li * field. The tracks at and after \a track_num move right 2051*600f14f4SXin Li * one position. To append a track to the end, set 2052*600f14f4SXin Li * \a track_num to \c object->data.cue_sheet.num_tracks . 2053*600f14f4SXin Li * \assert 2054*600f14f4SXin Li * \code object != NULL \endcode 2055*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode 2056*600f14f4SXin Li * \code object->data.cue_sheet.num_tracks >= track_num \endcode 2057*600f14f4SXin Li * \retval FLAC__bool 2058*600f14f4SXin Li * \c false if \a copy is \c true and malloc() fails, else \c true. 2059*600f14f4SXin Li */ 2060*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_blank_track(FLAC__StreamMetadata *object, uint32_t track_num); 2061*600f14f4SXin Li 2062*600f14f4SXin Li /** Delete a track in a CUESHEET block at the given index. 2063*600f14f4SXin Li * 2064*600f14f4SXin Li * \param object A pointer to an existing CUESHEET object. 2065*600f14f4SXin Li * \param track_num The index into the track array of the track to 2066*600f14f4SXin Li * delete. NOTE: this is not necessarily the same 2067*600f14f4SXin Li * as the track's \a number field. 2068*600f14f4SXin Li * \assert 2069*600f14f4SXin Li * \code object != NULL \endcode 2070*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode 2071*600f14f4SXin Li * \code object->data.cue_sheet.num_tracks > track_num \endcode 2072*600f14f4SXin Li * \retval FLAC__bool 2073*600f14f4SXin Li * \c false if realloc() fails, else \c true. 2074*600f14f4SXin Li */ 2075*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_delete_track(FLAC__StreamMetadata *object, uint32_t track_num); 2076*600f14f4SXin Li 2077*600f14f4SXin Li /** Check a cue sheet to see if it conforms to the FLAC specification. 2078*600f14f4SXin Li * See the format specification for limits on the contents of the 2079*600f14f4SXin Li * cue sheet. 2080*600f14f4SXin Li * 2081*600f14f4SXin Li * \param object A pointer to an existing CUESHEET object. 2082*600f14f4SXin Li * \param check_cd_da_subset If \c true, check CUESHEET against more 2083*600f14f4SXin Li * stringent requirements for a CD-DA (audio) disc. 2084*600f14f4SXin Li * \param violation Address of a pointer to a string. If there is a 2085*600f14f4SXin Li * violation, a pointer to a string explanation of the 2086*600f14f4SXin Li * violation will be returned here. \a violation may be 2087*600f14f4SXin Li * \c NULL if you don't need the returned string. Do not 2088*600f14f4SXin Li * free the returned string; it will always point to static 2089*600f14f4SXin Li * data. 2090*600f14f4SXin Li * \assert 2091*600f14f4SXin Li * \code object != NULL \endcode 2092*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode 2093*600f14f4SXin Li * \retval FLAC__bool 2094*600f14f4SXin Li * \c false if cue sheet is illegal, else \c true. 2095*600f14f4SXin Li */ 2096*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_is_legal(const FLAC__StreamMetadata *object, FLAC__bool check_cd_da_subset, const char **violation); 2097*600f14f4SXin Li 2098*600f14f4SXin Li /** Calculate and return the CDDB/freedb ID for a cue sheet. The function 2099*600f14f4SXin Li * assumes the cue sheet corresponds to a CD; the result is undefined 2100*600f14f4SXin Li * if the cuesheet's is_cd bit is not set. 2101*600f14f4SXin Li * 2102*600f14f4SXin Li * \param object A pointer to an existing CUESHEET object. 2103*600f14f4SXin Li * \assert 2104*600f14f4SXin Li * \code object != NULL \endcode 2105*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode 2106*600f14f4SXin Li * \retval FLAC__uint32 2107*600f14f4SXin Li * The unsigned integer representation of the CDDB/freedb ID 2108*600f14f4SXin Li */ 2109*600f14f4SXin Li FLAC_API FLAC__uint32 FLAC__metadata_object_cuesheet_calculate_cddb_id(const FLAC__StreamMetadata *object); 2110*600f14f4SXin Li 2111*600f14f4SXin Li /** Sets the MIME type of a PICTURE block. 2112*600f14f4SXin Li * 2113*600f14f4SXin Li * If \a copy is \c true, a copy of the string is stored; otherwise, the object 2114*600f14f4SXin Li * takes ownership of the pointer. The existing string will be freed if this 2115*600f14f4SXin Li * function is successful, otherwise the original string will remain if \a copy 2116*600f14f4SXin Li * is \c true and malloc() fails. 2117*600f14f4SXin Li * 2118*600f14f4SXin Li * \note It is safe to pass a const pointer to \a mime_type if \a copy is \c true. 2119*600f14f4SXin Li * 2120*600f14f4SXin Li * \param object A pointer to an existing PICTURE object. 2121*600f14f4SXin Li * \param mime_type A pointer to the MIME type string. The string must be 2122*600f14f4SXin Li * ASCII characters 0x20-0x7e, NUL-terminated. No validation 2123*600f14f4SXin Li * is done. 2124*600f14f4SXin Li * \param copy See above. 2125*600f14f4SXin Li * \assert 2126*600f14f4SXin Li * \code object != NULL \endcode 2127*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode 2128*600f14f4SXin Li * \code (mime_type != NULL) \endcode 2129*600f14f4SXin Li * \retval FLAC__bool 2130*600f14f4SXin Li * \c false if \a copy is \c true and malloc() fails, else \c true. 2131*600f14f4SXin Li */ 2132*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_picture_set_mime_type(FLAC__StreamMetadata *object, char *mime_type, FLAC__bool copy); 2133*600f14f4SXin Li 2134*600f14f4SXin Li /** Sets the description of a PICTURE block. 2135*600f14f4SXin Li * 2136*600f14f4SXin Li * If \a copy is \c true, a copy of the string is stored; otherwise, the object 2137*600f14f4SXin Li * takes ownership of the pointer. The existing string will be freed if this 2138*600f14f4SXin Li * function is successful, otherwise the original string will remain if \a copy 2139*600f14f4SXin Li * is \c true and malloc() fails. 2140*600f14f4SXin Li * 2141*600f14f4SXin Li * \note It is safe to pass a const pointer to \a description if \a copy is \c true. 2142*600f14f4SXin Li * 2143*600f14f4SXin Li * \param object A pointer to an existing PICTURE object. 2144*600f14f4SXin Li * \param description A pointer to the description string. The string must be 2145*600f14f4SXin Li * valid UTF-8, NUL-terminated. No validation is done. 2146*600f14f4SXin Li * \param copy See above. 2147*600f14f4SXin Li * \assert 2148*600f14f4SXin Li * \code object != NULL \endcode 2149*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode 2150*600f14f4SXin Li * \code (description != NULL) \endcode 2151*600f14f4SXin Li * \retval FLAC__bool 2152*600f14f4SXin Li * \c false if \a copy is \c true and malloc() fails, else \c true. 2153*600f14f4SXin Li */ 2154*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_picture_set_description(FLAC__StreamMetadata *object, FLAC__byte *description, FLAC__bool copy); 2155*600f14f4SXin Li 2156*600f14f4SXin Li /** Sets the picture data of a PICTURE block. 2157*600f14f4SXin Li * 2158*600f14f4SXin Li * If \a copy is \c true, a copy of the data is stored; otherwise, the object 2159*600f14f4SXin Li * takes ownership of the pointer. Also sets the \a data_length field of the 2160*600f14f4SXin Li * metadata object to what is passed in as the \a length parameter. The 2161*600f14f4SXin Li * existing data will be freed if this function is successful, otherwise the 2162*600f14f4SXin Li * original data and data_length will remain if \a copy is \c true and 2163*600f14f4SXin Li * malloc() fails. 2164*600f14f4SXin Li * 2165*600f14f4SXin Li * \note It is safe to pass a const pointer to \a data if \a copy is \c true. 2166*600f14f4SXin Li * 2167*600f14f4SXin Li * \param object A pointer to an existing PICTURE object. 2168*600f14f4SXin Li * \param data A pointer to the data to set. 2169*600f14f4SXin Li * \param length The length of \a data in bytes. 2170*600f14f4SXin Li * \param copy See above. 2171*600f14f4SXin Li * \assert 2172*600f14f4SXin Li * \code object != NULL \endcode 2173*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode 2174*600f14f4SXin Li * \code (data != NULL && length > 0) || 2175*600f14f4SXin Li * (data == NULL && length == 0 && copy == false) \endcode 2176*600f14f4SXin Li * \retval FLAC__bool 2177*600f14f4SXin Li * \c false if \a copy is \c true and malloc() fails, else \c true. 2178*600f14f4SXin Li */ 2179*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_picture_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, FLAC__uint32 length, FLAC__bool copy); 2180*600f14f4SXin Li 2181*600f14f4SXin Li /** Check a PICTURE block to see if it conforms to the FLAC specification. 2182*600f14f4SXin Li * See the format specification for limits on the contents of the 2183*600f14f4SXin Li * PICTURE block. 2184*600f14f4SXin Li * 2185*600f14f4SXin Li * \param object A pointer to existing PICTURE block to be checked. 2186*600f14f4SXin Li * \param violation Address of a pointer to a string. If there is a 2187*600f14f4SXin Li * violation, a pointer to a string explanation of the 2188*600f14f4SXin Li * violation will be returned here. \a violation may be 2189*600f14f4SXin Li * \c NULL if you don't need the returned string. Do not 2190*600f14f4SXin Li * free the returned string; it will always point to static 2191*600f14f4SXin Li * data. 2192*600f14f4SXin Li * \assert 2193*600f14f4SXin Li * \code object != NULL \endcode 2194*600f14f4SXin Li * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode 2195*600f14f4SXin Li * \retval FLAC__bool 2196*600f14f4SXin Li * \c false if PICTURE block is illegal, else \c true. 2197*600f14f4SXin Li */ 2198*600f14f4SXin Li FLAC_API FLAC__bool FLAC__metadata_object_picture_is_legal(const FLAC__StreamMetadata *object, const char **violation); 2199*600f14f4SXin Li 2200*600f14f4SXin Li 2201*600f14f4SXin Li /** Get the raw (binary) representation of a FLAC__StreamMetadata objeect. 2202*600f14f4SXin Li * After use, free() the returned buffer. The length of the buffer is 2203*600f14f4SXin Li * the length of the input metadata object plus 4 bytes for the header. 2204*600f14f4SXin Li * 2205*600f14f4SXin Li * \param object A pointer to metadata block to be converted. 2206*600f14f4SXin Li * \assert 2207*600f14f4SXin Li * \code object != NULL \endcode 2208*600f14f4SXin Li * \retval FLAC__byte* 2209*600f14f4SXin Li * \c NULL if there was an error, else a pointer to a buffer holding 2210*600f14f4SXin Li * the requested data. 2211*600f14f4SXin Li */ 2212*600f14f4SXin Li FLAC_API FLAC__byte * FLAC__metadata_object_get_raw(const FLAC__StreamMetadata *object); 2213*600f14f4SXin Li 2214*600f14f4SXin Li 2215*600f14f4SXin Li /** Turn a raw (binary) representation into a FLAC__StreamMetadata objeect. 2216*600f14f4SXin Li * The returned object must be deleted with FLAC__metadata_object_delete() 2217*600f14f4SXin Li * after use. 2218*600f14f4SXin Li * 2219*600f14f4SXin Li * \param buffer A pointer to a buffer containing a binary representation 2220*600f14f4SXin Li * to be converted to a FLAC__StreamMetadata object 2221*600f14f4SXin Li * \param length The length of the supplied buffer 2222*600f14f4SXin Li * \retval FLAC__StreamMetadata* 2223*600f14f4SXin Li * \c NULL if there was an error, else a pointer to a FLAC__StreamMetadata 2224*600f14f4SXin Li * holding the requested data. 2225*600f14f4SXin Li */ 2226*600f14f4SXin Li 2227*600f14f4SXin Li FLAC_API FLAC__StreamMetadata * FLAC__metadata_object_set_raw(FLAC__byte *buffer, FLAC__uint32 length); 2228*600f14f4SXin Li /* \} */ 2229*600f14f4SXin Li 2230*600f14f4SXin Li #ifdef __cplusplus 2231*600f14f4SXin Li } 2232*600f14f4SXin Li #endif 2233*600f14f4SXin Li 2234*600f14f4SXin Li #endif 2235