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  * 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 FLACPP__DECODER_H
00033 #define FLACPP__DECODER_H
00034 
00035 #include "export.h"
00036 
00037 #include "FLAC/file_decoder.h"
00038 #include "FLAC/seekable_stream_decoder.h"
00039 #include "FLAC/stream_decoder.h"
00040 
00041 
00069 namespace FLAC {
00070     namespace Decoder {
00071 
00072         // ============================================================
00073         //
00074         //  Equivalent: FLAC__StreamDecoder
00075         //
00076         // ============================================================
00077 
00091         class FLACPP_API Stream {
00092         public:
00093             class FLACPP_API State {
00094             public:
00095                 inline State(::FLAC__StreamDecoderState state): state_(state) { }
00096                 inline operator ::FLAC__StreamDecoderState() const { return state_; }
00097                 inline const char *as_cstring() const { return ::FLAC__StreamDecoderStateString[state_]; }
00098                 inline const char *resolved_as_cstring(const Stream &decoder) const { return ::FLAC__stream_decoder_get_resolved_state_string(decoder.decoder_); }
00099             protected:
00100                 ::FLAC__StreamDecoderState state_;
00101             };
00102 
00103             Stream();
00104             virtual ~Stream();
00105 
00106             bool is_valid() const;
00107             inline operator bool() const { return is_valid(); }
00108 
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             unsigned get_channels() const;
00118             ::FLAC__ChannelAssignment get_channel_assignment() const;
00119             unsigned get_bits_per_sample() const;
00120             unsigned get_sample_rate() const;
00121             unsigned get_blocksize() const;
00122 
00127             State init();
00128 
00129             void finish();
00130 
00131             bool flush();
00132             bool reset();
00133 
00134             bool process_single();
00135             bool process_until_end_of_metadata();
00136             bool process_until_end_of_stream();
00137         protected:
00138             virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
00139             virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
00140             virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00141             virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
00142 
00143             ::FLAC__StreamDecoder *decoder_;
00144         private:
00145             static ::FLAC__StreamDecoderReadStatus read_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
00146             static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00147             static void metadata_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00148             static void error_callback_(const ::FLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00149 
00150             // Private and undefined so you can't use them:
00151             Stream(const Stream &);
00152             void operator=(const Stream &);
00153         };
00154 
00155         /* \} */
00156 
00157         // ============================================================
00158         //
00159         //  Equivalent: FLAC__SeekableStreamDecoder
00160         //
00161         // ============================================================
00162 
00176         class FLACPP_API SeekableStream {
00177         public:
00178             class FLACPP_API State {
00179             public:
00180                 inline State(::FLAC__SeekableStreamDecoderState state): state_(state) { }
00181                 inline operator ::FLAC__SeekableStreamDecoderState() const { return state_; }
00182                 inline const char *as_cstring() const { return ::FLAC__SeekableStreamDecoderStateString[state_]; }
00183                 inline const char *resolved_as_cstring(const SeekableStream &decoder) const { return ::FLAC__seekable_stream_decoder_get_resolved_state_string(decoder.decoder_); }
00184             protected:
00185                 ::FLAC__SeekableStreamDecoderState state_;
00186             };
00187 
00188             SeekableStream();
00189             virtual ~SeekableStream();
00190 
00191             bool is_valid() const;
00192             inline operator bool() const { return is_valid(); }
00193 
00194             bool set_md5_checking(bool value);
00195             bool set_metadata_respond(::FLAC__MetadataType type);
00196             bool set_metadata_respond_application(const FLAC__byte id[4]);
00197             bool set_metadata_respond_all();
00198             bool set_metadata_ignore(::FLAC__MetadataType type);
00199             bool set_metadata_ignore_application(const FLAC__byte id[4]);
00200             bool set_metadata_ignore_all();
00201 
00202             State get_state() const;
00203             Stream::State get_stream_decoder_state() const;
00204             bool get_md5_checking() const;
00205             unsigned get_channels() const;
00206             ::FLAC__ChannelAssignment get_channel_assignment() const;
00207             unsigned get_bits_per_sample() const;
00208             unsigned get_sample_rate() const;
00209             unsigned get_blocksize() const;
00210 
00211             State init();
00212 
00213             bool finish();
00214 
00215             bool flush();
00216             bool reset();
00217 
00218             bool process_single();
00219             bool process_until_end_of_metadata();
00220             bool process_until_end_of_stream();
00221 
00222             bool seek_absolute(FLAC__uint64 sample);
00223         protected:
00224             virtual ::FLAC__SeekableStreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
00225             virtual ::FLAC__SeekableStreamDecoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset) = 0;
00226             virtual ::FLAC__SeekableStreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset) = 0;
00227             virtual ::FLAC__SeekableStreamDecoderLengthStatus length_callback(FLAC__uint64 *stream_length) = 0;
00228             virtual bool eof_callback() = 0;
00229             virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
00230             virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00231             virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
00232 
00233             ::FLAC__SeekableStreamDecoder *decoder_;
00234         private:
00235             static ::FLAC__SeekableStreamDecoderReadStatus read_callback_(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
00236             static ::FLAC__SeekableStreamDecoderSeekStatus seek_callback_(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
00237             static ::FLAC__SeekableStreamDecoderTellStatus tell_callback_(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
00238             static ::FLAC__SeekableStreamDecoderLengthStatus length_callback_(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
00239             static FLAC__bool eof_callback_(const ::FLAC__SeekableStreamDecoder *decoder, void *client_data);
00240             static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00241             static void metadata_callback_(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00242             static void error_callback_(const ::FLAC__SeekableStreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00243 
00244             // Private and undefined so you can't use them:
00245             SeekableStream(const SeekableStream &);
00246             void operator=(const SeekableStream &);
00247         };
00248 
00249         /* \} */
00250 
00251         // ============================================================
00252         //
00253         //  Equivalent: FLAC__FileDecoder
00254         //
00255         // ============================================================
00256 
00270         class FLACPP_API File {
00271         public:
00272             class FLACPP_API State {
00273             public:
00274                 inline State(::FLAC__FileDecoderState state): state_(state) { }
00275                 inline operator ::FLAC__FileDecoderState() const { return state_; }
00276                 inline const char *as_cstring() const { return ::FLAC__FileDecoderStateString[state_]; }
00277                 inline const char *resolved_as_cstring(const File &decoder) const { return ::FLAC__file_decoder_get_resolved_state_string(decoder.decoder_); }
00278             protected:
00279                 ::FLAC__FileDecoderState state_;
00280             };
00281 
00282             File();
00283             virtual ~File();
00284 
00285             bool is_valid() const;
00286             inline operator bool() const { return is_valid(); }
00287 
00288             bool set_md5_checking(bool value);
00289             bool set_filename(const char *value); 
00290             bool set_metadata_respond(::FLAC__MetadataType type);
00291             bool set_metadata_respond_application(const FLAC__byte id[4]);
00292             bool set_metadata_respond_all();
00293             bool set_metadata_ignore(::FLAC__MetadataType type);
00294             bool set_metadata_ignore_application(const FLAC__byte id[4]);
00295             bool set_metadata_ignore_all();
00296 
00297             State get_state() const;
00298             SeekableStream::State get_seekable_stream_decoder_state() const;
00299             Stream::State get_stream_decoder_state() const;
00300             bool get_md5_checking() const;
00301             unsigned get_channels() const;
00302             ::FLAC__ChannelAssignment get_channel_assignment() const;
00303             unsigned get_bits_per_sample() const;
00304             unsigned get_sample_rate() const;
00305             unsigned get_blocksize() const;
00306 
00307             State init();
00308 
00309             bool finish();
00310 
00311             bool process_single();
00312             bool process_until_end_of_metadata();
00313             bool process_until_end_of_file();
00314 
00315             bool seek_absolute(FLAC__uint64 sample);
00316         protected:
00317             virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
00318             virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00319             virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
00320 
00321             ::FLAC__FileDecoder *decoder_;
00322         private:
00323             static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::FLAC__FileDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00324             static void metadata_callback_(const ::FLAC__FileDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00325             static void error_callback_(const ::FLAC__FileDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00326 
00327             // Private and undefined so you can't use them:
00328             File(const File &);
00329             void operator=(const File &);
00330         };
00331 
00332         /* \} */
00333 
00334     };
00335 };
00336 
00337 #endif

Generated on Fri Oct 3 00:07:08 2003 for FLAC by doxygen1.3