1 /* libOggFLAC - Free Lossless Audio Codec + Ogg library
2 * Copyright (C) 2002,2003,2004,2005 Josh Coalson
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * - Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * - Neither the name of the Xiph.org Foundation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #ifndef OggFLAC__SEEKABLE_STREAM_ENCODER_H
33 #define OggFLAC__SEEKABLE_STREAM_ENCODER_H
37 #include "FLAC/stream_encoder.h"
38 #include "FLAC/seekable_stream_encoder.h"
45 /** \file include/OggFLAC/seekable_stream_encoder.h
48 * This module contains the functions which implement the seekable
51 * See the detailed documentation in the
52 * \link oggflac_seekable_stream_encoder seekable stream encoder \endlink module.
55 /** \defgroup oggflac_seekable_stream_encoder OggFLAC/seekable_stream_encoder.h: seekable stream encoder interface
56 * \ingroup oggflac_encoder
59 * This module contains the functions which implement the seekable
60 * stream encoder. The Ogg seekable stream encoder is derived
61 * from the FLAC seekable stream encoder.
63 * The interface here is nearly identical to FLAC's seekable stream
64 * encoder, including the callbacks, with the addition of a new required
65 * read callback (needed when writing back STREAMINFO after encoding) and
66 * OggFLAC__seekable_stream_encoder_set_serial_number(). See the
67 * \link flac_seekable_stream_encoder FLAC seekable stream encoder module \endlink
68 * for full documentation.
74 /** State values for an OggFLAC__SeekableStreamEncoder
76 * The encoder's state can be obtained by calling OggFLAC__stream_encoder_get_state().
80 OggFLAC__SEEKABLE_STREAM_ENCODER_OK = 0,
81 /**< The encoder is in the normal OK state. */
83 OggFLAC__SEEKABLE_STREAM_ENCODER_OGG_ERROR,
84 /**< An error occurred in the underlying Ogg layer. */
86 OggFLAC__SEEKABLE_STREAM_ENCODER_FLAC_STREAM_ENCODER_ERROR,
87 /**< An error occurred in the underlying FLAC stream encoder;
88 * check OggFLAC__seekable_stream_encoder_get_FLAC_stream_encoder_state().
91 OggFLAC__SEEKABLE_STREAM_ENCODER_MEMORY_ALLOCATION_ERROR,
92 /**< Memory allocation failed. */
94 OggFLAC__SEEKABLE_STREAM_ENCODER_WRITE_ERROR,
95 /**< The write callback returned an error. */
97 OggFLAC__SEEKABLE_STREAM_ENCODER_READ_ERROR,
98 /**< The read callback returned an error. */
100 OggFLAC__SEEKABLE_STREAM_ENCODER_SEEK_ERROR,
101 /**< The seek callback returned an error. */
103 OggFLAC__SEEKABLE_STREAM_ENCODER_TELL_ERROR,
104 /**< The tell callback returned an error. */
106 OggFLAC__SEEKABLE_STREAM_ENCODER_ALREADY_INITIALIZED,
107 /**< OggFLAC__seekable_stream_encoder_init() was called when the encoder was
108 * already initialized, usually because
109 * OggFLAC__seekable_stream_encoder_finish() was not called.
112 OggFLAC__SEEKABLE_STREAM_ENCODER_INVALID_CALLBACK,
113 /**< OggFLAC__seekable_stream_encoder_init() was called without all
114 * callbacks being set.
117 OggFLAC__SEEKABLE_STREAM_ENCODER_INVALID_SEEKTABLE,
118 /**< An invalid seek table was passed is the metadata to
119 * OggFLAC__seekable_stream_encoder_set_metadata().
122 OggFLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED
123 /**< The encoder is in the uninitialized state. */
125 } OggFLAC__SeekableStreamEncoderState;
127 /** Maps an OggFLAC__StreamEncoderState to a C string.
129 * Using an OggFLAC__StreamEncoderState as the index to this array
130 * will give the string equivalent. The contents should not be modified.
132 extern OggFLAC_API const char * const OggFLAC__SeekableStreamEncoderStateString[];
135 /** Return values for the OggFLAC__SeekableStreamEncoder read callback.
139 OggFLAC__SEEKABLE_STREAM_ENCODER_READ_STATUS_CONTINUE,
140 /**< The read was OK and decoding can continue. */
142 OggFLAC__SEEKABLE_STREAM_ENCODER_READ_STATUS_END_OF_STREAM,
143 /**< The read was attempted at the end of the stream. */
145 OggFLAC__SEEKABLE_STREAM_ENCODER_READ_STATUS_ABORT
146 /**< An unrecoverable error occurred. */
148 } OggFLAC__SeekableStreamEncoderReadStatus;
150 /** Maps a OggFLAC__SeekableStreamEncoderReadStatus to a C string.
152 * Using a OggFLAC__SeekableStreamEncoderReadStatus as the index to this array
153 * will give the string equivalent. The contents should not be modified.
155 extern OggFLAC_API const char * const OggFLAC__SeekableStreamEncoderReadStatusString[];
158 /***********************************************************************
160 * class OggFLAC__StreamEncoder
162 ***********************************************************************/
164 struct OggFLAC__SeekableStreamEncoderProtected;
165 struct OggFLAC__SeekableStreamEncoderPrivate;
166 /** The opaque structure definition for the seekable stream encoder type.
167 * See the \link oggflac_seekable_stream_encoder seekable stream encoder module \endlink
168 * for a detailed description.
171 struct OggFLAC__SeekableStreamEncoderProtected *protected_; /* avoid the C++ keyword 'protected' */
172 struct OggFLAC__SeekableStreamEncoderPrivate *private_; /* avoid the C++ keyword 'private' */
173 } OggFLAC__SeekableStreamEncoder;
175 /** Signature for the read callback.
176 * See OggFLAC__seekable_stream_encoder_set_read_callback() for more info.
178 * \param encoder The encoder instance calling the callback.
179 * \param buffer A pointer to a location for the callee to store
180 * data to be encoded.
181 * \param bytes A pointer to the size of the buffer. On entry
182 * to the callback, it contains the maximum number
183 * of bytes that may be stored in \a buffer. The
184 * callee must set it to the actual number of bytes
185 * stored (0 in case of error or end-of-stream) before
187 * \param client_data The callee's client data set through
188 * OggFLAC__seekable_stream_encoder_set_client_data().
189 * \retval OggFLAC__SeekableStreamEncoderReadStatus
190 * The callee's return status.
192 typedef OggFLAC__SeekableStreamEncoderReadStatus (*OggFLAC__SeekableStreamEncoderReadCallback)(const OggFLAC__SeekableStreamEncoder *encoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
194 /** Signature for the seek callback.
195 * See OggFLAC__seekable_stream_encoder_set_seek_callback()
196 * and FLAC__SeekableStreamEncoderSeekCallback for more info.
198 * \param encoder The encoder instance calling the callback.
199 * \param absolute_byte_offset The offset from the beginning of the stream
201 * \param client_data The callee's client data set through
202 * OggFLAC__seekable_stream_encoder_set_client_data().
203 * \retval FLAC__SeekableStreamEncoderSeekStatus
204 * The callee's return status.
206 typedef FLAC__SeekableStreamEncoderSeekStatus (*OggFLAC__SeekableStreamEncoderSeekCallback)(const OggFLAC__SeekableStreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
208 /** Signature for the tell callback.
209 * See OggFLAC__seekable_stream_encoder_set_tell_callback()
210 * and FLAC__SeekableStreamEncoderTellCallback for more info.
212 * \param encoder The encoder instance calling the callback.
213 * \param absolute_byte_offset The address at which to store the current
214 * position of the output.
215 * \param client_data The callee's client data set through
216 * OggFLAC__seekable_stream_encoder_set_client_data().
217 * \retval FLAC__SeekableStreamEncoderTellStatus
218 * The callee's return status.
220 typedef FLAC__SeekableStreamEncoderTellStatus (*OggFLAC__SeekableStreamEncoderTellCallback)(const OggFLAC__SeekableStreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
222 /** Signature for the write callback.
223 * See OggFLAC__seekable_stream_encoder_set_write_callback()
224 * and FLAC__SeekableStreamEncoderWriteCallback for more info.
226 * \param encoder The encoder instance calling the callback.
227 * \param buffer An array of encoded data of length \a bytes.
228 * \param bytes The byte length of \a buffer.
229 * \param samples The number of samples encoded by \a buffer.
230 * \c 0 has a special meaning; see
231 * OggFLAC__seekable_stream_encoder_set_write_callback().
232 * \param current_frame The number of current frame being encoded.
233 * \param client_data The callee's client data set through
234 * OggFLAC__seekable_stream_encoder_set_client_data().
235 * \retval FLAC__StreamEncoderWriteStatus
236 * The callee's return status.
238 typedef FLAC__StreamEncoderWriteStatus (*OggFLAC__SeekableStreamEncoderWriteCallback)(const OggFLAC__SeekableStreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
241 /***********************************************************************
243 * Class constructor/destructor
245 ***********************************************************************/
247 /** Create a new seekable stream encoder instance. The instance is created with
248 * default settings; see the individual OggFLAC__seekable_stream_encoder_set_*()
249 * functions for each setting's default.
251 * \retval OggFLAC__SeekableStreamEncoder*
252 * \c NULL if there was an error allocating memory, else the new instance.
254 OggFLAC_API OggFLAC__SeekableStreamEncoder *OggFLAC__seekable_stream_encoder_new();
256 /** Free an encoder instance. Deletes the object pointed to by \a encoder.
258 * \param encoder A pointer to an existing encoder.
260 * \code encoder != NULL \endcode
262 OggFLAC_API void OggFLAC__seekable_stream_encoder_delete(OggFLAC__SeekableStreamEncoder *encoder);
265 /***********************************************************************
267 * Public class method prototypes
269 ***********************************************************************/
271 /** Set the serial number for the FLAC stream.
274 * \param encoder An encoder instance to set.
275 * \param serial_number See above.
277 * \code encoder != NULL \endcode
279 * \c false if the encoder is already initialized, else \c true.
281 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_serial_number(OggFLAC__SeekableStreamEncoder *encoder, long serial_number);
283 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_verify()
286 * \param encoder An encoder instance to set.
287 * \param value Flag value (see above).
289 * \code encoder != NULL \endcode
291 * \c false if the encoder is already initialized, else \c true.
293 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_verify(OggFLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
295 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_streamable_subset()
298 * \param encoder An encoder instance to set.
299 * \param value Flag value (see above).
301 * \code encoder != NULL \endcode
303 * \c false if the encoder is already initialized, else \c true.
305 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_streamable_subset(OggFLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
307 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_do_mid_side_stereo()
310 * \param encoder An encoder instance to set.
311 * \param value Flag value (see above).
313 * \code encoder != NULL \endcode
315 * \c false if the encoder is already initialized, else \c true.
317 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_do_mid_side_stereo(OggFLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
319 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_loose_mid_side_stereo()
322 * \param encoder An encoder instance to set.
323 * \param value Flag value (see above).
325 * \code encoder != NULL \endcode
327 * \c false if the encoder is already initialized, else \c true.
329 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_loose_mid_side_stereo(OggFLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
331 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_channels()
334 * \param encoder An encoder instance to set.
335 * \param value See above.
337 * \code encoder != NULL \endcode
339 * \c false if the encoder is already initialized, else \c true.
341 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_channels(OggFLAC__SeekableStreamEncoder *encoder, unsigned value);
343 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_bits_per_sample()
346 * \param encoder An encoder instance to set.
347 * \param value See above.
349 * \code encoder != NULL \endcode
351 * \c false if the encoder is already initialized, else \c true.
353 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_bits_per_sample(OggFLAC__SeekableStreamEncoder *encoder, unsigned value);
355 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_sample_rate()
358 * \param encoder An encoder instance to set.
359 * \param value See above.
361 * \code encoder != NULL \endcode
363 * \c false if the encoder is already initialized, else \c true.
365 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_sample_rate(OggFLAC__SeekableStreamEncoder *encoder, unsigned value);
367 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_blocksize()
370 * \param encoder An encoder instance to set.
371 * \param value See above.
373 * \code encoder != NULL \endcode
375 * \c false if the encoder is already initialized, else \c true.
377 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_blocksize(OggFLAC__SeekableStreamEncoder *encoder, unsigned value);
379 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_apodization()
382 * \param encoder An encoder instance to set.
383 * \param specification See above.
385 * \code encoder != NULL \endcode
386 * \code specification != NULL \endcode
388 * \c false if the encoder is already initialized, else \c true.
390 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_apodization(OggFLAC__SeekableStreamEncoder *encoder, const char *specification);
392 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_max_lpc_order()
395 * \param encoder An encoder instance to set.
396 * \param value See above.
398 * \code encoder != NULL \endcode
400 * \c false if the encoder is already initialized, else \c true.
402 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_max_lpc_order(OggFLAC__SeekableStreamEncoder *encoder, unsigned value);
404 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_qlp_coeff_precision()
407 * \param encoder An encoder instance to set.
408 * \param value See above.
410 * \code encoder != NULL \endcode
412 * \c false if the encoder is already initialized, else \c true.
414 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_qlp_coeff_precision(OggFLAC__SeekableStreamEncoder *encoder, unsigned value);
416 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_qlp_coeff_prec_search()
419 * \param encoder An encoder instance to set.
420 * \param value See above.
422 * \code encoder != NULL \endcode
424 * \c false if the encoder is already initialized, else \c true.
426 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search(OggFLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
428 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_do_escape_coding()
431 * \param encoder An encoder instance to set.
432 * \param value See above.
434 * \code encoder != NULL \endcode
436 * \c false if the encoder is already initialized, else \c true.
438 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_do_escape_coding(OggFLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
440 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_do_exhaustive_model_search()
443 * \param encoder An encoder instance to set.
444 * \param value See above.
446 * \code encoder != NULL \endcode
448 * \c false if the encoder is already initialized, else \c true.
450 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_do_exhaustive_model_search(OggFLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
452 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_min_residual_partition_order()
455 * \param encoder An encoder instance to set.
456 * \param value See above.
458 * \code encoder != NULL \endcode
460 * \c false if the encoder is already initialized, else \c true.
462 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_min_residual_partition_order(OggFLAC__SeekableStreamEncoder *encoder, unsigned value);
464 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_max_residual_partition_order()
467 * \param encoder An encoder instance to set.
468 * \param value See above.
470 * \code encoder != NULL \endcode
472 * \c false if the encoder is already initialized, else \c true.
474 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_max_residual_partition_order(OggFLAC__SeekableStreamEncoder *encoder, unsigned value);
476 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_rice_parameter_search_dist()
479 * \param encoder An encoder instance to set.
480 * \param value See above.
482 * \code encoder != NULL \endcode
484 * \c false if the encoder is already initialized, else \c true.
486 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_rice_parameter_search_dist(OggFLAC__SeekableStreamEncoder *encoder, unsigned value);
488 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_total_samples_estimate()
491 * \param encoder An encoder instance to set.
492 * \param value See above.
494 * \code encoder != NULL \endcode
496 * \c false if the encoder is already initialized, else \c true.
498 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_total_samples_estimate(OggFLAC__SeekableStreamEncoder *encoder, FLAC__uint64 value);
500 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_metadata()
502 * \note The Ogg FLAC mapping requires that the VORBIS_COMMENT block be
503 * the second metadata block of the stream. The encoder already supplies
504 * the STREAMINFO block automatically. If \a metadata does not contain a
505 * VORBIS_COMMENT block, the encoder will supply that too. Otherwise, if
506 * \a metadata does contain a VORBIS_COMMENT block and it is not the
507 * first, this function will reorder \a metadata by moving the
508 * VORBIS_COMMENT block to the front; the relative ordering of the other
509 * blocks will remain as they were.
511 * \note The Ogg FLAC mapping limits the number of metadata blocks per
512 * stream to \c 65535. If \a num_blocks exceeds this the function will
515 * \default \c NULL, 0
516 * \param encoder An encoder instance to set.
517 * \param metadata See above.
518 * \param num_blocks See above.
520 * \code encoder != NULL \endcode
522 * \c false if the encoder is already initialized, or if
523 * \a num_blocks > 65535, else \c true.
525 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_metadata(OggFLAC__SeekableStreamEncoder *encoder, FLAC__StreamMetadata **metadata, unsigned num_blocks);
527 /** Set the read callback.
528 * The supplied function will be called when the encoder needs to read back
529 * encoded data. This happens during the metadata callback, when the encoder
530 * has to read, modify, and rewrite the metadata (e.g. seekpoints) gathered
531 * while encoding. The address of the buffer to be filled is supplied, along
532 * with the number of bytes the buffer can hold. The callback may choose to
533 * supply less data and modify the byte count but must be careful not to
534 * overflow the buffer. The callback then returns a status code chosen from
535 * OggFLAC__SeekableStreamEncoderReadStatus.
538 * The callback is mandatory and must be set before initialization.
541 * \param encoder A encoder instance to set.
542 * \param value See above.
544 * \code encoder != NULL \endcode
545 * \code value != NULL \endcode
547 * \c false if the encoder is already initialized, else \c true.
549 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_read_callback(OggFLAC__SeekableStreamEncoder *encoder, OggFLAC__SeekableStreamEncoderReadCallback value);
551 /** Set the seek callback.
552 * The supplied function will be called when the encoder needs to seek
553 * the output stream. The encoder will pass the absolute byte offset
554 * to seek to, 0 meaning the beginning of the stream.
557 * The callback is mandatory and must be set before initialization.
560 * \param encoder An encoder instance to set.
561 * \param value See above.
563 * \code encoder != NULL \endcode
564 * \code value != NULL \endcode
566 * \c false if the encoder is already initialized, else \c true.
568 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_seek_callback(OggFLAC__SeekableStreamEncoder *encoder, OggFLAC__SeekableStreamEncoderSeekCallback value);
570 /** Set the tell callback.
571 * The supplied function will be called when the encoder needs to know
572 * the current position of the output stream.
575 * The callback is mandatory and must be set before initialization.
578 * \param encoder An encoder instance to set.
579 * \param value See above.
581 * \code encoder != NULL \endcode
582 * \code value != NULL \endcode
584 * \c false if the encoder is already initialized, else \c true.
586 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_tell_callback(OggFLAC__SeekableStreamEncoder *encoder, OggFLAC__SeekableStreamEncoderTellCallback value);
588 /** Set the write callback.
589 * This is inherited from FLAC__StreamEncoder; see
590 * FLAC__stream_encoder_set_write_callback().
593 * Unlike the FLAC seekable stream encoder write callback, the Ogg
594 * seekable stream encoder write callback will be called twice when
595 * writing audio frames; once for the page header, and once for the page
596 * body. When writing the page header, the \a samples argument to the
597 * write callback will be \c 0.
600 * The callback is mandatory and must be set before initialization.
603 * \param encoder An encoder instance to set.
604 * \param value See above.
606 * \code encoder != NULL \endcode
607 * \code value != NULL \endcode
609 * \c false if the encoder is already initialized, else \c true.
611 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_write_callback(OggFLAC__SeekableStreamEncoder *encoder, OggFLAC__SeekableStreamEncoderWriteCallback value);
613 /** Set the client data to be passed back to callbacks.
614 * This value will be supplied to callbacks in their \a client_data
618 * \param encoder An encoder instance to set.
619 * \param value See above.
621 * \code encoder != NULL \endcode
623 * \c false if the encoder is already initialized, else \c true.
625 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_client_data(OggFLAC__SeekableStreamEncoder *encoder, void *value);
627 /** Get the current encoder state.
629 * \param encoder An encoder instance to query.
631 * \code encoder != NULL \endcode
632 * \retval OggFLAC__SeekableStreamEncoderState
633 * The current encoder state.
635 OggFLAC_API OggFLAC__SeekableStreamEncoderState OggFLAC__seekable_stream_encoder_get_state(const OggFLAC__SeekableStreamEncoder *encoder);
637 /** Get the state of the underlying FLAC stream encoder.
638 * Useful when the seekable stream encoder state is
639 * \c OggFLAC__SEEKABLE_STREAM_ENCODER_FLAC_STREAM_ENCODER_ERROR.
641 * \param encoder An encoder instance to query.
643 * \code encoder != NULL \endcode
644 * \retval FLAC__StreamEncoderState
645 * The FLAC stream encoder state.
647 OggFLAC_API FLAC__StreamEncoderState OggFLAC__seekable_stream_encoder_get_FLAC_stream_encoder_state(const OggFLAC__SeekableStreamEncoder *encoder);
649 /** Get the state of the underlying FLAC encoder's verify decoder.
650 * Useful when the seekable stream encoder state is
651 * \c OggFLAC__SEEKABLE_STREAM_ENCODER_FLAC_STREAM_ENCODER_ERROR
652 * and the FLAC stream encoder state is
653 * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
655 * \param encoder An encoder instance to query.
657 * \code encoder != NULL \endcode
658 * \retval FLAC__StreamDecoderState
659 * The FLAC verify decoder state.
661 OggFLAC_API FLAC__StreamDecoderState OggFLAC__seekable_stream_encoder_get_verify_decoder_state(const OggFLAC__SeekableStreamEncoder *encoder);
663 /** Get the current encoder state as a C string.
664 * This version automatically resolves
665 * \c OggFLAC__SEEKABLE_STREAM_ENCODER_FLAC_STREAM_ENCODER_ERROR
666 * by getting the FLAC stream encoder's resolved state.
668 * \param encoder A encoder instance to query.
670 * \code encoder != NULL \endcode
671 * \retval const char *
672 * The encoder state as a C string. Do not modify the contents.
674 OggFLAC_API const char *OggFLAC__seekable_stream_encoder_get_resolved_state_string(const OggFLAC__SeekableStreamEncoder *encoder);
676 /** Get relevant values about the nature of a verify decoder error.
677 * Inherited from FLAC__stream_encoder_get_verify_decoder_error_stats().
678 * Useful when the seekable stream encoder state is
679 * \c OggFLAC__SEEKABLE_STREAM_ENCODER_FLAC_STREAM_ENCODER_ERROR
680 * and the FLAC stream encoder state is
681 * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
683 * \param encoder An encoder instance to query.
684 * \param absolute_sample The absolute sample number of the mismatch.
685 * \param frame_number The number of the frame in which the mismatch occurred.
686 * \param channel The channel in which the mismatch occurred.
687 * \param sample The number of the sample (relative to the frame) in
688 * which the mismatch occurred.
689 * \param expected The expected value for the sample in question.
690 * \param got The actual value returned by the decoder.
692 * \code encoder != NULL \endcode
693 * \code absolute_sample != NULL \endcode
694 * \code frame_number != NULL \endcode
695 * \code channel != NULL \endcode
696 * \code sample != NULL \endcode
697 * \code expected != NULL \endcode
699 OggFLAC_API void OggFLAC__seekable_stream_encoder_get_verify_decoder_error_stats(const OggFLAC__SeekableStreamEncoder *encoder, FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
701 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_verify()
703 * \param encoder An encoder instance to query.
705 * \code encoder != NULL \endcode
707 * See OggFLAC__seekable_stream_encoder_set_verify().
709 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_get_verify(const OggFLAC__SeekableStreamEncoder *encoder);
711 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_streamable_subset()
713 * \param encoder An encoder instance to query.
715 * \code encoder != NULL \endcode
717 * See OggFLAC__seekable_stream_encoder_set_streamable_subset().
719 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_get_streamable_subset(const OggFLAC__SeekableStreamEncoder *encoder);
721 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_do_mid_side_stereo()
723 * \param encoder An encoder instance to query.
725 * \code encoder != NULL \endcode
727 * See OggFLAC__seekable_stream_encoder_get_do_mid_side_stereo().
729 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_get_do_mid_side_stereo(const OggFLAC__SeekableStreamEncoder *encoder);
731 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_loose_mid_side_stereo()
733 * \param encoder An encoder instance to query.
735 * \code encoder != NULL \endcode
737 * See OggFLAC__seekable_stream_encoder_set_loose_mid_side_stereo().
739 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_get_loose_mid_side_stereo(const OggFLAC__SeekableStreamEncoder *encoder);
741 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_channels()
743 * \param encoder An encoder instance to query.
745 * \code encoder != NULL \endcode
747 * See OggFLAC__seekable_stream_encoder_set_channels().
749 OggFLAC_API unsigned OggFLAC__seekable_stream_encoder_get_channels(const OggFLAC__SeekableStreamEncoder *encoder);
751 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_bits_per_sample()
753 * \param encoder An encoder instance to query.
755 * \code encoder != NULL \endcode
757 * See OggFLAC__seekable_stream_encoder_set_bits_per_sample().
759 OggFLAC_API unsigned OggFLAC__seekable_stream_encoder_get_bits_per_sample(const OggFLAC__SeekableStreamEncoder *encoder);
761 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_sample_rate()
763 * \param encoder An encoder instance to query.
765 * \code encoder != NULL \endcode
767 * See OggFLAC__seekable_stream_encoder_set_sample_rate().
769 OggFLAC_API unsigned OggFLAC__seekable_stream_encoder_get_sample_rate(const OggFLAC__SeekableStreamEncoder *encoder);
771 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_blocksize()
773 * \param encoder An encoder instance to query.
775 * \code encoder != NULL \endcode
777 * See OggFLAC__seekable_stream_encoder_set_blocksize().
779 OggFLAC_API unsigned OggFLAC__seekable_stream_encoder_get_blocksize(const OggFLAC__SeekableStreamEncoder *encoder);
781 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_max_lpc_order()
783 * \param encoder An encoder instance to query.
785 * \code encoder != NULL \endcode
787 * See OggFLAC__seekable_stream_encoder_set_max_lpc_order().
789 OggFLAC_API unsigned OggFLAC__seekable_stream_encoder_get_max_lpc_order(const OggFLAC__SeekableStreamEncoder *encoder);
791 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_qlp_coeff_precision()
793 * \param encoder An encoder instance to query.
795 * \code encoder != NULL \endcode
797 * See OggFLAC__seekable_stream_encoder_set_qlp_coeff_precision().
799 OggFLAC_API unsigned OggFLAC__seekable_stream_encoder_get_qlp_coeff_precision(const OggFLAC__SeekableStreamEncoder *encoder);
801 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_do_qlp_coeff_prec_search()
803 * \param encoder An encoder instance to query.
805 * \code encoder != NULL \endcode
807 * See OggFLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search().
809 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search(const OggFLAC__SeekableStreamEncoder *encoder);
811 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_do_escape_coding()
813 * \param encoder An encoder instance to query.
815 * \code encoder != NULL \endcode
817 * See OggFLAC__seekable_stream_encoder_set_do_escape_coding().
819 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_get_do_escape_coding(const OggFLAC__SeekableStreamEncoder *encoder);
821 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_do_exhaustive_model_search()
823 * \param encoder An encoder instance to query.
825 * \code encoder != NULL \endcode
827 * See OggFLAC__seekable_stream_encoder_set_do_exhaustive_model_search().
829 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_get_do_exhaustive_model_search(const OggFLAC__SeekableStreamEncoder *encoder);
831 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_min_residual_partition_order()
833 * \param encoder An encoder instance to query.
835 * \code encoder != NULL \endcode
837 * See OggFLAC__seekable_stream_encoder_set_min_residual_partition_order().
839 OggFLAC_API unsigned OggFLAC__seekable_stream_encoder_get_min_residual_partition_order(const OggFLAC__SeekableStreamEncoder *encoder);
841 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_man_residual_partition_order()
843 * \param encoder An encoder instance to query.
845 * \code encoder != NULL \endcode
847 * See OggFLAC__seekable_stream_encoder_set_max_residual_partition_order().
849 OggFLAC_API unsigned OggFLAC__seekable_stream_encoder_get_max_residual_partition_order(const OggFLAC__SeekableStreamEncoder *encoder);
851 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_rice_parameter_search_dist()
853 * \param encoder An encoder instance to query.
855 * \code encoder != NULL \endcode
857 * See OggFLAC__seekable_stream_encoder_set_rice_parameter_search_dist().
859 OggFLAC_API unsigned OggFLAC__seekable_stream_encoder_get_rice_parameter_search_dist(const OggFLAC__SeekableStreamEncoder *encoder);
861 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_total_samples_estimate()
863 * \param encoder An encoder instance to set.
865 * \code encoder != NULL \endcode
866 * \retval FLAC__uint64
867 * See OggFLAC__seekable_stream_encoder_get_total_samples_estimate().
869 OggFLAC_API FLAC__uint64 OggFLAC__seekable_stream_encoder_get_total_samples_estimate(const OggFLAC__SeekableStreamEncoder *encoder);
871 /** Initialize the encoder instance.
872 * Should be called after OggFLAC__seekable_stream_encoder_new() and
873 * OggFLAC__seekable_stream_encoder_set_*() but before OggFLAC__seekable_stream_encoder_process()
874 * or OggFLAC__seekable_stream_encoder_process_interleaved(). Will set and return
875 * the encoder state, which will be OggFLAC__SEEKABLE_STREAM_ENCODER_OK if
876 * initialization succeeded.
878 * The call to OggFLAC__seekable_stream_encoder_init() currently will also immediately
879 * call the write callback several times, once with the \c fLaC signature,
880 * and once for each encoded metadata block.
882 * \param encoder An uninitialized encoder instance.
884 * \code encoder != NULL \endcode
885 * \retval OggFLAC__SeekableStreamEncoderState
886 * \c OggFLAC__SEEKABLE_STREAM_ENCODER_OK if initialization was successful; see
887 * OggFLAC__SeekableStreamEncoderState for the meanings of other return values.
889 OggFLAC_API OggFLAC__SeekableStreamEncoderState OggFLAC__seekable_stream_encoder_init(OggFLAC__SeekableStreamEncoder *encoder);
891 /** Finish the encoding process.
892 * Flushes the encoding buffer, releases resources, resets the encoder
893 * settings to their defaults, and returns the encoder state to
894 * OggFLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED. Note that this can generate
895 * one or more write callbacks before returning.
897 * In the event of a prematurely-terminated encode, it is not strictly
898 * necessary to call this immediately before OggFLAC__seekable_stream_encoder_delete()
899 * but it is good practice to match every OggFLAC__seekable_stream_encoder_init()
900 * with an OggFLAC__seekable_stream_encoder_finish().
902 * \param encoder An uninitialized encoder instance.
904 * \code encoder != NULL \endcode
906 OggFLAC_API void OggFLAC__seekable_stream_encoder_finish(OggFLAC__SeekableStreamEncoder *encoder);
908 /** Submit data for encoding.
909 * This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_process().
911 * \param encoder An initialized encoder instance in the OK state.
912 * \param buffer An array of pointers to each channel's signal.
913 * \param samples The number of samples in one channel.
915 * \code encoder != NULL \endcode
916 * \code OggFLAC__seekable_stream_encoder_get_state(encoder) == OggFLAC__SEEKABLE_STREAM_ENCODER_OK \endcode
918 * \c true if successful, else \c false; in this case, check the
919 * encoder state with OggFLAC__seekable_stream_encoder_get_state() to see what
922 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_process(OggFLAC__SeekableStreamEncoder *encoder, const FLAC__int32 * const buffer[], unsigned samples);
924 /** Submit data for encoding.
925 * This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_process_interleaved().
927 * \param encoder An initialized encoder instance in the OK state.
928 * \param buffer An array of channel-interleaved data (see above).
929 * \param samples The number of samples in one channel, the same as for
930 * OggFLAC__seekable_stream_encoder_process(). For example, if
931 * encoding two channels, \c 1000 \a samples corresponds
932 * to a \a buffer of 2000 values.
934 * \code encoder != NULL \endcode
935 * \code OggFLAC__seekable_stream_encoder_get_state(encoder) == OggFLAC__SEEKABLE_STREAM_ENCODER_OK \endcode
937 * \c true if successful, else \c false; in this case, check the
938 * encoder state with OggFLAC__seekable_stream_encoder_get_state() to see what
941 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_process_interleaved(OggFLAC__SeekableStreamEncoder *encoder, const FLAC__int32 buffer[], unsigned samples);