159
165
* the caller using FLAC__metadata_object_delete().
161
167
* \code filename != NULL \endcode
162
* \code streaminfo != NULL \endcode
168
* \code tags != NULL \endcode
163
169
* \retval FLAC__bool
164
170
* \c true if a valid VORBIS_COMMENT block was read from \a filename,
165
* and \a *tags will be set to the address of the tag structure.
171
* and \a *tags will be set to the address of the metadata structure.
166
172
* Returns \c false if there was a memory allocation error, a file
167
173
* decoder error, or the file contained no VORBIS_COMMENT block, and
168
174
* \a *tags will be set to \c NULL.
170
176
FLAC_API FLAC__bool FLAC__metadata_get_tags(const char *filename, FLAC__StreamMetadata **tags);
178
/** Read the CUESHEET metadata block of the given FLAC file. This
179
* function will try to skip any ID3v2 tag at the head of the file.
181
* \param filename The path to the FLAC file to read.
182
* \param cuesheet The address where the returned pointer will be
183
* stored. The \a cuesheet object must be deleted by
184
* the caller using FLAC__metadata_object_delete().
186
* \code filename != NULL \endcode
187
* \code cuesheet != NULL \endcode
189
* \c true if a valid CUESHEET block was read from \a filename,
190
* and \a *cuesheet will be set to the address of the metadata
191
* structure. Returns \c false if there was a memory allocation
192
* error, a file decoder error, or the file contained no CUESHEET
193
* block, and \a *cuesheet will be set to \c NULL.
195
FLAC_API FLAC__bool FLAC__metadata_get_cuesheet(const char *filename, FLAC__StreamMetadata **cuesheet);
197
/** Read a PICTURE metadata block of the given FLAC file. This
198
* function will try to skip any ID3v2 tag at the head of the file.
199
* Since there can be more than one PICTURE block in a file, this
200
* function takes a number of parameters that act as constraints to
201
* the search. The PICTURE block with the largest area matching all
202
* the constraints will be returned, or \a *picture will be set to
203
* \c NULL if there was no such block.
205
* \param filename The path to the FLAC file to read.
206
* \param picture The address where the returned pointer will be
207
* stored. The \a picture object must be deleted by
208
* the caller using FLAC__metadata_object_delete().
209
* \param type The desired picture type. Use \c -1 to mean
211
* \param mime_type The desired MIME type, e.g. "image/jpeg". The
212
* string will be matched exactly. Use \c NULL to
213
* mean "any MIME type".
214
* \param description The desired description. The string will be
215
* matched exactly. Use \c NULL to mean "any
217
* \param max_width The maximum width in pixels desired. Use
218
* \c (unsigned)(-1) to mean "any width".
219
* \param max_height The maximum height in pixels desired. Use
220
* \c (unsigned)(-1) to mean "any height".
221
* \param max_depth The maximum color depth in bits-per-pixel desired.
222
* Use \c (unsigned)(-1) to mean "any depth".
223
* \param max_colors The maximum number of colors desired. Use
224
* \c (unsigned)(-1) to mean "any number of colors".
226
* \code filename != NULL \endcode
227
* \code picture != NULL \endcode
229
* \c true if a valid PICTURE block was read from \a filename,
230
* and \a *picture will be set to the address of the metadata
231
* structure. Returns \c false if there was a memory allocation
232
* error, a file decoder error, or the file contained no PICTURE
233
* block, and \a *picture will be set to \c NULL.
235
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, unsigned max_width, unsigned max_height, unsigned max_depth, unsigned max_colors);
521
586
* all metadata is read into memory, operated on in memory, and then written
522
587
* to file, which is more efficient than level 1 when editing multiple blocks.
589
* Currently Ogg FLAC is supported for read only, via
590
* FLAC__metadata_chain_read_ogg() but a subsequent
591
* FLAC__metadata_chain_write() will fail.
524
593
* The general usage of this interface is:
526
595
* - Create a new chain using FLAC__metadata_chain_new(). A chain is a
527
596
* linked list of FLAC metadata blocks.
528
597
* - Read all metadata into the the chain from a FLAC file using
529
* FLAC__metadata_chain_read() and check the status.
598
* FLAC__metadata_chain_read() or FLAC__metadata_chain_read_ogg() and
530
600
* - Optionally, consolidate the padding using
531
601
* FLAC__metadata_chain_merge_padding() or
532
602
* FLAC__metadata_chain_sort_padding().
621
691
FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH,
622
692
/**< FLAC__metadata_chain_write() was called on a chain read by
623
* FLAC__metadata_chain_read_with_callbacks(), or
624
* FLAC__metadata_chain_write_with_callbacks() or
625
* FLAC__metadata_chain_write_with_callbacks_and_tempfile() was
626
* called on a chain read by FLAC__metadata_chain_read(). Matching
627
* read/write methods must always be used. */
693
* FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(),
695
* FLAC__metadata_chain_write_with_callbacks()/FLAC__metadata_chain_write_with_callbacks_and_tempfile()
696
* was called on a chain read by
697
* FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg().
698
* Matching read/write methods must always be used. */
629
700
FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL
630
701
/**< FLAC__metadata_chain_write_with_callbacks() was called when the
689
760
FLAC_API FLAC__bool FLAC__metadata_chain_read(FLAC__Metadata_Chain *chain, const char *filename);
762
/*@@@@ add to unit tests*/
763
/** Read all metadata from an Ogg FLAC file into the chain.
765
* \note Ogg FLAC metadata data writing is not supported yet and
766
* FLAC__metadata_chain_write() will fail.
768
* \param chain A pointer to an existing chain.
769
* \param filename The path to the Ogg FLAC file to read.
771
* \code chain != NULL \endcode
772
* \code filename != NULL \endcode
774
* \c true if a valid list of metadata blocks was read from
775
* \a filename, else \c false. On failure, check the status with
776
* FLAC__metadata_chain_status().
778
FLAC_API FLAC__bool FLAC__metadata_chain_read_ogg(FLAC__Metadata_Chain *chain, const char *filename);
691
780
/** Read all metadata from a FLAC stream into the chain via I/O callbacks.
693
782
* The \a handle need only be open for reading, but must be seekable.
711
800
FLAC_API FLAC__bool FLAC__metadata_chain_read_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks);
802
/*@@@@ add to unit tests*/
803
/** Read all metadata from an Ogg FLAC stream into the chain via I/O callbacks.
805
* The \a handle need only be open for reading, but must be seekable.
806
* The equivalent minimum stdio fopen() file mode is \c "r" (or \c "rb"
809
* \note Ogg FLAC metadata data writing is not supported yet and
810
* FLAC__metadata_chain_write() will fail.
812
* \param chain A pointer to an existing chain.
813
* \param handle The I/O handle of the Ogg FLAC stream to read. The
814
* handle will NOT be closed after the metadata is read;
815
* that is the duty of the caller.
817
* A set of callbacks to use for I/O. The mandatory
818
* callbacks are \a read, \a seek, and \a tell.
820
* \code chain != NULL \endcode
822
* \c true if a valid list of metadata blocks was read from
823
* \a handle, else \c false. On failure, check the status with
824
* FLAC__metadata_chain_status().
826
FLAC_API FLAC__bool FLAC__metadata_chain_read_ogg_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks);
713
828
/** Checks if writing the given chain would require the use of a
714
829
* temporary file, or if it could be written in place.
1320
1442
* \code object != NULL \endcode
1321
1443
* \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
1444
* \code total_samples > 0 \endcode
1322
1445
* \retval FLAC__bool
1323
1446
* \c false if memory allocation fails, else \c true.
1325
1448
FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points(FLAC__StreamMetadata *object, unsigned num, FLAC__uint64 total_samples);
1450
/** Append a set of evenly-spaced seek point templates to the end of a
1454
* As with the other ..._seektable_template_... functions, you should
1455
* call FLAC__metadata_object_seektable_template_sort() when finished
1456
* to make the seek table legal.
1458
* \param object A pointer to an existing SEEKTABLE object.
1459
* \param samples The number of samples apart to space the placeholder
1460
* points. The first point will be at sample \c 0, the
1461
* second at sample \a samples, then 2*\a samples, and
1462
* so on. As long as \a samples and \a total_samples
1463
* are greater than \c 0, there will always be at least
1464
* one seekpoint at sample \c 0.
1465
* \param total_samples The total number of samples to be encoded;
1466
* the seekpoints will be spaced
1467
* \a samples samples apart.
1469
* \code object != NULL \endcode
1470
* \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
1471
* \code samples > 0 \endcode
1472
* \code total_samples > 0 \endcode
1473
* \retval FLAC__bool
1474
* \c false if memory allocation fails, else \c true.
1476
FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(FLAC__StreamMetadata *object, unsigned samples, FLAC__uint64 total_samples);
1327
1478
/** Sort a seek table's seek points according to the format specification,
1328
1479
* removing duplicates.
1850
2001
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_is_legal(const FLAC__StreamMetadata *object, FLAC__bool check_cd_da_subset, const char **violation);
2003
/* @@@@ add to unit tests */
2004
/** Calculate and return the CDDB/freedb ID for a cue sheet. The function
2005
* assumes the cue sheet corresponds to a CD; the result is undefined
2006
* if the cuesheet's is_cd bit is not set.
2008
* \param object A pointer to an existing CUESHEET object.
2010
* \code object != NULL \endcode
2011
* \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
2012
* \retval FLAC__uint32
2013
* The unsigned integer representation of the CDDB/freedb ID
2015
FLAC_API FLAC__uint32 FLAC__metadata_object_cuesheet_calculate_cddb_id(const FLAC__StreamMetadata *object);
2017
/** Sets the MIME type of a PICTURE block.
2019
* If \a copy is \c true, a copy of the string is stored; otherwise, the object
2020
* takes ownership of the pointer. The existing string will be freed if this
2021
* function is successful, otherwise the original string will remain if \a copy
2022
* is \c true and malloc() fails.
2024
* \note It is safe to pass a const pointer to \a mime_type if \a copy is \c true.
2026
* \param object A pointer to an existing PICTURE object.
2027
* \param mime_type A pointer to the MIME type string. The string must be
2028
* ASCII characters 0x20-0x7e, NUL-terminated. No validation
2030
* \param copy See above.
2032
* \code object != NULL \endcode
2033
* \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode
2034
* \code (mime_type != NULL) \endcode
2035
* \retval FLAC__bool
2036
* \c false if \a copy is \c true and malloc() fails, else \c true.
2038
FLAC_API FLAC__bool FLAC__metadata_object_picture_set_mime_type(FLAC__StreamMetadata *object, char *mime_type, FLAC__bool copy);
2040
/** Sets the description of a PICTURE block.
2042
* If \a copy is \c true, a copy of the string is stored; otherwise, the object
2043
* takes ownership of the pointer. The existing string will be freed if this
2044
* function is successful, otherwise the original string will remain if \a copy
2045
* is \c true and malloc() fails.
2047
* \note It is safe to pass a const pointer to \a description if \a copy is \c true.
2049
* \param object A pointer to an existing PICTURE object.
2050
* \param description A pointer to the description string. The string must be
2051
* valid UTF-8, NUL-terminated. No validation is done.
2052
* \param copy See above.
2054
* \code object != NULL \endcode
2055
* \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode
2056
* \code (description != NULL) \endcode
2057
* \retval FLAC__bool
2058
* \c false if \a copy is \c true and malloc() fails, else \c true.
2060
FLAC_API FLAC__bool FLAC__metadata_object_picture_set_description(FLAC__StreamMetadata *object, FLAC__byte *description, FLAC__bool copy);
2062
/** Sets the picture data of a PICTURE block.
2064
* If \a copy is \c true, a copy of the data is stored; otherwise, the object
2065
* takes ownership of the pointer. Also sets the \a data_length field of the
2066
* metadata object to what is passed in as the \a length parameter. The
2067
* existing data will be freed if this function is successful, otherwise the
2068
* original data and data_length will remain if \a copy is \c true and
2071
* \note It is safe to pass a const pointer to \a data if \a copy is \c true.
2073
* \param object A pointer to an existing PICTURE object.
2074
* \param data A pointer to the data to set.
2075
* \param length The length of \a data in bytes.
2076
* \param copy See above.
2078
* \code object != NULL \endcode
2079
* \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode
2080
* \code (data != NULL && length > 0) ||
2081
* (data == NULL && length == 0 && copy == false) \endcode
2082
* \retval FLAC__bool
2083
* \c false if \a copy is \c true and malloc() fails, else \c true.
2085
FLAC_API FLAC__bool FLAC__metadata_object_picture_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, FLAC__uint32 length, FLAC__bool copy);
2087
/** Check a PICTURE block to see if it conforms to the FLAC specification.
2088
* See the format specification for limits on the contents of the
2091
* \param object A pointer to existing PICTURE block to be checked.
2092
* \param violation Address of a pointer to a string. If there is a
2093
* violation, a pointer to a string explanation of the
2094
* violation will be returned here. \a violation may be
2095
* \c NULL if you don't need the returned string. Do not
2096
* free the returned string; it will always point to static
2099
* \code object != NULL \endcode
2100
* \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode
2101
* \retval FLAC__bool
2102
* \c false if PICTURE block is illegal, else \c true.
2104
FLAC_API FLAC__bool FLAC__metadata_object_picture_is_legal(const FLAC__StreamMetadata *object, const char **violation);
1854
2108
#ifdef __cplusplus