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