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 #if _MSC_VER > 1000
00034 #pragma once
00035 #endif // _MSC_VER > 1000
00036
00037 #include "openh323buildopts.h"
00038
00039 #include <lid.h>
00040 #include <opalplugin.h>
00041
00042
00043 #ifdef _MSC_VER
00044 #pragma warning(disable:4100)
00045 #endif
00046
00047
00048
00049 class OpalUSBDevice : public OpalLineInterfaceDevice
00050 {
00051
00052 PCLASSINFO(OpalUSBDevice, OpalLineInterfaceDevice);
00053
00054 public:
00055
00056 class SoundTones : public PSound
00057 {
00058 public:
00059 SoundTones(unsigned channels,
00060 unsigned samplesPerSecond,
00061 unsigned bitsPerSample,
00062 PINDEX bufferSize,
00063 const BYTE * buffer);
00064
00065 void RunContinuous(OpalUSBDevice * dev) const;
00066 };
00067
00070 OpalUSBDevice();
00071
00072 OpalUSBDevice(PluginHID_Definition * hid);
00073
00074 ~OpalUSBDevice() { Close(); };
00075
00078 virtual BOOL Open(
00079 const PString & device
00080 );
00081
00084 virtual BOOL IsOpen() const;
00085
00088 virtual BOOL Close();
00089
00092 virtual PString GetName() const;
00093
00096 virtual BOOL IsLineTerminal(
00097 unsigned line
00098 );
00099
00100 enum {
00101 POTSLine,
00102 PSTNLine,
00103 NumLines
00104 };
00105
00108 virtual BOOL IsLinePresent(
00109 unsigned line,
00110 BOOL force = FALSE
00111 );
00112
00113
00118 virtual BOOL IsLineOffHook(
00119 unsigned line
00120 );
00121
00125 virtual BOOL SetLineOffHook(
00126 unsigned line,
00127 BOOL newState = TRUE
00128 );
00129
00130
00133 virtual BOOL IsLineRinging(
00134 unsigned line,
00135 DWORD * cadence = NULL
00136 );
00137
00141 virtual BOOL RingLine(
00142 unsigned line,
00143 DWORD cadence
00144 );
00145
00148 virtual BOOL IsLineDisconnected(
00149 unsigned line,
00150 BOOL checkForWink = TRUE
00151 );
00152
00156 virtual PINDEX GetReadFrameSize(
00157 unsigned line
00158 );
00159
00160 virtual BOOL SetReadFrameSize(unsigned, PINDEX);
00161
00165 virtual PINDEX GetWriteFrameSize(
00166 unsigned line
00167 );
00168
00169 virtual BOOL SetWriteFrameSize(unsigned, PINDEX);
00170
00171
00174 virtual BOOL ReadFrame(
00175 unsigned line,
00176 void * buf,
00177 PINDEX & count
00178 );
00179
00182 virtual BOOL WriteFrame(
00183 unsigned line,
00184 const void * buf,
00185 PINDEX count,
00186 PINDEX & written
00187 );
00188
00193 virtual BOOL SetRecordVolume(
00194 unsigned line,
00195 unsigned volume
00196 );
00197
00202 virtual BOOL SetPlayVolume(
00203 unsigned line,
00204 unsigned volume
00205 );
00206
00211 virtual BOOL GetRecordVolume(
00212 unsigned line,
00213 unsigned & volume
00214 );
00215
00220 virtual BOOL GetPlayVolume(
00221 unsigned line,
00222 unsigned & volume
00223 );
00224
00228 virtual BOOL PlayDTMF(
00229 unsigned line,
00230 const char * digits,
00231 DWORD onTime = DefaultDTMFOnTime,
00232 DWORD offTime = DefaultDTMFOffTime
00233 );
00234
00235
00241 virtual char ReadDTMF(
00242 unsigned line
00243 );
00244
00247 virtual BOOL PlayTone(
00248 unsigned line,
00249 CallProgressTones tone
00250 );
00251
00254 virtual BOOL IsTonePlaying(
00255 unsigned line
00256 );
00257
00260 virtual BOOL StopTone(
00261 unsigned line
00262 );
00263
00271 virtual BOOL GetCallerID(
00272 unsigned line,
00273 PString & idString,
00274 BOOL full = FALSE
00275 );
00276
00285 virtual BOOL SetCallerID(
00286 unsigned line,
00287 const PString & idString
00288 );
00289
00292 virtual unsigned GetLineCount();
00293
00296 virtual OpalMediaFormat::List GetMediaFormats() const;
00297
00300 virtual BOOL SetReadFormat(unsigned line, const OpalMediaFormat &mediaFormat);
00301
00304 virtual SetWriteFormat(unsigned line,const OpalMediaFormat &mediaFormat);
00305
00308 virtual OpalMediaFormat GetReadFormat(unsigned line);
00309
00312 virtual OpalMediaFormat GetWriteFormat(unsigned line);
00313
00316 virtual BOOL StopReadCodec(
00317 unsigned line
00318 );
00319
00322 virtual BOOL StopWriteCodec(
00323 unsigned line
00324 );
00325
00328 virtual OpalLineInterfaceDevice::DeviceType GetDeviceType();
00329
00330 PString soundDev;
00331 BOOL exitTone;
00332
00333 protected:
00334
00337 void InterpretInput(unsigned int ret);
00338
00339
00340
00341 BOOL CreateSoundDevice(BOOL IsEncoder,
00342 const PString & device,
00343 PINDEX rate = 8000,
00344 PINDEX samples = 1
00345 );
00346
00347 OpalMediaFormat MediaFormat;
00348
00349
00350
00351 unsigned int InvokeMessage(unsigned msg,unsigned val=0);
00352
00353 PluginHID_Definition * HID;
00354
00355 PThread * MonitorThread;
00356 PSyncPoint monitorTickle;
00357 PDECLARE_NOTIFIER(PThread, OpalUSBDevice, Monitor);
00358 BOOL exitFlag;
00359
00360 BOOL PluggedIn;
00361 unsigned int InputData;
00362 PString digitbuffer;
00363 BOOL OffHookState;
00364 BOOL isRinging;
00365
00366
00367 BOOL useSound;
00368 PSoundChannel * RecSound;
00369 PSoundChannel * PlaySound;
00370 PINDEX soundChannelBuffers;
00371 PINDEX vol;
00372
00373
00374 BOOL useTones;
00375 CallProgressTones CurTone;
00376 PThread * ToneThread;
00377 PDECLARE_NOTIFIER(PThread, OpalUSBDevice, TonePlay);
00378 PMutex vbMutex;
00379
00380
00381 BOOL hasPSTN;
00382
00383
00384 BOOL isCell;
00385
00386 };
00387
00388
00389