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

include/OggFLAC++/decoder.h

Go to the documentation of this file.
00001 /* libOggFLAC++ - Free Lossless Audio Codec + Ogg 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 OggFLACPP__DECODER_H
00021 #define OggFLACPP__DECODER_H
00022 
00023 #include "OggFLAC/stream_decoder.h"
00024 // we only need this for the state abstraction really...
00025 #include "FLAC++/decoder.h"
00026 
00027 
00055 namespace OggFLAC {
00056     namespace Decoder {
00057 
00058         // ============================================================
00059         //
00060         //  Equivalent: OggFLAC__StreamDecoder
00061         //
00062         // ============================================================
00063 
00077         class Stream {
00078         public:
00079             class State {
00080             public:
00081                 inline State(::OggFLAC__StreamDecoderState state): state_(state) { }
00082                 inline operator ::OggFLAC__StreamDecoderState() const { return state_; }
00083                 inline const char *as_cstring() const { return ::OggFLAC__StreamDecoderStateString[state_]; }
00084             protected:
00085                 ::OggFLAC__StreamDecoderState state_;
00086             };
00087 
00088             Stream();
00089             virtual ~Stream();
00090 
00091             bool is_valid() const;
00092             inline operator bool() const { return is_valid(); }
00093 
00094             bool set_serial_number(long value);
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             FLAC::Decoder::Stream::State get_FLAC_stream_decoder_state() const;
00104             unsigned get_channels() const;
00105             ::FLAC__ChannelAssignment get_channel_assignment() const;
00106             unsigned get_bits_per_sample() const;
00107             unsigned get_sample_rate() const;
00108             unsigned get_blocksize() const;
00109 
00110             State init();
00111 
00112             void finish();
00113 
00114             bool flush();
00115             bool reset();
00116 
00117             bool process_single();
00118             bool process_until_end_of_metadata();
00119             bool process_until_end_of_stream();
00120         protected:
00121             virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
00122             virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
00123             virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00124             virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
00125 
00126             ::OggFLAC__StreamDecoder *decoder_;
00127         private:
00128             static ::FLAC__StreamDecoderReadStatus read_callback_(const ::OggFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
00129             static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00130             static void metadata_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00131             static void error_callback_(const ::OggFLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00132 
00133             // Private and undefined so you can't use them:
00134             Stream(const Stream &);
00135             void operator=(const Stream &);
00136         };
00137 
00138         /* \} */
00139 
00140     };
00141 };
00142 
00143 #endif

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