wvdbusserver: implement NameHasOwner request.
[wvstreams.git] / include / wvaudioencoder.h
bloba74e2f557a4656ecff91e14e1ba83f89a82bc1fd
1 /* -*- Mode: C++ -*-
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.
7 */
8 #ifndef __WVAUDIOENCODER_H
9 #define __WVAUDIOENCODER_H
11 #include "wvtypedencoder.h"
13 /**
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>
19 public:
21 /**
22 * Returns the number of channels.
23 * Returns: the number of channels
25 virtual unsigned int channels() const = 0;
27 /**
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>
37 public:
39 /**
40 * Returns the number of channels.
41 * Returns: the number of channels
43 virtual unsigned int channels() const = 0;
45 /**
46 * Returns the number of samples per frame.
47 * Returns: the frame size
49 virtual size_t samplesperframe() const = 0;
51 /**
52 * Synthesizes one audio frame to compensate for a missing packet.
53 * "outbuf" is the output buffer
54 * Returns: true on success
55 * @see encode
57 virtual bool missing(OBuffer &outbuf) = 0;
61 class WvSimpleAudioEncoder : public WvAudioEncoder
63 public:
65 WvSimpleAudioEncoder(unsigned int channels, unsigned int samplerate);
67 virtual unsigned int channels() const { return _channels; }
69 virtual size_t samplesperframe() const { return _samplesperframe; }
71 protected:
73 virtual bool _typedencode(IBuffer &inbuf, OBuffer &outbuf, bool flush);
75 virtual bool _typedfinish(OBuffer &outbuf);
77 private:
79 unsigned int _channels;
80 size_t _samplesperframe;
84 class WvSimpleAudioDecoder : public WvAudioDecoder
86 public:
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; }
96 protected:
98 virtual bool _typedencode(IBuffer &inbuf, OBuffer &outbuf, bool flush);
100 virtual bool _typedfinish(OBuffer &outbuf);
102 private:
104 unsigned int _channels;
105 size_t _samplesperframe;
109 #endif // __WVAUDIOENCODER_H