1 /* libOggFLAC - Free Lossless Audio Codec + Ogg library
2 * Copyright (C) 2002,2003 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 callback(@@@@@@new read callback and why@@@), with the addition of
65 * OggFLAC__seekable_stream_encoder_set_serial_number(). See the
66 * \link flac_seekable_stream_encoder FLAC seekable stream encoder module \endlink
67 * for full documentation.
73 /** State values for an OggFLAC__SeekableStreamEncoder
75 * The encoder's state can be obtained by calling OggFLAC__stream_encoder_get_state().
79 OggFLAC__SEEKABLE_STREAM_ENCODER_OK = 0,
80 /**< The encoder is in the normal OK state. */
82 OggFLAC__SEEKABLE_STREAM_ENCODER_OGG_ERROR,
83 /**< An error occurred in the underlying Ogg layer. */
85 OggFLAC__SEEKABLE_STREAM_ENCODER_FLAC_STREAM_ENCODER_ERROR,
86 /**< An error occurred in the underlying FLAC stream encoder;
87 * check OggFLAC__seekable_stream_encoder_get_FLAC_stream_encoder_state().
90 OggFLAC__SEEKABLE_STREAM_ENCODER_MEMORY_ALLOCATION_ERROR,
91 /**< Memory allocation failed. */
93 OggFLAC__SEEKABLE_STREAM_ENCODER_WRITE_ERROR,
94 /**< The write callback returned an error. */
96 OggFLAC__SEEKABLE_STREAM_ENCODER_READ_ERROR,
97 /**< The read callback returned an error. */
99 OggFLAC__SEEKABLE_STREAM_ENCODER_SEEK_ERROR,
100 /**< The seek callback returned an error. */
102 OggFLAC__SEEKABLE_STREAM_ENCODER_TELL_ERROR,
103 /**< The tell callback returned an error. */
105 OggFLAC__SEEKABLE_STREAM_ENCODER_ALREADY_INITIALIZED,
106 /**< OggFLAC__seekable_stream_encoder_init() was called when the encoder was
107 * already initialized, usually because
108 * OggFLAC__seekable_stream_encoder_finish() was not called.
111 OggFLAC__SEEKABLE_STREAM_ENCODER_INVALID_CALLBACK,
112 /**< OggFLAC__seekable_stream_encoder_init() was called without all
113 * callbacks being set.
116 OggFLAC__SEEKABLE_STREAM_ENCODER_INVALID_SEEKTABLE,
117 /**< An invalid seek table was passed is the metadata to
118 * OggFLAC__seekable_stream_encoder_set_metadata().
121 OggFLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED
122 /**< The encoder is in the uninitialized state. */
124 } OggFLAC__SeekableStreamEncoderState;
126 /** Maps an OggFLAC__StreamEncoderState to a C string.
128 * Using an OggFLAC__StreamEncoderState as the index to this array
129 * will give the string equivalent. The contents should not be modified.
131 extern OggFLAC_API const char * const OggFLAC__SeekableStreamEncoderStateString[];
134 /** Return values for the OggFLAC__SeekableStreamEncoder read callback.
138 OggFLAC__SEEKABLE_STREAM_ENCODER_READ_STATUS_CONTINUE,
139 /**< The read was OK and decoding can continue. */
141 OggFLAC__SEEKABLE_STREAM_ENCODER_READ_STATUS_END_OF_STREAM,
142 /**< The read was attempted at the end of the stream. */
144 OggFLAC__SEEKABLE_STREAM_ENCODER_READ_STATUS_ABORT
145 /**< An unrecoverable error occurred. */
147 } OggFLAC__SeekableStreamEncoderReadStatus;
149 /** Maps a OggFLAC__SeekableStreamEncoderReadStatus to a C string.
151 * Using a OggFLAC__SeekableStreamEncoderReadStatus as the index to this array
152 * will give the string equivalent. The contents should not be modified.
154 extern OggFLAC_API const char * const OggFLAC__SeekableStreamEncoderReadStatusString[];
157 /***********************************************************************
159 * class OggFLAC__StreamEncoder
161 ***********************************************************************/
163 struct OggFLAC__SeekableStreamEncoderProtected;
164 struct OggFLAC__SeekableStreamEncoderPrivate;
165 /** The opaque structure definition for the seekable stream encoder type.
166 * See the \link oggflac_seekable_stream_encoder seekable stream encoder module \endlink
167 * for a detailed description.
170 struct OggFLAC__SeekableStreamEncoderProtected *protected_; /* avoid the C++ keyword 'protected' */
171 struct OggFLAC__SeekableStreamEncoderPrivate *private_; /* avoid the C++ keyword 'private' */
172 } OggFLAC__SeekableStreamEncoder;
174 /** Signature for the read callback.
175 * See OggFLAC__seekable_stream_encoder_set_read_callback() for more info.
177 * \param encoder The encoder instance calling the callback.
178 * \param buffer A pointer to a location for the callee to store
179 * data to be encoded.
180 * \param bytes A pointer to the size of the buffer. On entry
181 * to the callback, it contains the maximum number
182 * of bytes that may be stored in \a buffer. The
183 * callee must set it to the actual number of bytes
184 * stored (0 in case of error or end-of-stream) before
186 * \param client_data The callee's client data set through
187 * OggFLAC__seekable_stream_encoder_set_client_data().
188 * \retval OggFLAC__SeekableStreamEncoderReadStatus
189 * The callee's return status.
191 typedef OggFLAC__SeekableStreamEncoderReadStatus (*OggFLAC__SeekableStreamEncoderReadCallback)(const OggFLAC__SeekableStreamEncoder *encoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
193 /** Signature for the seek callback.
194 * See OggFLAC__seekable_stream_encoder_set_seek_callback()
195 * and FLAC__SeekableStreamEncoderSeekCallback for more info.
197 * \param encoder The encoder instance calling the callback.
198 * \param absolute_byte_offset The offset from the beginning of the stream
200 * \param client_data The callee's client data set through
201 * OggFLAC__seekable_stream_encoder_set_client_data().
202 * \retval FLAC__SeekableStreamEncoderSeekStatus
203 * The callee's return status.
205 typedef FLAC__SeekableStreamEncoderSeekStatus (*OggFLAC__SeekableStreamEncoderSeekCallback)(const OggFLAC__SeekableStreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
207 /** Signature for the tell callback.
208 * See OggFLAC__seekable_stream_encoder_set_tell_callback()
209 * and FLAC__SeekableStreamEncoderTellCallback for more info.
211 * \param encoder The encoder instance calling the callback.
212 * \param absolute_byte_offset The address at which to store the current
213 * position of the output.
214 * \param client_data The callee's client data set through
215 * OggFLAC__seekable_stream_encoder_set_client_data().
216 * \retval FLAC__SeekableStreamEncoderTellStatus
217 * The callee's return status.
219 typedef FLAC__SeekableStreamEncoderTellStatus (*OggFLAC__SeekableStreamEncoderTellCallback)(const OggFLAC__SeekableStreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
221 /** Signature for the write callback.
222 * See OggFLAC__seekable_stream_encoder_set_write_callback()
223 * and FLAC__SeekableStreamEncoderWriteCallback for more info.
225 * \param encoder The encoder instance calling the callback.
226 * \param buffer An array of encoded data of length \a bytes.
227 * \param bytes The byte length of \a buffer.
228 * \param samples The number of samples encoded by \a buffer.
229 * \c 0 has a special meaning; see
230 * OggFLAC__seekable_stream_encoder_set_write_callback().
231 * \param current_frame The number of current frame being encoded.
232 * \param client_data The callee's client data set through
233 * OggFLAC__seekable_stream_encoder_set_client_data().
234 * \retval FLAC__StreamEncoderWriteStatus
235 * The callee's return status.
237 typedef FLAC__StreamEncoderWriteStatus (*OggFLAC__SeekableStreamEncoderWriteCallback)(const OggFLAC__SeekableStreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
240 /***********************************************************************
242 * Class constructor/destructor
244 ***********************************************************************/
246 /** Create a new seekable stream encoder instance. The instance is created with
247 * default settings; see the individual OggFLAC__seekable_stream_encoder_set_*()
248 * functions for each setting's default.
250 * \retval OggFLAC__SeekableStreamEncoder*
251 * \c NULL if there was an error allocating memory, else the new instance.
253 OggFLAC_API OggFLAC__SeekableStreamEncoder *OggFLAC__seekable_stream_encoder_new();
255 /** Free an encoder instance. Deletes the object pointed to by \a encoder.
257 * \param encoder A pointer to an existing encoder.
259 * \code encoder != NULL \endcode
261 OggFLAC_API void OggFLAC__seekable_stream_encoder_delete(OggFLAC__SeekableStreamEncoder *encoder);
264 /***********************************************************************
266 * Public class method prototypes
268 ***********************************************************************/
270 /** Set the serial number for the FLAC stream.
272 * \default \c NULL, 0
273 * \param encoder An encoder instance to set.
274 * \param serial_number See above.
276 * \code encoder != NULL \endcode
278 * \c false if the encoder is already initialized, else \c true.
280 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_serial_number(OggFLAC__SeekableStreamEncoder *encoder, long serial_number);
282 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_verify()
285 * \param encoder An encoder instance to set.
286 * \param value Flag value (see above).
288 * \code encoder != NULL \endcode
290 * \c false if the encoder is already initialized, else \c true.
292 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_verify(OggFLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
294 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_streamable_subset()
297 * \param encoder An encoder instance to set.
298 * \param value Flag value (see above).
300 * \code encoder != NULL \endcode
302 * \c false if the encoder is already initialized, else \c true.
304 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_streamable_subset(OggFLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
306 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_do_mid_side_stereo()
309 * \param encoder An encoder instance to set.
310 * \param value Flag value (see above).
312 * \code encoder != NULL \endcode
314 * \c false if the encoder is already initialized, else \c true.
316 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_do_mid_side_stereo(OggFLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
318 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_loose_mid_side_stereo()
321 * \param encoder An encoder instance to set.
322 * \param value Flag value (see above).
324 * \code encoder != NULL \endcode
326 * \c false if the encoder is already initialized, else \c true.
328 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_loose_mid_side_stereo(OggFLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
330 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_channels()
333 * \param encoder An encoder instance to set.
334 * \param value See above.
336 * \code encoder != NULL \endcode
338 * \c false if the encoder is already initialized, else \c true.
340 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_channels(OggFLAC__SeekableStreamEncoder *encoder, unsigned value);
342 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_bits_per_sample()
345 * \param encoder An encoder instance to set.
346 * \param value See above.
348 * \code encoder != NULL \endcode
350 * \c false if the encoder is already initialized, else \c true.
352 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_bits_per_sample(OggFLAC__SeekableStreamEncoder *encoder, unsigned value);
354 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_sample_rate()
357 * \param encoder An encoder instance to set.
358 * \param value See above.
360 * \code encoder != NULL \endcode
362 * \c false if the encoder is already initialized, else \c true.
364 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_sample_rate(OggFLAC__SeekableStreamEncoder *encoder, unsigned value);
366 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_blocksize()
369 * \param encoder An encoder instance to set.
370 * \param value See above.
372 * \code encoder != NULL \endcode
374 * \c false if the encoder is already initialized, else \c true.
376 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_blocksize(OggFLAC__SeekableStreamEncoder *encoder, unsigned value);
378 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_max_lpc_order()
381 * \param encoder An encoder instance to set.
382 * \param value See above.
384 * \code encoder != NULL \endcode
386 * \c false if the encoder is already initialized, else \c true.
388 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_max_lpc_order(OggFLAC__SeekableStreamEncoder *encoder, unsigned value);
390 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_qlp_coeff_precision()
393 * \param encoder An encoder instance to set.
394 * \param value See above.
396 * \code encoder != NULL \endcode
398 * \c false if the encoder is already initialized, else \c true.
400 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_qlp_coeff_precision(OggFLAC__SeekableStreamEncoder *encoder, unsigned value);
402 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_qlp_coeff_prec_search()
405 * \param encoder An encoder instance to set.
406 * \param value See above.
408 * \code encoder != NULL \endcode
410 * \c false if the encoder is already initialized, else \c true.
412 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search(OggFLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
414 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_do_escape_coding()
417 * \param encoder An encoder instance to set.
418 * \param value See above.
420 * \code encoder != NULL \endcode
422 * \c false if the encoder is already initialized, else \c true.
424 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_do_escape_coding(OggFLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
426 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_do_exhaustive_model_search()
429 * \param encoder An encoder instance to set.
430 * \param value See above.
432 * \code encoder != NULL \endcode
434 * \c false if the encoder is already initialized, else \c true.
436 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_do_exhaustive_model_search(OggFLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
438 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_min_residual_partition_order()
441 * \param encoder An encoder instance to set.
442 * \param value See above.
444 * \code encoder != NULL \endcode
446 * \c false if the encoder is already initialized, else \c true.
448 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_min_residual_partition_order(OggFLAC__SeekableStreamEncoder *encoder, unsigned value);
450 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_max_residual_partition_order()
453 * \param encoder An encoder instance to set.
454 * \param value See above.
456 * \code encoder != NULL \endcode
458 * \c false if the encoder is already initialized, else \c true.
460 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_max_residual_partition_order(OggFLAC__SeekableStreamEncoder *encoder, unsigned value);
462 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_rice_parameter_search_dist()
465 * \param encoder An encoder instance to set.
466 * \param value See above.
468 * \code encoder != NULL \endcode
470 * \c false if the encoder is already initialized, else \c true.
472 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_rice_parameter_search_dist(OggFLAC__SeekableStreamEncoder *encoder, unsigned value);
474 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_total_samples_estimate()
477 * \param encoder An encoder instance to set.
478 * \param value See above.
480 * \code encoder != NULL \endcode
482 * \c false if the encoder is already initialized, else \c true.
484 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_total_samples_estimate(OggFLAC__SeekableStreamEncoder *encoder, FLAC__uint64 value);
486 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_set_metadata()
488 * \default \c NULL, 0
489 * \param encoder An encoder instance to set.
490 * \param metadata See above.
491 * \param num_blocks See above.
493 * \code encoder != NULL \endcode
495 * \c false if the encoder is already initialized, else \c true.
497 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_metadata(OggFLAC__SeekableStreamEncoder *encoder, FLAC__StreamMetadata **metadata, unsigned num_blocks);
499 /** Set the read callback.
500 * The supplied function will be called when the encoder needs to read back
501 * encoded data. This happens during the metadata callback, when the encoder
502 * has to read, modify, and rewrite the metadata (e.g. seekpoints) gathered
503 * while encoding. The address of the buffer to be filled is supplied, along
504 * with the number of bytes the buffer can hold. The callback may choose to
505 * supply less data and modify the byte count but must be careful not to
506 * overflow the buffer. The callback then returns a status code chosen from
507 * OggFLAC__SeekableStreamEncoderReadStatus.
510 * The callback is mandatory and must be set before initialization.
513 * \param encoder A encoder instance to set.
514 * \param value See above.
516 * \code encoder != NULL \endcode
517 * \code value != NULL \endcode
519 * \c false if the encoder is already initialized, else \c true.
521 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_read_callback(OggFLAC__SeekableStreamEncoder *encoder, OggFLAC__SeekableStreamEncoderReadCallback value);
523 /** Set the seek callback.
524 * The supplied function will be called when the encoder needs to seek
525 * the output stream. The encoder will pass the absolute byte offset
526 * to seek to, 0 meaning the beginning of the stream.
529 * The callback is mandatory and must be set before initialization.
532 * \param encoder An encoder instance to set.
533 * \param value See above.
535 * \code encoder != NULL \endcode
536 * \code value != NULL \endcode
538 * \c false if the encoder is already initialized, else \c true.
540 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_seek_callback(OggFLAC__SeekableStreamEncoder *encoder, OggFLAC__SeekableStreamEncoderSeekCallback value);
542 /** Set the tell callback.
543 * The supplied function will be called when the encoder needs to know
544 * the current position of the output stream.
547 * The callback is mandatory and must be set before initialization.
550 * \param encoder An encoder instance to set.
551 * \param value See above.
553 * \code encoder != NULL \endcode
554 * \code value != NULL \endcode
556 * \c false if the encoder is already initialized, else \c true.
558 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_tell_callback(OggFLAC__SeekableStreamEncoder *encoder, OggFLAC__SeekableStreamEncoderTellCallback value);
560 /** Set the write callback.
561 * This is inherited from FLAC__StreamEncoder; see
562 * FLAC__stream_encoder_set_write_callback().
565 * Unlike the FLAC seekable stream encoder write callback, the Ogg
566 * seekable stream encoder write callback will be called twice when
567 * writing audio frames; once for the page header, and once for the page
568 * body. When writing the page header, the \a samples argument to the
569 * write callback will be \c 0.
572 * The callback is mandatory and must be set before initialization.
575 * \param encoder An encoder instance to set.
576 * \param value See above.
578 * \code encoder != NULL \endcode
579 * \code value != NULL \endcode
581 * \c false if the encoder is already initialized, else \c true.
583 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_write_callback(OggFLAC__SeekableStreamEncoder *encoder, OggFLAC__SeekableStreamEncoderWriteCallback value);
585 /** Set the client data to be passed back to callbacks.
586 * This value will be supplied to callbacks in their \a client_data
590 * \param encoder An encoder instance to set.
591 * \param value See above.
593 * \code encoder != NULL \endcode
595 * \c false if the encoder is already initialized, else \c true.
597 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_set_client_data(OggFLAC__SeekableStreamEncoder *encoder, void *value);
599 /** Get the current encoder state.
601 * \param encoder An encoder instance to query.
603 * \code encoder != NULL \endcode
604 * \retval OggFLAC__SeekableStreamEncoderState
605 * The current encoder state.
607 OggFLAC_API OggFLAC__SeekableStreamEncoderState OggFLAC__seekable_stream_encoder_get_state(const OggFLAC__SeekableStreamEncoder *encoder);
609 /** Get the state of the underlying FLAC stream encoder.
610 * Useful when the seekable stream encoder state is
611 * \c OggFLAC__SEEKABLE_STREAM_ENCODER_FLAC_STREAM_ENCODER_ERROR.
613 * \param encoder An encoder instance to query.
615 * \code encoder != NULL \endcode
616 * \retval FLAC__StreamEncoderState
617 * The FLAC stream encoder state.
619 OggFLAC_API FLAC__StreamEncoderState OggFLAC__seekable_stream_encoder_get_FLAC_stream_encoder_state(const OggFLAC__SeekableStreamEncoder *encoder);
621 /** Get the state of the underlying FLAC encoder's verify decoder.
622 * Useful when the seekable stream encoder state is
623 * \c OggFLAC__SEEKABLE_STREAM_ENCODER_FLAC_STREAM_ENCODER_ERROR
624 * and the FLAC stream encoder state is
625 * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
627 * \param encoder An encoder instance to query.
629 * \code encoder != NULL \endcode
630 * \retval FLAC__StreamDecoderState
631 * The FLAC verify decoder state.
633 OggFLAC_API FLAC__StreamDecoderState OggFLAC__seekable_stream_encoder_get_verify_decoder_state(const OggFLAC__SeekableStreamEncoder *encoder);
635 /** Get the current encoder state as a C string.
636 * This version automatically resolves
637 * \c OggFLAC__SEEKABLE_STREAM_ENCODER_FLAC_STREAM_ENCODER_ERROR
638 * by getting the FLAC stream encoder's resolved state.
640 * \param encoder A encoder instance to query.
642 * \code encoder != NULL \endcode
643 * \retval const char *
644 * The encoder state as a C string. Do not modify the contents.
646 OggFLAC_API const char *OggFLAC__seekable_stream_encoder_get_resolved_state_string(const OggFLAC__SeekableStreamEncoder *encoder);
648 /** Get relevant values about the nature of a verify decoder error.
649 * Inherited from FLAC__stream_encoder_get_verify_decoder_error_stats().
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.
656 * \param absolute_sample The absolute sample number of the mismatch.
657 * \param frame_number The number of the frame in which the mismatch occurred.
658 * \param channel The channel in which the mismatch occurred.
659 * \param sample The number of the sample (relative to the frame) in
660 * which the mismatch occurred.
661 * \param expected The expected value for the sample in question.
662 * \param got The actual value returned by the decoder.
664 * \code encoder != NULL \endcode
665 * \code absolute_sample != NULL \endcode
666 * \code frame_number != NULL \endcode
667 * \code channel != NULL \endcode
668 * \code sample != NULL \endcode
669 * \code expected != NULL \endcode
671 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);
673 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_verify()
675 * \param encoder An encoder instance to query.
677 * \code encoder != NULL \endcode
679 * See OggFLAC__seekable_stream_encoder_set_verify().
681 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_get_verify(const OggFLAC__SeekableStreamEncoder *encoder);
683 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_streamable_subset()
685 * \param encoder An encoder instance to query.
687 * \code encoder != NULL \endcode
689 * See OggFLAC__seekable_stream_encoder_set_streamable_subset().
691 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_get_streamable_subset(const OggFLAC__SeekableStreamEncoder *encoder);
693 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_do_mid_side_stereo()
695 * \param encoder An encoder instance to query.
697 * \code encoder != NULL \endcode
699 * See OggFLAC__seekable_stream_encoder_get_do_mid_side_stereo().
701 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_get_do_mid_side_stereo(const OggFLAC__SeekableStreamEncoder *encoder);
703 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_loose_mid_side_stereo()
705 * \param encoder An encoder instance to query.
707 * \code encoder != NULL \endcode
709 * See OggFLAC__seekable_stream_encoder_set_loose_mid_side_stereo().
711 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_get_loose_mid_side_stereo(const OggFLAC__SeekableStreamEncoder *encoder);
713 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_channels()
715 * \param encoder An encoder instance to query.
717 * \code encoder != NULL \endcode
719 * See OggFLAC__seekable_stream_encoder_set_channels().
721 OggFLAC_API unsigned OggFLAC__seekable_stream_encoder_get_channels(const OggFLAC__SeekableStreamEncoder *encoder);
723 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_bits_per_sample()
725 * \param encoder An encoder instance to query.
727 * \code encoder != NULL \endcode
729 * See OggFLAC__seekable_stream_encoder_set_bits_per_sample().
731 OggFLAC_API unsigned OggFLAC__seekable_stream_encoder_get_bits_per_sample(const OggFLAC__SeekableStreamEncoder *encoder);
733 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_sample_rate()
735 * \param encoder An encoder instance to query.
737 * \code encoder != NULL \endcode
739 * See OggFLAC__seekable_stream_encoder_set_sample_rate().
741 OggFLAC_API unsigned OggFLAC__seekable_stream_encoder_get_sample_rate(const OggFLAC__SeekableStreamEncoder *encoder);
743 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_blocksize()
745 * \param encoder An encoder instance to query.
747 * \code encoder != NULL \endcode
749 * See OggFLAC__seekable_stream_encoder_set_blocksize().
751 OggFLAC_API unsigned OggFLAC__seekable_stream_encoder_get_blocksize(const OggFLAC__SeekableStreamEncoder *encoder);
753 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_max_lpc_order()
755 * \param encoder An encoder instance to query.
757 * \code encoder != NULL \endcode
759 * See OggFLAC__seekable_stream_encoder_set_max_lpc_order().
761 OggFLAC_API unsigned OggFLAC__seekable_stream_encoder_get_max_lpc_order(const OggFLAC__SeekableStreamEncoder *encoder);
763 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_qlp_coeff_precision()
765 * \param encoder An encoder instance to query.
767 * \code encoder != NULL \endcode
769 * See OggFLAC__seekable_stream_encoder_set_qlp_coeff_precision().
771 OggFLAC_API unsigned OggFLAC__seekable_stream_encoder_get_qlp_coeff_precision(const OggFLAC__SeekableStreamEncoder *encoder);
773 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_do_qlp_coeff_prec_search()
775 * \param encoder An encoder instance to query.
777 * \code encoder != NULL \endcode
779 * See OggFLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search().
781 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search(const OggFLAC__SeekableStreamEncoder *encoder);
783 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_do_escape_coding()
785 * \param encoder An encoder instance to query.
787 * \code encoder != NULL \endcode
789 * See OggFLAC__seekable_stream_encoder_set_do_escape_coding().
791 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_get_do_escape_coding(const OggFLAC__SeekableStreamEncoder *encoder);
793 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_do_exhaustive_model_search()
795 * \param encoder An encoder instance to query.
797 * \code encoder != NULL \endcode
799 * See OggFLAC__seekable_stream_encoder_set_do_exhaustive_model_search().
801 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_get_do_exhaustive_model_search(const OggFLAC__SeekableStreamEncoder *encoder);
803 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_min_residual_partition_order()
805 * \param encoder An encoder instance to query.
807 * \code encoder != NULL \endcode
809 * See OggFLAC__seekable_stream_encoder_set_min_residual_partition_order().
811 OggFLAC_API unsigned OggFLAC__seekable_stream_encoder_get_min_residual_partition_order(const OggFLAC__SeekableStreamEncoder *encoder);
813 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_man_residual_partition_order()
815 * \param encoder An encoder instance to query.
817 * \code encoder != NULL \endcode
819 * See OggFLAC__seekable_stream_encoder_set_max_residual_partition_order().
821 OggFLAC_API unsigned OggFLAC__seekable_stream_encoder_get_max_residual_partition_order(const OggFLAC__SeekableStreamEncoder *encoder);
823 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_rice_parameter_search_dist()
825 * \param encoder An encoder instance to query.
827 * \code encoder != NULL \endcode
829 * See OggFLAC__seekable_stream_encoder_set_rice_parameter_search_dist().
831 OggFLAC_API unsigned OggFLAC__seekable_stream_encoder_get_rice_parameter_search_dist(const OggFLAC__SeekableStreamEncoder *encoder);
833 /** This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_get_total_samples_estimate()
835 * \param encoder An encoder instance to set.
837 * \code encoder != NULL \endcode
838 * \retval FLAC__uint64
839 * See OggFLAC__seekable_stream_encoder_get_total_samples_estimate().
841 OggFLAC_API FLAC__uint64 OggFLAC__seekable_stream_encoder_get_total_samples_estimate(const OggFLAC__SeekableStreamEncoder *encoder);
843 /** Initialize the encoder instance.
844 * Should be called after OggFLAC__seekable_stream_encoder_new() and
845 * OggFLAC__seekable_stream_encoder_set_*() but before OggFLAC__seekable_stream_encoder_process()
846 * or OggFLAC__seekable_stream_encoder_process_interleaved(). Will set and return
847 * the encoder state, which will be OggFLAC__SEEKABLE_STREAM_ENCODER_OK if
848 * initialization succeeded.
850 * The call to OggFLAC__seekable_stream_encoder_init() currently will also immediately
851 * call the write callback several times, once with the \c fLaC signature,
852 * and once for each encoded metadata block.
854 * \param encoder An uninitialized encoder instance.
856 * \code encoder != NULL \endcode
857 * \retval OggFLAC__SeekableStreamEncoderState
858 * \c OggFLAC__SEEKABLE_STREAM_ENCODER_OK if initialization was successful; see
859 * OggFLAC__SeekableStreamEncoderState for the meanings of other return values.
861 OggFLAC_API OggFLAC__SeekableStreamEncoderState OggFLAC__seekable_stream_encoder_init(OggFLAC__SeekableStreamEncoder *encoder);
863 /** Finish the encoding process.
864 * Flushes the encoding buffer, releases resources, resets the encoder
865 * settings to their defaults, and returns the encoder state to
866 * OggFLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED. Note that this can generate
867 * one or more write callbacks before returning.
869 * In the event of a prematurely-terminated encode, it is not strictly
870 * necessary to call this immediately before OggFLAC__seekable_stream_encoder_delete()
871 * but it is good practice to match every OggFLAC__seekable_stream_encoder_init()
872 * with an OggFLAC__seekable_stream_encoder_finish().
874 * \param encoder An uninitialized encoder instance.
876 * \code encoder != NULL \endcode
878 OggFLAC_API void OggFLAC__seekable_stream_encoder_finish(OggFLAC__SeekableStreamEncoder *encoder);
880 /** Submit data for encoding.
881 * This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_process().
883 * \param encoder An initialized encoder instance in the OK state.
884 * \param buffer An array of pointers to each channel's signal.
885 * \param samples The number of samples in one channel.
887 * \code encoder != NULL \endcode
888 * \code OggFLAC__seekable_stream_encoder_get_state(encoder) == OggFLAC__SEEKABLE_STREAM_ENCODER_OK \endcode
890 * \c true if successful, else \c false; in this case, check the
891 * encoder state with OggFLAC__seekable_stream_encoder_get_state() to see what
894 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_process(OggFLAC__SeekableStreamEncoder *encoder, const FLAC__int32 * const buffer[], unsigned samples);
896 /** Submit data for encoding.
897 * This is inherited from FLAC__StreamEncoder; see FLAC__stream_encoder_process_interleaved().
899 * \param encoder An initialized encoder instance in the OK state.
900 * \param buffer An array of channel-interleaved data (see above).
901 * \param samples The number of samples in one channel, the same as for
902 * OggFLAC__seekable_stream_encoder_process(). For example, if
903 * encoding two channels, \c 1000 \a samples corresponds
904 * to a \a buffer of 2000 values.
906 * \code encoder != NULL \endcode
907 * \code OggFLAC__seekable_stream_encoder_get_state(encoder) == OggFLAC__SEEKABLE_STREAM_ENCODER_OK \endcode
909 * \c true if successful, else \c false; in this case, check the
910 * encoder state with OggFLAC__seekable_stream_encoder_get_state() to see what
913 OggFLAC_API FLAC__bool OggFLAC__seekable_stream_encoder_process_interleaved(OggFLAC__SeekableStreamEncoder *encoder, const FLAC__int32 buffer[], unsigned samples);