1 /* libOggFLAC++ - Free Lossless Audio Codec + Ogg library
2 * Copyright (C) 2002 Josh Coalson
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef OggFLACPP__ENCODER_H
21 #define OggFLACPP__ENCODER_H
23 #include "OggFLAC/stream_encoder.h"
25 // we only need these for the state abstractions really...
26 #include "FLAC++/decoder.h"
27 #include "FLAC++/encoder.h"
30 /** \file include/OggFLAC++/encoder.h
33 * This module contains the classes which implement the various
36 * See the detailed documentation in the
37 * \link oggflacpp_encoder encoder \endlink module.
40 /** \defgroup oggflacpp_encoder OggFLAC++/encoder.h: encoder classes
44 * This module describes the encoder layers provided by libOggFLAC++.
46 * The libOggFLAC++ encoder classes are object wrappers around their
47 * counterparts in libOggFLAC. Only the stream encoding layer in
48 * libOggFLAC is provided here. The interface is very similar;
49 * make sure to read the \link oggflac_encoder libOggFLAC encoder module \endlink.
51 * The only real difference here is that instead of passing in C function
52 * pointers for callbacks, you inherit from the encoder class and provide
53 * implementations for the callbacks in the derived class; because of this
54 * there is no need for a 'client_data' property.
60 // ============================================================
62 // Equivalent: OggFLAC__StreamEncoder
64 // ============================================================
66 /** \defgroup oggflacpp_stream_encoder OggFLAC++/encoder.h: stream encoder class
67 * \ingroup oggflacpp_encoder
70 * This class wraps the ::OggFLAC__StreamEncoder.
72 * See the \link oggflac_stream_encoder libOggFLAC stream encoder module \endlink.
77 /** This class wraps the ::OggFLAC__StreamEncoder.
83 inline State(::OggFLAC__StreamEncoderState state): state_(state) { }
84 inline operator ::OggFLAC__StreamEncoderState() const { return state_; }
85 inline const char *as_cstring() const { return ::OggFLAC__StreamEncoderStateString[state_]; }
87 ::OggFLAC__StreamEncoderState state_;
93 bool is_valid() const;
94 inline operator bool() const { return is_valid(); }
96 bool set_serial_number(long value);
97 bool set_verify(bool value);
98 bool set_streamable_subset(bool value);
99 bool set_do_mid_side_stereo(bool value);
100 bool set_loose_mid_side_stereo(bool value);
101 bool set_channels(unsigned value);
102 bool set_bits_per_sample(unsigned value);
103 bool set_sample_rate(unsigned value);
104 bool set_blocksize(unsigned value);
105 bool set_max_lpc_order(unsigned value);
106 bool set_qlp_coeff_precision(unsigned value);
107 bool set_do_qlp_coeff_prec_search(bool value);
108 bool set_do_escape_coding(bool value);
109 bool set_do_exhaustive_model_search(bool value);
110 bool set_min_residual_partition_order(unsigned value);
111 bool set_max_residual_partition_order(unsigned value);
112 bool set_rice_parameter_search_dist(unsigned value);
113 bool set_total_samples_estimate(FLAC__uint64 value);
114 bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
116 State get_state() const;
117 FLAC::Encoder::Stream::State get_FLAC_stream_encoder_state() const;
118 FLAC::Decoder::Stream::State get_verify_decoder_state() const;
119 void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
120 bool get_verify() const;
121 bool get_streamable_subset() const;
122 bool get_do_mid_side_stereo() const;
123 bool get_loose_mid_side_stereo() const;
124 unsigned get_channels() const;
125 unsigned get_bits_per_sample() const;
126 unsigned get_sample_rate() const;
127 unsigned get_blocksize() const;
128 unsigned get_max_lpc_order() const;
129 unsigned get_qlp_coeff_precision() const;
130 bool get_do_qlp_coeff_prec_search() const;
131 bool get_do_escape_coding() const;
132 bool get_do_exhaustive_model_search() const;
133 unsigned get_min_residual_partition_order() const;
134 unsigned get_max_residual_partition_order() const;
135 unsigned get_rice_parameter_search_dist() const;
136 FLAC__uint64 get_total_samples_estimate() const;
142 bool process(const FLAC__int32 * const buffer[], unsigned samples);
143 bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
145 virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
147 ::OggFLAC__StreamEncoder *encoder_;
149 static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::OggFLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
151 // Private and undefined so you can't use them:
152 Stream(const Stream &);
153 void operator=(const Stream &);