00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef OggFLACPP__DECODER_H
00021 #define OggFLACPP__DECODER_H
00022
00023 #include "OggFLAC/stream_decoder.h"
00024
00025 #include "FLAC++/decoder.h"
00026
00027
00055 namespace OggFLAC {
00056 namespace Decoder {
00057
00058
00059
00060
00061
00062
00063
00077 class Stream {
00078 public:
00079 class State {
00080 public:
00081 inline State(::OggFLAC__StreamDecoderState state): state_(state) { }
00082 inline operator ::OggFLAC__StreamDecoderState() const { return state_; }
00083 inline const char *as_cstring() const { return ::OggFLAC__StreamDecoderStateString[state_]; }
00084 protected:
00085 ::OggFLAC__StreamDecoderState state_;
00086 };
00087
00088 Stream();
00089 virtual ~Stream();
00090
00091 bool is_valid() const;
00092 inline operator bool() const { return is_valid(); }
00093
00094 bool set_serial_number(long value);
00095 bool set_metadata_respond(::FLAC__MetadataType type);
00096 bool set_metadata_respond_application(const FLAC__byte id[4]);
00097 bool set_metadata_respond_all();
00098 bool set_metadata_ignore(::FLAC__MetadataType type);
00099 bool set_metadata_ignore_application(const FLAC__byte id[4]);
00100 bool set_metadata_ignore_all();
00101
00102 State get_state() const;
00103 FLAC::Decoder::Stream::State get_FLAC_stream_decoder_state() const;
00104 unsigned get_channels() const;
00105 ::FLAC__ChannelAssignment get_channel_assignment() const;
00106 unsigned get_bits_per_sample() const;
00107 unsigned get_sample_rate() const;
00108 unsigned get_blocksize() const;
00109
00110 State init();
00111
00112 void finish();
00113
00114 bool flush();
00115 bool reset();
00116
00117 bool process_single();
00118 bool process_until_end_of_metadata();
00119 bool process_until_end_of_stream();
00120 protected:
00121 virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
00122 virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
00123 virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00124 virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
00125
00126 ::OggFLAC__StreamDecoder *decoder_;
00127 private:
00128 static ::FLAC__StreamDecoderReadStatus read_callback_(const ::OggFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
00129 static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00130 static void metadata_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00131 static void error_callback_(const ::OggFLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00132
00133
00134 Stream(const Stream &);
00135 void operator=(const Stream &);
00136 };
00137
00138
00139
00140 };
00141 };
00142
00143 #endif