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