Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

wvaudioencoder.h

Go to the documentation of this file.
00001 /* -*- Mode: C++ -*- 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2003 Net Integration Technologies, Inc. 00004 * 00005 * Interface declaring additional methods required for a WvEncoder that 00006 * supports packetized audio formats. 00007 */ 00008 #ifndef __WVAUDIOENCODER_H 00009 #define __WVAUDIOENCODER_H 00010 00011 #include "wvtypedencoder.h" 00012 00013 /** 00014 * Abstract base class for encoders for PCM audio. This interface should be 00015 * added to a WvEncoder. 00016 */ 00017 class WvAudioEncoder : public WvTypedEncoder<float, unsigned char> 00018 { 00019 public: 00020 00021 /** 00022 * Returns the number of channels. 00023 * Returns: the number of channels 00024 */ 00025 virtual unsigned int channels() const = 0; 00026 00027 /** 00028 * Returns the number of samples per frame. 00029 * Returns: the frame size 00030 */ 00031 virtual size_t samplesperframe() const = 0; 00032 }; 00033 00034 00035 class WvAudioDecoder : public WvTypedEncoder<unsigned char, float> 00036 { 00037 public: 00038 00039 /** 00040 * Returns the number of channels. 00041 * Returns: the number of channels 00042 */ 00043 virtual unsigned int channels() const = 0; 00044 00045 /** 00046 * Returns the number of samples per frame. 00047 * Returns: the frame size 00048 */ 00049 virtual size_t samplesperframe() const = 0; 00050 00051 /** 00052 * Synthesizes one audio frame to compensate for a missing packet. 00053 * "outbuf" is the output buffer 00054 * Returns: true on success 00055 * @see encode 00056 */ 00057 virtual bool missing(OBuffer &outbuf) = 0; 00058 }; 00059 00060 00061 class WvSimpleAudioEncoder : public WvAudioEncoder 00062 { 00063 public: 00064 00065 WvSimpleAudioEncoder(unsigned int channels, unsigned int samplerate); 00066 00067 virtual unsigned int channels() const { return _channels; } 00068 00069 virtual size_t samplesperframe() const { return _samplesperframe; } 00070 00071 protected: 00072 00073 virtual bool _typedencode(IBuffer &inbuf, OBuffer &outbuf, bool flush); 00074 00075 virtual bool _typedfinish(OBuffer &outbuf); 00076 00077 private: 00078 00079 unsigned int _channels; 00080 size_t _samplesperframe; 00081 }; 00082 00083 00084 class WvSimpleAudioDecoder : public WvAudioDecoder 00085 { 00086 public: 00087 00088 WvSimpleAudioDecoder(unsigned int channels, unsigned int samplerate); 00089 00090 virtual unsigned int channels() const { return _channels; } 00091 00092 virtual size_t samplesperframe() const { return _samplesperframe; } 00093 00094 virtual bool missing(OBuffer &outbuf) { return false; } 00095 00096 protected: 00097 00098 virtual bool _typedencode(IBuffer &inbuf, OBuffer &outbuf, bool flush); 00099 00100 virtual bool _typedfinish(OBuffer &outbuf); 00101 00102 private: 00103 00104 unsigned int _channels; 00105 size_t _samplesperframe; 00106 }; 00107 00108 00109 #endif // __WVAUDIOENCODER_H

Generated on Tue Oct 5 01:09:19 2004 for WvStreams by doxygen 1.3.7