Bayonne2 / Common C++ 2 Framework: audio2.h Source File

Bayonne2 / Common C++ 2 Framework
audio2.h
Go to the documentation of this file.
1 // Copyright (C) 1999-2005 Open Source Telecom Corporation.
2 // Copyright (C) 2006-2008 David Sugar, Tycho Softworks.
3 //
4 // This file is part of GNU ccAudio2.
5 //
6 // GNU ccAudio2 is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU Lesser General Public License as published
8 // by the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // GNU ccAudio2 is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with GNU ccAudio2. If not, see <http://www.gnu.org/licenses/>.
18 
25 #ifndef CCXX_AUDIO_H_
26 #define CCXX_AUDIO_H_
27 
28 #ifndef CCXX_PACKING
29 #if defined(__GNUC__)
30 #define CCXX_PACKED
31 #elif !defined(__hpux) && !defined(_AIX)
32  #define CCXX_PACKED
33 #endif
34 #endif
35 
36 #ifndef W32
37 #if defined(_WIN32) && defined(_MSC_VER)
38 #pragma warning(disable: 4996)
39 #define W32
40 #endif
41 #if defined(__BORLANDC__) && defined(__Windows)
42 #define W32
43 #endif
44 #endif
45 
46 #if !defined(__EXPORT) && defined(W32)
47 #define __EXPORT __declspec(dllimport)
48 #endif
49 
50 #ifndef __EXPORT
51  #define __EXPORT
52 #endif
53 
54 #ifdef W32
55 #include <windows.h>
56 #ifndef ssize_t
57 #define ssize_t int
58 #endif
59 #else
60 #include <cstddef>
61 #include <cstdlib>
62 #include <sys/types.h>
63 #include <netinet/in.h>
64 #endif
65 
66 #include <ctime>
67 
68  namespace ost {
69 
70  #define AUDIO_SIGNED_LINEAR_RAW 1
71  #define AUDIO_LINEAR_CONVERSION 1
72  #define AUDIO_CODEC_MODULES 1
73  #define AUDIO_LINEAR_FRAMING 1
74  #define AUDIO_NATIVE_METHODS 1
75  #define AUDIO_RATE_RESAMPLER 1
76 
77 class __EXPORT AudioCodec;
78 class __EXPORT AudioDevice;
79 
88  class __EXPORT Audio
89 {
90 public:
91 #ifdef W32
92  typedef short Sample;
93  typedef short *Linear;
94  typedef short Level;
95  typedef DWORD timeout_t;
96  typedef WORD snd16_t;
97  typedef DWORD snd32_t;
98 #else
99   typedef int16_t snd16_t;
100   typedef int32_t snd32_t;
101   typedef int16_t Level;
102   typedef int16_t Sample;
103   typedef int16_t *Linear;
104   typedef unsigned long timeout_t;
105 #endif
106 
107   static const unsigned ndata;
108 
109   typedef struct {
110   float v2;
111   float v3;
112   float fac;
113  } goertzel_state_t;
114 
115   typedef struct {
116   int hit1;
117   int hit2;
118   int hit3;
119   int hit4;
120   int mhit;
121 
122   goertzel_state_t row_out[4];
123   goertzel_state_t col_out[4];
124   goertzel_state_t row_out2nd[4];
125   goertzel_state_t col_out2nd[4];
126   goertzel_state_t fax_tone;
127   goertzel_state_t fax_tone2nd;
128   float energy;
129 
130   int current_sample;
131   char digits[129];
132   int current_digits;
133   int detected_digits;
134   int lost_digits;
135   int digit_hits[16];
136   int fax_hits;
137  } dtmf_detect_state_t;
138 
139   typedef struct {
140   float fac;
141  } tone_detection_descriptor_t;
142 
143   typedef unsigned char *Encoded;
144 
148   enum Rate {
149   rateUnknown,
150   rate6khz = 6000,
151   rate8khz = 8000,
152   rate16khz = 16000,
153   rate32khz = 32000,
154   rate44khz = 44100
155  };
156 
157   typedef enum Rate Rate;
158 
162   enum Mode {
163   modeRead,
164   modeReadAny,
165   modeReadOne,
166   modeWrite,
167   modeCache,
168   modeInfo,
169   modeFeed,
170 
171   modeAppend, // app specific placeholders...
172   modeCreate
173  };
174 
175   typedef enum Mode Mode;
176 
180   enum Encoding {
181   unknownEncoding = 0,
182   g721ADPCM,
183   g722Audio,
184   g722_7bit,
185   g722_6bit,
186   g723_2bit,
187   g723_3bit,
188   g723_5bit,
189   gsmVoice,
190   msgsmVoice,
191   mulawAudio,
192   alawAudio,
193   mp1Audio,
194   mp2Audio,
195   mp3Audio,
196   okiADPCM,
197   voxADPCM,
198   sx73Voice,
199   sx96Voice,
200 
201  // Please keep the PCM types at the end of the list -
202  // see the "is this PCM or not?" code in
203  // AudioFile::close for why.
204   cdaStereo,
205   cdaMono,
206   pcm8Stereo,
207   pcm8Mono,
208   pcm16Stereo,
209   pcm16Mono,
210   pcm32Stereo,
211   pcm32Mono,
212 
213  // speex codecs
214   speexVoice, // narrow band
215   speexAudio,
216 
217   g729Audio,
218   ilbcAudio,
219   speexUltra,
220 
221   speexNarrow = speexVoice,
222   speexWide = speexAudio,
223   g723_4bit = g721ADPCM
224  };
225   typedef enum Encoding Encoding;
226 
230   enum Format {
231   raw,
232   snd,
233   riff,
234   mpeg,
235   wave
236  };
237   typedef enum Format Format;
238 
242   enum DeviceMode {
243   PLAY,
244   RECORD,
245   PLAYREC
246  };
247   typedef enum DeviceMode DeviceMode;
248 
252   enum Error {
253   errSuccess = 0,
254   errReadLast,
255   errNotOpened,
256   errEndOfFile,
257   errStartOfFile,
258   errRateInvalid,
259   errEncodingInvalid,
260   errReadInterrupt,
261   errWriteInterrupt,
262   errReadFailure,
263   errWriteFailure,
264   errReadIncomplete,
265   errWriteIncomplete,
266   errRequestInvalid,
267   errTOCFailed,
268   errStatFailed,
269   errInvalidTrack,
270   errPlaybackFailed,
271   errNotPlaying,
272   errNoCodec
273  };
274   typedef enum Error Error;
275 
276 
277 #ifdef CCXX_PACKED
278 #pragma pack(1)
279 #endif
280 
281   typedef struct {
282 #if __BYTE_ORDER == __LITTLE_ENDIAN
283   unsigned char mp_sync1 : 8;
284   unsigned char mp_crc : 1;
285   unsigned char mp_layer : 2;
286   unsigned char mp_ver : 2;
287   unsigned char mp_sync2 : 3;
288 
289   unsigned char mp_priv : 1;
290   unsigned char mp_pad : 1;
291   unsigned char mp_srate : 2;
292   unsigned char mp_brate : 4;
293 
294   unsigned char mp_emp : 2;
295   unsigned char mp_original : 1;
296   unsigned char mp_copyright: 1;
297   unsigned char mp_extend : 2;
298   unsigned char mp_channels : 2;
299 
300 #else
301  unsigned char mp_sync1 : 8;
302 
303  unsigned char mp_sync2 : 3;
304  unsigned char mp_ver : 2;
305  unsigned char mp_layer : 2;
306  unsigned char mp_crc : 1;
307 
308  unsigned char mp_brate : 4;
309  unsigned char mp_srate : 2;
310  unsigned char mp_pad : 1;
311  unsigned char mp_priv : 1;
312 
313  unsigned char mp_channels : 2;
314  unsigned char mp_extend : 2;
315  unsigned char mp_copyright : 1;
316  unsigned char mp_original : 1;
317  unsigned char mp_emp : 2;
318 #endif
319  } mpeg_audio;
320 
321   typedef struct {
322   char tag_id[3];
323   char tag_title[30];
324   char tag_artist[30];
325   char tag_album[30];
326   char tag_year[4];
327   char tag_note[30];
328   unsigned char genre;
329  } mpeg_tagv1;
330 
331 #ifdef CCXX_PACKED
332 #pragma pack()
333 #endif
334 
338   class __EXPORT Info
339  {
340  public:
341   Format format;
342   Encoding encoding;
343   unsigned long rate;
344   unsigned long bitrate;
345   unsigned order;
346   unsigned framesize, framecount, headersize, padding;
347   timeout_t framing;
348   char *annotation;
349 
350  Info();
351  void clear(void);
352  void set(void);
353  void setFraming(timeout_t frame);
354  void setRate(Rate rate);
355  };
356 
363  static Level tolevel(float dbm);
364 
371  static float todbm(Level power);
372 
380  static bool hasDevice(unsigned device = 0);
381 
392  static AudioDevice *getDevice(unsigned device = 0, DeviceMode mode = PLAY);
393 
399  static const char *getCodecPath(void);
400 
408  static const char *getMIME(Info &info);
409 
417  static const char *getName(Encoding encoding);
418 
426  static const char *getExtension(Encoding encoding);
427 
438  static Encoding getEncoding(const char *name);
439 
446  static Encoding getStereo(Encoding encoding);
447 
454  static Encoding getMono(Encoding encoding);
455 
462  static bool isLinear(Encoding encoding);
463 
472  static bool isBuffered(Encoding encoding);
473 
480  static bool isMono(Encoding encoding);
481 
488  static bool isStereo(Encoding encoding);
489 
497  static Rate getRate(Encoding encoding);
498 
507  static Rate getRate(Encoding e, Rate request);
508 
516  static timeout_t getFraming(Encoding encoding, timeout_t timeout = 0);
517 
525  static timeout_t getFraming(Info &info, timeout_t timeout = 0);
526 
534  static bool isEndian(Encoding encoding);
535 
543  static bool isEndian(Info &info);
544 
554  static bool swapEndian(Encoding encoding, void *buffer, unsigned number);
555 
564  static void swapEncoded(Info &info, Encoded data, size_t bytes);
565 
576  static bool swapEndian(Info &info, void *buffer, unsigned number);
577 
586  static Level getImpulse(Encoding encoding, void *buffer, unsigned number);
587 
596  static Level getImpulse(Info &info, void *buffer, unsigned number = 0);
597 
607  static Level getPeak(Encoding encoding, void *buffer, unsigned number);
608 
618  static Level getPeak(Info &info, void *buffer, unsigned number = 0);
619 
627  static void toTimestamp(timeout_t duration, char *address, size_t size);
628 
635  static timeout_t toTimeout(const char *timestamp);
636 
659  static int getFrame(Encoding encoding, int samples = 0);
660 
673  static int getCount(Encoding encoding);
674 
683  static unsigned long toSamples(Encoding encoding, size_t bytes);
684 
693  static unsigned long toSamples(Info &info, size_t bytes);
694 
703  static size_t toBytes(Info &info, unsigned long number);
704 
713  static size_t toBytes(Encoding encoding, unsigned long number);
714 
723  static void fill(unsigned char *address, int number, Encoding encoding);
724 
731  static bool loadPlugin(const char *path);
732 
740  static size_t maxFramesize(Info &info);
741 };
742 
750  class __EXPORT AudioResample : public Audio
751 {
752 protected:
753   unsigned mfact, dfact, max;
754   unsigned gpos, ppos;
755   Sample last;
756   Linear buffer;
757 
758 public:
759  AudioResample(Rate mul, Rate div);
760  ~AudioResample();
761 
762  size_t process(Linear from, Linear to, size_t count);
763  size_t estimate(size_t count);
764 };
765 
774  class __EXPORT AudioTone : public Audio
775 {
776 protected:
777   Rate rate;
778   unsigned samples;
779   Linear frame;
780   double df1, df2, p1, p2;
781   Level m1, m2;
782   bool silencer;
783 
787  void silence(void);
788 
792  void reset(void);
793 
797  void cleanup(void);
798 
805  void single(unsigned freq, Level level);
806 
815  void dual(unsigned f1, unsigned f2, Level l1, Level l2);
816 
817 public:
823   inline Rate getRate(void)
824  {return rate;};
825 
831   inline size_t getSamples(void)
832  {return samples;};
833 
839  bool isSilent(void);
840 
848  virtual Linear getFrame(void);
849 
858  unsigned getFrames(Linear buffer, unsigned number);
859 
866  virtual bool isComplete(void);
867 
874  AudioTone(timeout_t duration = 20, Rate rate = rate8khz);
875 
886  AudioTone(unsigned f1, unsigned f2, Level l1, Level l2,
887  timeout_t duration = 20, Rate sample = rate8khz);
888 
897  AudioTone(unsigned freq, Level level, timeout_t duration = 20, Rate sample = rate8khz);
898 
899  virtual ~AudioTone();
900 };
901 
908  class __EXPORT AudioBase : public Audio
909 {
910 protected:
911   Info info;
912 
913 public:
917  AudioBase();
918 
924  AudioBase(Info *info);
925 
929  virtual ~AudioBase();
930 
936   inline Encoding getEncoding(void)
937  {return info.encoding;};
938 
944   inline unsigned getSampleRate(void)
945  {return info.rate;};
946 
954  virtual ssize_t putBuffer(Encoded data, size_t size) = 0;
955 
964  ssize_t putNative(Encoded data, size_t size);
965 
973  virtual ssize_t getBuffer(Encoded data, size_t size) = 0;
974 
981   inline ssize_t getPacket(Encoded data)
982  {return getBuffer(data, 0);};
983 
991  ssize_t getNative(Encoded data, size_t size);
992 };
993 
1001  class __EXPORT AudioBuffer : public AudioBase
1002 {
1003 public:
1004  AudioBuffer(Info *info, size_t size = 4096);
1005  virtual ~AudioBuffer();
1006 
1014  ssize_t getBuffer(Encoded data, size_t number);
1015 
1023  ssize_t putBuffer(Encoded data, size_t number);
1024 
1025 private:
1026   char *buf;
1027   size_t size, start, len;
1028   void *mutexObject;
1029 
1030  void enter(void);
1031  void leave(void);
1032 };
1033 
1042  class __EXPORT AudioFile: public AudioBase
1043 {
1044 protected:
1045   char *pathname;
1046   Error error;
1047   unsigned long header; // offset to start of audio
1048   unsigned long minimum; // minimum sample size required
1049   unsigned long length; // current size of file, including header
1050 
1051  void initialize(void);
1052  void getWaveFormat(int size);
1053  void mp3info(mpeg_audio *mp3);
1054 
1055  union {
1056   int fd;
1057   void *handle;
1058  } file;
1059 
1060   Mode mode;
1061   unsigned long iolimit;
1062 
1063  virtual bool afCreate(const char *path, bool exclusive = false);
1064  virtual bool afOpen(const char *path, Mode m = modeWrite);
1065  virtual bool afPeek(unsigned char *data, unsigned size);
1066 
1067  AudioCodec *getCodec(void);
1068 
1081  virtual int afRead(unsigned char *data, unsigned size);
1082 
1094  virtual int afWrite(unsigned char *data, unsigned size);
1095 
1105  virtual bool afSeek(unsigned long pos);
1106 
1110  virtual void afClose(void);
1111 
1119   virtual char *getContinuation(void)
1120  {return NULL;};
1121 
1130  const char * getErrorStr(Error err);
1131 
1132  Error setError(Error err);
1133 
1140   inline unsigned long getHeader(void)
1141  {return header;};
1142 
1151  unsigned short getShort(unsigned char *data);
1152 
1161  void setShort(unsigned char *data, unsigned short value);
1162 
1171  unsigned long getLong(unsigned char *data);
1172 
1181  void setLong(unsigned char *data, unsigned long value);
1182 
1183 public:
1190  AudioFile(const char *name, unsigned long offset = 0);
1191 
1199  AudioFile(const char *name, Info *info, unsigned long minimum = 0);
1200 
1204   inline AudioFile()
1205  {initialize();};
1206 
1207  virtual ~AudioFile();
1208 
1219  void open(const char *name, Mode mode = modeWrite, timeout_t framing = 0);
1220 
1231  void create(const char *name, Info *info, bool exclusive = false, timeout_t framing = 0);
1232 
1239  time_t getAge(void);
1240 
1246   inline size_t getSize(void)
1247  {return maxFramesize(info);};
1248 
1254  void close(void);
1255 
1263  void clear(void);
1264 
1276  ssize_t getBuffer(Encoded buffer, size_t len = 0);
1277 
1286  unsigned getLinear(Linear buffer, unsigned request = 0);
1287 
1299  ssize_t putBuffer(Encoded buffer, size_t len = 0);
1300 
1309  unsigned putLinear(Linear buffer, unsigned request = 0);
1310 
1325  Error getSamples(void *buffer, unsigned samples = 0);
1326 
1340  Error putSamples(void *buffer, unsigned samples = 0);
1341 
1349  Error skip(long number);
1350 
1358  Error setPosition(unsigned long samples = ~0l);
1359 
1367  Error position(const char *timestamp);
1368 
1375  void getPosition(char *timestamp, size_t size);
1376 
1384  Error setLimit(unsigned long maximum = 0l);
1385 
1393  Error getInfo(Info *info);
1394 
1403  Error setMinimum(unsigned long minimum);
1404 
1414  unsigned long getAbsolutePosition(void);
1415 
1427  unsigned long getPosition(void);
1428 
1434  virtual bool isOpen(void);
1435 
1443   virtual bool hasPositioning(void)
1444  {return true;};
1445 
1451   inline Encoding getEncoding(void)
1452  {return info.encoding;};
1453 
1459   inline Format getFormat(void)
1460  {return info.format;};
1461 
1468   inline unsigned getSampleRate(void)
1469  {return info.rate;};
1470 
1476   inline char *getAnnotation(void)
1477  {return info.annotation;};
1478 
1484   inline Error getError(void)
1485  {return error;};
1486 
1487   inline bool operator!(void)
1488  {return (bool)!isOpen();};
1489 
1495  bool isSigned(void);
1496 };
1497 
1509  class __EXPORT AudioStream : public AudioFile
1510 {
1511 protected:
1512   AudioCodec *codec; // if needed
1513   Encoded framebuf;
1514   bool streamable;
1515   Linear bufferFrame;
1516   unsigned bufferPosition;
1517   unsigned bufferChannels;
1518   Linear encBuffer, decBuffer;
1519   unsigned encSize, decSize;
1520 
1521  unsigned bufAudio(Linear samples, unsigned count, unsigned size);
1522 
1523 public:
1527  AudioStream();
1528 
1536  AudioStream(const char *name, Mode mode = modeRead, timeout_t framing = 0);
1537 
1546  AudioStream(const char *name, Info *info, bool exclusive = false, timeout_t framing = 0);
1547 
1548  virtual ~AudioStream();
1549 
1557  ssize_t getBuffer(Encoded data, size_t count);
1558 
1566  void open(const char *name, Mode mode = modeRead, timeout_t framing = 0);
1567 
1576  void create(const char *name, Info *info, bool exclusive = false, timeout_t framing = 0);
1577 
1581  void close(void);
1582 
1586  void flush(void);
1587 
1594  bool isStreamable(void);
1595 
1599  unsigned getCount(void); // frame count
1600 
1610  unsigned getEncoded(AudioCodec *codec, Encoded address, unsigned frames = 1);
1611 
1621  unsigned putEncoded(AudioCodec *codec, Encoded address, unsigned frames = 1);
1622 
1630  unsigned getEncoded(Encoded address, unsigned frames = 1);
1631 
1639  unsigned putEncoded(Encoded address, unsigned frames = 1);
1640 
1648  ssize_t getPacket(Encoded data);
1649 
1658  unsigned getMono(Linear buffer, unsigned frames = 1);
1659 
1668  unsigned getStereo(Linear buffer, unsigned frames = 1);
1669 
1678  unsigned putMono(Linear buffer, unsigned frames = 1);
1679 
1688  unsigned putStereo(Linear buffer, unsigned frames = 1);
1689 
1699  unsigned bufMono(Linear buffer, unsigned count);
1700 
1710  unsigned bufStereo(Linear buffer, unsigned count);
1711 
1717   inline AudioCodec *getCodec(void)
1718  {return codec;};
1719 };
1720 
1733  class __EXPORT AudioCodec : public Audio
1734 {
1735 protected:
1736   static AudioCodec *first;
1737   AudioCodec *next;
1738   Encoding encoding;
1739   const char *name;
1740   Info info;
1741 
1742  AudioCodec();
1743 
1751   virtual AudioCodec *getByFormat(const char *format)
1752  {return this;};
1753 
1760   virtual AudioCodec *getByInfo(Info &info)
1761  {return this;};
1762 
1763 public:
1770  AudioCodec(const char *name, Encoding encoding);
1771 
1772   virtual ~AudioCodec() {};
1773 
1780  static void endCodec(AudioCodec *codec);
1781 
1791  static AudioCodec *getCodec(Encoding encoding, const char *format = NULL, bool loaded = false);
1792 
1801  static AudioCodec *getCodec(Info &info, bool loaded = false);
1802 
1809  static bool load(const char *name);
1810 
1818  static bool load(Encoding encoding);
1819 
1828  virtual Level getImpulse(void *buffer, unsigned number = 0);
1829 
1837  virtual Level getPeak(void *buffer, unsigned number = 0);
1838 
1849  virtual bool isSilent(Level threashold, void *buffer, unsigned number = 0);
1850 
1859  virtual unsigned encode(Linear buffer, void *dest, unsigned number = 0) = 0;
1860 
1869  virtual unsigned encodeBuffered(Linear Buffer, Encoded dest, unsigned number);
1870 
1879  virtual unsigned decode(Linear buffer, void *source, unsigned number = 0) = 0;
1880 
1890  virtual unsigned decodeBuffered(Linear buffer, Encoded source, unsigned len);
1891 
1897  virtual unsigned getEstimated(void);
1898 
1904  virtual unsigned getRequired(void);
1905 
1915  virtual unsigned getPacket(Encoded destination, Encoded data, unsigned size);
1916 
1922   inline Info getInfo(void)
1923  {return info;};
1924 };
1925 
1926  class __EXPORT AudioDevice : public AudioBase
1927 {
1928 protected:
1929   bool enabled;
1930 
1931 public:
1932   virtual ~AudioDevice() {};
1933 
1941  virtual unsigned putSamples(Linear buffer, unsigned count) = 0;
1942 
1950  virtual unsigned getSamples(Linear buffer, unsigned count) = 0;
1951 
1960  virtual ssize_t putBuffer(Encoded data, size_t count);
1961 
1970  virtual ssize_t getBuffer(Encoded data, size_t count);
1971 
1979   virtual bool setEncoded(Info &info)
1980  {return false;};
1981 
1990  virtual bool setAudio(Rate rate = rate8khz, bool stereo = false, timeout_t framing = 20) = 0;
1991 
1998   virtual void sync(void)
1999  {return;};
2000 
2004  virtual void flush(void) = 0;
2005 
2015  unsigned bufMono(Linear buffer, unsigned count);
2016 
2026  unsigned bufStereo(Linear buffer, unsigned count);
2027 
2033   inline Info *getInfo(void)
2034  {return &info;};
2035 
2044   inline bool isEnabled(void)
2045  {return enabled;};
2046 };
2047 
2056  class __EXPORT TelTone : public AudioTone
2057 {
2058 public:
2059   typedef struct _tonedef {
2060   struct _tonedef *next;
2061   timeout_t duration, silence;
2062   unsigned count;
2063   unsigned short f1, f2;
2064  } tonedef_t;
2065 
2066   typedef struct _tonekey {
2067   struct _tonekey *next;
2068   struct _tonedef *first;
2069   struct _tonedef *last;
2070   char id[1];
2071  } tonekey_t;
2072 
2081  TelTone(tonekey_t *key, Level level, timeout_t frame = 20);
2082  ~TelTone();
2083 
2090  Linear getFrame(void);
2091 
2098  bool isComplete(void);
2099 
2100 
2108  static bool load(const char *pathname, const char *locale = NULL);
2109 
2117  static tonekey_t *find(const char *tone, const char *locale = NULL);
2118 
2119 protected:
2120   tonekey_t *tone;
2121   tonedef_t *def;
2122   unsigned remaining, silent, count;
2123   timeout_t framing;
2124   Level level;
2125   bool complete;
2126 };
2127 
2137  class __EXPORT DTMFTones : public AudioTone
2138 {
2139 protected:
2140   unsigned remaining, dtmfframes;
2141   timeout_t frametime;
2142   const char *digits;
2143   Level level;
2144   bool complete;
2145 
2146 public:
2155  DTMFTones(const char *digits, Level level, timeout_t duration = 20, timeout_t interdigit = 60);
2156 
2157  ~DTMFTones();
2158 
2159  Linear getFrame(void);
2160  bool isComplete(void);
2161 };
2162 
2172  class __EXPORT MFTones : public AudioTone
2173 {
2174 protected:
2175   unsigned remaining, mfframes;
2176   timeout_t frametime;
2177   const char *digits;
2178   Level level;
2179   bool complete, kflag;
2180 
2181 public:
2190  MFTones(const char *digits, Level level, timeout_t duration = 20, timeout_t interdigit = 60);
2191 
2192  ~MFTones();
2193 
2194  Linear getFrame(void);
2195  bool isComplete(void);
2196 };
2197 
2198 
2203  class __EXPORT DTMFDetect : public Audio
2204 {
2205 public:
2206  DTMFDetect();
2207  ~DTMFDetect();
2208 
2217  int putSamples(Linear buffer, int count);
2218 
2225  int getResult(char *data, int size);
2226 
2227 protected:
2228  void goertzelInit(goertzel_state_t *s, tone_detection_descriptor_t *t);
2229  void goertzelUpdate(goertzel_state_t *s, Sample x[], int samples);
2230  float goertzelResult(goertzel_state_t *s);
2231 
2232 private:
2233   dtmf_detect_state_t *state;
2234   tone_detection_descriptor_t dtmf_detect_row[4];
2235   tone_detection_descriptor_t dtmf_detect_col[4];
2236   tone_detection_descriptor_t dtmf_detect_row_2nd[4];
2237   tone_detection_descriptor_t dtmf_detect_col_2nd[4];
2238   tone_detection_descriptor_t fax_detect;
2239   tone_detection_descriptor_t fax_detect_2nd;
2240 };
2241 
2242 }
2243 
2244 #endif
2245 
ost::Audio::Mode
Mode
File processing mode, whether to skip missing files, etc.
Definition: audio2.h:162
ost::AudioTone::m2
Level m2
Definition: audio2.h:781
ost::AudioFile::AudioFile
AudioFile()
Construct an audio file without attaching to the filesystem.
Definition: audio2.h:1204
ost::TelTone::def
tonedef_t * def
Definition: audio2.h:2121
ost::AudioFile::handle
void * handle
Definition: audio2.h:1057
ost::Audio
Generic audio class to hold master data types and various useful class encapsulated friend functions ...
Definition: audio2.h:88
ost::AudioStream
AudioStream accesses AudioFile base class content as fixed frames of streaming linear samples...
Definition: audio2.h:1509
ost::Audio::Level
int16_t Level
Definition: audio2.h:101
ost::AudioBuffer::buf
char * buf
Definition: audio2.h:1026
ost::AudioFile::getAnnotation
char * getAnnotation(void)
Get annotation extracted from header of containing file.
Definition: audio2.h:1476
ost::AudioCodec::~AudioCodec
virtual ~AudioCodec()
Definition: audio2.h:1772
ost::AudioCodec::info
Info info
Definition: audio2.h:1740
ost::AudioCodec::getByInfo
virtual AudioCodec * getByInfo(Info &info)
get a codec by audio source info descriptor.
Definition: audio2.h:1760
ost::Audio::Encoded
unsigned char * Encoded
Definition: audio2.h:143
ost::AudioFile::getError
Error getError(void)
Get last error code.
Definition: audio2.h:1484
ost::Audio::Encoding
Encoding
Audio encoding formats.
Definition: audio2.h:180
ost::Audio::Info::encoding
Encoding encoding
Definition: audio2.h:342
ost::MFTones::kflag
bool kflag
Definition: audio2.h:2179
ost::TelTone::level
Level level
Definition: audio2.h:2124
error
__EXPORT AppLog & error(AppLog &sl)
Manipulator for error level.
Definition: applog.h:541
ost::Audio::Info::annotation
char * annotation
Definition: audio2.h:348
ost::Audio::Rate
Rate
Audio encoding rate, samples per second.
Definition: audio2.h:148
ost::AudioFile::getSampleRate
unsigned getSampleRate(void)
Get audio encoding sample rate, in samples per second, for this audio file.
Definition: audio2.h:1468
ost::AudioCodec
The codec class is a virtual used for transcoding audio samples between linear frames (or other known...
Definition: audio2.h:1733
ost::AudioResample::buffer
Linear buffer
Definition: audio2.h:756
ost::AudioFile::getHeader
unsigned long getHeader(void)
Get number of bytes in the file header.
Definition: audio2.h:1140
ost::AudioStream::codec
AudioCodec * codec
Definition: audio2.h:1512
ost::Audio::Info::padding
unsigned padding
Definition: audio2.h:346
ost::TelTone::_tonekey::last
struct _tonedef * last
Definition: audio2.h:2069
ost::Audio::Linear
int16_t * Linear
Definition: audio2.h:103
ost::TelTone::_tonedef::f2
unsigned short f2
Definition: audio2.h:2063
info
__EXPORT AppLog & info(AppLog &sl)
Manipulator for info level.
Definition: applog.h:581
ost::TelTone::_tonekey::next
struct _tonekey * next
Definition: audio2.h:2067
ost::AudioStream::encBuffer
Linear encBuffer
Definition: audio2.h:1518
ost::AudioDevice::~AudioDevice
virtual ~AudioDevice()
Definition: audio2.h:1932
ost::AudioResample
The AudioResample class is used to manage linear intropolation buffering for rate conversions...
Definition: audio2.h:750
ost::AudioFile::getSize
size_t getSize(void)
Get maximum size of frame buffer for data use.
Definition: audio2.h:1246
ost::DTMFDetect::state
dtmf_detect_state_t * state
Definition: audio2.h:2233
ost::AudioBuffer::start
size_t start
Definition: audio2.h:1027
ost::MFTones
MFTones is used to generate a series of mf audio data from a "telephone" number passed as an ASCII st...
Definition: audio2.h:2172
ost::Audio::Info::format
Format format
Definition: audio2.h:341
ost::AudioStream::streamable
bool streamable
Definition: audio2.h:1514
find
__EXPORT char * find(const char *cs, char *str, size_t len=0)
ost::Audio::Info
Audio source description.
Definition: audio2.h:338
ost::AudioFile::iolimit
unsigned long iolimit
Definition: audio2.h:1061
ost::AudioCodec::first
static AudioCodec * first
Definition: audio2.h:1736
ost::AudioDevice::enabled
bool enabled
Definition: audio2.h:1929
ost::AudioBuffer
The AudioBuffer class is for mixing one-to-one soft joins.
Definition: audio2.h:1001
ost::AudioBase::getPacket
ssize_t getPacket(Encoded data)
Get's a packet of audio data.
Definition: audio2.h:981
ost::AudioStream::bufferFrame
Linear bufferFrame
Definition: audio2.h:1515
ost::DTMFDetect::fax_detect
tone_detection_descriptor_t fax_detect
Definition: audio2.h:2238
timeout_t
unsigned long timeout_t
Definition: thread.h:74
ost::AudioTone::getSamples
size_t getSamples(void)
Get the frame size for the number of audio samples generated.
Definition: audio2.h:831
ost::DTMFTones::level
Level level
Definition: audio2.h:2143
ost::DTMFTones::digits
const char * digits
Definition: audio2.h:2142
ost::TelTone::_tonedef::next
struct _tonedef * next
Definition: audio2.h:2060
ost::MFTones::level
Level level
Definition: audio2.h:2178
ost::AudioFile::header
unsigned long header
Definition: audio2.h:1047
ost::AudioBase::getEncoding
Encoding getEncoding(void)
Generic get encoding.
Definition: audio2.h:936
ost::AudioFile
A class used to manipulate audio data.
Definition: audio2.h:1042
ost::DTMFTones::complete
bool complete
Definition: audio2.h:2144
Buffer
The buffer class represents an IPC service that is built upon a buffer of fixed capacity that can be ...
Definition: buffer.h:81
ost::AudioDevice::sync
virtual void sync(void)
Synchronize timing for audio device to next audio frame.
Definition: audio2.h:1998
ost::AudioBase
AudioBase base class for many other audio classes which stream data.
Definition: audio2.h:908
ost::AudioDevice::getInfo
Info * getInfo(void)
Get audio device source descriptor in effect for the device.
Definition: audio2.h:2033
ost::Audio::Info::framing
timeout_t framing
Definition: audio2.h:347
ost::Audio::snd32_t
int32_t snd32_t
Definition: audio2.h:100
ost::MFTones::frametime
timeout_t frametime
Definition: audio2.h:2176
ost::AudioCodec::next
AudioCodec * next
Definition: audio2.h:1737
ost::AudioResample::last
Sample last
Definition: audio2.h:755
ost::AudioStream::framebuf
Encoded framebuf
Definition: audio2.h:1513
ost::AudioResample::mfact
unsigned mfact
Definition: audio2.h:753
ost::AudioCodec::getInfo
Info getInfo(void)
Get an info description for this codec.
Definition: audio2.h:1922
ost::AudioResample::ppos
unsigned ppos
Definition: audio2.h:754
ost::MFTones::remaining
unsigned remaining
Definition: audio2.h:2175
ost::AudioStream::encSize
unsigned encSize
Definition: audio2.h:1519
ost::AudioFile::error
Error error
Definition: audio2.h:1046
ost::DTMFTones::remaining
unsigned remaining
Definition: audio2.h:2140
ost::AudioTone::p2
double p2
Definition: audio2.h:780
ost::Audio::ndata
static const unsigned ndata
Definition: audio2.h:107
ost::AudioTone::samples
unsigned samples
Definition: audio2.h:778
ost::AudioFile::getEncoding
Encoding getEncoding(void)
Return audio encoding format for this audio file.
Definition: audio2.h:1451
ost::AudioCodec::getByFormat
virtual AudioCodec * getByFormat(const char *format)
often used to create a "new" codec of a subtype based on encoding format, default returns the current...
Definition: audio2.h:1751
ost::TelTone::_tonedef::count
unsigned count
Definition: audio2.h:2062
ost::Audio::Format
Format
Audio container file format.
Definition: audio2.h:230
ost::TelTone::complete
bool complete
Definition: audio2.h:2125
ost::Audio::Info::bitrate
unsigned long bitrate
Definition: audio2.h:344
ost::TelTone::_tonedef::silence
timeout_t silence
Definition: audio2.h:2061
ost::AudioTone::rate
Rate rate
Definition: audio2.h:777
ost::TelTone::silent
unsigned silent
Definition: audio2.h:2122
ost::AudioFile::getContinuation
virtual char * getContinuation(void)
This function is used to splice multiple audio files together into a single stream of continues audio...
Definition: audio2.h:1119
ost::AudioStream::getCodec
AudioCodec * getCodec(void)
Return the codec being used if there is one.
Definition: audio2.h:1717
ost::Audio::Info::rate
unsigned long rate
Definition: audio2.h:343
ost::AudioTone
The AudioTone class is used to create a frame of audio encoded single or dualtones.
Definition: audio2.h:774
ost::AudioBase::info
Info info
Definition: audio2.h:911
ost::DTMFDetect::fax_detect_2nd
tone_detection_descriptor_t fax_detect_2nd
Definition: audio2.h:2239
ost::TelTone::tone
tonekey_t * tone
Definition: audio2.h:2120
__EXPORT
#define __EXPORT
Definition: audio2.h:51
ost::AudioBase::getSampleRate
unsigned getSampleRate(void)
Generic sample rate.
Definition: audio2.h:944
ost::AudioCodec::encoding
Encoding encoding
Definition: audio2.h:1738
ost::AudioTone::silencer
bool silencer
Definition: audio2.h:782
ost::TelTone::_tonekey::first
struct _tonedef * first
Definition: audio2.h:2068
ost::DTMFTones::frametime
timeout_t frametime
Definition: audio2.h:2141
ost::AudioFile::operator!
bool operator!(void)
Definition: audio2.h:1487
ost::TelTone
An object that is used to sequence and extract telephony tones based on a telephony tone descriptor r...
Definition: audio2.h:2056
ost::Audio::DeviceMode
DeviceMode
Audio device access mode.
Definition: audio2.h:242
ost::MFTones::digits
const char * digits
Definition: audio2.h:2177
ost::AudioStream::bufferChannels
unsigned bufferChannels
Definition: audio2.h:1517
ost::AudioDevice::setEncoded
virtual bool setEncoded(Info &info)
Use encoding source descriptor to select the audio encoding format the audio device should be using...
Definition: audio2.h:1979
ost::AudioStream::bufferPosition
unsigned bufferPosition
Definition: audio2.h:1516
ost::AudioFile::length
unsigned long length
Definition: audio2.h:1049
ost::AudioFile::getFormat
Format getFormat(void)
Return base file format of containing audio file.
Definition: audio2.h:1459
ost::Audio::mpeg_tagv1::genre
unsigned char genre
Definition: audio2.h:328
ost::Audio::dtmf_detect_state_t::fax_tone
goertzel_state_t fax_tone
Definition: audio2.h:126
ost::Audio::dtmf_detect_state_t::fax_tone2nd
goertzel_state_t fax_tone2nd
Definition: audio2.h:127
ost::TelTone::framing
timeout_t framing
Definition: audio2.h:2123
ost::AudioTone::frame
Linear frame
Definition: audio2.h:779
ost::AudioBuffer::mutexObject
void * mutexObject
Definition: audio2.h:1028
ost::AudioDevice::isEnabled
bool isEnabled(void)
Whether device is currently enabled.
Definition: audio2.h:2044
ost::AudioFile::pathname
char * pathname
Definition: audio2.h:1045
ost::DTMFDetect
DTMFDetect is used for detecting DTMF tones in a stream of audio.
Definition: audio2.h:2203
ost::AudioFile::hasPositioning
virtual bool hasPositioning(void)
Return true if underlying derived class supports direct access to file positioning.
Definition: audio2.h:1443
ost::Audio::timeout_t
unsigned long timeout_t
Definition: audio2.h:104
ost::AudioTone::getRate
Rate getRate(void)
Get the sample encoding rate being used for the tone generator.
Definition: audio2.h:823
ost::Audio::Error
Error
Audio error conditions.
Definition: audio2.h:252
ost::AudioCodec::name
const char * name
Definition: audio2.h:1739
ost::AudioFile::mode
Mode mode
Definition: audio2.h:1060
ost::Audio::Info::order
unsigned order
Definition: audio2.h:345
ost::DTMFTones
DTMFTones is used to generate a series of dtmf audio data from a "telephone" number passed as an ASCI...
Definition: audio2.h:2137
ost::Audio::snd16_t
int16_t snd16_t
Definition: audio2.h:99
ost::Audio::Sample
int16_t Sample
Definition: audio2.h:102
ost::AudioFile::minimum
unsigned long minimum
Definition: audio2.h:1048

Generated on Dec 21, 2017 for commoncpp2-1.8.1, ccrtp-1.7.2, libzrtpcpp-2.3.4, ccscript3-1.1.7, ccaudio2-1.0.0 and bayonne2-2.3.2 (after installation in /usr/local/) by   doxygen 1.8.6

AltStyle によって変換されたページ (->オリジナル) /