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  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 "FLAC/file_decoder.h"
00024 #include "FLAC/seekable_stream_decoder.h"
00025 #include "FLAC/stream_decoder.h"
00026 
00027 
00055 namespace FLAC {
00056     namespace Decoder {
00057 
00058         // ============================================================
00059         //
00060         //  Equivalent: FLAC__StreamDecoder
00061         //
00062         // ============================================================
00063 
00077         class Stream {
00078         public:
00079             class State {
00080             public:
00081                 inline State(::FLAC__StreamDecoderState state): state_(state) { }
00082                 inline operator ::FLAC__StreamDecoderState() const { return state_; }
00083                 inline const char *as_cstring() const { return ::FLAC__StreamDecoderStateString[state_]; }
00084                 const char *resolved_as_cstring(const Stream &) const;
00085             protected:
00086                 ::FLAC__StreamDecoderState state_;
00087             };
00088 
00089             Stream();
00090             virtual ~Stream();
00091 
00092             bool is_valid() const;
00093             inline operator bool() const { return is_valid(); }
00094 
00095             bool set_metadata_respond(::FLAC__MetadataType type);
00096             bool set_metadata_respond_application(const FLAC__byte id[4]);
00097             bool set_metadata_respond_all();
00098             bool set_metadata_ignore(::FLAC__MetadataType type);
00099             bool set_metadata_ignore_application(const FLAC__byte id[4]);
00100             bool set_metadata_ignore_all();
00101 
00102             State get_state() const;
00103             unsigned get_channels() const;
00104             ::FLAC__ChannelAssignment get_channel_assignment() const;
00105             unsigned get_bits_per_sample() const;
00106             unsigned get_sample_rate() const;
00107             unsigned get_blocksize() const;
00108 
00113             State init();
00114 
00115             void finish();
00116 
00117             bool flush();
00118             bool reset();
00119 
00120             bool process_single();
00121             bool process_until_end_of_metadata();
00122             bool process_until_end_of_stream();
00123         protected:
00124             virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
00125             virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
00126             virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00127             virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
00128 
00129             ::FLAC__StreamDecoder *decoder_;
00130         private:
00131             static ::FLAC__StreamDecoderReadStatus read_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
00132             static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00133             static void metadata_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00134             static void error_callback_(const ::FLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00135 
00136             // Private and undefined so you can't use them:
00137             Stream(const Stream &);
00138             void operator=(const Stream &);
00139         };
00140 
00141         /* \} */
00142 
00143 
00144         // ============================================================
00145         //
00146         //  Equivalent: FLAC__SeekableStreamDecoder
00147         //
00148         // ============================================================
00149 
00163         class SeekableStream {
00164         public:
00165             class State {
00166             public:
00167                 inline State(::FLAC__SeekableStreamDecoderState state): state_(state) { }
00168                 inline operator ::FLAC__SeekableStreamDecoderState() const { return state_; }
00169                 inline const char *as_cstring() const { return ::FLAC__SeekableStreamDecoderStateString[state_]; }
00170                 const char *resolved_as_cstring(const SeekableStream &) const;
00171             protected:
00172                 ::FLAC__SeekableStreamDecoderState state_;
00173             };
00174 
00175             SeekableStream();
00176             virtual ~SeekableStream();
00177 
00178             bool is_valid() const;
00179             inline operator bool() const { return is_valid(); }
00180 
00181             bool set_md5_checking(bool value);
00182             bool set_metadata_respond(::FLAC__MetadataType type);
00183             bool set_metadata_respond_application(const FLAC__byte id[4]);
00184             bool set_metadata_respond_all();
00185             bool set_metadata_ignore(::FLAC__MetadataType type);
00186             bool set_metadata_ignore_application(const FLAC__byte id[4]);
00187             bool set_metadata_ignore_all();
00188 
00189             State get_state() const;
00190             Stream::State get_stream_decoder_state() const;
00191             bool get_md5_checking() const;
00192             unsigned get_channels() const;
00193             ::FLAC__ChannelAssignment get_channel_assignment() const;
00194             unsigned get_bits_per_sample() const;
00195             unsigned get_sample_rate() const;
00196             unsigned get_blocksize() const;
00197 
00198             State init();
00199 
00200             bool finish();
00201 
00202             bool flush();
00203             bool reset();
00204 
00205             bool process_single();
00206             bool process_until_end_of_metadata();
00207             bool process_until_end_of_stream();
00208 
00209             bool seek_absolute(FLAC__uint64 sample);
00210         protected:
00211             virtual ::FLAC__SeekableStreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
00212             virtual ::FLAC__SeekableStreamDecoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset) = 0;
00213             virtual ::FLAC__SeekableStreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset) = 0;
00214             virtual ::FLAC__SeekableStreamDecoderLengthStatus length_callback(FLAC__uint64 *stream_length) = 0;
00215             virtual bool eof_callback() = 0;
00216             virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
00217             virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00218             virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
00219 
00220             ::FLAC__SeekableStreamDecoder *decoder_;
00221         private:
00222             static ::FLAC__SeekableStreamDecoderReadStatus read_callback_(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
00223             static ::FLAC__SeekableStreamDecoderSeekStatus seek_callback_(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
00224             static ::FLAC__SeekableStreamDecoderTellStatus tell_callback_(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
00225             static ::FLAC__SeekableStreamDecoderLengthStatus length_callback_(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
00226             static FLAC__bool eof_callback_(const ::FLAC__SeekableStreamDecoder *decoder, void *client_data);
00227             static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00228             static void metadata_callback_(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00229             static void error_callback_(const ::FLAC__SeekableStreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00230 
00231             // Private and undefined so you can't use them:
00232             SeekableStream(const SeekableStream &);
00233             void operator=(const SeekableStream &);
00234         };
00235 
00236         /* \} */
00237 
00238 
00239         // ============================================================
00240         //
00241         //  Equivalent: FLAC__FileDecoder
00242         //
00243         // ============================================================
00244 
00258         class File {
00259         public:
00260             class State {
00261             public:
00262                 inline State(::FLAC__FileDecoderState state): state_(state) { }
00263                 inline operator ::FLAC__FileDecoderState() const { return state_; }
00264                 inline const char *as_cstring() const { return ::FLAC__FileDecoderStateString[state_]; }
00265                 const char *resolved_as_cstring(const File &) const;
00266             protected:
00267                 ::FLAC__FileDecoderState state_;
00268             };
00269 
00270             File();
00271             virtual ~File();
00272 
00273             bool is_valid() const;
00274             inline operator bool() const { return is_valid(); }
00275 
00276             bool set_md5_checking(bool value);
00277             bool set_filename(const char *value); 
00278             bool set_metadata_respond(::FLAC__MetadataType type);
00279             bool set_metadata_respond_application(const FLAC__byte id[4]);
00280             bool set_metadata_respond_all();
00281             bool set_metadata_ignore(::FLAC__MetadataType type);
00282             bool set_metadata_ignore_application(const FLAC__byte id[4]);
00283             bool set_metadata_ignore_all();
00284 
00285             State get_state() const;
00286             SeekableStream::State get_seekable_stream_decoder_state() const;
00287             Stream::State get_stream_decoder_state() const;
00288             bool get_md5_checking() const;
00289             unsigned get_channels() const;
00290             ::FLAC__ChannelAssignment get_channel_assignment() const;
00291             unsigned get_bits_per_sample() const;
00292             unsigned get_sample_rate() const;
00293             unsigned get_blocksize() const;
00294 
00295             State init();
00296 
00297             bool finish();
00298 
00299             bool process_single();
00300             bool process_until_end_of_metadata();
00301             bool process_until_end_of_file();
00302 
00303             bool seek_absolute(FLAC__uint64 sample);
00304         protected:
00305             virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
00306             virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00307             virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
00308 
00309             ::FLAC__FileDecoder *decoder_;
00310         private:
00311             static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::FLAC__FileDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00312             static void metadata_callback_(const ::FLAC__FileDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00313             static void error_callback_(const ::FLAC__FileDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00314 
00315             // Private and undefined so you can't use them:
00316             File(const File &);
00317             void operator=(const File &);
00318         };
00319 
00320         /* \} */
00321 
00322     };
00323 };
00324 
00325 #endif

Generated on Tue Sep 24 21:17:40 2002 for FLAC by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002