Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

include/OggFLAC++/encoder.h

Go to the documentation of this file.
00001 /* libOggFLAC++ - Free Lossless Audio Codec + Ogg library
00002  * Copyright (C) 2002,2003  Josh Coalson
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions
00006  * are met:
00007  *
00008  * - Redistributions of source code must retain the above copyright
00009  * notice, this list of conditions and the following disclaimer.
00010  *
00011  * - Redistributions in binary form must reproduce the above copyright
00012  * notice, this list of conditions and the following disclaimer in the
00013  * documentation and/or other materials provided with the distribution.
00014  *
00015  * - Neither the name of the Xiph.org Foundation nor the names of its
00016  * contributors may be used to endorse or promote products derived from
00017  * this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00022  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
00023  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00024  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00025  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00026  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00027  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00028  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00029  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030  */
00031 
00032 #ifndef OggFLACPP__ENCODER_H
00033 #define OggFLACPP__ENCODER_H
00034 
00035 #include "export.h"
00036 
00037 #include "OggFLAC/file_encoder.h"
00038 #include "OggFLAC/seekable_stream_encoder.h"
00039 #include "OggFLAC/stream_encoder.h"
00040 #include "decoder.h"
00041 // we only need these for the state abstractions really...
00042 #include "FLAC++/decoder.h"
00043 #include "FLAC++/encoder.h"
00044 
00045 
00073 namespace OggFLAC {
00074     namespace Encoder {
00075 
00076         // ============================================================
00077         //
00078         //  Equivalent: OggFLAC__StreamEncoder
00079         //
00080         // ============================================================
00081 
00095         class OggFLACPP_API Stream {
00096         public:
00097             class OggFLACPP_API State {
00098             public:
00099                 inline State(::OggFLAC__StreamEncoderState state): state_(state) { }
00100                 inline operator ::OggFLAC__StreamEncoderState() const { return state_; }
00101                 inline const char *as_cstring() const { return ::OggFLAC__StreamEncoderStateString[state_]; }
00102                 inline const char *resolved_as_cstring(const Stream &encoder) const { return ::OggFLAC__stream_encoder_get_resolved_state_string(encoder.encoder_); }
00103             protected:
00104                 ::OggFLAC__StreamEncoderState state_;
00105             };
00106 
00107             Stream();
00108             virtual ~Stream();
00109 
00110             bool is_valid() const;
00111             inline operator bool() const { return is_valid(); }
00112 
00113             bool set_serial_number(long value);
00114             bool set_verify(bool value);
00115             bool set_streamable_subset(bool value);
00116             bool set_do_mid_side_stereo(bool value);
00117             bool set_loose_mid_side_stereo(bool value);
00118             bool set_channels(unsigned value);
00119             bool set_bits_per_sample(unsigned value);
00120             bool set_sample_rate(unsigned value);
00121             bool set_blocksize(unsigned value);
00122             bool set_max_lpc_order(unsigned value);
00123             bool set_qlp_coeff_precision(unsigned value);
00124             bool set_do_qlp_coeff_prec_search(bool value);
00125             bool set_do_escape_coding(bool value);
00126             bool set_do_exhaustive_model_search(bool value);
00127             bool set_min_residual_partition_order(unsigned value);
00128             bool set_max_residual_partition_order(unsigned value);
00129             bool set_rice_parameter_search_dist(unsigned value);
00130             bool set_total_samples_estimate(FLAC__uint64 value);
00131             bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
00132 
00133             State    get_state() const;
00134             FLAC::Encoder::Stream::State get_FLAC_stream_encoder_state() const;
00135             FLAC::Decoder::Stream::State get_verify_decoder_state() const;
00136             void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
00137             bool     get_verify() const;
00138             bool     get_streamable_subset() const;
00139             bool     get_do_mid_side_stereo() const;
00140             bool     get_loose_mid_side_stereo() const;
00141             unsigned get_channels() const;
00142             unsigned get_bits_per_sample() const;
00143             unsigned get_sample_rate() const;
00144             unsigned get_blocksize() const;
00145             unsigned get_max_lpc_order() const;
00146             unsigned get_qlp_coeff_precision() const;
00147             bool     get_do_qlp_coeff_prec_search() const;
00148             bool     get_do_escape_coding() const;
00149             bool     get_do_exhaustive_model_search() const;
00150             unsigned get_min_residual_partition_order() const;
00151             unsigned get_max_residual_partition_order() const;
00152             unsigned get_rice_parameter_search_dist() const;
00153             FLAC__uint64 get_total_samples_estimate() const;
00154 
00155             State init();
00156 
00157             void finish();
00158 
00159             bool process(const FLAC__int32 * const buffer[], unsigned samples);
00160             bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
00161         protected:
00162             virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
00163             virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00164 
00165             ::OggFLAC__StreamEncoder *encoder_;
00166         private:
00167             static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::OggFLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
00168             static void metadata_callback_(const ::OggFLAC__StreamEncoder *encoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00169 
00170             // Private and undefined so you can't use them:
00171             Stream(const Stream &);
00172             void operator=(const Stream &);
00173         };
00174 
00175         /* \} */
00176 
00190         class OggFLACPP_API SeekableStream {
00191         public:
00192             class OggFLACPP_API State {
00193             public:
00194                 inline State(::OggFLAC__SeekableStreamEncoderState state): state_(state) { }
00195                 inline operator ::OggFLAC__SeekableStreamEncoderState() const { return state_; }
00196                 inline const char *as_cstring() const { return ::OggFLAC__SeekableStreamEncoderStateString[state_]; }
00197                 inline const char *resolved_as_cstring(const SeekableStream &encoder) const { return ::OggFLAC__seekable_stream_encoder_get_resolved_state_string(encoder.encoder_); }
00198             protected:
00199                 ::OggFLAC__SeekableStreamEncoderState state_;
00200             };
00201 
00202             SeekableStream();
00203             virtual ~SeekableStream();
00204 
00205             bool is_valid() const;
00206             inline operator bool() const { return is_valid(); }
00207 
00208             bool set_serial_number(long value);
00209             bool set_verify(bool value);
00210             bool set_streamable_subset(bool value);
00211             bool set_do_mid_side_stereo(bool value);
00212             bool set_loose_mid_side_stereo(bool value);
00213             bool set_channels(unsigned value);
00214             bool set_bits_per_sample(unsigned value);
00215             bool set_sample_rate(unsigned value);
00216             bool set_blocksize(unsigned value);
00217             bool set_max_lpc_order(unsigned value);
00218             bool set_qlp_coeff_precision(unsigned value);
00219             bool set_do_qlp_coeff_prec_search(bool value);
00220             bool set_do_escape_coding(bool value);
00221             bool set_do_exhaustive_model_search(bool value);
00222             bool set_min_residual_partition_order(unsigned value);
00223             bool set_max_residual_partition_order(unsigned value);
00224             bool set_rice_parameter_search_dist(unsigned value);
00225             bool set_total_samples_estimate(FLAC__uint64 value);
00226             bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
00227 
00228             State    get_state() const;
00229             FLAC::Encoder::SeekableStream::State get_FLAC_seekable_stream_encoder_state() const;
00230             FLAC::Encoder::Stream::State get_FLAC_stream_encoder_state() const;
00231             FLAC::Decoder::Stream::State get_verify_decoder_state() const;
00232             void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
00233             bool     get_verify() const;
00234             bool     get_streamable_subset() const;
00235             bool     get_do_mid_side_stereo() const;
00236             bool     get_loose_mid_side_stereo() const;
00237             unsigned get_channels() const;
00238             unsigned get_bits_per_sample() const;
00239             unsigned get_sample_rate() const;
00240             unsigned get_blocksize() const;
00241             unsigned get_max_lpc_order() const;
00242             unsigned get_qlp_coeff_precision() const;
00243             bool     get_do_qlp_coeff_prec_search() const;
00244             bool     get_do_escape_coding() const;
00245             bool     get_do_exhaustive_model_search() const;
00246             unsigned get_min_residual_partition_order() const;
00247             unsigned get_max_residual_partition_order() const;
00248             unsigned get_rice_parameter_search_dist() const;
00249             FLAC__uint64 get_total_samples_estimate() const;
00250 
00251             State init();
00252 
00253             void finish();
00254 
00255             bool process(const FLAC__int32 * const buffer[], unsigned samples);
00256             bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
00257         protected:
00258             virtual ::FLAC__SeekableStreamEncoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset) = 0;
00259             virtual ::FLAC__SeekableStreamEncoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset) = 0;
00260             virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
00261 
00262             ::OggFLAC__SeekableStreamEncoder *encoder_;
00263         private:
00264             static ::FLAC__SeekableStreamEncoderSeekStatus seek_callback_(const OggFLAC__SeekableStreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
00265             static ::FLAC__SeekableStreamEncoderTellStatus tell_callback_(const OggFLAC__SeekableStreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
00266             static ::FLAC__StreamEncoderWriteStatus write_callback_(const OggFLAC__SeekableStreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
00267 
00268             // Private and undefined so you can't use them:
00269             SeekableStream(const SeekableStream &);
00270             void operator=(const SeekableStream &);
00271         };
00272 
00273         /* \} */
00274 
00288         class OggFLACPP_API File {
00289         public:
00290             class OggFLACPP_API State {
00291             public:
00292                 inline State(::OggFLAC__FileEncoderState state): state_(state) { }
00293                 inline operator ::OggFLAC__FileEncoderState() const { return state_; }
00294                 inline const char *as_cstring() const { return ::OggFLAC__FileEncoderStateString[state_]; }
00295                 inline const char *resolved_as_cstring(const File &encoder) const { return ::OggFLAC__file_encoder_get_resolved_state_string(encoder.encoder_); }
00296             protected:
00297                 ::OggFLAC__FileEncoderState state_;
00298             };
00299 
00300             File();
00301             virtual ~File();
00302 
00303             bool is_valid() const;
00304             inline operator bool() const { return is_valid(); }
00305 
00306             bool set_serial_number(long value);
00307             bool set_verify(bool value);
00308             bool set_streamable_subset(bool value);
00309             bool set_do_mid_side_stereo(bool value);
00310             bool set_loose_mid_side_stereo(bool value);
00311             bool set_channels(unsigned value);
00312             bool set_bits_per_sample(unsigned value);
00313             bool set_sample_rate(unsigned value);
00314             bool set_blocksize(unsigned value);
00315             bool set_max_lpc_order(unsigned value);
00316             bool set_qlp_coeff_precision(unsigned value);
00317             bool set_do_qlp_coeff_prec_search(bool value);
00318             bool set_do_escape_coding(bool value);
00319             bool set_do_exhaustive_model_search(bool value);
00320             bool set_min_residual_partition_order(unsigned value);
00321             bool set_max_residual_partition_order(unsigned value);
00322             bool set_rice_parameter_search_dist(unsigned value);
00323             bool set_total_samples_estimate(FLAC__uint64 value);
00324             bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
00325             bool set_filename(const char *value);
00326 
00327             State    get_state() const;
00328             SeekableStream::State get_seekable_stream_encoder_state() const;
00329             FLAC::Encoder::SeekableStream::State get_FLAC_seekable_stream_encoder_state() const;
00330             FLAC::Encoder::Stream::State get_FLAC_stream_encoder_state() const;
00331             FLAC::Decoder::Stream::State get_verify_decoder_state() const;
00332             void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
00333             bool     get_verify() const;
00334             bool     get_streamable_subset() const;
00335             bool     get_do_mid_side_stereo() const;
00336             bool     get_loose_mid_side_stereo() const;
00337             unsigned get_channels() const;
00338             unsigned get_bits_per_sample() const;
00339             unsigned get_sample_rate() const;
00340             unsigned get_blocksize() const;
00341             unsigned get_max_lpc_order() const;
00342             unsigned get_qlp_coeff_precision() const;
00343             bool     get_do_qlp_coeff_prec_search() const;
00344             bool     get_do_escape_coding() const;
00345             bool     get_do_exhaustive_model_search() const;
00346             unsigned get_min_residual_partition_order() const;
00347             unsigned get_max_residual_partition_order() const;
00348             unsigned get_rice_parameter_search_dist() const;
00349             FLAC__uint64 get_total_samples_estimate() const;
00350 
00351             State init();
00352 
00353             void finish();
00354 
00355             bool process(const FLAC__int32 * const buffer[], unsigned samples);
00356             bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
00357         protected:
00358             virtual void progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate);
00359 
00360             ::OggFLAC__FileEncoder *encoder_;
00361         private:
00362             static void progress_callback_(const ::OggFLAC__FileEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
00363 
00364             // Private and undefined so you can't use them:
00365             File(const Stream &);
00366             void operator=(const Stream &);
00367         };
00368 
00369         /* \} */
00370 
00371     };
00372 };
00373 
00374 #endif

Generated on Fri Oct 3 00:07:09 2003 for FLAC by doxygen1.3