vpblid.h

Go to the documentation of this file.
00001 /*
00002  * vpblid.h
00003  *
00004  * Voicetronix VPB4 line interface device
00005  *
00006  * Copyright (c) 1999-2001 Equivalence Pty. Ltd.
00007  *
00008  * The contents of this file are subject to the Mozilla Public License
00009  * Version 1.0 (the "License"); you may not use this file except in
00010  * compliance with the License. You may obtain a copy of the License at
00011  * http://www.mozilla.org/MPL/
00012  *
00013  * Software distributed under the License is distributed on an "AS IS"
00014  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00015  * the License for the specific language governing rights and limitations
00016  * under the License.
00017  *
00018  * The Original Code is Open H323 Library.
00019  *
00020  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00021  *
00022  * Contributor(s): ______________________________________.
00023  *
00024  * $Log: vpblid.h,v $
00025  * Revision 2.10  2005/11/30 13:35:26  csoutheren
00026  * Changed tags for Doxygen
00027  *
00028  * Revision 2.9  2004/10/06 13:03:41  rjongbloed
00029  * Added "configure" support for known LIDs
00030  * Changed LID GetName() function to be normalised against the GetAllNames()
00031  *   return values and fixed the pre-factory registration system.
00032  * Added a GetDescription() function to do what the previous GetName() did.
00033  *
00034  * Revision 2.8  2004/02/19 10:46:44  rjongbloed
00035  * Merged OpenH323 version 1.13.1 changes.
00036  *
00037  * Revision 2.7  2003/03/24 07:18:29  robertj
00038  * Added registration system for LIDs so can work with various LID types by
00039  *   name instead of class instance.
00040  *
00041  * Revision 2.6  2002/11/10 11:33:17  robertj
00042  * Updated to OpenH323 v1.10.3
00043  *
00044  * Revision 2.5  2002/09/16 02:52:35  robertj
00045  * Added #define so can select if #pragma interface/implementation is used on
00046  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00047  *
00048  * Revision 2.4  2002/09/04 06:01:47  robertj
00049  * Updated to OpenH323 v1.9.6
00050  *
00051  * Revision 2.3  2002/01/14 06:35:57  robertj
00052  * Updated to OpenH323 v1.7.9
00053  *
00054  * Revision 2.2  2001/10/05 00:22:13  robertj
00055  * Updated to PWLib 1.2.0 and OpenH323 1.7.0
00056  *
00057  * Revision 2.1  2001/08/01 05:18:51  robertj
00058  * Made OpalMediaFormatList class global to help with documentation.
00059  *
00060  * Revision 2.0  2001/07/27 15:48:24  robertj
00061  * Conversion of OpenH323 to Open Phone Abstraction Library (OPAL)
00062  *
00063  * Revision 1.16  2003/08/13 22:02:03  dereksmithies
00064  * Apply patch from Daniel Bichara to GetOSHandle() for VPB devices. Thanks.
00065  *
00066  * Revision 1.15  2003/03/05 06:26:41  robertj
00067  * Added function to play a WAV file to LID, thanks Pietro Ravasio
00068  *
00069  * Revision 1.14  2002/09/16 01:14:15  robertj
00070  * Added #define so can select if #pragma interface/implementation is used on
00071  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00072  *
00073  * Revision 1.13  2002/09/03 06:19:37  robertj
00074  * Normalised the multi-include header prevention ifdef/define symbol.
00075  *
00076  * Revision 1.12  2002/08/05 10:03:47  robertj
00077  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00078  *
00079  * Revision 1.11  2002/07/02 03:20:37  dereks
00080  * Fix check for line disconnected state.   Remove timer on line ringing.
00081  *
00082  * Revision 1.10  2001/11/19 06:35:59  robertj
00083  * Added tone generation handling
00084  *
00085  * Revision 1.9  2001/09/13 05:27:46  robertj
00086  * Fixed incorrect return type in virtual function, thanks Vjacheslav Andrejev
00087  *
00088  * Revision 1.8  2001/02/09 05:16:24  robertj
00089  * Added #pragma interface for GNU C++.
00090  *
00091  * Revision 1.7  2001/01/25 07:27:14  robertj
00092  * Major changes to add more flexible OpalMediaFormat class to normalise
00093  *   all information about media types, especially codecs.
00094  *
00095  * Revision 1.6  2001/01/24 05:34:49  robertj
00096  * Altered volume control range to be percentage, ie 100 is max volume.
00097  *
00098  * Revision 1.5  2000/11/24 10:50:52  robertj
00099  * Modified the ReadFrame/WriteFrame functions to allow for variable length codecs.
00100  *
00101  * Revision 1.4  2000/11/20 04:35:40  robertj
00102  * Changed tone detection API slightly to allow detection of multiple
00103  * simultaneous tones
00104  *
00105  * Revision 1.3  2000/05/02 04:32:25  robertj
00106  * Fixed copyright notice comment.
00107  *
00108  * Revision 1.2  2000/01/07 08:28:09  robertj
00109  * Additions and changes to line interface device base class.
00110  *
00111  * Revision 1.1  1999/12/23 23:02:35  robertj
00112  * File reorganision for separating RTP from H.323 and creation of LID for VPB support.
00113  *
00114  */
00115 
00116 #ifndef __OPAL_VPBLID_H
00117 #define __OPAL_VPBLID_H
00118 
00119 #ifdef P_USE_PRAGMA
00120 #pragma interface
00121 #endif
00122 
00123 
00124 #include <opal/buildopts.h>
00125 
00126 #ifdef HAS_VPB
00127 
00128 #include <lids/lid.h>
00129 #include <vpbapi.h>
00130 
00131 
00133 
00134 // DR - this thread is needed to keep tones playing indefinately, as VPB
00135 // tones normally end after a defined period.
00136 class ToneThread : public PThread
00137 {
00138   PCLASSINFO(PThread, ToneThread);
00139 
00140   public:
00141     ToneThread(int handle, VPB_TONE tone);
00142     ~ToneThread();
00143     void Main();
00144 
00145   private:
00146     int        handle;   // VPB handle to play tone on
00147     VPB_TONE   vpbtone;  // tone parameters of tone to play
00148     PSyncPoint shutdown; // used to signal Main() to finish
00149 };
00150 
00151 
00153 
00156 class OpalVpbDevice : public OpalLineInterfaceDevice
00157 {
00158   PCLASSINFO(OpalVpbDevice, OpalLineInterfaceDevice);
00159 
00160   public:
00163     OpalVpbDevice();
00164 
00168     ~OpalVpbDevice() { Close(); }
00169 
00172     virtual BOOL Open(
00173       const PString & device      
00174     );
00175 
00178     virtual BOOL Close();
00179 
00183     virtual PString GetDeviceType() const;
00184 
00187     virtual PString GetDeviceName() const;
00188 
00191     virtual PStringArray GetAllNames() const;
00192 
00195     virtual PString GetDescription() const;
00196 
00197 
00200     virtual unsigned GetLineCount();
00201 
00206     virtual BOOL IsLineOffHook(
00207       unsigned line   
00208     );
00209 
00213     virtual BOOL SetLineOffHook(
00214       unsigned line,        
00215       BOOL newState = TRUE  
00216     );
00217 
00218 
00221     virtual BOOL IsLineRinging(
00222       unsigned line,          
00223       DWORD * cadence = NULL  
00224     );
00225 
00229     virtual BOOL IsLineDisconnected(
00230       unsigned line,   
00231       BOOL checkForWink = TRUE
00232     );
00233 
00236     virtual OpalMediaFormatList GetMediaFormats() const;
00237 
00240     virtual BOOL SetReadFormat(
00241       unsigned line,    
00242       const OpalMediaFormat & mediaFormat   
00243     );
00244 
00247     virtual BOOL SetWriteFormat(
00248       unsigned line,    
00249       const OpalMediaFormat & mediaFormat   
00250     );
00251 
00254     virtual OpalMediaFormat GetReadFormat(
00255       unsigned line    
00256     );
00257 
00260     virtual OpalMediaFormat GetWriteFormat(
00261       unsigned line    
00262     );
00263 
00266     virtual BOOL StopReadCodec(
00267       unsigned line   
00268     );
00269 
00272     virtual BOOL StopWriteCodec(
00273       unsigned line   
00274     );
00275 
00280     virtual BOOL SetReadFrameSize(
00281       unsigned line,    
00282       PINDEX frameSize  
00283     );
00284 
00289     virtual BOOL SetWriteFrameSize(
00290       unsigned line,    
00291       PINDEX frameSize  
00292     );
00293 
00297     virtual PINDEX GetReadFrameSize(
00298       unsigned line   
00299     );
00300 
00304     virtual PINDEX GetWriteFrameSize(
00305       unsigned line   
00306     );
00307 
00310     virtual BOOL ReadFrame(
00311       unsigned line,    
00312       void * buf,   
00313       PINDEX & count    
00314     );
00315 
00318     virtual BOOL WriteFrame(
00319       unsigned line,    
00320       const void * buf, 
00321       PINDEX count,     
00322       PINDEX & written  
00323     );
00324 
00325 
00330     virtual BOOL SetRecordVolume(
00331       unsigned line,    
00332       unsigned volume   
00333     );
00334 
00339     virtual BOOL SetPlayVolume(
00340       unsigned line,    
00341       unsigned volume   
00342     );
00343 
00346     int GetOSHandle(
00347       unsigned line     
00348     );
00349 
00355     virtual char ReadDTMF(
00356       unsigned line   
00357     );
00358 
00362     virtual BOOL PlayDTMF(
00363       unsigned line,            
00364       const char * digits,      
00365       DWORD onTime = 90,        
00366       DWORD offTime = 30        
00367     );
00368 
00369 
00372     virtual unsigned IsToneDetected(
00373       unsigned line   
00374     );
00375 
00376     virtual BOOL PlayTone(
00377       unsigned line,          
00378       CallProgressTones tone  
00379     );
00380 
00381     virtual BOOL StopTone(
00382       unsigned line   
00383     );
00384         
00385     virtual BOOL PlayAudio(
00386       unsigned line,            
00387       const PString & filename  
00388     );
00389     
00390     virtual BOOL StopAudio(
00391       unsigned line   
00392     );
00393 
00394   protected:
00395     unsigned cardNumber;
00396     unsigned lineCount;
00397 
00398     enum { MaxLineCount = 8 };
00399 
00400     struct LineState {
00401       BOOL Open(unsigned cardNumber, unsigned lineNumber);
00402       BOOL SetLineOffHook(BOOL newState);
00403       BOOL IsLineRinging(DWORD *);
00404 
00405       int        handle;
00406       BOOL       currentHookState;
00407       PINDEX     readFormat,    writeFormat;
00408       PINDEX     readFrameSize, writeFrameSize;
00409       BOOL       readIdle,      writeIdle;
00410       PMutex     DTMFmutex;
00411       BOOL       DTMFplaying;
00412       ToneThread *myToneThread;
00413     } lineState[MaxLineCount];
00414 };
00415 
00416 
00417 #define OPAL_VPB_TYPE_NAME  "VPB"
00418 #define OPAL_REGISTER_VPB() OPAL_REGISTER_LID(OpalVpbDevice, OPAL_VPB_TYPE_NAME)
00419 
00420 #else // HAS_VPB
00421 
00422 #define OPAL_REGISTER_VPB()
00423 
00424 #endif // HAS_VPB
00425 
00426 #endif // __OPAL_VPBLID_H
00427 
00428 

Generated on Mon Sep 25 16:20:12 2006 for OPAL by  doxygen 1.4.7