Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class 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,2003  Josh Coalson
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions
00006  * are met:
00007  *
00008  * - Redistributions of source code must retain the above copyright
00009  * notice, this list of conditions and the following disclaimer.
00010  *
00011  * - Redistributions in binary form must reproduce the above copyright
00012  * notice, this list of conditions and the following disclaimer in the
00013  * documentation and/or other materials provided with the distribution.
00014  *
00015  * - Neither the name of the Xiph.org Foundation nor the names of its
00016  * contributors may be used to endorse or promote products derived from
00017  * this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00022  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
00023  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00024  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00025  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00026  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00027  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00028  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00029  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030  */
00031 
00032 #ifndef OggFLACPP__DECODER_H
00033 #define OggFLACPP__DECODER_H
00034 
00035 #include "export.h"
00036 
00037 #include "OggFLAC/stream_decoder.h"
00038 // we only need this for the state abstraction really...
00039 #include "FLAC++/decoder.h"
00040 
00041 
00069 namespace OggFLAC {
00070     namespace Decoder {
00071 
00072         // ============================================================
00073         //
00074         //  Equivalent: OggFLAC__StreamDecoder
00075         //
00076         // ============================================================
00077 
00091         class OggFLACPP_API Stream {
00092         public:
00093             class OggFLACPP_API State {
00094             public:
00095                 inline State(::OggFLAC__StreamDecoderState state): state_(state) { }
00096                 inline operator ::OggFLAC__StreamDecoderState() const { return state_; }
00097                 inline const char *as_cstring() const { return ::OggFLAC__StreamDecoderStateString[state_]; }
00098             protected:
00099                 ::OggFLAC__StreamDecoderState state_;
00100             };
00101 
00102             Stream();
00103             virtual ~Stream();
00104 
00105             bool is_valid() const;
00106             inline operator bool() const { return is_valid(); }
00107 
00108             bool set_serial_number(long value);
00109             bool set_metadata_respond(::FLAC__MetadataType type);
00110             bool set_metadata_respond_application(const FLAC__byte id[4]);
00111             bool set_metadata_respond_all();
00112             bool set_metadata_ignore(::FLAC__MetadataType type);
00113             bool set_metadata_ignore_application(const FLAC__byte id[4]);
00114             bool set_metadata_ignore_all();
00115 
00116             State get_state() const;
00117             FLAC::Decoder::Stream::State get_FLAC_stream_decoder_state() const;
00118             unsigned get_channels() const;
00119             ::FLAC__ChannelAssignment get_channel_assignment() const;
00120             unsigned get_bits_per_sample() const;
00121             unsigned get_sample_rate() const;
00122             unsigned get_blocksize() const;
00123 
00124             State init();
00125 
00126             void finish();
00127 
00128             bool flush();
00129             bool reset();
00130 
00131             bool process_single();
00132             bool process_until_end_of_metadata();
00133             bool process_until_end_of_stream();
00134         protected:
00135             virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
00136             virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
00137             virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00138             virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
00139 
00140             ::OggFLAC__StreamDecoder *decoder_;
00141         private:
00142             static ::FLAC__StreamDecoderReadStatus read_callback_(const ::OggFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
00143             static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00144             static void metadata_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00145             static void error_callback_(const ::OggFLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00146 
00147             // Private and undefined so you can't use them:
00148             Stream(const Stream &);
00149             void operator=(const Stream &);
00150         };
00151 
00152         /* \} */
00153 
00154     };
00155 };
00156 
00157 #endif

Generated on Mon Jun 28 13:04:37 2004 for FLAC by doxygen 1.3.6