Main Page Modules Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# include/FLAC++/decoder.h

Go to the documentation of this file.

    00001 /* libFLAC++ - Free Lossless Audio Codec library
    00002  * Copyright (C) 2002,2003  Josh Coalson
    00003  *
    00004  * This library is free software; you can redistribute it and/or
    00005  * modify it under the terms of the GNU Library General Public
    00006  * License as published by the Free Software Foundation; either
    00007  * version 2 of the License, or (at your option) any later version.
    00008  *
    00009  * This library is distributed in the hope that it will be useful,
    00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012  * Library General Public License for more details.
    00013  *
    00014  * You should have received a copy of the GNU Library General Public
    00015  * License along with this library; if not, write to the
    00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017  * Boston, MA  02111-1307, USA.
    00018  */
    00019
    00020 #ifndef FLACPP__DECODER_H
    00021 #define FLACPP__DECODER_H
    00022
    00023 #include "export.h"
    00024
    00025 #include "FLAC/file_decoder.h"
    00026 #include "FLAC/seekable_stream_decoder.h"
    00027 #include "FLAC/stream_decoder.h"
    00028
    00029
    00057 namespace FLAC {
    00058     namespace Decoder {
    00059
    00060         // ============================================================
    00061         //
    00062         //  Equivalent: FLAC__StreamDecoder
    00063         //
    00064         // ============================================================
    00065
    00079         class FLACPP_API Stream {
    00080         public:
    00081             class FLACPP_API State {
    00082             public:
    00083                 inline State(::FLAC__StreamDecoderState state): state_(state) { }
    00084                 inline operator ::FLAC__StreamDecoderState() const { return state_; }
    00085                 inline const char *as_cstring() const { return ::FLAC__StreamDecoderStateString[state_]; }
    00086                 const char *resolved_as_cstring(const Stream &) const;
    00087             protected:
    00088                 ::FLAC__StreamDecoderState state_;
    00089             };
    00090
    00091             Stream();
    00092             virtual ~Stream();
    00093
    00094             bool is_valid() const;
    00095             inline operator bool() const { return is_valid(); }
    00096
    00097             bool set_metadata_respond(::FLAC__MetadataType type);
    00098             bool set_metadata_respond_application(const FLAC__byte id[4]);
    00099             bool set_metadata_respond_all();
    00100             bool set_metadata_ignore(::FLAC__MetadataType type);
    00101             bool set_metadata_ignore_application(const FLAC__byte id[4]);
    00102             bool set_metadata_ignore_all();
    00103
    00104             State get_state() const;
    00105             unsigned get_channels() const;
    00106             ::FLAC__ChannelAssignment get_channel_assignment() const;
    00107             unsigned get_bits_per_sample() const;
    00108             unsigned get_sample_rate() const;
    00109             unsigned get_blocksize() const;
    00110
    00115             State init();
    00116
    00117             void finish();
    00118
    00119             bool flush();
    00120             bool reset();
    00121
    00122             bool process_single();
    00123             bool process_until_end_of_metadata();
    00124             bool process_until_end_of_stream();
    00125         protected:
    00126             virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
    00127             virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
    00128             virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
    00129             virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
    00130
    00131             ::FLAC__StreamDecoder *decoder_;
    00132         private:
    00133             static ::FLAC__StreamDecoderReadStatus read_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
    00134             static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
    00135             static void metadata_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
    00136             static void error_callback_(const ::FLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
    00137
    00138             // Private and undefined so you can't use them:
    00139             Stream(const Stream &);
    00140             void operator=(const Stream &);
    00141         };
    00142
    00143         /* \} */
    00144
    00145
    00146         // ============================================================
    00147         //
    00148         //  Equivalent: FLAC__SeekableStreamDecoder
    00149         //
    00150         // ============================================================
    00151
    00165         class FLACPP_API SeekableStream {
    00166         public:
    00167             class FLACPP_API State {
    00168             public:
    00169                 inline State(::FLAC__SeekableStreamDecoderState state): state_(state) { }
    00170                 inline operator ::FLAC__SeekableStreamDecoderState() const { return state_; }
    00171                 inline const char *as_cstring() const { return ::FLAC__SeekableStreamDecoderStateString[state_]; }
    00172                 const char *resolved_as_cstring(const SeekableStream &) const;
    00173             protected:
    00174                 ::FLAC__SeekableStreamDecoderState state_;
    00175             };
    00176
    00177             SeekableStream();
    00178             virtual ~SeekableStream();
    00179
    00180             bool is_valid() const;
    00181             inline operator bool() const { return is_valid(); }
    00182
    00183             bool set_md5_checking(bool value);
    00184             bool set_metadata_respond(::FLAC__MetadataType type);
    00185             bool set_metadata_respond_application(const FLAC__byte id[4]);
    00186             bool set_metadata_respond_all();
    00187             bool set_metadata_ignore(::FLAC__MetadataType type);
    00188             bool set_metadata_ignore_application(const FLAC__byte id[4]);
    00189             bool set_metadata_ignore_all();
    00190
    00191             State get_state() const;
    00192             Stream::State get_stream_decoder_state() const;
    00193             bool get_md5_checking() const;
    00194             unsigned get_channels() const;
    00195             ::FLAC__ChannelAssignment get_channel_assignment() const;
    00196             unsigned get_bits_per_sample() const;
    00197             unsigned get_sample_rate() const;
    00198             unsigned get_blocksize() const;
    00199
    00200             State init();
    00201
    00202             bool finish();
    00203
    00204             bool flush();
    00205             bool reset();
    00206
    00207             bool process_single();
    00208             bool process_until_end_of_metadata();
    00209             bool process_until_end_of_stream();
    00210
    00211             bool seek_absolute(FLAC__uint64 sample);
    00212         protected:
    00213             virtual ::FLAC__SeekableStreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
    00214             virtual ::FLAC__SeekableStreamDecoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset) = 0;
    00215             virtual ::FLAC__SeekableStreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset) = 0;
    00216             virtual ::FLAC__SeekableStreamDecoderLengthStatus length_callback(FLAC__uint64 *stream_length) = 0;
    00217             virtual bool eof_callback() = 0;
    00218             virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
    00219             virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
    00220             virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
    00221
    00222             ::FLAC__SeekableStreamDecoder *decoder_;
    00223         private:
    00224             static ::FLAC__SeekableStreamDecoderReadStatus read_callback_(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
    00225             static ::FLAC__SeekableStreamDecoderSeekStatus seek_callback_(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
    00226             static ::FLAC__SeekableStreamDecoderTellStatus tell_callback_(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
    00227             static ::FLAC__SeekableStreamDecoderLengthStatus length_callback_(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
    00228             static FLAC__bool eof_callback_(const ::FLAC__SeekableStreamDecoder *decoder, void *client_data);
    00229             static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
    00230             static void metadata_callback_(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
    00231             static void error_callback_(const ::FLAC__SeekableStreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
    00232
    00233             // Private and undefined so you can't use them:
    00234             SeekableStream(const SeekableStream &);
    00235             void operator=(const SeekableStream &);
    00236         };
    00237
    00238         /* \} */
    00239
    00240
    00241         // ============================================================
    00242         //
    00243         //  Equivalent: FLAC__FileDecoder
    00244         //
    00245         // ============================================================
    00246
    00260         class FLACPP_API File {
    00261         public:
    00262             class FLACPP_API State {
    00263             public:
    00264                 inline State(::FLAC__FileDecoderState state): state_(state) { }
    00265                 inline operator ::FLAC__FileDecoderState() const { return state_; }
    00266                 inline const char *as_cstring() const { return ::FLAC__FileDecoderStateString[state_]; }
    00267                 const char *resolved_as_cstring(const File &) const;
    00268             protected:
    00269                 ::FLAC__FileDecoderState state_;
    00270             };
    00271
    00272             File();
    00273             virtual ~File();
    00274
    00275             bool is_valid() const;
    00276             inline operator bool() const { return is_valid(); }
    00277
    00278             bool set_md5_checking(bool value);
    00279             bool set_filename(const char *value);
    00280             bool set_metadata_respond(::FLAC__MetadataType type);
    00281             bool set_metadata_respond_application(const FLAC__byte id[4]);
    00282             bool set_metadata_respond_all();
    00283             bool set_metadata_ignore(::FLAC__MetadataType type);
    00284             bool set_metadata_ignore_application(const FLAC__byte id[4]);
    00285             bool set_metadata_ignore_all();
    00286
    00287             State get_state() const;
    00288             SeekableStream::State get_seekable_stream_decoder_state() const;
    00289             Stream::State get_stream_decoder_state() const;
    00290             bool get_md5_checking() const;
    00291             unsigned get_channels() const;
    00292             ::FLAC__ChannelAssignment get_channel_assignment() const;
    00293             unsigned get_bits_per_sample() const;
    00294             unsigned get_sample_rate() const;
    00295             unsigned get_blocksize() const;
    00296
    00297             State init();
    00298
    00299             bool finish();
    00300
    00301             bool process_single();
    00302             bool process_until_end_of_metadata();
    00303             bool process_until_end_of_file();
    00304
    00305             bool seek_absolute(FLAC__uint64 sample);
    00306         protected:
    00307             virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
    00308             virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
    00309             virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
    00310
    00311             ::FLAC__FileDecoder *decoder_;
    00312         private:
    00313             static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::FLAC__FileDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
    00314             static void metadata_callback_(const ::FLAC__FileDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
    00315             static void error_callback_(const ::FLAC__FileDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
    00316
    00317             // Private and undefined so you can't use them:
    00318             File(const File &);
    00319             void operator=(const File &);
    00320         };
    00321
    00322         /* \} */
    00323
    00324     };
    00325 };
    00326
    00327 #endif