2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2003 Net Integration Technologies, Inc.
5 * Interface declaring additional methods required for a WvEncoder that
6 * supports packetized audio formats.
8 #ifndef __WVAUDIOENCODER_H
9 #define __WVAUDIOENCODER_H
11 #include "wvtypedencoder.h"
14 * Abstract base class for encoders for PCM audio. This interface should be
15 * added to a WvEncoder.
17 class WvAudioEncoder
: public WvTypedEncoder
<float, unsigned char>
22 * Returns the number of channels.
23 * Returns: the number of channels
25 virtual unsigned int channels() const = 0;
28 * Returns the number of samples per frame.
29 * Returns: the frame size
31 virtual size_t samplesperframe() const = 0;
35 class WvAudioDecoder
: public WvTypedEncoder
<unsigned char, float>
40 * Returns the number of channels.
41 * Returns: the number of channels
43 virtual unsigned int channels() const = 0;
46 * Returns the number of samples per frame.
47 * Returns: the frame size
49 virtual size_t samplesperframe() const = 0;
52 * Synthesizes one audio frame to compensate for a missing packet.
53 * "outbuf" is the output buffer
54 * Returns: true on success
57 virtual bool missing(OBuffer
&outbuf
) = 0;
61 class WvSimpleAudioEncoder
: public WvAudioEncoder
65 WvSimpleAudioEncoder(unsigned int channels
, unsigned int samplerate
);
67 virtual unsigned int channels() const { return _channels
; }
69 virtual size_t samplesperframe() const { return _samplesperframe
; }
73 virtual bool _typedencode(IBuffer
&inbuf
, OBuffer
&outbuf
, bool flush
);
75 virtual bool _typedfinish(OBuffer
&outbuf
);
79 unsigned int _channels
;
80 size_t _samplesperframe
;
84 class WvSimpleAudioDecoder
: public WvAudioDecoder
88 WvSimpleAudioDecoder(unsigned int channels
, unsigned int samplerate
);
90 virtual unsigned int channels() const { return _channels
; }
92 virtual size_t samplesperframe() const { return _samplesperframe
; }
94 virtual bool missing(OBuffer
&outbuf
) { return false; }
98 virtual bool _typedencode(IBuffer
&inbuf
, OBuffer
&outbuf
, bool flush
);
100 virtual bool _typedfinish(OBuffer
&outbuf
);
104 unsigned int _channels
;
105 size_t _samplesperframe
;
109 #endif // __WVAUDIOENCODER_H