annotate win64-mingw/include/FLAC++/decoder.h @ 122:62723f530572

Remove Vamp SDK (at least from OSX directory). We're beginning to include it in the main build instead.
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 18 Mar 2016 14:04:03 +0000
parents c9cf28b398fb
children
rev   line source
cannam@120 1 /* libFLAC++ - Free Lossless Audio Codec library
cannam@120 2 * Copyright (C) 2002,2003,2004,2005,2006,2007 Josh Coalson
cannam@120 3 *
cannam@120 4 * Redistribution and use in source and binary forms, with or without
cannam@120 5 * modification, are permitted provided that the following conditions
cannam@120 6 * are met:
cannam@120 7 *
cannam@120 8 * - Redistributions of source code must retain the above copyright
cannam@120 9 * notice, this list of conditions and the following disclaimer.
cannam@120 10 *
cannam@120 11 * - Redistributions in binary form must reproduce the above copyright
cannam@120 12 * notice, this list of conditions and the following disclaimer in the
cannam@120 13 * documentation and/or other materials provided with the distribution.
cannam@120 14 *
cannam@120 15 * - Neither the name of the Xiph.org Foundation nor the names of its
cannam@120 16 * contributors may be used to endorse or promote products derived from
cannam@120 17 * this software without specific prior written permission.
cannam@120 18 *
cannam@120 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
cannam@120 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
cannam@120 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
cannam@120 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
cannam@120 23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
cannam@120 24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
cannam@120 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
cannam@120 26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
cannam@120 27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
cannam@120 28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
cannam@120 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cannam@120 30 */
cannam@120 31
cannam@120 32 #ifndef FLACPP__DECODER_H
cannam@120 33 #define FLACPP__DECODER_H
cannam@120 34
cannam@120 35 #include "export.h"
cannam@120 36
cannam@120 37 #include <string>
cannam@120 38 #include "FLAC/stream_decoder.h"
cannam@120 39
cannam@120 40
cannam@120 41 /** \file include/FLAC++/decoder.h
cannam@120 42 *
cannam@120 43 * \brief
cannam@120 44 * This module contains the classes which implement the various
cannam@120 45 * decoders.
cannam@120 46 *
cannam@120 47 * See the detailed documentation in the
cannam@120 48 * \link flacpp_decoder decoder \endlink module.
cannam@120 49 */
cannam@120 50
cannam@120 51 /** \defgroup flacpp_decoder FLAC++/decoder.h: decoder classes
cannam@120 52 * \ingroup flacpp
cannam@120 53 *
cannam@120 54 * \brief
cannam@120 55 * This module describes the decoder layers provided by libFLAC++.
cannam@120 56 *
cannam@120 57 * The libFLAC++ decoder classes are object wrappers around their
cannam@120 58 * counterparts in libFLAC. All decoding layers available in
cannam@120 59 * libFLAC are also provided here. The interface is very similar;
cannam@120 60 * make sure to read the \link flac_decoder libFLAC decoder module \endlink.
cannam@120 61 *
cannam@120 62 * There are only two significant differences here. First, instead of
cannam@120 63 * passing in C function pointers for callbacks, you inherit from the
cannam@120 64 * decoder class and provide implementations for the callbacks in your
cannam@120 65 * derived class; because of this there is no need for a 'client_data'
cannam@120 66 * property.
cannam@120 67 *
cannam@120 68 * Second, there are two stream decoder classes. FLAC::Decoder::Stream
cannam@120 69 * is used for the same cases that FLAC__stream_decoder_init_stream() /
cannam@120 70 * FLAC__stream_decoder_init_ogg_stream() are used, and FLAC::Decoder::File
cannam@120 71 * is used for the same cases that
cannam@120 72 * FLAC__stream_decoder_init_FILE() and FLAC__stream_decoder_init_file() /
cannam@120 73 * FLAC__stream_decoder_init_ogg_FILE() and FLAC__stream_decoder_init_ogg_file()
cannam@120 74 * are used.
cannam@120 75 */
cannam@120 76
cannam@120 77 namespace FLAC {
cannam@120 78 namespace Decoder {
cannam@120 79
cannam@120 80 /** \ingroup flacpp_decoder
cannam@120 81 * \brief
cannam@120 82 * This class wraps the ::FLAC__StreamDecoder. If you are
cannam@120 83 * decoding from a file, FLAC::Decoder::File may be more
cannam@120 84 * convenient.
cannam@120 85 *
cannam@120 86 * The usage of this class is similar to FLAC__StreamDecoder,
cannam@120 87 * except instead of providing callbacks to
cannam@120 88 * FLAC__stream_decoder_init*_stream(), you will inherit from this
cannam@120 89 * class and override the virtual callback functions with your
cannam@120 90 * own implementations, then call init() or init_ogg(). The rest
cannam@120 91 * of the calls work the same as in the C layer.
cannam@120 92 *
cannam@120 93 * Only the read, write, and error callbacks are mandatory. The
cannam@120 94 * others are optional; this class provides default
cannam@120 95 * implementations that do nothing. In order for seeking to work
cannam@120 96 * you must overide seek_callback(), tell_callback(),
cannam@120 97 * length_callback(), and eof_callback().
cannam@120 98 */
cannam@120 99 class FLACPP_API Stream {
cannam@120 100 public:
cannam@120 101 /** This class is a wrapper around FLAC__StreamDecoderState.
cannam@120 102 */
cannam@120 103 class FLACPP_API State {
cannam@120 104 public:
cannam@120 105 inline State(::FLAC__StreamDecoderState state): state_(state) { }
cannam@120 106 inline operator ::FLAC__StreamDecoderState() const { return state_; }
cannam@120 107 inline const char *as_cstring() const { return ::FLAC__StreamDecoderStateString[state_]; }
cannam@120 108 inline const char *resolved_as_cstring(const Stream &decoder) const { return ::FLAC__stream_decoder_get_resolved_state_string(decoder.decoder_); }
cannam@120 109 protected:
cannam@120 110 ::FLAC__StreamDecoderState state_;
cannam@120 111 };
cannam@120 112
cannam@120 113 Stream();
cannam@120 114 virtual ~Stream();
cannam@120 115
cannam@120 116 //@{
cannam@120 117 /** Call after construction to check the that the object was created
cannam@120 118 * successfully. If not, use get_state() to find out why not.
cannam@120 119 */
cannam@120 120 virtual bool is_valid() const;
cannam@120 121 inline operator bool() const { return is_valid(); } ///< See is_valid()
cannam@120 122 //@}
cannam@120 123
cannam@120 124 virtual bool set_ogg_serial_number(long value); ///< See FLAC__stream_decoder_set_ogg_serial_number()
cannam@120 125 virtual bool set_md5_checking(bool value); ///< See FLAC__stream_decoder_set_md5_checking()
cannam@120 126 virtual bool set_metadata_respond(::FLAC__MetadataType type); ///< See FLAC__stream_decoder_set_metadata_respond()
cannam@120 127 virtual bool set_metadata_respond_application(const FLAC__byte id[4]); ///< See FLAC__stream_decoder_set_metadata_respond_application()
cannam@120 128 virtual bool set_metadata_respond_all(); ///< See FLAC__stream_decoder_set_metadata_respond_all()
cannam@120 129 virtual bool set_metadata_ignore(::FLAC__MetadataType type); ///< See FLAC__stream_decoder_set_metadata_ignore()
cannam@120 130 virtual bool set_metadata_ignore_application(const FLAC__byte id[4]); ///< See FLAC__stream_decoder_set_metadata_ignore_application()
cannam@120 131 virtual bool set_metadata_ignore_all(); ///< See FLAC__stream_decoder_set_metadata_ignore_all()
cannam@120 132
cannam@120 133 /* get_state() is not virtual since we want subclasses to be able to return their own state */
cannam@120 134 State get_state() const; ///< See FLAC__stream_decoder_get_state()
cannam@120 135 virtual bool get_md5_checking() const; ///< See FLAC__stream_decoder_get_md5_checking()
cannam@120 136 virtual FLAC__uint64 get_total_samples() const; ///< See FLAC__stream_decoder_get_total_samples()
cannam@120 137 virtual unsigned get_channels() const; ///< See FLAC__stream_decoder_get_channels()
cannam@120 138 virtual ::FLAC__ChannelAssignment get_channel_assignment() const; ///< See FLAC__stream_decoder_get_channel_assignment()
cannam@120 139 virtual unsigned get_bits_per_sample() const; ///< See FLAC__stream_decoder_get_bits_per_sample()
cannam@120 140 virtual unsigned get_sample_rate() const; ///< See FLAC__stream_decoder_get_sample_rate()
cannam@120 141 virtual unsigned get_blocksize() const; ///< See FLAC__stream_decoder_get_blocksize()
cannam@120 142 virtual bool get_decode_position(FLAC__uint64 *position) const; ///< See FLAC__stream_decoder_get_decode_position()
cannam@120 143
cannam@120 144 virtual ::FLAC__StreamDecoderInitStatus init(); ///< Seek FLAC__stream_decoder_init_stream()
cannam@120 145 virtual ::FLAC__StreamDecoderInitStatus init_ogg(); ///< Seek FLAC__stream_decoder_init_ogg_stream()
cannam@120 146
cannam@120 147 virtual bool finish(); ///< See FLAC__stream_decoder_finish()
cannam@120 148
cannam@120 149 virtual bool flush(); ///< See FLAC__stream_decoder_flush()
cannam@120 150 virtual bool reset(); ///< See FLAC__stream_decoder_reset()
cannam@120 151
cannam@120 152 virtual bool process_single(); ///< See FLAC__stream_decoder_process_single()
cannam@120 153 virtual bool process_until_end_of_metadata(); ///< See FLAC__stream_decoder_process_until_end_of_metadata()
cannam@120 154 virtual bool process_until_end_of_stream(); ///< See FLAC__stream_decoder_process_until_end_of_stream()
cannam@120 155 virtual bool skip_single_frame(); ///< See FLAC__stream_decoder_skip_single_frame()
cannam@120 156
cannam@120 157 virtual bool seek_absolute(FLAC__uint64 sample); ///< See FLAC__stream_decoder_seek_absolute()
cannam@120 158 protected:
cannam@120 159 /// see FLAC__StreamDecoderReadCallback
cannam@120 160 virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes) = 0;
cannam@120 161
cannam@120 162 /// see FLAC__StreamDecoderSeekCallback
cannam@120 163 virtual ::FLAC__StreamDecoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset);
cannam@120 164
cannam@120 165 /// see FLAC__StreamDecoderTellCallback
cannam@120 166 virtual ::FLAC__StreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset);
cannam@120 167
cannam@120 168 /// see FLAC__StreamDecoderLengthCallback
cannam@120 169 virtual ::FLAC__StreamDecoderLengthStatus length_callback(FLAC__uint64 *stream_length);
cannam@120 170
cannam@120 171 /// see FLAC__StreamDecoderEofCallback
cannam@120 172 virtual bool eof_callback();
cannam@120 173
cannam@120 174 /// see FLAC__StreamDecoderWriteCallback
cannam@120 175 virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
cannam@120 176
cannam@120 177 /// see FLAC__StreamDecoderMetadataCallback
cannam@120 178 virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata);
cannam@120 179
cannam@120 180 /// see FLAC__StreamDecoderErrorCallback
cannam@120 181 virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
cannam@120 182
cannam@120 183 #if (defined _MSC_VER) || (defined __BORLANDC__) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC)
cannam@120 184 // lame hack: some MSVC/GCC versions can't see a protected decoder_ from nested State::resolved_as_cstring()
cannam@120 185 friend State;
cannam@120 186 #endif
cannam@120 187 ::FLAC__StreamDecoder *decoder_;
cannam@120 188
cannam@120 189 static ::FLAC__StreamDecoderReadStatus read_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
cannam@120 190 static ::FLAC__StreamDecoderSeekStatus seek_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
cannam@120 191 static ::FLAC__StreamDecoderTellStatus tell_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
cannam@120 192 static ::FLAC__StreamDecoderLengthStatus length_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
cannam@120 193 static FLAC__bool eof_callback_(const ::FLAC__StreamDecoder *decoder, void *client_data);
cannam@120 194 static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
cannam@120 195 static void metadata_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
cannam@120 196 static void error_callback_(const ::FLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
cannam@120 197 private:
cannam@120 198 // Private and undefined so you can't use them:
cannam@120 199 Stream(const Stream &);
cannam@120 200 void operator=(const Stream &);
cannam@120 201 };
cannam@120 202
cannam@120 203 /** \ingroup flacpp_decoder
cannam@120 204 * \brief
cannam@120 205 * This class wraps the ::FLAC__StreamDecoder. If you are
cannam@120 206 * not decoding from a file, you may need to use
cannam@120 207 * FLAC::Decoder::Stream.
cannam@120 208 *
cannam@120 209 * The usage of this class is similar to FLAC__StreamDecoder,
cannam@120 210 * except instead of providing callbacks to
cannam@120 211 * FLAC__stream_decoder_init*_FILE() or
cannam@120 212 * FLAC__stream_decoder_init*_file(), you will inherit from this
cannam@120 213 * class and override the virtual callback functions with your
cannam@120 214 * own implementations, then call init() or init_off(). The rest
cannam@120 215 * of the calls work the same as in the C layer.
cannam@120 216 *
cannam@120 217 * Only the write, and error callbacks from FLAC::Decoder::Stream
cannam@120 218 * are mandatory. The others are optional; this class provides
cannam@120 219 * full working implementations for all other callbacks and
cannam@120 220 * supports seeking.
cannam@120 221 */
cannam@120 222 class FLACPP_API File: public Stream {
cannam@120 223 public:
cannam@120 224 File();
cannam@120 225 virtual ~File();
cannam@120 226
cannam@120 227 virtual ::FLAC__StreamDecoderInitStatus init(FILE *file); ///< See FLAC__stream_decoder_init_FILE()
cannam@120 228 virtual ::FLAC__StreamDecoderInitStatus init(const char *filename); ///< See FLAC__stream_decoder_init_file()
cannam@120 229 virtual ::FLAC__StreamDecoderInitStatus init(const std::string &filename); ///< See FLAC__stream_decoder_init_file()
cannam@120 230 virtual ::FLAC__StreamDecoderInitStatus init_ogg(FILE *file); ///< See FLAC__stream_decoder_init_ogg_FILE()
cannam@120 231 virtual ::FLAC__StreamDecoderInitStatus init_ogg(const char *filename); ///< See FLAC__stream_decoder_init_ogg_file()
cannam@120 232 virtual ::FLAC__StreamDecoderInitStatus init_ogg(const std::string &filename); ///< See FLAC__stream_decoder_init_ogg_file()
cannam@120 233 protected:
cannam@120 234 // this is a dummy implementation to satisfy the pure virtual in Stream that is actually supplied internally by the C layer
cannam@120 235 virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes);
cannam@120 236 private:
cannam@120 237 // Private and undefined so you can't use them:
cannam@120 238 File(const File &);
cannam@120 239 void operator=(const File &);
cannam@120 240 };
cannam@120 241
cannam@120 242 }
cannam@120 243 }
cannam@120 244
cannam@120 245 #endif