decoder.h
Go to the documentation of this file.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
00033 #ifndef FLACPP__DECODER_H
00034 #define FLACPP__DECODER_H
00035
00036 #include "export.h"
00037
00038 #include <string>
00039 #include "FLAC/stream_decoder.h"
00040
00041
00078 namespace FLAC {
00079 namespace Decoder {
00080
00100 class FLACPP_API Stream {
00101 public:
00104 class FLACPP_API State {
00105 public:
00106 inline State(::FLAC__StreamDecoderState state): state_(state) { }
00107 inline operator ::FLAC__StreamDecoderState() const { return state_; }
00108 inline const char *as_cstring() const { return ::FLAC__StreamDecoderStateString[state_]; }
00109 inline const char *resolved_as_cstring(const Stream &decoder) const { return ::FLAC__stream_decoder_get_resolved_state_string(decoder.decoder_); }
00110 protected:
00111 ::FLAC__StreamDecoderState state_;
00112 };
00113
00114 Stream();
00115 virtual ~Stream();
00116
00118
00121 virtual bool is_valid() const;
00122 inline operator bool() const { return is_valid(); }
00123
00124
00125 virtual bool set_ogg_serial_number(long value);
00126 virtual bool set_md5_checking(bool value);
00127 virtual bool set_metadata_respond(::FLAC__MetadataType type);
00128 virtual bool set_metadata_respond_application(const FLAC__byte id[4]);
00129 virtual bool set_metadata_respond_all();
00130 virtual bool set_metadata_ignore(::FLAC__MetadataType type);
00131 virtual bool set_metadata_ignore_application(const FLAC__byte id[4]);
00132 virtual bool set_metadata_ignore_all();
00133
00134
00135 State get_state() const;
00136 virtual bool get_md5_checking() const;
00137 virtual FLAC__uint64 get_total_samples() const;
00138 virtual unsigned get_channels() const;
00139 virtual ::FLAC__ChannelAssignment get_channel_assignment() const;
00140 virtual unsigned get_bits_per_sample() const;
00141 virtual unsigned get_sample_rate() const;
00142 virtual unsigned get_blocksize() const;
00143 virtual bool get_decode_position(FLAC__uint64 *position) const;
00144
00145 virtual ::FLAC__StreamDecoderInitStatus init();
00146 virtual ::FLAC__StreamDecoderInitStatus init_ogg();
00147
00148 virtual bool finish();
00149
00150 virtual bool flush();
00151 virtual bool reset();
00152
00153 virtual bool process_single();
00154 virtual bool process_until_end_of_metadata();
00155 virtual bool process_until_end_of_stream();
00156 virtual bool skip_single_frame();
00157
00158 virtual bool seek_absolute(FLAC__uint64 sample);
00159 protected:
00161 virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes) = 0;
00162
00164 virtual ::FLAC__StreamDecoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset);
00165
00167 virtual ::FLAC__StreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset);
00168
00170 virtual ::FLAC__StreamDecoderLengthStatus length_callback(FLAC__uint64 *stream_length);
00171
00173 virtual bool eof_callback();
00174
00176 virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
00177
00179 virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata);
00180
00182 virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
00183
00184 #if (defined _MSC_VER) || (defined __BORLANDC__) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC)
00185
00186 friend State;
00187 #endif
00188 ::FLAC__StreamDecoder *decoder_;
00189
00190 static ::FLAC__StreamDecoderReadStatus read_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
00191 static ::FLAC__StreamDecoderSeekStatus seek_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
00192 static ::FLAC__StreamDecoderTellStatus tell_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
00193 static ::FLAC__StreamDecoderLengthStatus length_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
00194 static FLAC__bool eof_callback_(const ::FLAC__StreamDecoder *decoder, void *client_data);
00195 static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00196 static void metadata_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00197 static void error_callback_(const ::FLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00198 private:
00199
00200 Stream(const Stream &);
00201 void operator=(const Stream &);
00202 };
00203
00223 class FLACPP_API File: public Stream {
00224 public:
00225 File();
00226 virtual ~File();
00227
00228 virtual ::FLAC__StreamDecoderInitStatus init(FILE *file);
00229 virtual ::FLAC__StreamDecoderInitStatus init(const char *filename);
00230 virtual ::FLAC__StreamDecoderInitStatus init(const std::string &filename);
00231 virtual ::FLAC__StreamDecoderInitStatus init_ogg(FILE *file);
00232 virtual ::FLAC__StreamDecoderInitStatus init_ogg(const char *filename);
00233 virtual ::FLAC__StreamDecoderInitStatus init_ogg(const std::string &filename);
00234 protected:
00235
00236 virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes);
00237 private:
00238
00239 File(const File &);
00240 void operator=(const File &);
00241 };
00242
00243 }
00244 }
00245
00246 #endif