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 ::OggFLAC__StreamDecoder *decoder_;
00148 private:
00149 static ::FLAC__StreamDecoderReadStatus read_callback_(const ::OggFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
00150 static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00151 static void metadata_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00152 static void error_callback_(const ::OggFLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00153
00154
00155 Stream(const Stream &);
00156 void operator=(const Stream &);
00157 };
00158
00159
00160
00161
00162
00163
00164
00165
00166
00180 class OggFLACPP_API SeekableStream {
00181 public:
00182 class OggFLACPP_API State {
00183 public:
00184 inline State(::OggFLAC__SeekableStreamDecoderState state): state_(state) { }
00185 inline operator ::OggFLAC__SeekableStreamDecoderState() const { return state_; }
00186 inline const char *as_cstring() const { return ::OggFLAC__SeekableStreamDecoderStateString[state_]; }
00187 inline const char *resolved_as_cstring(const SeekableStream &decoder) const { return ::OggFLAC__seekable_stream_decoder_get_resolved_state_string(decoder.decoder_); }
00188 protected:
00189 ::OggFLAC__SeekableStreamDecoderState state_;
00190 };
00191
00192 SeekableStream();
00193 virtual ~SeekableStream();
00194
00195 bool is_valid() const;
00196 inline operator bool() const { return is_valid(); }
00197
00198 bool set_serial_number(long value);
00199 bool set_md5_checking(bool value);
00200 bool set_metadata_respond(::FLAC__MetadataType type);
00201 bool set_metadata_respond_application(const FLAC__byte id[4]);
00202 bool set_metadata_respond_all();
00203 bool set_metadata_ignore(::FLAC__MetadataType type);
00204 bool set_metadata_ignore_application(const FLAC__byte id[4]);
00205 bool set_metadata_ignore_all();
00206
00207 State get_state() const;
00208 FLAC::Decoder::SeekableStream::State get_FLAC_seekable_stream_decoder_state() const;
00209 FLAC::Decoder::Stream::State get_FLAC_stream_decoder_state() const;
00210 bool get_md5_checking() const;
00211 unsigned get_channels() const;
00212 ::FLAC__ChannelAssignment get_channel_assignment() const;
00213 unsigned get_bits_per_sample() const;
00214 unsigned get_sample_rate() const;
00215 unsigned get_blocksize() const;
00216
00217 State init();
00218
00219 bool finish();
00220
00221 bool flush();
00222 bool reset();
00223
00224 bool process_single();
00225 bool process_until_end_of_metadata();
00226 bool process_until_end_of_stream();
00227
00228 bool seek_absolute(FLAC__uint64 sample);
00229 protected:
00230 virtual ::FLAC__SeekableStreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
00231 virtual ::FLAC__SeekableStreamDecoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset) = 0;
00232 virtual ::FLAC__SeekableStreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset) = 0;
00233 virtual ::FLAC__SeekableStreamDecoderLengthStatus length_callback(FLAC__uint64 *stream_length) = 0;
00234 virtual bool eof_callback() = 0;
00235 virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
00236 virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00237 virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
00238
00239 ::OggFLAC__SeekableStreamDecoder *decoder_;
00240 private:
00241 static ::FLAC__SeekableStreamDecoderReadStatus read_callback_(const ::OggFLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
00242 static ::FLAC__SeekableStreamDecoderSeekStatus seek_callback_(const ::OggFLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
00243 static ::FLAC__SeekableStreamDecoderTellStatus tell_callback_(const ::OggFLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
00244 static ::FLAC__SeekableStreamDecoderLengthStatus length_callback_(const ::OggFLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
00245 static FLAC__bool eof_callback_(const ::OggFLAC__SeekableStreamDecoder *decoder, void *client_data);
00246 static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::OggFLAC__SeekableStreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00247 static void metadata_callback_(const ::OggFLAC__SeekableStreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00248 static void error_callback_(const ::OggFLAC__SeekableStreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00249
00250
00251 SeekableStream(const SeekableStream &);
00252 void operator=(const SeekableStream &);
00253 };
00254
00255
00256
00257
00258
00259
00260
00261
00262
00276 class OggFLACPP_API File {
00277 public:
00278 class OggFLACPP_API State {
00279 public:
00280 inline State(::OggFLAC__FileDecoderState state): state_(state) { }
00281 inline operator ::OggFLAC__FileDecoderState() const { return state_; }
00282 inline const char *as_cstring() const { return ::OggFLAC__FileDecoderStateString[state_]; }
00283 inline const char *resolved_as_cstring(const File &decoder) const { return ::OggFLAC__file_decoder_get_resolved_state_string(decoder.decoder_); }
00284 protected:
00285 ::OggFLAC__FileDecoderState state_;
00286 };
00287
00288 File();
00289 virtual ~File();
00290
00291 bool is_valid() const;
00292 inline operator bool() const { return is_valid(); }
00293
00294 bool set_serial_number(long value);
00295 bool set_md5_checking(bool value);
00296 bool set_filename(const char *value);
00297 bool set_metadata_respond(::FLAC__MetadataType type);
00298 bool set_metadata_respond_application(const FLAC__byte id[4]);
00299 bool set_metadata_respond_all();
00300 bool set_metadata_ignore(::FLAC__MetadataType type);
00301 bool set_metadata_ignore_application(const FLAC__byte id[4]);
00302 bool set_metadata_ignore_all();
00303
00304 State get_state() const;
00305 FLAC::Decoder::File::State get_FLAC_file_decoder_state() const;
00306 FLAC::Decoder::SeekableStream::State get_FLAC_seekable_stream_decoder_state() const;
00307 FLAC::Decoder::Stream::State get_FLAC_stream_decoder_state() const;
00308 bool get_md5_checking() const;
00309 unsigned get_channels() const;
00310 ::FLAC__ChannelAssignment get_channel_assignment() const;
00311 unsigned get_bits_per_sample() const;
00312 unsigned get_sample_rate() const;
00313 unsigned get_blocksize() const;
00314
00315 State init();
00316
00317 bool finish();
00318
00319 bool process_single();
00320 bool process_until_end_of_metadata();
00321 bool process_until_end_of_file();
00322
00323 bool seek_absolute(FLAC__uint64 sample);
00324 protected:
00325 virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
00326 virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00327 virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
00328
00329 ::OggFLAC__FileDecoder *decoder_;
00330 private:
00331 static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::OggFLAC__FileDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00332 static void metadata_callback_(const ::OggFLAC__FileDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00333 static void error_callback_(const ::OggFLAC__FileDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00334
00335
00336 File(const File &);
00337 void operator=(const File &);
00338 };
00339
00340
00341
00342 };
00343 };
00344
00345 #endif