106
116
virtual ~Stream();
108
bool is_valid() const;
109
inline operator bool() const { return is_valid(); }
111
bool set_verify(bool value);
112
bool set_streamable_subset(bool value);
113
bool set_do_mid_side_stereo(bool value);
114
bool set_loose_mid_side_stereo(bool value);
115
bool set_channels(unsigned value);
116
bool set_bits_per_sample(unsigned value);
117
bool set_sample_rate(unsigned value);
118
bool set_blocksize(unsigned value);
119
bool set_max_lpc_order(unsigned value);
120
bool set_qlp_coeff_precision(unsigned value);
121
bool set_do_qlp_coeff_prec_search(bool value);
122
bool set_do_escape_coding(bool value);
123
bool set_do_exhaustive_model_search(bool value);
124
bool set_min_residual_partition_order(unsigned value);
125
bool set_max_residual_partition_order(unsigned value);
126
bool set_rice_parameter_search_dist(unsigned value);
127
bool set_total_samples_estimate(FLAC__uint64 value);
128
bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
129
bool set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks);
131
State get_state() const;
132
Decoder::Stream::State get_verify_decoder_state() const;
133
void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
134
bool get_verify() const;
135
bool get_streamable_subset() const;
136
bool get_do_mid_side_stereo() const;
137
bool get_loose_mid_side_stereo() const;
138
unsigned get_channels() const;
139
unsigned get_bits_per_sample() const;
140
unsigned get_sample_rate() const;
141
unsigned get_blocksize() const;
142
unsigned get_max_lpc_order() const;
143
unsigned get_qlp_coeff_precision() const;
144
bool get_do_qlp_coeff_prec_search() const;
145
bool get_do_escape_coding() const;
146
bool get_do_exhaustive_model_search() const;
147
unsigned get_min_residual_partition_order() const;
148
unsigned get_max_residual_partition_order() const;
149
unsigned get_rice_parameter_search_dist() const;
150
FLAC__uint64 get_total_samples_estimate() const;
156
bool process(const FLAC__int32 * const buffer[], unsigned samples);
157
bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
119
/** Call after construction to check the that the object was created
120
* successfully. If not, use get_state() to find out why not.
123
virtual bool is_valid() const;
124
inline operator bool() const { return is_valid(); } ///< See is_valid()
127
virtual bool set_ogg_serial_number(long value); ///< See FLAC__stream_encoder_set_ogg_serial_number()
128
virtual bool set_verify(bool value); ///< See FLAC__stream_encoder_set_verify()
129
virtual bool set_streamable_subset(bool value); ///< See FLAC__stream_encoder_set_streamable_subset()
130
virtual bool set_channels(unsigned value); ///< See FLAC__stream_encoder_set_channels()
131
virtual bool set_bits_per_sample(unsigned value); ///< See FLAC__stream_encoder_set_bits_per_sample()
132
virtual bool set_sample_rate(unsigned value); ///< See FLAC__stream_encoder_set_sample_rate()
133
virtual bool set_compression_level(unsigned value); ///< See FLAC__stream_encoder_set_compression_level()
134
virtual bool set_blocksize(unsigned value); ///< See FLAC__stream_encoder_set_blocksize()
135
virtual bool set_do_mid_side_stereo(bool value); ///< See FLAC__stream_encoder_set_do_mid_side_stereo()
136
virtual bool set_loose_mid_side_stereo(bool value); ///< See FLAC__stream_encoder_set_loose_mid_side_stereo()
137
virtual bool set_apodization(const char *specification); ///< See FLAC__stream_encoder_set_apodization()
138
virtual bool set_max_lpc_order(unsigned value); ///< See FLAC__stream_encoder_set_max_lpc_order()
139
virtual bool set_qlp_coeff_precision(unsigned value); ///< See FLAC__stream_encoder_set_qlp_coeff_precision()
140
virtual bool set_do_qlp_coeff_prec_search(bool value); ///< See FLAC__stream_encoder_set_do_qlp_coeff_prec_search()
141
virtual bool set_do_escape_coding(bool value); ///< See FLAC__stream_encoder_set_do_escape_coding()
142
virtual bool set_do_exhaustive_model_search(bool value); ///< See FLAC__stream_encoder_set_do_exhaustive_model_search()
143
virtual bool set_min_residual_partition_order(unsigned value); ///< See FLAC__stream_encoder_set_min_residual_partition_order()
144
virtual bool set_max_residual_partition_order(unsigned value); ///< See FLAC__stream_encoder_set_max_residual_partition_order()
145
virtual bool set_rice_parameter_search_dist(unsigned value); ///< See FLAC__stream_encoder_set_rice_parameter_search_dist()
146
virtual bool set_total_samples_estimate(FLAC__uint64 value); ///< See FLAC__stream_encoder_set_total_samples_estimate()
147
virtual bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks); ///< See FLAC__stream_encoder_set_metadata()
148
virtual bool set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks); ///< See FLAC__stream_encoder_set_metadata()
150
/* get_state() is not virtual since we want subclasses to be able to return their own state */
151
State get_state() const; ///< See FLAC__stream_encoder_get_state()
152
virtual Decoder::Stream::State get_verify_decoder_state() const; ///< See FLAC__stream_encoder_get_verify_decoder_state()
153
virtual void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got); ///< See FLAC__stream_encoder_get_verify_decoder_error_stats()
154
virtual bool get_verify() const; ///< See FLAC__stream_encoder_get_verify()
155
virtual bool get_streamable_subset() const; ///< See FLAC__stream_encoder_get_streamable_subset()
156
virtual bool get_do_mid_side_stereo() const; ///< See FLAC__stream_encoder_get_do_mid_side_stereo()
157
virtual bool get_loose_mid_side_stereo() const; ///< See FLAC__stream_encoder_get_loose_mid_side_stereo()
158
virtual unsigned get_channels() const; ///< See FLAC__stream_encoder_get_channels()
159
virtual unsigned get_bits_per_sample() const; ///< See FLAC__stream_encoder_get_bits_per_sample()
160
virtual unsigned get_sample_rate() const; ///< See FLAC__stream_encoder_get_sample_rate()
161
virtual unsigned get_blocksize() const; ///< See FLAC__stream_encoder_get_blocksize()
162
virtual unsigned get_max_lpc_order() const; ///< See FLAC__stream_encoder_get_max_lpc_order()
163
virtual unsigned get_qlp_coeff_precision() const; ///< See FLAC__stream_encoder_get_qlp_coeff_precision()
164
virtual bool get_do_qlp_coeff_prec_search() const; ///< See FLAC__stream_encoder_get_do_qlp_coeff_prec_search()
165
virtual bool get_do_escape_coding() const; ///< See FLAC__stream_encoder_get_do_escape_coding()
166
virtual bool get_do_exhaustive_model_search() const; ///< See FLAC__stream_encoder_get_do_exhaustive_model_search()
167
virtual unsigned get_min_residual_partition_order() const; ///< See FLAC__stream_encoder_get_min_residual_partition_order()
168
virtual unsigned get_max_residual_partition_order() const; ///< See FLAC__stream_encoder_get_max_residual_partition_order()
169
virtual unsigned get_rice_parameter_search_dist() const; ///< See FLAC__stream_encoder_get_rice_parameter_search_dist()
170
virtual FLAC__uint64 get_total_samples_estimate() const; ///< See FLAC__stream_encoder_get_total_samples_estimate()
172
virtual ::FLAC__StreamEncoderInitStatus init(); ///< See FLAC__stream_encoder_init_stream()
173
virtual ::FLAC__StreamEncoderInitStatus init_ogg(); ///< See FLAC__stream_encoder_init_ogg_stream()
175
virtual bool finish(); ///< See FLAC__stream_encoder_finish()
177
virtual bool process(const FLAC__int32 * const buffer[], unsigned samples); ///< See FLAC__stream_encoder_process()
178
virtual bool process_interleaved(const FLAC__int32 buffer[], unsigned samples); ///< See FLAC__stream_encoder_process_interleaved()
159
virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
160
virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
162
#if (defined _MSC_VER) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC)
180
/// See FLAC__StreamEncoderReadCallback
181
virtual ::FLAC__StreamEncoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes);
183
/// See FLAC__StreamEncoderWriteCallback
184
virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame) = 0;
186
/// See FLAC__StreamEncoderSeekCallback
187
virtual ::FLAC__StreamEncoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset);
189
/// See FLAC__StreamEncoderTellCallback
190
virtual ::FLAC__StreamEncoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset);
192
/// See FLAC__StreamEncoderMetadataCallback
193
virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata);
195
#if (defined _MSC_VER) || (defined __BORLANDC__) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC)
163
196
// lame hack: some MSVC/GCC versions can't see a protected encoder_ from nested State::resolved_as_cstring()
166
199
::FLAC__StreamEncoder *encoder_;
168
static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
201
static ::FLAC__StreamEncoderReadStatus read_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
202
static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data);
203
static ::FLAC__StreamEncoderSeekStatus seek_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
204
static ::FLAC__StreamEncoderTellStatus tell_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
169
205
static void metadata_callback_(const ::FLAC__StreamEncoder *encoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
171
207
// Private and undefined so you can't use them:
172
208
Stream(const Stream &);
173
209
void operator=(const Stream &);
178
/** \defgroup flacpp_seekable_stream_encoder FLAC++/encoder.h: seekable stream encoder class
179
* \ingroup flacpp_encoder
182
* This class wraps the ::FLAC__SeekableStreamEncoder.
184
* See the \link flac_seekable_stream_encoder libFLAC seekable stream encoder module \endlink.
189
/** This class wraps the ::FLAC__SeekableStreamEncoder.
191
class FLACPP_API SeekableStream {
193
class FLACPP_API State {
195
inline State(::FLAC__SeekableStreamEncoderState state): state_(state) { }
196
inline operator ::FLAC__SeekableStreamEncoderState() const { return state_; }
197
inline const char *as_cstring() const { return ::FLAC__SeekableStreamEncoderStateString[state_]; }
198
inline const char *resolved_as_cstring(const SeekableStream &encoder) const { return ::FLAC__seekable_stream_encoder_get_resolved_state_string(encoder.encoder_); }
200
::FLAC__SeekableStreamEncoderState state_;
204
virtual ~SeekableStream();
206
bool is_valid() const;
207
inline operator bool() const { return is_valid(); }
209
bool set_verify(bool value);
210
bool set_streamable_subset(bool value);
211
bool set_do_mid_side_stereo(bool value);
212
bool set_loose_mid_side_stereo(bool value);
213
bool set_channels(unsigned value);
214
bool set_bits_per_sample(unsigned value);
215
bool set_sample_rate(unsigned value);
216
bool set_blocksize(unsigned value);
217
bool set_max_lpc_order(unsigned value);
218
bool set_qlp_coeff_precision(unsigned value);
219
bool set_do_qlp_coeff_prec_search(bool value);
220
bool set_do_escape_coding(bool value);
221
bool set_do_exhaustive_model_search(bool value);
222
bool set_min_residual_partition_order(unsigned value);
223
bool set_max_residual_partition_order(unsigned value);
224
bool set_rice_parameter_search_dist(unsigned value);
225
bool set_total_samples_estimate(FLAC__uint64 value);
226
bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
227
bool set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks);
229
State get_state() const;
230
Stream::State get_stream_encoder_state() const;
231
Decoder::Stream::State get_verify_decoder_state() const;
232
void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
233
bool get_verify() const;
234
bool get_streamable_subset() const;
235
bool get_do_mid_side_stereo() const;
236
bool get_loose_mid_side_stereo() const;
237
unsigned get_channels() const;
238
unsigned get_bits_per_sample() const;
239
unsigned get_sample_rate() const;
240
unsigned get_blocksize() const;
241
unsigned get_max_lpc_order() const;
242
unsigned get_qlp_coeff_precision() const;
243
bool get_do_qlp_coeff_prec_search() const;
244
bool get_do_escape_coding() const;
245
bool get_do_exhaustive_model_search() const;
246
unsigned get_min_residual_partition_order() const;
247
unsigned get_max_residual_partition_order() const;
248
unsigned get_rice_parameter_search_dist() const;
249
FLAC__uint64 get_total_samples_estimate() const;
255
bool process(const FLAC__int32 * const buffer[], unsigned samples);
256
bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
258
virtual ::FLAC__SeekableStreamEncoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset) = 0;
259
virtual ::FLAC__SeekableStreamEncoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset) = 0;
260
virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
262
#if (defined _MSC_VER) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC)
263
// lame hack: some MSVC/GCC versions can't see a protected encoder_ from nested State::resolved_as_cstring()
266
::FLAC__SeekableStreamEncoder *encoder_;
268
static ::FLAC__SeekableStreamEncoderSeekStatus seek_callback_(const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
269
static ::FLAC__SeekableStreamEncoderTellStatus tell_callback_(const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
270
static ::FLAC__StreamEncoderWriteStatus write_callback_(const FLAC__SeekableStreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
272
// Private and undefined so you can't use them:
273
SeekableStream(const SeekableStream &);
274
void operator=(const SeekableStream &);
279
/** \defgroup flacpp_file_encoder FLAC++/encoder.h: file encoder class
280
* \ingroup flacpp_encoder
283
* This class wraps the ::FLAC__FileEncoder.
285
* See the \link flac_file_encoder libFLAC file encoder module \endlink.
290
/** This class wraps the ::FLAC__FileEncoder.
292
class FLACPP_API File {
294
class FLACPP_API State {
296
inline State(::FLAC__FileEncoderState state): state_(state) { }
297
inline operator ::FLAC__FileEncoderState() const { return state_; }
298
inline const char *as_cstring() const { return ::FLAC__FileEncoderStateString[state_]; }
299
inline const char *resolved_as_cstring(const File &encoder) const { return ::FLAC__file_encoder_get_resolved_state_string(encoder.encoder_); }
301
::FLAC__FileEncoderState state_;
212
/** \ingroup flacpp_encoder
214
* This class wraps the ::FLAC__StreamEncoder. If you are
215
* not encoding to a file, you may need to use
216
* FLAC::Encoder::Stream.
218
* The usage of this class is similar to FLAC__StreamEncoder,
219
* except instead of providing callbacks to
220
* FLAC__stream_encoder_init*_FILE() or
221
* FLAC__stream_encoder_init*_file(), you will inherit from this
222
* class and override the virtual callback functions with your
223
* own implementations, then call init() or init_ogg(). The rest
224
* of the calls work the same as in the C layer.
226
* There are no mandatory callbacks; all the callbacks from
227
* FLAC::Encoder::Stream are implemented here fully and support
228
* full post-encode STREAMINFO and SEEKTABLE updating. There is
229
* only an optional progress callback which you may override to
230
* get periodic reports on the progress of the encode.
232
class FLACPP_API File: public Stream {
307
bool is_valid() const;
308
inline operator bool() const { return is_valid(); }
310
bool set_verify(bool value);
311
bool set_streamable_subset(bool value);
312
bool set_do_mid_side_stereo(bool value);
313
bool set_loose_mid_side_stereo(bool value);
314
bool set_channels(unsigned value);
315
bool set_bits_per_sample(unsigned value);
316
bool set_sample_rate(unsigned value);
317
bool set_blocksize(unsigned value);
318
bool set_max_lpc_order(unsigned value);
319
bool set_qlp_coeff_precision(unsigned value);
320
bool set_do_qlp_coeff_prec_search(bool value);
321
bool set_do_escape_coding(bool value);
322
bool set_do_exhaustive_model_search(bool value);
323
bool set_min_residual_partition_order(unsigned value);
324
bool set_max_residual_partition_order(unsigned value);
325
bool set_rice_parameter_search_dist(unsigned value);
326
bool set_total_samples_estimate(FLAC__uint64 value);
327
bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
328
bool set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks);
329
bool set_filename(const char *value);
331
State get_state() const;
332
SeekableStream::State get_seekable_stream_encoder_state() const;
333
Stream::State get_stream_encoder_state() const;
334
Decoder::Stream::State get_verify_decoder_state() const;
335
void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
336
bool get_verify() const;
337
bool get_streamable_subset() const;
338
bool get_do_mid_side_stereo() const;
339
bool get_loose_mid_side_stereo() const;
340
unsigned get_channels() const;
341
unsigned get_bits_per_sample() const;
342
unsigned get_sample_rate() const;
343
unsigned get_blocksize() const;
344
unsigned get_max_lpc_order() const;
345
unsigned get_qlp_coeff_precision() const;
346
bool get_do_qlp_coeff_prec_search() const;
347
bool get_do_escape_coding() const;
348
bool get_do_exhaustive_model_search() const;
349
unsigned get_min_residual_partition_order() const;
350
unsigned get_max_residual_partition_order() const;
351
unsigned get_rice_parameter_search_dist() const;
352
FLAC__uint64 get_total_samples_estimate() const;
358
bool process(const FLAC__int32 * const buffer[], unsigned samples);
359
bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
237
virtual ::FLAC__StreamEncoderInitStatus init(FILE *file); ///< See FLAC__stream_encoder_init_FILE()
238
virtual ::FLAC__StreamEncoderInitStatus init(const char *filename); ///< See FLAC__stream_encoder_init_file()
239
virtual ::FLAC__StreamEncoderInitStatus init(const std::string &filename); ///< See FLAC__stream_encoder_init_file()
240
virtual ::FLAC__StreamEncoderInitStatus init_ogg(FILE *file); ///< See FLAC__stream_encoder_init_ogg_FILE()
241
virtual ::FLAC__StreamEncoderInitStatus init_ogg(const char *filename); ///< See FLAC__stream_encoder_init_ogg_file()
242
virtual ::FLAC__StreamEncoderInitStatus init_ogg(const std::string &filename); ///< See FLAC__stream_encoder_init_ogg_file()
244
/// See FLAC__StreamEncoderProgressCallback
361
245
virtual void progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate);
363
#if (defined _MSC_VER) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC)
364
// lame hack: some MSVC/GCC versions can't see a protected encoder_ from nested State::resolved_as_cstring()
367
::FLAC__FileEncoder *encoder_;
247
/// This is a dummy implementation to satisfy the pure virtual in Stream that is actually supplied internally by the C layer
248
virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame);
369
static void progress_callback_(const ::FLAC__FileEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
250
static void progress_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
371
252
// Private and undefined so you can't use them:
372
253
File(const Stream &);
373
254
void operator=(const Stream &);