~ubuntu-branches/ubuntu/hoary/flac/hoary

« back to all changes in this revision

Viewing changes to include/OggFLAC++/decoder.h

  • Committer: Bazaar Package Importer
  • Author(s): Matt Zimmerman
  • Date: 2004-04-16 15:14:31 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040416151431-eyloggqxpwbwpogz
Tags: 1.1.0-11
Ensure that libFLAC is linked with -lm on all architectures, and
regardless of whether nasm is present

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* libOggFLAC++ - Free Lossless Audio Codec + Ogg library
 
2
 * Copyright (C) 2002,2003  Josh Coalson
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Library General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Library General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Library General Public
 
15
 * License along with this library; if not, write to the
 
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
 * Boston, MA  02111-1307, USA.
 
18
 */
 
19
 
 
20
#ifndef OggFLACPP__DECODER_H
 
21
#define OggFLACPP__DECODER_H
 
22
 
 
23
#include "export.h"
 
24
 
 
25
#include "OggFLAC/stream_decoder.h"
 
26
// we only need this for the state abstraction really...
 
27
#include "FLAC++/decoder.h"
 
28
 
 
29
 
 
30
/** \file include/OggFLAC++/decoder.h
 
31
 *
 
32
 *  \brief
 
33
 *  This module contains the classes which implement the various
 
34
 *  decoders.
 
35
 *
 
36
 *  See the detailed documentation in the
 
37
 *  \link oggflacpp_decoder decoder \endlink module.
 
38
 */
 
39
 
 
40
/** \defgroup oggflacpp_decoder OggFLAC++/decoder.h: decoder classes
 
41
 *  \ingroup oggflacpp
 
42
 *
 
43
 *  \brief
 
44
 *  This module describes the decoder layers provided by libOggFLAC++.
 
45
 *
 
46
 * The libOggFLAC++ decoder classes are object wrappers around their
 
47
 * counterparts in libOggFLAC.  Only the stream decoding layer in
 
48
 * libOggFLAC provided here.  The interface is very similar;
 
49
 * make sure to read the \link oggflac_decoder libOggFLAC decoder module \endlink.
 
50
 *
 
51
 * The only real difference here is that instead of passing in C function
 
52
 * pointers for callbacks, you inherit from the decoder class and provide
 
53
 * implementations for the callbacks in the derived class; because of this
 
54
 * there is no need for a 'client_data' property.
 
55
 */
 
56
 
 
57
namespace OggFLAC {
 
58
        namespace Decoder {
 
59
 
 
60
                // ============================================================
 
61
                //
 
62
                //  Equivalent: OggFLAC__StreamDecoder
 
63
                //
 
64
                // ============================================================
 
65
 
 
66
                /** \defgroup oggflacpp_stream_decoder OggFLAC++/decoder.h: stream decoder class
 
67
                 *  \ingroup oggflacpp_decoder
 
68
                 *
 
69
                 *  \brief
 
70
                 *  This class wraps the ::OggFLAC__StreamDecoder.
 
71
                 *
 
72
                 * See the \link oggflac_stream_decoder libOggFLAC stream decoder module \endlink.
 
73
                 *
 
74
                 * \{
 
75
                 */
 
76
 
 
77
                /** This class wraps the ::OggFLAC__StreamDecoder.
 
78
                 */
 
79
                class OggFLACPP_API Stream {
 
80
                public:
 
81
                        class OggFLACPP_API State {
 
82
                        public:
 
83
                                inline State(::OggFLAC__StreamDecoderState state): state_(state) { }
 
84
                                inline operator ::OggFLAC__StreamDecoderState() const { return state_; }
 
85
                                inline const char *as_cstring() const { return ::OggFLAC__StreamDecoderStateString[state_]; }
 
86
                        protected:
 
87
                                ::OggFLAC__StreamDecoderState state_;
 
88
                        };
 
89
 
 
90
                        Stream();
 
91
                        virtual ~Stream();
 
92
 
 
93
                        bool is_valid() const;
 
94
                        inline operator bool() const { return is_valid(); }
 
95
 
 
96
                        bool set_serial_number(long value);
 
97
                        bool set_metadata_respond(::FLAC__MetadataType type);
 
98
                        bool set_metadata_respond_application(const FLAC__byte id[4]);
 
99
                        bool set_metadata_respond_all();
 
100
                        bool set_metadata_ignore(::FLAC__MetadataType type);
 
101
                        bool set_metadata_ignore_application(const FLAC__byte id[4]);
 
102
                        bool set_metadata_ignore_all();
 
103
 
 
104
                        State get_state() const;
 
105
                        FLAC::Decoder::Stream::State get_FLAC_stream_decoder_state() const;
 
106
                        unsigned get_channels() const;
 
107
                        ::FLAC__ChannelAssignment get_channel_assignment() const;
 
108
                        unsigned get_bits_per_sample() const;
 
109
                        unsigned get_sample_rate() const;
 
110
                        unsigned get_blocksize() const;
 
111
 
 
112
                        State init();
 
113
 
 
114
                        void finish();
 
115
 
 
116
                        bool flush();
 
117
                        bool reset();
 
118
 
 
119
                        bool process_single();
 
120
                        bool process_until_end_of_metadata();
 
121
                        bool process_until_end_of_stream();
 
122
                protected:
 
123
                        virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
 
124
                        virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
 
125
                        virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
 
126
                        virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
 
127
 
 
128
                        ::OggFLAC__StreamDecoder *decoder_;
 
129
                private:
 
130
                        static ::FLAC__StreamDecoderReadStatus read_callback_(const ::OggFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
 
131
                        static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
 
132
                        static void metadata_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
 
133
                        static void error_callback_(const ::OggFLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
 
134
 
 
135
                        // Private and undefined so you can't use them:
 
136
                        Stream(const Stream &);
 
137
                        void operator=(const Stream &);
 
138
                };
 
139
 
 
140
                /* \} */
 
141
 
 
142
        };
 
143
};
 
144
 
 
145
#endif