00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #if _MSC_VER > 1000
00037 #pragma once
00038 #endif // _MSC_VER > 1000
00039
00040 #include "openh323buildopts.h"
00041
00042 #include <lid.h>
00043 #include <opalplugin.h>
00044 #include <ptlib/sound.h>
00045
00046
00047 #ifdef _MSC_VER
00048 #pragma warning(disable:4100)
00049 #endif
00050
00051
00052
00053 class OpalUSBDevice : public OpalLineInterfaceDevice
00054 {
00055
00056 PCLASSINFO(OpalUSBDevice, OpalLineInterfaceDevice);
00057
00058 public:
00059
00060 class SoundTones : public PSound
00061 {
00062 public:
00063 SoundTones(unsigned channels,
00064 unsigned samplesPerSecond,
00065 unsigned bitsPerSample,
00066 PINDEX bufferSize,
00067 const BYTE * buffer);
00068
00069 void RunContinuous(OpalUSBDevice * dev) const;
00070 };
00071
00074 OpalUSBDevice();
00075
00076 OpalUSBDevice(PluginHID_Definition * hid);
00077
00078 ~OpalUSBDevice() { Close(); };
00079
00082 virtual BOOL Open(
00083 const PString & device
00084 );
00085
00088 virtual BOOL IsOpen() const;
00089
00092 virtual BOOL Close();
00093
00096 virtual PString GetName() const;
00097
00100 virtual BOOL IsLineTerminal(
00101 unsigned line
00102 );
00103
00104 enum {
00105 POTSLine,
00106 PSTNLine,
00107 NumLines
00108 };
00109
00112 virtual BOOL IsLinePresent(
00113 unsigned line,
00114 BOOL force = FALSE
00115 );
00116
00117
00122 virtual BOOL IsLineOffHook(
00123 unsigned line
00124 );
00125
00129 virtual BOOL SetLineOffHook(
00130 unsigned line,
00131 BOOL newState = TRUE
00132 );
00133
00134
00137 virtual BOOL IsLineRinging(
00138 unsigned line,
00139 DWORD * cadence = NULL
00140 );
00141
00145 virtual BOOL RingLine(
00146 unsigned line,
00147 DWORD cadence
00148 );
00149
00152 virtual BOOL IsLineDisconnected(
00153 unsigned line,
00154 BOOL checkForWink = TRUE
00155 );
00156
00160 virtual PINDEX GetReadFrameSize(
00161 unsigned line
00162 );
00163
00164 virtual BOOL SetReadFrameSize(unsigned, PINDEX);
00165
00169 virtual PINDEX GetWriteFrameSize(
00170 unsigned line
00171 );
00172
00173 virtual BOOL SetWriteFrameSize(unsigned, PINDEX);
00174
00175
00178 virtual BOOL ReadFrame(
00179 unsigned line,
00180 void * buf,
00181 PINDEX & count
00182 );
00183
00186 virtual BOOL WriteFrame(
00187 unsigned line,
00188 const void * buf,
00189 PINDEX count,
00190 PINDEX & written
00191 );
00192
00197 virtual BOOL SetRecordVolume(
00198 unsigned line,
00199 unsigned volume
00200 );
00201
00206 virtual BOOL SetPlayVolume(
00207 unsigned line,
00208 unsigned volume
00209 );
00210
00215 virtual BOOL GetRecordVolume(
00216 unsigned line,
00217 unsigned & volume
00218 );
00219
00224 virtual BOOL GetPlayVolume(
00225 unsigned line,
00226 unsigned & volume
00227 );
00228
00232 virtual BOOL PlayDTMF(
00233 unsigned line,
00234 const char * digits,
00235 DWORD onTime = DefaultDTMFOnTime,
00236 DWORD offTime = DefaultDTMFOffTime
00237 );
00238
00239
00245 virtual char ReadDTMF(
00246 unsigned line
00247 );
00248
00251 virtual BOOL PlayTone(
00252 unsigned line,
00253 CallProgressTones tone
00254 );
00255
00258 virtual BOOL IsTonePlaying(
00259 unsigned line
00260 );
00261
00264 virtual BOOL StopTone(
00265 unsigned line
00266 );
00267
00275 virtual BOOL GetCallerID(
00276 unsigned line,
00277 PString & idString,
00278 BOOL full = FALSE
00279 );
00280
00289 virtual BOOL SetCallerID(
00290 unsigned line,
00291 const PString & idString
00292 );
00293
00296 virtual unsigned GetLineCount();
00297
00300 virtual OpalMediaFormat::List GetMediaFormats() const;
00301
00304 virtual BOOL SetReadFormat(unsigned line, const OpalMediaFormat &mediaFormat);
00305
00308 virtual SetWriteFormat(unsigned line,const OpalMediaFormat &mediaFormat);
00309
00312 virtual OpalMediaFormat GetReadFormat(unsigned line);
00313
00316 virtual OpalMediaFormat GetWriteFormat(unsigned line);
00317
00320 virtual BOOL StopReadCodec(
00321 unsigned line
00322 );
00323
00326 virtual BOOL StopWriteCodec(
00327 unsigned line
00328 );
00329
00332 virtual OpalLineInterfaceDevice::DeviceType GetDeviceType();
00333
00334 PString soundDev;
00335 BOOL exitTone;
00336
00337 protected:
00338
00341 void InterpretInput(unsigned int ret);
00342
00343
00344
00345 BOOL CreateSoundDevice(BOOL IsEncoder,
00346 const PString & device,
00347 PINDEX rate = 8000,
00348 PINDEX samples = 1
00349 );
00350
00351 OpalMediaFormat MediaFormat;
00352
00353
00354
00355 unsigned int InvokeMessage(unsigned msg,unsigned val=0);
00356
00357 PluginHID_Definition * HID;
00358
00359 PThread * MonitorThread;
00360 PSyncPoint monitorTickle;
00361 PDECLARE_NOTIFIER(PThread, OpalUSBDevice, Monitor);
00362 BOOL exitFlag;
00363
00364 BOOL PluggedIn;
00365 unsigned int InputData;
00366 PString digitbuffer;
00367 BOOL OffHookState;
00368 BOOL isRinging;
00369
00370
00371 BOOL useSound;
00372 PSoundChannel * RecSound;
00373 PSoundChannel * PlaySound;
00374 PINDEX soundChannelBuffers;
00375 PINDEX vol;
00376
00377
00378 BOOL useTones;
00379 CallProgressTones CurTone;
00380 PThread * ToneThread;
00381 PDECLARE_NOTIFIER(PThread, OpalUSBDevice, TonePlay);
00382 PMutex vbMutex;
00383
00384
00385 BOOL hasPSTN;
00386
00387
00388 BOOL isCell;
00389
00390 };
00391
00392
00393