1
/* libOggFLAC++ - Free Lossless Audio Codec + Ogg library
2
* Copyright (C) 2002,2003 Josh Coalson
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.
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.
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.
20
#ifndef OggFLACPP__DECODER_H
21
#define OggFLACPP__DECODER_H
25
#include "OggFLAC/stream_decoder.h"
26
// we only need this for the state abstraction really...
27
#include "FLAC++/decoder.h"
30
/** \file include/OggFLAC++/decoder.h
33
* This module contains the classes which implement the various
36
* See the detailed documentation in the
37
* \link oggflacpp_decoder decoder \endlink module.
40
/** \defgroup oggflacpp_decoder OggFLAC++/decoder.h: decoder classes
44
* This module describes the decoder layers provided by libOggFLAC++.
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.
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.
60
// ============================================================
62
// Equivalent: OggFLAC__StreamDecoder
64
// ============================================================
66
/** \defgroup oggflacpp_stream_decoder OggFLAC++/decoder.h: stream decoder class
67
* \ingroup oggflacpp_decoder
70
* This class wraps the ::OggFLAC__StreamDecoder.
72
* See the \link oggflac_stream_decoder libOggFLAC stream decoder module \endlink.
77
/** This class wraps the ::OggFLAC__StreamDecoder.
79
class OggFLACPP_API Stream {
81
class OggFLACPP_API State {
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_]; }
87
::OggFLAC__StreamDecoderState state_;
93
bool is_valid() const;
94
inline operator bool() const { return is_valid(); }
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();
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;
119
bool process_single();
120
bool process_until_end_of_metadata();
121
bool process_until_end_of_stream();
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;
128
::OggFLAC__StreamDecoder *decoder_;
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);
135
// Private and undefined so you can't use them:
136
Stream(const Stream &);
137
void operator=(const Stream &);