00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef OggFLACPP__DECODER_H
00033 #define OggFLACPP__DECODER_H
00034
00035 #include "export.h"
00036
00037 #include "OggFLAC/stream_decoder.h"
00038
00039 #include "FLAC++/decoder.h"
00040
00041
00069 namespace OggFLAC {
00070 namespace Decoder {
00071
00072
00073
00074
00075
00076
00077
00091 class OggFLACPP_API Stream {
00092 public:
00093 class OggFLACPP_API State {
00094 public:
00095 inline State(::OggFLAC__StreamDecoderState state): state_(state) { }
00096 inline operator ::OggFLAC__StreamDecoderState() const { return state_; }
00097 inline const char *as_cstring() const { return ::OggFLAC__StreamDecoderStateString[state_]; }
00098 protected:
00099 ::OggFLAC__StreamDecoderState state_;
00100 };
00101
00102 Stream();
00103 virtual ~Stream();
00104
00105 bool is_valid() const;
00106 inline operator bool() const { return is_valid(); }
00107
00108 bool set_serial_number(long value);
00109 bool set_metadata_respond(::FLAC__MetadataType type);
00110 bool set_metadata_respond_application(const FLAC__byte id[4]);
00111 bool set_metadata_respond_all();
00112 bool set_metadata_ignore(::FLAC__MetadataType type);
00113 bool set_metadata_ignore_application(const FLAC__byte id[4]);
00114 bool set_metadata_ignore_all();
00115
00116 State get_state() const;
00117 FLAC::Decoder::Stream::State get_FLAC_stream_decoder_state() const;
00118 unsigned get_channels() const;
00119 ::FLAC__ChannelAssignment get_channel_assignment() const;
00120 unsigned get_bits_per_sample() const;
00121 unsigned get_sample_rate() const;
00122 unsigned get_blocksize() const;
00123
00124 State init();
00125
00126 void finish();
00127
00128 bool flush();
00129 bool reset();
00130
00131 bool process_single();
00132 bool process_until_end_of_metadata();
00133 bool process_until_end_of_stream();
00134 protected:
00135 virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
00136 virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
00137 virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00138 virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
00139
00140 ::OggFLAC__StreamDecoder *decoder_;
00141 private:
00142 static ::FLAC__StreamDecoderReadStatus read_callback_(const ::OggFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
00143 static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00144 static void metadata_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00145 static void error_callback_(const ::OggFLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00146
00147
00148 Stream(const Stream &);
00149 void operator=(const Stream &);
00150 };
00151
00152
00153
00154 };
00155 };
00156
00157 #endif