Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class 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                 const char *resolved_as_cstring(const Stream &) const;
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         //
00160         //  Equivalent: FLAC__SeekableStreamDecoder
00161         //
00162         // ============================================================
00163 
00177         class FLACPP_API SeekableStream {
00178         public:
00179             class FLACPP_API State {
00180             public:
00181                 inline State(::FLAC__SeekableStreamDecoderState state): state_(state) { }
00182                 inline operator ::FLAC__SeekableStreamDecoderState() const { return state_; }
00183                 inline const char *as_cstring() const { return ::FLAC__SeekableStreamDecoderStateString[state_]; }
00184                 const char *resolved_as_cstring(const SeekableStream &) const;
00185             protected:
00186                 ::FLAC__SeekableStreamDecoderState state_;
00187             };
00188 
00189             SeekableStream();
00190             virtual ~SeekableStream();
00191 
00192             bool is_valid() const;
00193             inline operator bool() const { return is_valid(); }
00194 
00195             bool set_md5_checking(bool value);
00196             bool set_metadata_respond(::FLAC__MetadataType type);
00197             bool set_metadata_respond_application(const FLAC__byte id[4]);
00198             bool set_metadata_respond_all();
00199             bool set_metadata_ignore(::FLAC__MetadataType type);
00200             bool set_metadata_ignore_application(const FLAC__byte id[4]);
00201             bool set_metadata_ignore_all();
00202 
00203             State get_state() const;
00204             Stream::State get_stream_decoder_state() const;
00205             bool get_md5_checking() const;
00206             unsigned get_channels() const;
00207             ::FLAC__ChannelAssignment get_channel_assignment() const;
00208             unsigned get_bits_per_sample() const;
00209             unsigned get_sample_rate() const;
00210             unsigned get_blocksize() const;
00211 
00212             State init();
00213 
00214             bool finish();
00215 
00216             bool flush();
00217             bool reset();
00218 
00219             bool process_single();
00220             bool process_until_end_of_metadata();
00221             bool process_until_end_of_stream();
00222 
00223             bool seek_absolute(FLAC__uint64 sample);
00224         protected:
00225             virtual ::FLAC__SeekableStreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
00226             virtual ::FLAC__SeekableStreamDecoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset) = 0;
00227             virtual ::FLAC__SeekableStreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset) = 0;
00228             virtual ::FLAC__SeekableStreamDecoderLengthStatus length_callback(FLAC__uint64 *stream_length) = 0;
00229             virtual bool eof_callback() = 0;
00230             virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
00231             virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00232             virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
00233 
00234             ::FLAC__SeekableStreamDecoder *decoder_;
00235         private:
00236             static ::FLAC__SeekableStreamDecoderReadStatus read_callback_(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
00237             static ::FLAC__SeekableStreamDecoderSeekStatus seek_callback_(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
00238             static ::FLAC__SeekableStreamDecoderTellStatus tell_callback_(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
00239             static ::FLAC__SeekableStreamDecoderLengthStatus length_callback_(const ::FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
00240             static FLAC__bool eof_callback_(const ::FLAC__SeekableStreamDecoder *decoder, void *client_data);
00241             static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00242             static void metadata_callback_(const ::FLAC__SeekableStreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00243             static void error_callback_(const ::FLAC__SeekableStreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00244 
00245             // Private and undefined so you can't use them:
00246             SeekableStream(const SeekableStream &);
00247             void operator=(const SeekableStream &);
00248         };
00249 
00250         /* \} */
00251 
00252 
00253         // ============================================================
00254         //
00255         //  Equivalent: FLAC__FileDecoder
00256         //
00257         // ============================================================
00258 
00272         class FLACPP_API File {
00273         public:
00274             class FLACPP_API State {
00275             public:
00276                 inline State(::FLAC__FileDecoderState state): state_(state) { }
00277                 inline operator ::FLAC__FileDecoderState() const { return state_; }
00278                 inline const char *as_cstring() const { return ::FLAC__FileDecoderStateString[state_]; }
00279                 const char *resolved_as_cstring(const File &) const;
00280             protected:
00281                 ::FLAC__FileDecoderState state_;
00282             };
00283 
00284             File();
00285             virtual ~File();
00286 
00287             bool is_valid() const;
00288             inline operator bool() const { return is_valid(); }
00289 
00290             bool set_md5_checking(bool value);
00291             bool set_filename(const char *value); 
00292             bool set_metadata_respond(::FLAC__MetadataType type);
00293             bool set_metadata_respond_application(const FLAC__byte id[4]);
00294             bool set_metadata_respond_all();
00295             bool set_metadata_ignore(::FLAC__MetadataType type);
00296             bool set_metadata_ignore_application(const FLAC__byte id[4]);
00297             bool set_metadata_ignore_all();
00298 
00299             State get_state() const;
00300             SeekableStream::State get_seekable_stream_decoder_state() const;
00301             Stream::State get_stream_decoder_state() const;
00302             bool get_md5_checking() const;
00303             unsigned get_channels() const;
00304             ::FLAC__ChannelAssignment get_channel_assignment() const;
00305             unsigned get_bits_per_sample() const;
00306             unsigned get_sample_rate() const;
00307             unsigned get_blocksize() const;
00308 
00309             State init();
00310 
00311             bool finish();
00312 
00313             bool process_single();
00314             bool process_until_end_of_metadata();
00315             bool process_until_end_of_file();
00316 
00317             bool seek_absolute(FLAC__uint64 sample);
00318         protected:
00319             virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
00320             virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00321             virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
00322 
00323             ::FLAC__FileDecoder *decoder_;
00324         private:
00325             static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::FLAC__FileDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00326             static void metadata_callback_(const ::FLAC__FileDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00327             static void error_callback_(const ::FLAC__FileDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00328 
00329             // Private and undefined so you can't use them:
00330             File(const File &);
00331             void operator=(const File &);
00332         };
00333 
00334         /* \} */
00335 
00336     };
00337 };
00338 
00339 #endif

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