more doxygen docs
[platform/upstream/flac.git] / include / OggFLAC++ / encoder.h
1 /* libOggFLAC++ - Free Lossless Audio Codec + Ogg library
2  * Copyright (C) 2002  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__ENCODER_H
21 #define OggFLACPP__ENCODER_H
22
23 #include "OggFLAC/stream_encoder.h"
24 #include "decoder.h"
25 // we only need these for the state abstractions really...
26 #include "FLAC++/decoder.h"
27 #include "FLAC++/encoder.h"
28
29
30 /** \file include/OggFLAC++/encoder.h
31  *
32  *  \brief
33  *  This module contains the classes which implement the various
34  *  encoders.
35  *
36  *  See the detailed documentation in the
37  *  \link oggflacpp_encoder encoder \endlink module.
38  */
39
40 /** \defgroup oggflacpp_encoder OggFLAC++/encoder.h: encoder classes
41  *  \ingroup oggflacpp
42  *
43  *  \brief
44  *  This module describes the encoder layers provided by libOggFLAC++.
45  *
46  * The libOggFLAC++ encoder classes are object wrappers around their
47  * counterparts in libOggFLAC.  Only the stream encoding layer in
48  * libOggFLAC is provided here.  The interface is very similar;
49  * make sure to read the \link oggflac_encoder libOggFLAC encoder 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 encoder 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 Encoder {
59
60                 // ============================================================
61                 //
62                 //  Equivalent: OggFLAC__StreamEncoder
63                 //
64                 // ============================================================
65
66                 /** \defgroup oggflacpp_stream_encoder OggFLAC++/encoder.h: stream encoder class
67                  *  \ingroup oggflacpp_encoder
68                  *
69                  *  \brief
70                  *  This class wraps the ::OggFLAC__StreamEncoder.
71                  *
72                  * See the \link oggflac_stream_encoder libOggFLAC stream encoder module \endlink.
73                  *
74                  * \{
75                  */
76
77                 /** This class wraps the ::OggFLAC__StreamEncoder.
78                  */
79                 class Stream {
80                 public:
81                         class State {
82                         public:
83                                 inline State(::OggFLAC__StreamEncoderState state): state_(state) { }
84                                 inline operator ::OggFLAC__StreamEncoderState() const { return state_; }
85                                 inline const char *as_cstring() const { return ::OggFLAC__StreamEncoderStateString[state_]; }
86                         protected:
87                                 ::OggFLAC__StreamEncoderState 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_verify(bool value);
97                         bool set_streamable_subset(bool value);
98                         bool set_do_mid_side_stereo(bool value);
99                         bool set_loose_mid_side_stereo(bool value);
100                         bool set_channels(unsigned value);
101                         bool set_bits_per_sample(unsigned value);
102                         bool set_sample_rate(unsigned value);
103                         bool set_blocksize(unsigned value);
104                         bool set_max_lpc_order(unsigned value);
105                         bool set_qlp_coeff_precision(unsigned value);
106                         bool set_do_qlp_coeff_prec_search(bool value);
107                         bool set_do_escape_coding(bool value);
108                         bool set_do_exhaustive_model_search(bool value);
109                         bool set_min_residual_partition_order(unsigned value);
110                         bool set_max_residual_partition_order(unsigned value);
111                         bool set_rice_parameter_search_dist(unsigned value);
112                         bool set_total_samples_estimate(FLAC__uint64 value);
113                         bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
114
115                         State    get_state() const;
116                         FLAC::Encoder::Stream::State get_FLAC_stream_encoder_state() const;
117                         FLAC::Decoder::Stream::State get_verify_decoder_state() const;
118                         void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
119                         bool     get_verify() const;
120                         bool     get_streamable_subset() const;
121                         bool     get_do_mid_side_stereo() const;
122                         bool     get_loose_mid_side_stereo() const;
123                         unsigned get_channels() const;
124                         unsigned get_bits_per_sample() const;
125                         unsigned get_sample_rate() const;
126                         unsigned get_blocksize() const;
127                         unsigned get_max_lpc_order() const;
128                         unsigned get_qlp_coeff_precision() const;
129                         bool     get_do_qlp_coeff_prec_search() const;
130                         bool     get_do_escape_coding() const;
131                         bool     get_do_exhaustive_model_search() const;
132                         unsigned get_min_residual_partition_order() const;
133                         unsigned get_max_residual_partition_order() const;
134                         unsigned get_rice_parameter_search_dist() const;
135                         FLAC__uint64 get_total_samples_estimate() const;
136
137                         State init();
138
139                         void finish();
140
141                         bool process(const FLAC__int32 * const buffer[], unsigned samples);
142                         bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
143                 protected:
144                         virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
145
146                         ::OggFLAC__StreamEncoder *encoder_;
147                 private:
148                         static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::OggFLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
149
150                         // Private and undefined so you can't use them:
151                         Stream(const Stream &);
152                         void operator=(const Stream &);
153                 };
154
155                 /* \} */
156
157         };
158 };
159
160 #endif