00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
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 
00042 #include "FLAC++/decoder.h"
00043 #include "FLAC++/encoder.h"
00044 
00045 
00073 namespace OggFLAC {
00074     namespace Encoder {
00075 
00076         
00077         
00078         
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 #if (defined _MSC_VER) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC)
00166             
00167             friend State;
00168 #endif
00169             ::OggFLAC__StreamEncoder *encoder_;
00170         private:
00171             static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::OggFLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
00172             static void metadata_callback_(const ::OggFLAC__StreamEncoder *encoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00173 
00174             
00175             Stream(const Stream &);
00176             void operator=(const Stream &);
00177         };
00178 
00179         
00180 
00194         class OggFLACPP_API SeekableStream {
00195         public:
00196             class OggFLACPP_API State {
00197             public:
00198                 inline State(::OggFLAC__SeekableStreamEncoderState state): state_(state) { }
00199                 inline operator ::OggFLAC__SeekableStreamEncoderState() const { return state_; }
00200                 inline const char *as_cstring() const { return ::OggFLAC__SeekableStreamEncoderStateString[state_]; }
00201                 inline const char *resolved_as_cstring(const SeekableStream &encoder) const { return ::OggFLAC__seekable_stream_encoder_get_resolved_state_string(encoder.encoder_); }
00202             protected:
00203                 ::OggFLAC__SeekableStreamEncoderState state_;
00204             };
00205 
00206             SeekableStream();
00207             virtual ~SeekableStream();
00208 
00209             bool is_valid() const;
00210             inline operator bool() const { return is_valid(); }
00211 
00212             bool set_serial_number(long value);
00213             bool set_verify(bool value);
00214             bool set_streamable_subset(bool value);
00215             bool set_do_mid_side_stereo(bool value);
00216             bool set_loose_mid_side_stereo(bool value);
00217             bool set_channels(unsigned value);
00218             bool set_bits_per_sample(unsigned value);
00219             bool set_sample_rate(unsigned value);
00220             bool set_blocksize(unsigned value);
00221             bool set_max_lpc_order(unsigned value);
00222             bool set_qlp_coeff_precision(unsigned value);
00223             bool set_do_qlp_coeff_prec_search(bool value);
00224             bool set_do_escape_coding(bool value);
00225             bool set_do_exhaustive_model_search(bool value);
00226             bool set_min_residual_partition_order(unsigned value);
00227             bool set_max_residual_partition_order(unsigned value);
00228             bool set_rice_parameter_search_dist(unsigned value);
00229             bool set_total_samples_estimate(FLAC__uint64 value);
00230             bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
00231 
00232             State    get_state() const;
00233             FLAC::Encoder::Stream::State get_FLAC_stream_encoder_state() const;
00234             FLAC::Decoder::Stream::State get_verify_decoder_state() const;
00235             void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
00236             bool     get_verify() const;
00237             bool     get_streamable_subset() const;
00238             bool     get_do_mid_side_stereo() const;
00239             bool     get_loose_mid_side_stereo() const;
00240             unsigned get_channels() const;
00241             unsigned get_bits_per_sample() const;
00242             unsigned get_sample_rate() const;
00243             unsigned get_blocksize() const;
00244             unsigned get_max_lpc_order() const;
00245             unsigned get_qlp_coeff_precision() const;
00246             bool     get_do_qlp_coeff_prec_search() const;
00247             bool     get_do_escape_coding() const;
00248             bool     get_do_exhaustive_model_search() const;
00249             unsigned get_min_residual_partition_order() const;
00250             unsigned get_max_residual_partition_order() const;
00251             unsigned get_rice_parameter_search_dist() const;
00252             FLAC__uint64 get_total_samples_estimate() const;
00253 
00254             State init();
00255 
00256             void finish();
00257 
00258             bool process(const FLAC__int32 * const buffer[], unsigned samples);
00259             bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
00260         protected:
00261             virtual ::OggFLAC__SeekableStreamEncoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
00262             virtual ::FLAC__SeekableStreamEncoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset) = 0;
00263             virtual ::FLAC__SeekableStreamEncoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset) = 0;
00264             virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
00265 
00266 #if (defined _MSC_VER) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC)
00267             
00268             friend State;
00269 #endif
00270             ::OggFLAC__SeekableStreamEncoder *encoder_;
00271         private:
00272             static ::OggFLAC__SeekableStreamEncoderReadStatus read_callback_(const OggFLAC__SeekableStreamEncoder *encoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
00273             static ::FLAC__SeekableStreamEncoderSeekStatus seek_callback_(const OggFLAC__SeekableStreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
00274             static ::FLAC__SeekableStreamEncoderTellStatus tell_callback_(const OggFLAC__SeekableStreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
00275             static ::FLAC__StreamEncoderWriteStatus write_callback_(const OggFLAC__SeekableStreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
00276 
00277             
00278             SeekableStream(const SeekableStream &);
00279             void operator=(const SeekableStream &);
00280         };
00281 
00282         
00283 
00297         class OggFLACPP_API File {
00298         public:
00299             class OggFLACPP_API State {
00300             public:
00301                 inline State(::OggFLAC__FileEncoderState state): state_(state) { }
00302                 inline operator ::OggFLAC__FileEncoderState() const { return state_; }
00303                 inline const char *as_cstring() const { return ::OggFLAC__FileEncoderStateString[state_]; }
00304                 inline const char *resolved_as_cstring(const File &encoder) const { return ::OggFLAC__file_encoder_get_resolved_state_string(encoder.encoder_); }
00305             protected:
00306                 ::OggFLAC__FileEncoderState state_;
00307             };
00308 
00309             File();
00310             virtual ~File();
00311 
00312             bool is_valid() const;
00313             inline operator bool() const { return is_valid(); }
00314 
00315             bool set_serial_number(long value);
00316             bool set_verify(bool value);
00317             bool set_streamable_subset(bool value);
00318             bool set_do_mid_side_stereo(bool value);
00319             bool set_loose_mid_side_stereo(bool value);
00320             bool set_channels(unsigned value);
00321             bool set_bits_per_sample(unsigned value);
00322             bool set_sample_rate(unsigned value);
00323             bool set_blocksize(unsigned value);
00324             bool set_max_lpc_order(unsigned value);
00325             bool set_qlp_coeff_precision(unsigned value);
00326             bool set_do_qlp_coeff_prec_search(bool value);
00327             bool set_do_escape_coding(bool value);
00328             bool set_do_exhaustive_model_search(bool value);
00329             bool set_min_residual_partition_order(unsigned value);
00330             bool set_max_residual_partition_order(unsigned value);
00331             bool set_rice_parameter_search_dist(unsigned value);
00332             bool set_total_samples_estimate(FLAC__uint64 value);
00333             bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
00334             bool set_filename(const char *value);
00335 
00336             State    get_state() const;
00337             SeekableStream::State get_seekable_stream_encoder_state() const;
00338             FLAC::Encoder::Stream::State get_FLAC_stream_encoder_state() const;
00339             FLAC::Decoder::Stream::State get_verify_decoder_state() const;
00340             void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
00341             bool     get_verify() const;
00342             bool     get_streamable_subset() const;
00343             bool     get_do_mid_side_stereo() const;
00344             bool     get_loose_mid_side_stereo() const;
00345             unsigned get_channels() const;
00346             unsigned get_bits_per_sample() const;
00347             unsigned get_sample_rate() const;
00348             unsigned get_blocksize() const;
00349             unsigned get_max_lpc_order() const;
00350             unsigned get_qlp_coeff_precision() const;
00351             bool     get_do_qlp_coeff_prec_search() const;
00352             bool     get_do_escape_coding() const;
00353             bool     get_do_exhaustive_model_search() const;
00354             unsigned get_min_residual_partition_order() const;
00355             unsigned get_max_residual_partition_order() const;
00356             unsigned get_rice_parameter_search_dist() const;
00357             FLAC__uint64 get_total_samples_estimate() const;
00358 
00359             State init();
00360 
00361             void finish();
00362 
00363             bool process(const FLAC__int32 * const buffer[], unsigned samples);
00364             bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
00365         protected:
00366             virtual void progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate);
00367 
00368 #if (defined _MSC_VER) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC)
00369             
00370             friend State;
00371 #endif
00372             ::OggFLAC__FileEncoder *encoder_;
00373         private:
00374             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);
00375 
00376             
00377             File(const Stream &);
00378             void operator=(const Stream &);
00379         };
00380 
00381         
00382 
00383     }
00384 }
00385 
00386 #endif