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/file_decoder.h"
00038 #include "OggFLAC/seekable_stream_decoder.h"
00039 #include "OggFLAC/stream_decoder.h"
00040
00041 #include "FLAC++/decoder.h"
00042
00043
00071 namespace OggFLAC {
00072 namespace Decoder {
00073
00074
00075
00076
00077
00078
00079
00093 class OggFLACPP_API Stream {
00094 public:
00095 class OggFLACPP_API State {
00096 public:
00097 inline State(::OggFLAC__StreamDecoderState state): state_(state) { }
00098 inline operator ::OggFLAC__StreamDecoderState() const { return state_; }
00099 inline const char *as_cstring() const { return ::OggFLAC__StreamDecoderStateString[state_]; }
00100 inline const char *resolved_as_cstring(const Stream &decoder) const { return ::OggFLAC__stream_decoder_get_resolved_state_string(decoder.decoder_); }
00101 protected:
00102 ::OggFLAC__StreamDecoderState state_;
00103 };
00104
00105 Stream();
00106 virtual ~Stream();
00107
00108 bool is_valid() const;
00109 inline operator bool() const { return is_valid(); }
00110
00111 bool set_serial_number(long value);
00112 bool set_metadata_respond(::FLAC__MetadataType type);
00113 bool set_metadata_respond_application(const FLAC__byte id[4]);
00114 bool set_metadata_respond_all();
00115 bool set_metadata_ignore(::FLAC__MetadataType type);
00116 bool set_metadata_ignore_application(const FLAC__byte id[4]);
00117 bool set_metadata_ignore_all();
00118
00119 State get_state() const;
00120 FLAC::Decoder::Stream::State get_FLAC_stream_decoder_state() const;
00121 unsigned get_channels() const;
00122 ::FLAC__ChannelAssignment get_channel_assignment() const;
00123 unsigned get_bits_per_sample() const;
00124 unsigned get_sample_rate() const;
00125 unsigned get_blocksize() const;
00126
00131 State init();
00132
00133 void finish();
00134
00135 bool flush();
00136 bool reset();
00137
00138 bool process_single();
00139 bool process_until_end_of_metadata();
00140 bool process_until_end_of_stream();
00141 protected:
00142 virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
00143 virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
00144 virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00145 virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
00146
00147 #if (defined _MSC_VER) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96)))
00148
00149 friend State;
00150 #endif
00151 ::OggFLAC__StreamDecoder *decoder_;
00152 private:
00153 static ::FLAC__StreamDecoderReadStatus read_callback_(const ::OggFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
00154 static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00155 static void metadata_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00156 static void error_callback_(const ::OggFLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00157
00158
00159 Stream(const Stream &);
00160 void operator=(const Stream &);
00161 };
00162
00163
00164
00165
00166
00167
00168
00169
00170
00184 class OggFLACPP_API SeekableStream {
00185 public:
00186 class OggFLACPP_API State {
00187 public:
00188 inline State(::OggFLAC__SeekableStreamDecoderState state): state_(state) { }
00189 inline operator ::OggFLAC__SeekableStreamDecoderState() const { return state_; }
00190 inline const char *as_cstring() const { return ::OggFLAC__SeekableStreamDecoderStateString[state_]; }
00191 inline const char *resolved_as_cstring(const SeekableStream &decoder) const { return ::OggFLAC__seekable_stream_decoder_get_resolved_state_string(decoder.decoder_); }
00192 protected:
00193 ::OggFLAC__SeekableStreamDecoderState state_;
00194 };
00195
00196 SeekableStream();
00197 virtual ~SeekableStream();
00198
00199 bool is_valid() const;
00200 inline operator bool() const { return is_valid(); }
00201
00202 bool set_serial_number(long value);
00203 bool set_md5_checking(bool value);
00204 bool set_metadata_respond(::FLAC__MetadataType type);
00205 bool set_metadata_respond_application(const FLAC__byte id[4]);
00206 bool set_metadata_respond_all();
00207 bool set_metadata_ignore(::FLAC__MetadataType type);
00208 bool set_metadata_ignore_application(const FLAC__byte id[4]);
00209 bool set_metadata_ignore_all();
00210
00211 State get_state() const;
00212 OggFLAC::Decoder::Stream::State get_stream_decoder_state() const;
00213 FLAC::Decoder::Stream::State get_FLAC_stream_decoder_state() const;
00214 bool get_md5_checking() const;
00215 unsigned get_channels() const;
00216 ::FLAC__ChannelAssignment get_channel_assignment() const;
00217 unsigned get_bits_per_sample() const;
00218 unsigned get_sample_rate() const;
00219 unsigned get_blocksize() const;
00220
00221 State init();
00222
00223 bool finish();
00224
00225 bool flush();
00226 bool reset();
00227
00228 bool process_single();
00229 bool process_until_end_of_metadata();
00230 bool process_until_end_of_stream();
00231
00232 bool seek_absolute(FLAC__uint64 sample);
00233 protected:
00234 virtual ::OggFLAC__SeekableStreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
00235 virtual ::OggFLAC__SeekableStreamDecoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset) = 0;
00236 virtual ::OggFLAC__SeekableStreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset) = 0;
00237 virtual ::OggFLAC__SeekableStreamDecoderLengthStatus length_callback(FLAC__uint64 *stream_length) = 0;
00238 virtual bool eof_callback() = 0;
00239 virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
00240 virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00241 virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
00242
00243 #if (defined _MSC_VER) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96)))
00244
00245 friend State;
00246 #endif
00247 ::OggFLAC__SeekableStreamDecoder *decoder_;
00248 private:
00249 static ::OggFLAC__SeekableStreamDecoderReadStatus read_callback_(const ::OggFLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
00250 static ::OggFLAC__SeekableStreamDecoderSeekStatus seek_callback_(const ::OggFLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
00251 static ::OggFLAC__SeekableStreamDecoderTellStatus tell_callback_(const ::OggFLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
00252 static ::OggFLAC__SeekableStreamDecoderLengthStatus length_callback_(const ::OggFLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
00253 static FLAC__bool eof_callback_(const ::OggFLAC__SeekableStreamDecoder *decoder, void *client_data);
00254 static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::OggFLAC__SeekableStreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00255 static void metadata_callback_(const ::OggFLAC__SeekableStreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00256 static void error_callback_(const ::OggFLAC__SeekableStreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00257
00258
00259 SeekableStream(const SeekableStream &);
00260 void operator=(const SeekableStream &);
00261 };
00262
00263
00264
00265
00266
00267
00268
00269
00270
00284 class OggFLACPP_API File {
00285 public:
00286 class OggFLACPP_API State {
00287 public:
00288 inline State(::OggFLAC__FileDecoderState state): state_(state) { }
00289 inline operator ::OggFLAC__FileDecoderState() const { return state_; }
00290 inline const char *as_cstring() const { return ::OggFLAC__FileDecoderStateString[state_]; }
00291 inline const char *resolved_as_cstring(const File &decoder) const { return ::OggFLAC__file_decoder_get_resolved_state_string(decoder.decoder_); }
00292 protected:
00293 ::OggFLAC__FileDecoderState state_;
00294 };
00295
00296 File();
00297 virtual ~File();
00298
00299 bool is_valid() const;
00300 inline operator bool() const { return is_valid(); }
00301
00302 bool set_serial_number(long value);
00303 bool set_md5_checking(bool value);
00304 bool set_filename(const char *value);
00305 bool set_metadata_respond(::FLAC__MetadataType type);
00306 bool set_metadata_respond_application(const FLAC__byte id[4]);
00307 bool set_metadata_respond_all();
00308 bool set_metadata_ignore(::FLAC__MetadataType type);
00309 bool set_metadata_ignore_application(const FLAC__byte id[4]);
00310 bool set_metadata_ignore_all();
00311
00312 State get_state() const;
00313 OggFLAC::Decoder::SeekableStream::State get_seekable_stream_decoder_state() const;
00314 OggFLAC::Decoder::Stream::State get_stream_decoder_state() const;
00315 FLAC::Decoder::Stream::State get_FLAC_stream_decoder_state() const;
00316 bool get_md5_checking() const;
00317 unsigned get_channels() const;
00318 ::FLAC__ChannelAssignment get_channel_assignment() const;
00319 unsigned get_bits_per_sample() const;
00320 unsigned get_sample_rate() const;
00321 unsigned get_blocksize() const;
00322
00323 State init();
00324
00325 bool finish();
00326
00327 bool process_single();
00328 bool process_until_end_of_metadata();
00329 bool process_until_end_of_file();
00330
00331 bool seek_absolute(FLAC__uint64 sample);
00332 protected:
00333 virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
00334 virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00335 virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
00336
00337 #if (defined _MSC_VER) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96)))
00338
00339 friend State;
00340 #endif
00341 ::OggFLAC__FileDecoder *decoder_;
00342 private:
00343 static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::OggFLAC__FileDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00344 static void metadata_callback_(const ::OggFLAC__FileDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00345 static void error_callback_(const ::OggFLAC__FileDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00346
00347
00348 File(const File &);
00349 void operator=(const File &);
00350 };
00351
00352
00353
00354 };
00355 };
00356
00357 #endif