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