change libOggFLAC++ API to make OggFLAC::Decoder::Stream and OggFLAC::Encoder::Stream inherit from their FLAC counterparts
This commit is contained in:
parent
edf672ed84
commit
68acb04a4d
@ -124,26 +124,27 @@ namespace FLAC {
|
||||
*
|
||||
* \{
|
||||
*/
|
||||
bool is_valid() const;
|
||||
virtual bool is_valid() const;
|
||||
inline operator bool() const { return is_valid(); }
|
||||
/* \} */
|
||||
|
||||
bool set_md5_checking(bool value); ///< See FLAC__stream_decoder_set_md5_checking()
|
||||
bool set_metadata_respond(::FLAC__MetadataType type); ///< See FLAC__stream_decoder_set_metadata_respond()
|
||||
bool set_metadata_respond_application(const FLAC__byte id[4]); ///< See FLAC__stream_decoder_set_metadata_respond_application()
|
||||
bool set_metadata_respond_all(); ///< See FLAC__stream_decoder_set_metadata_respond_all()
|
||||
bool set_metadata_ignore(::FLAC__MetadataType type); ///< See FLAC__stream_decoder_set_metadata_ignore()
|
||||
bool set_metadata_ignore_application(const FLAC__byte id[4]); ///< See FLAC__stream_decoder_set_metadata_ignore_application()
|
||||
bool set_metadata_ignore_all(); ///< See FLAC__stream_decoder_set_metadata_ignore_all()
|
||||
virtual bool set_md5_checking(bool value); ///< See FLAC__stream_decoder_set_md5_checking()
|
||||
virtual bool set_metadata_respond(::FLAC__MetadataType type); ///< See FLAC__stream_decoder_set_metadata_respond()
|
||||
virtual bool set_metadata_respond_application(const FLAC__byte id[4]); ///< See FLAC__stream_decoder_set_metadata_respond_application()
|
||||
virtual bool set_metadata_respond_all(); ///< See FLAC__stream_decoder_set_metadata_respond_all()
|
||||
virtual bool set_metadata_ignore(::FLAC__MetadataType type); ///< See FLAC__stream_decoder_set_metadata_ignore()
|
||||
virtual bool set_metadata_ignore_application(const FLAC__byte id[4]); ///< See FLAC__stream_decoder_set_metadata_ignore_application()
|
||||
virtual bool set_metadata_ignore_all(); ///< See FLAC__stream_decoder_set_metadata_ignore_all()
|
||||
|
||||
State get_state() const; ///< See FLAC__stream_decoder_get_state()
|
||||
bool get_md5_checking() const; ///< See FLAC__stream_decoder_get_md5_checking()
|
||||
FLAC__uint64 get_total_samples() const; ///< See FLAC__stream_decoder_get_total_samples()
|
||||
unsigned get_channels() const; ///< See FLAC__stream_decoder_get_channels()
|
||||
::FLAC__ChannelAssignment get_channel_assignment() const; ///< See FLAC__stream_decoder_get_channel_assignment()
|
||||
unsigned get_bits_per_sample() const; ///< See FLAC__stream_decoder_get_bits_per_sample()
|
||||
unsigned get_sample_rate() const; ///< See FLAC__stream_decoder_get_sample_rate()
|
||||
unsigned get_blocksize() const; ///< See FLAC__stream_decoder_get_blocksize()
|
||||
/* get_state() is not virtual since we want subclasses to be able to return their own state */
|
||||
State get_state() const; ///< See FLAC__stream_decoder_get_state()
|
||||
virtual bool get_md5_checking() const; ///< See FLAC__stream_decoder_get_md5_checking()
|
||||
virtual FLAC__uint64 get_total_samples() const; ///< See FLAC__stream_decoder_get_total_samples()
|
||||
virtual unsigned get_channels() const; ///< See FLAC__stream_decoder_get_channels()
|
||||
virtual ::FLAC__ChannelAssignment get_channel_assignment() const; ///< See FLAC__stream_decoder_get_channel_assignment()
|
||||
virtual unsigned get_bits_per_sample() const; ///< See FLAC__stream_decoder_get_bits_per_sample()
|
||||
virtual unsigned get_sample_rate() const; ///< See FLAC__stream_decoder_get_sample_rate()
|
||||
virtual unsigned get_blocksize() const; ///< See FLAC__stream_decoder_get_blocksize()
|
||||
|
||||
/** Initialize the instance; as with the C interface,
|
||||
* init() should be called after construction and 'set'
|
||||
@ -151,19 +152,19 @@ namespace FLAC {
|
||||
*
|
||||
* See FLAC__stream_decoder_init_stream().
|
||||
*/
|
||||
::FLAC__StreamDecoderInitStatus init();
|
||||
virtual ::FLAC__StreamDecoderInitStatus init();
|
||||
|
||||
void finish(); ///< See FLAC__stream_decoder_finish()
|
||||
virtual void finish(); ///< See FLAC__stream_decoder_finish()
|
||||
|
||||
bool flush(); ///< See FLAC__stream_decoder_flush()
|
||||
bool reset(); ///< See FLAC__stream_decoder_reset()
|
||||
virtual bool flush(); ///< See FLAC__stream_decoder_flush()
|
||||
virtual bool reset(); ///< See FLAC__stream_decoder_reset()
|
||||
|
||||
bool process_single(); ///< See FLAC__stream_decoder_process_single()
|
||||
bool process_until_end_of_metadata(); ///< See FLAC__stream_decoder_process_until_end_of_metadata()
|
||||
bool process_until_end_of_stream(); ///< See FLAC__stream_decoder_process_until_end_of_stream()
|
||||
bool skip_single_frame(); ///< See FLAC__stream_decoder_skip_single_frame()
|
||||
virtual bool process_single(); ///< See FLAC__stream_decoder_process_single()
|
||||
virtual bool process_until_end_of_metadata(); ///< See FLAC__stream_decoder_process_until_end_of_metadata()
|
||||
virtual bool process_until_end_of_stream(); ///< See FLAC__stream_decoder_process_until_end_of_stream()
|
||||
virtual bool skip_single_frame(); ///< See FLAC__stream_decoder_skip_single_frame()
|
||||
|
||||
bool seek_absolute(FLAC__uint64 sample); ///< See FLAC__stream_decoder_seek_absolute()
|
||||
virtual bool seek_absolute(FLAC__uint64 sample); ///< See FLAC__stream_decoder_seek_absolute()
|
||||
protected:
|
||||
/// see FLAC__StreamDecoderReadCallback
|
||||
virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
|
||||
@ -193,6 +194,9 @@ namespace FLAC {
|
||||
// lame hack: some MSVC/GCC versions can't see a protected decoder_ from nested State::resolved_as_cstring()
|
||||
friend State;
|
||||
#endif
|
||||
// hackery solely for the use of libOggFLAC++
|
||||
Stream(::FLAC__StreamDecoder *);
|
||||
|
||||
::FLAC__StreamDecoder *decoder_;
|
||||
|
||||
static ::FLAC__StreamDecoderReadStatus read_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
|
||||
|
@ -126,51 +126,52 @@ namespace FLAC {
|
||||
*
|
||||
* \{
|
||||
*/
|
||||
bool is_valid() const;
|
||||
virtual bool is_valid() const;
|
||||
inline operator bool() const { return is_valid(); }
|
||||
/* \} */
|
||||
|
||||
bool set_verify(bool value); ///< See FLAC__stream_encoder_set_verify()
|
||||
bool set_streamable_subset(bool value); ///< See FLAC__stream_encoder_set_streamable_subset()
|
||||
bool set_do_mid_side_stereo(bool value); ///< See FLAC__stream_encoder_set_do_mid_side_stereo()
|
||||
bool set_loose_mid_side_stereo(bool value); ///< See FLAC__stream_encoder_set_loose_mid_side_stereo()
|
||||
bool set_channels(unsigned value); ///< See FLAC__stream_encoder_set_channels()
|
||||
bool set_bits_per_sample(unsigned value); ///< See FLAC__stream_encoder_set_bits_per_sample()
|
||||
bool set_sample_rate(unsigned value); ///< See FLAC__stream_encoder_set_sample_rate()
|
||||
bool set_blocksize(unsigned value); ///< See FLAC__stream_encoder_set_blocksize()
|
||||
bool set_apodization(const char *specification); ///< See FLAC__stream_encoder_set_apodization()
|
||||
bool set_max_lpc_order(unsigned value); ///< See FLAC__stream_encoder_set_max_lpc_order()
|
||||
bool set_qlp_coeff_precision(unsigned value); ///< See FLAC__stream_encoder_set_qlp_coeff_precision()
|
||||
bool set_do_qlp_coeff_prec_search(bool value); ///< See FLAC__stream_encoder_set_do_qlp_coeff_prec_search()
|
||||
bool set_do_escape_coding(bool value); ///< See FLAC__stream_encoder_set_do_escape_coding()
|
||||
bool set_do_exhaustive_model_search(bool value); ///< See FLAC__stream_encoder_set_do_exhaustive_model_search()
|
||||
bool set_min_residual_partition_order(unsigned value); ///< See FLAC__stream_encoder_set_min_residual_partition_order()
|
||||
bool set_max_residual_partition_order(unsigned value); ///< See FLAC__stream_encoder_set_max_residual_partition_order()
|
||||
bool set_rice_parameter_search_dist(unsigned value); ///< See FLAC__stream_encoder_set_rice_parameter_search_dist()
|
||||
bool set_total_samples_estimate(FLAC__uint64 value); ///< See FLAC__stream_encoder_set_total_samples_estimate()
|
||||
bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks); ///< See FLAC__stream_encoder_set_metadata()
|
||||
bool set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks); ///< See FLAC__stream_encoder_set_metadata()
|
||||
virtual bool set_verify(bool value); ///< See FLAC__stream_encoder_set_verify()
|
||||
virtual bool set_streamable_subset(bool value); ///< See FLAC__stream_encoder_set_streamable_subset()
|
||||
virtual bool set_do_mid_side_stereo(bool value); ///< See FLAC__stream_encoder_set_do_mid_side_stereo()
|
||||
virtual bool set_loose_mid_side_stereo(bool value); ///< See FLAC__stream_encoder_set_loose_mid_side_stereo()
|
||||
virtual bool set_channels(unsigned value); ///< See FLAC__stream_encoder_set_channels()
|
||||
virtual bool set_bits_per_sample(unsigned value); ///< See FLAC__stream_encoder_set_bits_per_sample()
|
||||
virtual bool set_sample_rate(unsigned value); ///< See FLAC__stream_encoder_set_sample_rate()
|
||||
virtual bool set_blocksize(unsigned value); ///< See FLAC__stream_encoder_set_blocksize()
|
||||
virtual bool set_apodization(const char *specification); ///< See FLAC__stream_encoder_set_apodization()
|
||||
virtual bool set_max_lpc_order(unsigned value); ///< See FLAC__stream_encoder_set_max_lpc_order()
|
||||
virtual bool set_qlp_coeff_precision(unsigned value); ///< See FLAC__stream_encoder_set_qlp_coeff_precision()
|
||||
virtual bool set_do_qlp_coeff_prec_search(bool value); ///< See FLAC__stream_encoder_set_do_qlp_coeff_prec_search()
|
||||
virtual bool set_do_escape_coding(bool value); ///< See FLAC__stream_encoder_set_do_escape_coding()
|
||||
virtual bool set_do_exhaustive_model_search(bool value); ///< See FLAC__stream_encoder_set_do_exhaustive_model_search()
|
||||
virtual bool set_min_residual_partition_order(unsigned value); ///< See FLAC__stream_encoder_set_min_residual_partition_order()
|
||||
virtual bool set_max_residual_partition_order(unsigned value); ///< See FLAC__stream_encoder_set_max_residual_partition_order()
|
||||
virtual bool set_rice_parameter_search_dist(unsigned value); ///< See FLAC__stream_encoder_set_rice_parameter_search_dist()
|
||||
virtual bool set_total_samples_estimate(FLAC__uint64 value); ///< See FLAC__stream_encoder_set_total_samples_estimate()
|
||||
virtual bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks); ///< See FLAC__stream_encoder_set_metadata()
|
||||
virtual bool set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks); ///< See FLAC__stream_encoder_set_metadata()
|
||||
|
||||
State get_state() const; ///< See FLAC__stream_encoder_get_state()
|
||||
Decoder::Stream::State get_verify_decoder_state() const; ///< See FLAC__stream_encoder_get_verify_decoder_state()
|
||||
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()
|
||||
bool get_verify() const; ///< See FLAC__stream_encoder_get_verify()
|
||||
bool get_streamable_subset() const; ///< See FLAC__stream_encoder_get_streamable_subset()
|
||||
bool get_do_mid_side_stereo() const; ///< See FLAC__stream_encoder_get_do_mid_side_stereo()
|
||||
bool get_loose_mid_side_stereo() const; ///< See FLAC__stream_encoder_get_loose_mid_side_stereo()
|
||||
unsigned get_channels() const; ///< See FLAC__stream_encoder_get_channels()
|
||||
unsigned get_bits_per_sample() const; ///< See FLAC__stream_encoder_get_bits_per_sample()
|
||||
unsigned get_sample_rate() const; ///< See FLAC__stream_encoder_get_sample_rate()
|
||||
unsigned get_blocksize() const; ///< See FLAC__stream_encoder_get_blocksize()
|
||||
unsigned get_max_lpc_order() const; ///< See FLAC__stream_encoder_get_max_lpc_order()
|
||||
unsigned get_qlp_coeff_precision() const; ///< See FLAC__stream_encoder_get_qlp_coeff_precision()
|
||||
bool get_do_qlp_coeff_prec_search() const; ///< See FLAC__stream_encoder_get_do_qlp_coeff_prec_search()
|
||||
bool get_do_escape_coding() const; ///< See FLAC__stream_encoder_get_do_escape_coding()
|
||||
bool get_do_exhaustive_model_search() const; ///< See FLAC__stream_encoder_get_do_exhaustive_model_search()
|
||||
unsigned get_min_residual_partition_order() const; ///< See FLAC__stream_encoder_get_min_residual_partition_order()
|
||||
unsigned get_max_residual_partition_order() const; ///< See FLAC__stream_encoder_get_max_residual_partition_order()
|
||||
unsigned get_rice_parameter_search_dist() const; ///< See FLAC__stream_encoder_get_rice_parameter_search_dist()
|
||||
FLAC__uint64 get_total_samples_estimate() const; ///< See FLAC__stream_encoder_get_total_samples_estimate()
|
||||
/* get_state() is not virtual since we want subclasses to be able to return their own state */
|
||||
State get_state() const; ///< See FLAC__stream_encoder_get_state()
|
||||
virtual Decoder::Stream::State get_verify_decoder_state() const; ///< See FLAC__stream_encoder_get_verify_decoder_state()
|
||||
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()
|
||||
virtual bool get_verify() const; ///< See FLAC__stream_encoder_get_verify()
|
||||
virtual bool get_streamable_subset() const; ///< See FLAC__stream_encoder_get_streamable_subset()
|
||||
virtual bool get_do_mid_side_stereo() const; ///< See FLAC__stream_encoder_get_do_mid_side_stereo()
|
||||
virtual bool get_loose_mid_side_stereo() const; ///< See FLAC__stream_encoder_get_loose_mid_side_stereo()
|
||||
virtual unsigned get_channels() const; ///< See FLAC__stream_encoder_get_channels()
|
||||
virtual unsigned get_bits_per_sample() const; ///< See FLAC__stream_encoder_get_bits_per_sample()
|
||||
virtual unsigned get_sample_rate() const; ///< See FLAC__stream_encoder_get_sample_rate()
|
||||
virtual unsigned get_blocksize() const; ///< See FLAC__stream_encoder_get_blocksize()
|
||||
virtual unsigned get_max_lpc_order() const; ///< See FLAC__stream_encoder_get_max_lpc_order()
|
||||
virtual unsigned get_qlp_coeff_precision() const; ///< See FLAC__stream_encoder_get_qlp_coeff_precision()
|
||||
virtual bool get_do_qlp_coeff_prec_search() const; ///< See FLAC__stream_encoder_get_do_qlp_coeff_prec_search()
|
||||
virtual bool get_do_escape_coding() const; ///< See FLAC__stream_encoder_get_do_escape_coding()
|
||||
virtual bool get_do_exhaustive_model_search() const; ///< See FLAC__stream_encoder_get_do_exhaustive_model_search()
|
||||
virtual unsigned get_min_residual_partition_order() const; ///< See FLAC__stream_encoder_get_min_residual_partition_order()
|
||||
virtual unsigned get_max_residual_partition_order() const; ///< See FLAC__stream_encoder_get_max_residual_partition_order()
|
||||
virtual unsigned get_rice_parameter_search_dist() const; ///< See FLAC__stream_encoder_get_rice_parameter_search_dist()
|
||||
virtual FLAC__uint64 get_total_samples_estimate() const; ///< See FLAC__stream_encoder_get_total_samples_estimate()
|
||||
|
||||
/** Initialize the instance; as with the C interface,
|
||||
* init() should be called after construction and 'set'
|
||||
@ -178,12 +179,12 @@ namespace FLAC {
|
||||
*
|
||||
* See FLAC__stream_encoder_init_stream().
|
||||
*/
|
||||
::FLAC__StreamEncoderInitStatus init();
|
||||
virtual ::FLAC__StreamEncoderInitStatus init();
|
||||
|
||||
void finish(); ///< See FLAC__stream_encoder_finish()
|
||||
virtual void finish(); ///< See FLAC__stream_encoder_finish()
|
||||
|
||||
bool process(const FLAC__int32 * const buffer[], unsigned samples); ///< See FLAC__stream_encoder_process()
|
||||
bool process_interleaved(const FLAC__int32 buffer[], unsigned samples); ///< See FLAC__stream_encoder_process_interleaved()
|
||||
virtual bool process(const FLAC__int32 * const buffer[], unsigned samples); ///< See FLAC__stream_encoder_process()
|
||||
virtual bool process_interleaved(const FLAC__int32 buffer[], unsigned samples); ///< See FLAC__stream_encoder_process_interleaved()
|
||||
protected:
|
||||
/// See FLAC__StreamEncoderWriteCallback
|
||||
virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
|
||||
@ -201,6 +202,9 @@ namespace FLAC {
|
||||
// lame hack: some MSVC/GCC versions can't see a protected encoder_ from nested State::resolved_as_cstring()
|
||||
friend State;
|
||||
#endif
|
||||
// hackery solely for the use of libOggFLAC++
|
||||
Stream(::FLAC__StreamEncoder *);
|
||||
|
||||
::FLAC__StreamEncoder *encoder_;
|
||||
|
||||
static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
|
||||
|
@ -278,6 +278,11 @@
|
||||
* two new convenience functions that may be useful:
|
||||
* FLAC__metadata_object_cuesheet_calculate_cddb_id() and
|
||||
* FLAC__metadata_get_cuesheet().
|
||||
*
|
||||
* In libOggFLAC++, OggFLAC::Decoder::Stream now inherits from
|
||||
* FLAC::Decoder::Stream and OggFLAC::Encoder::Stream now inherits from
|
||||
* FLAC::Encoder::Stream, which means both OggFLAC and FLAC can be
|
||||
* supported by using common code for everything after initialization.
|
||||
*/
|
||||
|
||||
/** \defgroup flac FLAC C API
|
||||
|
@ -71,6 +71,37 @@
|
||||
* used, and OggFLAC::Decoder::File is used for the same cases that
|
||||
* OggFLAC__stream_decoder_init_FILE() and OggFLAC__stream_decoder_init_file()
|
||||
* are used.
|
||||
*
|
||||
* Note that OggFLAC::Decoder::Stream inherits from FLAC::Decoder::Stream so
|
||||
* it is possible to support both FLAC and Ogg FLAC decoding with only a
|
||||
* little specialized code (just up to initialization). For example,
|
||||
* \code
|
||||
* class MyFLACDecoder: public FLAC::Decoder::Stream
|
||||
* {
|
||||
* // implement callbacks
|
||||
* };
|
||||
* FLAC::Decoder::Stream *flac = new MyFLACDecoder();
|
||||
* if(*flac) {
|
||||
* flac->set_...();
|
||||
* // continue set_ calls()
|
||||
* if(flac->init() == ::FLAC__STREAM_DECODER_INIT_STATUS_OK)
|
||||
* my_process_stream(flac);
|
||||
* }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* class MyOggFLACDecoder: public OggFLAC::Decoder::Stream
|
||||
* {
|
||||
* // implement callbacks
|
||||
* };
|
||||
* FLAC::Decoder::Stream *oggflac = new MyOggFLACDecoder();
|
||||
* if(*oggflac) {
|
||||
* oggflac->set_serial_number();
|
||||
* // continue set_ calls()
|
||||
* if(oggflac->init() == ::FLAC__STREAM_DECODER_INIT_STATUS_OK)
|
||||
* my_process_stream(oggflac);
|
||||
* }
|
||||
* \endcode
|
||||
*/
|
||||
|
||||
namespace OggFLAC {
|
||||
@ -105,14 +136,14 @@ namespace OggFLAC {
|
||||
* you must overide seek_callback(), tell_callback(),
|
||||
* length_callback(), and eof_callback().
|
||||
*/
|
||||
class OggFLACPP_API Stream {
|
||||
class OggFLACPP_API Stream: public FLAC::Decoder::Stream {
|
||||
public:
|
||||
class OggFLACPP_API State {
|
||||
public:
|
||||
inline State(::OggFLAC__StreamDecoderState state): state_(state) { }
|
||||
inline operator ::OggFLAC__StreamDecoderState() const { return state_; }
|
||||
inline const char *as_cstring() const { return ::OggFLAC__StreamDecoderStateString[state_]; }
|
||||
inline const char *resolved_as_cstring(const Stream &decoder) const { return ::OggFLAC__stream_decoder_get_resolved_state_string(decoder.decoder_); }
|
||||
inline const char *resolved_as_cstring(const Stream &decoder) const { return ::OggFLAC__stream_decoder_get_resolved_state_string((const OggFLAC__StreamDecoder*)decoder.decoder_); }
|
||||
protected:
|
||||
::OggFLAC__StreamDecoderState state_;
|
||||
};
|
||||
@ -120,15 +151,6 @@ namespace OggFLAC {
|
||||
Stream();
|
||||
virtual ~Stream();
|
||||
|
||||
/** Call after construction to check the that the object was created
|
||||
* successfully. If not, use get_state() to find out why not.
|
||||
*
|
||||
* \{
|
||||
*/
|
||||
bool is_valid() const;
|
||||
inline operator bool() const { return is_valid(); }
|
||||
/* \} */
|
||||
|
||||
bool set_serial_number(long value); ///< See OggFLAC__stream_decoder_set_serial_number()
|
||||
bool set_md5_checking(bool value); ///< See OggFLAC__stream_decoder_set_md5_checking()
|
||||
bool set_metadata_respond(::FLAC__MetadataType type); ///< See OggFLAC__stream_decoder_set_metadata_respond()
|
||||
@ -168,44 +190,10 @@ namespace OggFLAC {
|
||||
|
||||
bool seek_absolute(FLAC__uint64 sample); ///< See OggFLAC__stream_decoder_seek_absolute()
|
||||
protected:
|
||||
/// see FLAC__StreamDecoderReadCallback
|
||||
virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
|
||||
|
||||
/// see FLAC__StreamDecoderSeekCallback
|
||||
virtual ::FLAC__StreamDecoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset);
|
||||
|
||||
/// see FLAC__StreamDecoderTellCallback
|
||||
virtual ::FLAC__StreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset);
|
||||
|
||||
/// see FLAC__StreamDecoderLengthCallback
|
||||
virtual ::FLAC__StreamDecoderLengthStatus length_callback(FLAC__uint64 *stream_length);
|
||||
|
||||
/// see FLAC__StreamDecoderEofCallback
|
||||
virtual bool eof_callback();
|
||||
|
||||
/// see FLAC__StreamDecoderWriteCallback
|
||||
virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
|
||||
|
||||
/// see FLAC__StreamDecoderMetadataCallback
|
||||
virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata);
|
||||
|
||||
/// see FLAC__StreamDecoderErrorCallback
|
||||
virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
|
||||
|
||||
#if (defined _MSC_VER) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC)
|
||||
// lame hack: some MSVC/GCC versions can't see a protected decoder_ from nested State::resolved_as_cstring()
|
||||
friend State;
|
||||
#endif
|
||||
::OggFLAC__StreamDecoder *decoder_;
|
||||
|
||||
static ::FLAC__StreamDecoderReadStatus read_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
|
||||
static ::FLAC__StreamDecoderSeekStatus seek_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
|
||||
static ::FLAC__StreamDecoderTellStatus tell_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
|
||||
static ::FLAC__StreamDecoderLengthStatus length_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
|
||||
static FLAC__bool eof_callback_(const ::FLAC__StreamDecoder *decoder, void *client_data);
|
||||
static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
|
||||
static void metadata_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
|
||||
static void error_callback_(const ::FLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
|
||||
private:
|
||||
// Private and undefined so you can't use them:
|
||||
Stream(const Stream &);
|
||||
|
@ -73,6 +73,37 @@
|
||||
* used, and OggFLAC::Encoder::File is used for the same cases that
|
||||
* OggFLAC__stream_encoder_init_FILE() and OggFLAC__stream_encoder_init_file()
|
||||
* are used.
|
||||
*
|
||||
* Note that OggFLAC::Encoder::Stream inherits from FLAC::Encoder::Stream so
|
||||
* it is possible to support both FLAC and Ogg FLAC encoding with only a
|
||||
* little specialized code (just up to initialization). For example,
|
||||
* \code
|
||||
* class MyFLACEncoder: public FLAC::Encoder::Stream
|
||||
* {
|
||||
* // implement callbacks
|
||||
* };
|
||||
* FLAC::Encoder::Stream *flac = new MyFLACEncoder();
|
||||
* if(*flac) {
|
||||
* flac->set_...();
|
||||
* // continue set_ calls()
|
||||
* if(flac->init() == ::FLAC__STREAM_ENCODER_INIT_STATUS_OK)
|
||||
* my_process_stream(flac);
|
||||
* }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* class MyOggFLACEncoder: public OggFLAC::Encoder::Stream
|
||||
* {
|
||||
* // implement callbacks
|
||||
* };
|
||||
* FLAC::Encoder::Stream *oggflac = new MyOggFLACEncoder();
|
||||
* if(*oggflac) {
|
||||
* oggflac->set_serial_number();
|
||||
* // continue set_ calls()
|
||||
* if(oggflac->init() == ::FLAC__STREAM_ENCODER_INIT_STATUS_OK)
|
||||
* my_process_stream(oggflac);
|
||||
* }
|
||||
* \endcode
|
||||
*/
|
||||
|
||||
namespace OggFLAC {
|
||||
@ -108,14 +139,14 @@ namespace OggFLAC {
|
||||
* tell_callback(); see OggFLAC__stream_encoder_init_stream() as to
|
||||
* why.
|
||||
*/
|
||||
class OggFLACPP_API Stream {
|
||||
class OggFLACPP_API Stream: public FLAC::Encoder::Stream {
|
||||
public:
|
||||
class OggFLACPP_API State {
|
||||
public:
|
||||
inline State(::OggFLAC__StreamEncoderState state): state_(state) { }
|
||||
inline operator ::OggFLAC__StreamEncoderState() const { return state_; }
|
||||
inline const char *as_cstring() const { return ::OggFLAC__StreamEncoderStateString[state_]; }
|
||||
inline const char *resolved_as_cstring(const Stream &encoder) const { return ::OggFLAC__stream_encoder_get_resolved_state_string(encoder.encoder_); }
|
||||
inline const char *resolved_as_cstring(const Stream &encoder) const { return ::OggFLAC__stream_encoder_get_resolved_state_string((const OggFLAC__StreamEncoder*)encoder.encoder_); }
|
||||
protected:
|
||||
::OggFLAC__StreamEncoderState state_;
|
||||
};
|
||||
@ -123,15 +154,6 @@ namespace OggFLAC {
|
||||
Stream();
|
||||
virtual ~Stream();
|
||||
|
||||
/** Call after construction to check the that the object was created
|
||||
* successfully. If not, use get_state() to find out why not.
|
||||
*
|
||||
* \{
|
||||
*/
|
||||
bool is_valid() const;
|
||||
inline operator bool() const { return is_valid(); }
|
||||
/* \} */
|
||||
|
||||
bool set_serial_number(long value); ///< See OggFLAC__stream_encoder_set_serial_number()
|
||||
bool set_verify(bool value); ///< See OggFLAC__stream_encoder_set_verify()
|
||||
bool set_streamable_subset(bool value); ///< See OggFLAC__stream_encoder_set_streamable_subset()
|
||||
@ -192,29 +214,11 @@ namespace OggFLAC {
|
||||
/// See OggFLAC__StreamEncoderReadCallback
|
||||
virtual ::OggFLAC__StreamEncoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes);
|
||||
|
||||
/// See FLAC__StreamEncoderWriteCallback
|
||||
virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
|
||||
|
||||
/// See FLAC__StreamEncoderSeekCallback
|
||||
virtual ::FLAC__StreamEncoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset);
|
||||
|
||||
/// See FLAC__StreamEncoderTellCallback
|
||||
virtual ::FLAC__StreamEncoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset);
|
||||
|
||||
/// See FLAC__StreamEncoderTellCallback
|
||||
virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata);
|
||||
|
||||
#if (defined _MSC_VER) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC)
|
||||
// lame hack: some MSVC/GCC versions can't see a protected encoder_ from nested State::resolved_as_cstring()
|
||||
friend State;
|
||||
#endif
|
||||
::OggFLAC__StreamEncoder *encoder_;
|
||||
|
||||
static ::OggFLAC__StreamEncoderReadStatus read_callback_(const ::OggFLAC__StreamEncoder *encoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
|
||||
static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
|
||||
static ::FLAC__StreamEncoderSeekStatus seek_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
|
||||
static ::FLAC__StreamEncoderTellStatus tell_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
|
||||
static void metadata_callback_(const ::FLAC__StreamEncoder *encoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
|
||||
private:
|
||||
// Private and undefined so you can't use them:
|
||||
Stream(const Stream &);
|
||||
|
@ -44,8 +44,18 @@ namespace FLAC {
|
||||
decoder_(::FLAC__stream_decoder_new())
|
||||
{ }
|
||||
|
||||
Stream::Stream(::FLAC__StreamDecoder *decoder):
|
||||
decoder_(decoder)
|
||||
{ }
|
||||
|
||||
Stream::~Stream()
|
||||
{
|
||||
// WATCHOUT: must check for NULL not only because
|
||||
// ::FLAC__stream_encoder_new() might have failed in
|
||||
// the constructor, but also because
|
||||
// OggFLAC::Encoder::Stream deletes the encoder_ before
|
||||
// we get to it here to make the C inheritance magic
|
||||
// work.
|
||||
if(0 != decoder_) {
|
||||
::FLAC__stream_decoder_finish(decoder_);
|
||||
::FLAC__stream_decoder_delete(decoder_);
|
||||
|
@ -45,8 +45,18 @@ namespace FLAC {
|
||||
encoder_(::FLAC__stream_encoder_new())
|
||||
{ }
|
||||
|
||||
Stream::Stream(::FLAC__StreamEncoder *encoder):
|
||||
encoder_(encoder)
|
||||
{ }
|
||||
|
||||
Stream::~Stream()
|
||||
{
|
||||
// WATCHOUT: must check for NULL not only because
|
||||
// ::FLAC__stream_encoder_new() might have failed in
|
||||
// the constructor, but also because
|
||||
// OggFLAC::Encoder::Stream deletes the encoder_ before
|
||||
// we get to it here to make the C inheritance magic
|
||||
// work.
|
||||
if(0 != encoder_) {
|
||||
::FLAC__stream_encoder_finish(encoder_);
|
||||
::FLAC__stream_encoder_delete(encoder_);
|
||||
|
@ -51,13 +51,13 @@ namespace OggFLAC {
|
||||
::FLAC__StreamDecoderInitStatus File::init(FILE *file)
|
||||
{
|
||||
FLAC__ASSERT(0 != decoder_);
|
||||
return ::OggFLAC__stream_decoder_init_FILE(decoder_, file, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this);
|
||||
return ::OggFLAC__stream_decoder_init_FILE((OggFLAC__StreamDecoder*)decoder_, file, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this);
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderInitStatus File::init(const char *filename)
|
||||
{
|
||||
FLAC__ASSERT(0 != decoder_);
|
||||
return ::OggFLAC__stream_decoder_init_file(decoder_, filename, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this);
|
||||
return ::OggFLAC__stream_decoder_init_file((OggFLAC__StreamDecoder*)decoder_, filename, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this);
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderInitStatus File::init(const std::string &filename)
|
||||
|
@ -45,19 +45,18 @@ namespace OggFLAC {
|
||||
{ }
|
||||
|
||||
File::~File()
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
::FLAC__StreamEncoderInitStatus File::init(FILE *file)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_encoder_init_FILE(encoder_, file, progress_callback_, /*client_data=*/(void*)this);
|
||||
return ::OggFLAC__stream_encoder_init_FILE((OggFLAC__StreamEncoder*)encoder_, file, progress_callback_, /*client_data=*/(void*)this);
|
||||
}
|
||||
|
||||
::FLAC__StreamEncoderInitStatus File::init(const char *filename)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_encoder_init_file(encoder_, filename, progress_callback_, /*client_data=*/(void*)this);
|
||||
return ::OggFLAC__stream_encoder_init_file((OggFLAC__StreamEncoder*)encoder_, filename, progress_callback_, /*client_data=*/(void*)this);
|
||||
}
|
||||
|
||||
::FLAC__StreamEncoderInitStatus File::init(const std::string &filename)
|
||||
|
@ -40,277 +40,180 @@
|
||||
namespace OggFLAC {
|
||||
namespace Decoder {
|
||||
|
||||
// We can inherit from FLAC::Decoder::Stream because we jam a
|
||||
// OggFLAC__StreamDecoder pointer into the decoder_ member,
|
||||
// hence the pointer casting on decoder_ everywhere.
|
||||
|
||||
Stream::Stream():
|
||||
decoder_(::OggFLAC__stream_decoder_new())
|
||||
FLAC::Decoder::Stream((FLAC__StreamDecoder*)::OggFLAC__stream_decoder_new())
|
||||
{ }
|
||||
|
||||
Stream::~Stream()
|
||||
{
|
||||
if(0 != decoder_) {
|
||||
::OggFLAC__stream_decoder_finish(decoder_);
|
||||
::OggFLAC__stream_decoder_delete(decoder_);
|
||||
::OggFLAC__stream_decoder_finish((OggFLAC__StreamDecoder*)decoder_);
|
||||
::OggFLAC__stream_decoder_delete((OggFLAC__StreamDecoder*)decoder_);
|
||||
// this is our signal to FLAC::Decoder::Stream::~Stream()
|
||||
// that we already deleted the decoder our way, so it
|
||||
// doesn't need to:
|
||||
decoder_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool Stream::is_valid() const
|
||||
{
|
||||
return 0 != decoder_;
|
||||
}
|
||||
|
||||
bool Stream::set_md5_checking(bool value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_decoder_set_md5_checking(decoder_, value);
|
||||
return (bool)::OggFLAC__stream_decoder_set_md5_checking((OggFLAC__StreamDecoder*)decoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_serial_number(long value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_decoder_set_serial_number(decoder_, value);
|
||||
return (bool)::OggFLAC__stream_decoder_set_serial_number((OggFLAC__StreamDecoder*)decoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_metadata_respond(::FLAC__MetadataType type)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_decoder_set_metadata_respond(decoder_, type);
|
||||
return (bool)::OggFLAC__stream_decoder_set_metadata_respond((OggFLAC__StreamDecoder*)decoder_, type);
|
||||
}
|
||||
|
||||
bool Stream::set_metadata_respond_application(const FLAC__byte id[4])
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_decoder_set_metadata_respond_application(decoder_, id);
|
||||
return (bool)::OggFLAC__stream_decoder_set_metadata_respond_application((OggFLAC__StreamDecoder*)decoder_, id);
|
||||
}
|
||||
|
||||
bool Stream::set_metadata_respond_all()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_decoder_set_metadata_respond_all(decoder_);
|
||||
return (bool)::OggFLAC__stream_decoder_set_metadata_respond_all((OggFLAC__StreamDecoder*)decoder_);
|
||||
}
|
||||
|
||||
bool Stream::set_metadata_ignore(::FLAC__MetadataType type)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_decoder_set_metadata_ignore(decoder_, type);
|
||||
return (bool)::OggFLAC__stream_decoder_set_metadata_ignore((OggFLAC__StreamDecoder*)decoder_, type);
|
||||
}
|
||||
|
||||
bool Stream::set_metadata_ignore_application(const FLAC__byte id[4])
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_decoder_set_metadata_ignore_application(decoder_, id);
|
||||
return (bool)::OggFLAC__stream_decoder_set_metadata_ignore_application((OggFLAC__StreamDecoder*)decoder_, id);
|
||||
}
|
||||
|
||||
bool Stream::set_metadata_ignore_all()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_decoder_set_metadata_ignore_all(decoder_);
|
||||
return (bool)::OggFLAC__stream_decoder_set_metadata_ignore_all((OggFLAC__StreamDecoder*)decoder_);
|
||||
}
|
||||
|
||||
Stream::State Stream::get_state() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return State(::OggFLAC__stream_decoder_get_state(decoder_));
|
||||
return State(::OggFLAC__stream_decoder_get_state((const OggFLAC__StreamDecoder*)decoder_));
|
||||
}
|
||||
|
||||
FLAC::Decoder::Stream::State Stream::get_FLAC_stream_decoder_state() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return FLAC::Decoder::Stream::State(::OggFLAC__stream_decoder_get_FLAC_stream_decoder_state(decoder_));
|
||||
return FLAC::Decoder::Stream::State(::OggFLAC__stream_decoder_get_FLAC_stream_decoder_state((const OggFLAC__StreamDecoder*)decoder_));
|
||||
}
|
||||
|
||||
bool Stream::get_md5_checking() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_decoder_get_md5_checking(decoder_);
|
||||
return (bool)::OggFLAC__stream_decoder_get_md5_checking((const OggFLAC__StreamDecoder*)decoder_);
|
||||
}
|
||||
|
||||
FLAC__uint64 Stream::get_total_samples() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_decoder_get_total_samples(decoder_);
|
||||
return ::OggFLAC__stream_decoder_get_total_samples((const OggFLAC__StreamDecoder*)decoder_);
|
||||
}
|
||||
|
||||
unsigned Stream::get_channels() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_decoder_get_channels(decoder_);
|
||||
return ::OggFLAC__stream_decoder_get_channels((const OggFLAC__StreamDecoder*)decoder_);
|
||||
}
|
||||
|
||||
::FLAC__ChannelAssignment Stream::get_channel_assignment() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_decoder_get_channel_assignment(decoder_);
|
||||
return ::OggFLAC__stream_decoder_get_channel_assignment((const OggFLAC__StreamDecoder*)decoder_);
|
||||
}
|
||||
|
||||
unsigned Stream::get_bits_per_sample() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_decoder_get_bits_per_sample(decoder_);
|
||||
return ::OggFLAC__stream_decoder_get_bits_per_sample((const OggFLAC__StreamDecoder*)decoder_);
|
||||
}
|
||||
|
||||
unsigned Stream::get_sample_rate() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_decoder_get_sample_rate(decoder_);
|
||||
return ::OggFLAC__stream_decoder_get_sample_rate((const OggFLAC__StreamDecoder*)decoder_);
|
||||
}
|
||||
|
||||
unsigned Stream::get_blocksize() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_decoder_get_blocksize(decoder_);
|
||||
return ::OggFLAC__stream_decoder_get_blocksize((const OggFLAC__StreamDecoder*)decoder_);
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderInitStatus Stream::init()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_decoder_init_stream(decoder_, read_callback_, seek_callback_, tell_callback_, length_callback_, eof_callback_, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this);
|
||||
return ::OggFLAC__stream_decoder_init_stream((OggFLAC__StreamDecoder*)decoder_, read_callback_, seek_callback_, tell_callback_, length_callback_, eof_callback_, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this);
|
||||
}
|
||||
|
||||
void Stream::finish()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
::OggFLAC__stream_decoder_finish(decoder_);
|
||||
::OggFLAC__stream_decoder_finish((OggFLAC__StreamDecoder*)decoder_);
|
||||
}
|
||||
|
||||
bool Stream::flush()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_decoder_flush(decoder_);
|
||||
return (bool)::OggFLAC__stream_decoder_flush((OggFLAC__StreamDecoder*)decoder_);
|
||||
}
|
||||
|
||||
bool Stream::reset()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_decoder_reset(decoder_);
|
||||
return (bool)::OggFLAC__stream_decoder_reset((OggFLAC__StreamDecoder*)decoder_);
|
||||
}
|
||||
|
||||
bool Stream::process_single()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_decoder_process_single(decoder_);
|
||||
return (bool)::OggFLAC__stream_decoder_process_single((OggFLAC__StreamDecoder*)decoder_);
|
||||
}
|
||||
|
||||
bool Stream::process_until_end_of_metadata()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_decoder_process_until_end_of_metadata(decoder_);
|
||||
return (bool)::OggFLAC__stream_decoder_process_until_end_of_metadata((OggFLAC__StreamDecoder*)decoder_);
|
||||
}
|
||||
|
||||
bool Stream::process_until_end_of_stream()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_decoder_process_until_end_of_stream(decoder_);
|
||||
return (bool)::OggFLAC__stream_decoder_process_until_end_of_stream((OggFLAC__StreamDecoder*)decoder_);
|
||||
}
|
||||
|
||||
bool Stream::skip_single_frame()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_decoder_skip_single_frame(decoder_);
|
||||
return (bool)::OggFLAC__stream_decoder_skip_single_frame((OggFLAC__StreamDecoder*)decoder_);
|
||||
}
|
||||
|
||||
bool Stream::seek_absolute(FLAC__uint64 sample)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_decoder_seek_absolute(decoder_, sample);
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderSeekStatus Stream::seek_callback(FLAC__uint64 absolute_byte_offset)
|
||||
{
|
||||
(void)absolute_byte_offset;
|
||||
return ::FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderTellStatus Stream::tell_callback(FLAC__uint64 *absolute_byte_offset)
|
||||
{
|
||||
(void)absolute_byte_offset;
|
||||
return ::FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderLengthStatus Stream::length_callback(FLAC__uint64 *stream_length)
|
||||
{
|
||||
(void)stream_length;
|
||||
return ::FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
bool Stream::eof_callback()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void Stream::metadata_callback(const ::FLAC__StreamMetadata *metadata)
|
||||
{
|
||||
(void)metadata;
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderReadStatus Stream::read_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data)
|
||||
{
|
||||
(void)decoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
return instance->read_callback(buffer, bytes);
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderSeekStatus Stream::seek_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data)
|
||||
{
|
||||
(void) decoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
return instance->seek_callback(absolute_byte_offset);
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderTellStatus Stream::tell_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data)
|
||||
{
|
||||
(void) decoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
return instance->tell_callback(absolute_byte_offset);
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderLengthStatus Stream::length_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data)
|
||||
{
|
||||
(void) decoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
return instance->length_callback(stream_length);
|
||||
}
|
||||
|
||||
FLAC__bool Stream::eof_callback_(const ::FLAC__StreamDecoder *decoder, void *client_data)
|
||||
{
|
||||
(void) decoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
return instance->eof_callback();
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderWriteStatus Stream::write_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
|
||||
{
|
||||
(void)decoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
return instance->write_callback(frame, buffer);
|
||||
}
|
||||
|
||||
void Stream::metadata_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data)
|
||||
{
|
||||
(void)decoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
instance->metadata_callback(metadata);
|
||||
}
|
||||
|
||||
void Stream::error_callback_(const ::FLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data)
|
||||
{
|
||||
(void)decoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
instance->error_callback(status);
|
||||
return (bool)::OggFLAC__stream_decoder_seek_absolute((OggFLAC__StreamDecoder*)decoder_, sample);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,141 +40,144 @@
|
||||
namespace OggFLAC {
|
||||
namespace Encoder {
|
||||
|
||||
// We can inherit from FLAC::Encoder::Stream because we jam a
|
||||
// OggFLAC__StreamEncoder pointer into the encoder_ member,
|
||||
// hence the pointer casting on encoder_ everywhere.
|
||||
|
||||
Stream::Stream():
|
||||
encoder_(::OggFLAC__stream_encoder_new())
|
||||
FLAC::Encoder::Stream((FLAC__StreamEncoder*)::OggFLAC__stream_encoder_new())
|
||||
{ }
|
||||
|
||||
Stream::~Stream()
|
||||
{
|
||||
if(0 != encoder_) {
|
||||
::OggFLAC__stream_encoder_finish(encoder_);
|
||||
::OggFLAC__stream_encoder_delete(encoder_);
|
||||
::OggFLAC__stream_encoder_finish((OggFLAC__StreamEncoder*)encoder_);
|
||||
::OggFLAC__stream_encoder_delete((OggFLAC__StreamEncoder*)encoder_);
|
||||
// this is our signal to FLAC::Encoder::Stream::~Stream()
|
||||
// that we already deleted the encoder our way, so it
|
||||
// doesn't need to:
|
||||
encoder_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool Stream::is_valid() const
|
||||
{
|
||||
return 0 != encoder_;
|
||||
}
|
||||
|
||||
bool Stream::set_serial_number(long value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_serial_number(encoder_, value);
|
||||
return (bool)::OggFLAC__stream_encoder_set_serial_number((OggFLAC__StreamEncoder*)encoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_verify(bool value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_verify(encoder_, value);
|
||||
return (bool)::OggFLAC__stream_encoder_set_verify((OggFLAC__StreamEncoder*)encoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_streamable_subset(bool value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_streamable_subset(encoder_, value);
|
||||
return (bool)::OggFLAC__stream_encoder_set_streamable_subset((OggFLAC__StreamEncoder*)encoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_do_mid_side_stereo(bool value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_do_mid_side_stereo(encoder_, value);
|
||||
return (bool)::OggFLAC__stream_encoder_set_do_mid_side_stereo((OggFLAC__StreamEncoder*)encoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_loose_mid_side_stereo(bool value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_loose_mid_side_stereo(encoder_, value);
|
||||
return (bool)::OggFLAC__stream_encoder_set_loose_mid_side_stereo((OggFLAC__StreamEncoder*)encoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_channels(unsigned value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_channels(encoder_, value);
|
||||
return (bool)::OggFLAC__stream_encoder_set_channels((OggFLAC__StreamEncoder*)encoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_bits_per_sample(unsigned value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_bits_per_sample(encoder_, value);
|
||||
return (bool)::OggFLAC__stream_encoder_set_bits_per_sample((OggFLAC__StreamEncoder*)encoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_sample_rate(unsigned value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_sample_rate(encoder_, value);
|
||||
return (bool)::OggFLAC__stream_encoder_set_sample_rate((OggFLAC__StreamEncoder*)encoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_blocksize(unsigned value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_blocksize(encoder_, value);
|
||||
return (bool)::OggFLAC__stream_encoder_set_blocksize((OggFLAC__StreamEncoder*)encoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_apodization(const char *specification)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_apodization(encoder_, specification);
|
||||
return (bool)::OggFLAC__stream_encoder_set_apodization((OggFLAC__StreamEncoder*)encoder_, specification);
|
||||
}
|
||||
|
||||
bool Stream::set_max_lpc_order(unsigned value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_max_lpc_order(encoder_, value);
|
||||
return (bool)::OggFLAC__stream_encoder_set_max_lpc_order((OggFLAC__StreamEncoder*)encoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_qlp_coeff_precision(unsigned value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_qlp_coeff_precision(encoder_, value);
|
||||
return (bool)::OggFLAC__stream_encoder_set_qlp_coeff_precision((OggFLAC__StreamEncoder*)encoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_do_qlp_coeff_prec_search(bool value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_do_qlp_coeff_prec_search(encoder_, value);
|
||||
return (bool)::OggFLAC__stream_encoder_set_do_qlp_coeff_prec_search((OggFLAC__StreamEncoder*)encoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_do_escape_coding(bool value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_do_escape_coding(encoder_, value);
|
||||
return (bool)::OggFLAC__stream_encoder_set_do_escape_coding((OggFLAC__StreamEncoder*)encoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_do_exhaustive_model_search(bool value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_do_exhaustive_model_search(encoder_, value);
|
||||
return (bool)::OggFLAC__stream_encoder_set_do_exhaustive_model_search((OggFLAC__StreamEncoder*)encoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_min_residual_partition_order(unsigned value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_min_residual_partition_order(encoder_, value);
|
||||
return (bool)::OggFLAC__stream_encoder_set_min_residual_partition_order((OggFLAC__StreamEncoder*)encoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_max_residual_partition_order(unsigned value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_max_residual_partition_order(encoder_, value);
|
||||
return (bool)::OggFLAC__stream_encoder_set_max_residual_partition_order((OggFLAC__StreamEncoder*)encoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_rice_parameter_search_dist(unsigned value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_rice_parameter_search_dist(encoder_, value);
|
||||
return (bool)::OggFLAC__stream_encoder_set_rice_parameter_search_dist((OggFLAC__StreamEncoder*)encoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_total_samples_estimate(FLAC__uint64 value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_total_samples_estimate(encoder_, value);
|
||||
return (bool)::OggFLAC__stream_encoder_set_total_samples_estimate((OggFLAC__StreamEncoder*)encoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_set_metadata(encoder_, metadata, num_blocks);
|
||||
return (bool)::OggFLAC__stream_encoder_set_metadata((OggFLAC__StreamEncoder*)encoder_, metadata, num_blocks);
|
||||
}
|
||||
|
||||
bool Stream::set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks)
|
||||
@ -194,162 +197,162 @@ namespace OggFLAC {
|
||||
}
|
||||
#if (defined _MSC_VER) || (defined __SUNPRO_CC)
|
||||
// complete the hack
|
||||
const bool ok = (bool)::OggFLAC__stream_encoder_set_metadata(encoder_, m, num_blocks);
|
||||
const bool ok = (bool)::OggFLAC__stream_encoder_set_metadata((OggFLAC__StreamEncoder*)encoder_, m, num_blocks);
|
||||
delete [] m;
|
||||
return ok;
|
||||
#else
|
||||
return (bool)::OggFLAC__stream_encoder_set_metadata(encoder_, m, num_blocks);
|
||||
return (bool)::OggFLAC__stream_encoder_set_metadata((OggFLAC__StreamEncoder*)encoder_, m, num_blocks);
|
||||
#endif
|
||||
}
|
||||
|
||||
Stream::State Stream::get_state() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return State(::OggFLAC__stream_encoder_get_state(encoder_));
|
||||
return State(::OggFLAC__stream_encoder_get_state((const OggFLAC__StreamEncoder*)encoder_));
|
||||
}
|
||||
|
||||
FLAC::Encoder::Stream::State Stream::get_FLAC_stream_encoder_state() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return FLAC::Encoder::Stream::State(::OggFLAC__stream_encoder_get_FLAC_stream_encoder_state(encoder_));
|
||||
return FLAC::Encoder::Stream::State(::OggFLAC__stream_encoder_get_FLAC_stream_encoder_state((const OggFLAC__StreamEncoder*)encoder_));
|
||||
}
|
||||
|
||||
FLAC::Decoder::Stream::State Stream::get_verify_decoder_state() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return FLAC::Decoder::Stream::State(::OggFLAC__stream_encoder_get_verify_decoder_state(encoder_));
|
||||
return FLAC::Decoder::Stream::State(::OggFLAC__stream_encoder_get_verify_decoder_state((const OggFLAC__StreamEncoder*)encoder_));
|
||||
}
|
||||
|
||||
void Stream::get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
::OggFLAC__stream_encoder_get_verify_decoder_error_stats(encoder_, absolute_sample, frame_number, channel, sample, expected, got);
|
||||
::OggFLAC__stream_encoder_get_verify_decoder_error_stats((const OggFLAC__StreamEncoder*)encoder_, absolute_sample, frame_number, channel, sample, expected, got);
|
||||
}
|
||||
|
||||
bool Stream::get_verify() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_get_verify(encoder_);
|
||||
return (bool)::OggFLAC__stream_encoder_get_verify((const OggFLAC__StreamEncoder*)encoder_);
|
||||
}
|
||||
|
||||
bool Stream::get_streamable_subset() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_get_streamable_subset(encoder_);
|
||||
return (bool)::OggFLAC__stream_encoder_get_streamable_subset((const OggFLAC__StreamEncoder*)encoder_);
|
||||
}
|
||||
|
||||
bool Stream::get_do_mid_side_stereo() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_get_do_mid_side_stereo(encoder_);
|
||||
return (bool)::OggFLAC__stream_encoder_get_do_mid_side_stereo((const OggFLAC__StreamEncoder*)encoder_);
|
||||
}
|
||||
|
||||
bool Stream::get_loose_mid_side_stereo() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_get_loose_mid_side_stereo(encoder_);
|
||||
return (bool)::OggFLAC__stream_encoder_get_loose_mid_side_stereo((const OggFLAC__StreamEncoder*)encoder_);
|
||||
}
|
||||
|
||||
unsigned Stream::get_channels() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_encoder_get_channels(encoder_);
|
||||
return ::OggFLAC__stream_encoder_get_channels((const OggFLAC__StreamEncoder*)encoder_);
|
||||
}
|
||||
|
||||
unsigned Stream::get_bits_per_sample() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_encoder_get_bits_per_sample(encoder_);
|
||||
return ::OggFLAC__stream_encoder_get_bits_per_sample((const OggFLAC__StreamEncoder*)encoder_);
|
||||
}
|
||||
|
||||
unsigned Stream::get_sample_rate() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_encoder_get_sample_rate(encoder_);
|
||||
return ::OggFLAC__stream_encoder_get_sample_rate((const OggFLAC__StreamEncoder*)encoder_);
|
||||
}
|
||||
|
||||
unsigned Stream::get_blocksize() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_encoder_get_blocksize(encoder_);
|
||||
return ::OggFLAC__stream_encoder_get_blocksize((const OggFLAC__StreamEncoder*)encoder_);
|
||||
}
|
||||
|
||||
unsigned Stream::get_max_lpc_order() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_encoder_get_max_lpc_order(encoder_);
|
||||
return ::OggFLAC__stream_encoder_get_max_lpc_order((const OggFLAC__StreamEncoder*)encoder_);
|
||||
}
|
||||
|
||||
unsigned Stream::get_qlp_coeff_precision() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_encoder_get_qlp_coeff_precision(encoder_);
|
||||
return ::OggFLAC__stream_encoder_get_qlp_coeff_precision((const OggFLAC__StreamEncoder*)encoder_);
|
||||
}
|
||||
|
||||
bool Stream::get_do_qlp_coeff_prec_search() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_get_do_qlp_coeff_prec_search(encoder_);
|
||||
return (bool)::OggFLAC__stream_encoder_get_do_qlp_coeff_prec_search((const OggFLAC__StreamEncoder*)encoder_);
|
||||
}
|
||||
|
||||
bool Stream::get_do_escape_coding() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_get_do_escape_coding(encoder_);
|
||||
return (bool)::OggFLAC__stream_encoder_get_do_escape_coding((const OggFLAC__StreamEncoder*)encoder_);
|
||||
}
|
||||
|
||||
bool Stream::get_do_exhaustive_model_search() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_get_do_exhaustive_model_search(encoder_);
|
||||
return (bool)::OggFLAC__stream_encoder_get_do_exhaustive_model_search((const OggFLAC__StreamEncoder*)encoder_);
|
||||
}
|
||||
|
||||
unsigned Stream::get_min_residual_partition_order() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_encoder_get_min_residual_partition_order(encoder_);
|
||||
return ::OggFLAC__stream_encoder_get_min_residual_partition_order((const OggFLAC__StreamEncoder*)encoder_);
|
||||
}
|
||||
|
||||
unsigned Stream::get_max_residual_partition_order() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_encoder_get_max_residual_partition_order(encoder_);
|
||||
return ::OggFLAC__stream_encoder_get_max_residual_partition_order((const OggFLAC__StreamEncoder*)encoder_);
|
||||
}
|
||||
|
||||
unsigned Stream::get_rice_parameter_search_dist() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_encoder_get_rice_parameter_search_dist(encoder_);
|
||||
return ::OggFLAC__stream_encoder_get_rice_parameter_search_dist((const OggFLAC__StreamEncoder*)encoder_);
|
||||
}
|
||||
|
||||
FLAC__uint64 Stream::get_total_samples_estimate() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_encoder_get_total_samples_estimate(encoder_);
|
||||
return ::OggFLAC__stream_encoder_get_total_samples_estimate((const OggFLAC__StreamEncoder*)encoder_);
|
||||
}
|
||||
|
||||
::FLAC__StreamEncoderInitStatus Stream::init()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::OggFLAC__stream_encoder_init_stream(encoder_, read_callback_, write_callback_, seek_callback_, tell_callback_, metadata_callback_, /*client_data=*/(void*)this);
|
||||
return ::OggFLAC__stream_encoder_init_stream((OggFLAC__StreamEncoder*)encoder_, read_callback_, write_callback_, seek_callback_, tell_callback_, metadata_callback_, /*client_data=*/(void*)this);
|
||||
}
|
||||
|
||||
void Stream::finish()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
::OggFLAC__stream_encoder_finish(encoder_);
|
||||
::OggFLAC__stream_encoder_finish((OggFLAC__StreamEncoder*)encoder_);
|
||||
}
|
||||
|
||||
bool Stream::process(const FLAC__int32 * const buffer[], unsigned samples)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_process(encoder_, buffer, samples);
|
||||
return (bool)::OggFLAC__stream_encoder_process((OggFLAC__StreamEncoder*)encoder_, buffer, samples);
|
||||
}
|
||||
|
||||
bool Stream::process_interleaved(const FLAC__int32 buffer[], unsigned samples)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::OggFLAC__stream_encoder_process_interleaved(encoder_, buffer, samples);
|
||||
return (bool)::OggFLAC__stream_encoder_process_interleaved((OggFLAC__StreamEncoder*)encoder_, buffer, samples);
|
||||
}
|
||||
|
||||
::OggFLAC__StreamEncoderReadStatus Stream::read_callback(FLAC__byte buffer[], unsigned *bytes)
|
||||
@ -358,23 +361,6 @@ namespace OggFLAC {
|
||||
return ::OggFLAC__STREAM_ENCODER_READ_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
::FLAC__StreamEncoderSeekStatus Stream::seek_callback(FLAC__uint64 absolute_byte_offset)
|
||||
{
|
||||
(void)absolute_byte_offset;
|
||||
return ::FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
::FLAC__StreamEncoderTellStatus Stream::tell_callback(FLAC__uint64 *absolute_byte_offset)
|
||||
{
|
||||
(void)absolute_byte_offset;
|
||||
return ::FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
void Stream::metadata_callback(const ::FLAC__StreamMetadata *metadata)
|
||||
{
|
||||
(void)metadata;
|
||||
}
|
||||
|
||||
::OggFLAC__StreamEncoderReadStatus Stream::read_callback_(const ::OggFLAC__StreamEncoder *encoder, FLAC__byte buffer[], unsigned *bytes, void *client_data)
|
||||
{
|
||||
(void)encoder;
|
||||
@ -384,41 +370,5 @@ namespace OggFLAC {
|
||||
return instance->read_callback(buffer, bytes);
|
||||
}
|
||||
|
||||
::FLAC__StreamEncoderWriteStatus Stream::write_callback_(const ::FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data)
|
||||
{
|
||||
(void)encoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
return instance->write_callback(buffer, bytes, samples, current_frame);
|
||||
}
|
||||
|
||||
::FLAC__StreamEncoderSeekStatus Stream::seek_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data)
|
||||
{
|
||||
(void)encoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
return instance->seek_callback(absolute_byte_offset);
|
||||
}
|
||||
|
||||
::FLAC__StreamEncoderTellStatus Stream::tell_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data)
|
||||
{
|
||||
(void)encoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
return instance->tell_callback(absolute_byte_offset);
|
||||
}
|
||||
|
||||
void Stream::metadata_callback_(const ::FLAC__StreamEncoder *encoder, const FLAC__StreamMetadata *metadata, void *client_data)
|
||||
{
|
||||
(void)encoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
instance->metadata_callback(metadata);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ test_libOggFLAC___LDADD = \
|
||||
$(top_builddir)/src/test_libs_common/libtest_libs_common.la \
|
||||
$(top_builddir)/src/libOggFLAC++/libOggFLAC++.la \
|
||||
$(top_builddir)/src/libOggFLAC/libOggFLAC.la \
|
||||
$(top_builddir)/src/libFLAC++/libFLAC++.la \
|
||||
$(top_builddir)/src/libFLAC/libFLAC.la \
|
||||
@OGG_LIBS@ \
|
||||
-lm
|
||||
|
@ -27,9 +27,9 @@ PROGRAM_NAME = test_libOggFLAC++
|
||||
INCLUDES = -I$(topdir)/include
|
||||
|
||||
ifeq ($(DARWIN_BUILD),yes)
|
||||
EXPLICIT_LIBS = $(libdir)/libgrabbag.a $(libdir)/libreplaygain_analysis.a $(libdir)/libtest_libs_common.a $(libdir)/libOggFLAC++.a $(libdir)/libOggFLAC.a $(libdir)/libFLAC.a $(OGG_LIB_DIR)/libogg.a -lm
|
||||
EXPLICIT_LIBS = $(libdir)/libgrabbag.a $(libdir)/libreplaygain_analysis.a $(libdir)/libtest_libs_common.a $(libdir)/libOggFLAC++.a $(libdir)/libOggFLAC.a $(libdir)/libFLAC++.a $(libdir)/libFLAC.a $(OGG_LIB_DIR)/libogg.a -lm
|
||||
else
|
||||
LIBS = -lgrabbag -lreplaygain_analysis -ltest_libs_common -lOggFLAC++ -lOggFLAC -lFLAC -L$(OGG_LIB_DIR) -logg -lm
|
||||
LIBS = -lgrabbag -lreplaygain_analysis -ltest_libs_common -lOggFLAC++ -lOggFLAC -lFLAC++ -lFLAC -L$(OGG_LIB_DIR) -logg -lm
|
||||
endif
|
||||
|
||||
SRCS_CPP = \
|
||||
|
Loading…
Reference in New Issue
Block a user