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-2000 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 1.17  2005/11/30 13:05:01  csoutheren
00026  * Changed tags for Doxygen
00027  *
00028  * Revision 1.16  2003/08/13 22:02:03  dereksmithies
00029  * Apply patch from Daniel Bichara to GetOSHandle() for VPB devices. Thanks.
00030  *
00031  * Revision 1.15  2003/03/05 06:26:41  robertj
00032  * Added function to play a WAV file to LID, thanks Pietro Ravasio
00033  *
00034  * Revision 1.14  2002/09/16 01:14:15  robertj
00035  * Added #define so can select if #pragma interface/implementation is used on
00036  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00037  *
00038  * Revision 1.13  2002/09/03 06:19:37  robertj
00039  * Normalised the multi-include header prevention ifdef/define symbol.
00040  *
00041  * Revision 1.12  2002/08/05 10:03:47  robertj
00042  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00043  *
00044  * Revision 1.11  2002/07/02 03:20:37  dereks
00045  * Fix check for line disconnected state.   Remove timer on line ringing.
00046  *
00047  * Revision 1.10  2001/11/19 06:35:59  robertj
00048  * Added tone generation handling
00049  *
00050  * Revision 1.9  2001/09/13 05:27:46  robertj
00051  * Fixed incorrect return type in virtual function, thanks Vjacheslav Andrejev
00052  *
00053  * Revision 1.8  2001/02/09 05:16:24  robertj
00054  * Added #pragma interface for GNU C++.
00055  *
00056  * Revision 1.7  2001/01/25 07:27:14  robertj
00057  * Major changes to add more flexible OpalMediaFormat class to normalise
00058  *   all information about media types, especially codecs.
00059  *
00060  * Revision 1.6  2001/01/24 05:34:49  robertj
00061  * Altered volume control range to be percentage, ie 100 is max volume.
00062  *
00063  * Revision 1.5  2000/11/24 10:50:52  robertj
00064  * Modified the ReadFrame/WriteFrame functions to allow for variable length codecs.
00065  *
00066  * Revision 1.4  2000/11/20 04:35:40  robertj
00067  * Changed tone detection API slightly to allow detection of multiple
00068  * simultaneous tones
00069  *
00070  * Revision 1.3  2000/05/02 04:32:25  robertj
00071  * Fixed copyright notice comment.
00072  *
00073  * Revision 1.2  2000/01/07 08:28:09  robertj
00074  * Additions and changes to line interface device base class.
00075  *
00076  * Revision 1.1  1999/12/23 23:02:35  robertj
00077  * File reorganision for separating RTP from H.323 and creation of LID for VPB support.
00078  *
00079  */
00080 
00081 #ifndef __OPAL_VPBLID_H
00082 #define __OPAL_VPBLID_H
00083 
00084 #ifdef P_USE_PRAGMA
00085 #pragma interface
00086 #endif
00087 
00088 
00089 #include "lid.h"
00090 #include <vpbapi.h>
00091 
00092 
00094 // DR - this thread is needed to keep tones playing indefinately, as VPB
00095 // tones normally end after a defined period.
00096 class ToneThread : public PThread
00097 {
00098   PCLASSINFO(PThread, ToneThread);
00099 
00100   public:
00101     ToneThread(int handle, VPB_TONE tone);
00102     ~ToneThread();
00103     void Main();
00104 
00105   private:
00106     int        handle;   // VPB handle to play tone on
00107     VPB_TONE   vpbtone;  // tone parameters of tone to play
00108     PSyncPoint shutdown; // used to signal Main() to finish
00109 };
00110 
00111 
00114 class OpalVpbDevice : public OpalLineInterfaceDevice
00115 {
00116   PCLASSINFO(OpalVpbDevice, OpalLineInterfaceDevice);
00117 
00118   public:
00121     OpalVpbDevice();
00122 
00126     ~OpalVpbDevice() { Close(); }
00127 
00130     virtual BOOL Open(
00131       const PString & device      
00132     );
00133 
00136     virtual BOOL Close();
00137 
00140     virtual PString GetName() const;
00141 
00144     virtual unsigned GetLineCount();
00145 
00146 
00151     virtual BOOL IsLineOffHook(
00152       unsigned line   
00153     );
00154 
00158     virtual BOOL SetLineOffHook(
00159       unsigned line,        
00160       BOOL newState = TRUE  
00161     );
00162 
00163 
00166     virtual BOOL IsLineRinging(
00167       unsigned line,          
00168       DWORD * cadence = NULL  
00169     );
00170 
00174     virtual BOOL IsLineDisconnected(
00175       unsigned line,   
00176       BOOL checkForWink = TRUE
00177     );
00178 
00181     virtual OpalMediaFormat::List GetMediaFormats() const;
00182 
00185     virtual BOOL SetReadFormat(
00186       unsigned line,    
00187       const OpalMediaFormat & mediaFormat   
00188     );
00189 
00192     virtual BOOL SetWriteFormat(
00193       unsigned line,    
00194       const OpalMediaFormat & mediaFormat   
00195     );
00196 
00199     virtual OpalMediaFormat GetReadFormat(
00200       unsigned line    
00201     );
00202 
00205     virtual OpalMediaFormat GetWriteFormat(
00206       unsigned line    
00207     );
00208 
00211     virtual BOOL StopReadCodec(
00212       unsigned line   
00213     );
00214 
00217     virtual BOOL StopWriteCodec(
00218       unsigned line   
00219     );
00220 
00225     virtual BOOL SetReadFrameSize(
00226       unsigned line,    
00227       PINDEX frameSize  
00228     );
00229 
00234     virtual BOOL SetWriteFrameSize(
00235       unsigned line,    
00236       PINDEX frameSize  
00237     );
00238 
00242     virtual PINDEX GetReadFrameSize(
00243       unsigned line   
00244     );
00245 
00249     virtual PINDEX GetWriteFrameSize(
00250       unsigned line   
00251     );
00252 
00255     virtual BOOL ReadFrame(
00256       unsigned line,    
00257       void * buf,   
00258       PINDEX & count    
00259     );
00260 
00263     virtual BOOL WriteFrame(
00264       unsigned line,    
00265       const void * buf, 
00266       PINDEX count,     
00267       PINDEX & written  
00268     );
00269 
00270 
00275     virtual BOOL SetRecordVolume(
00276       unsigned line,    
00277       unsigned volume   
00278     );
00279 
00284     virtual BOOL SetPlayVolume(
00285       unsigned line,    
00286       unsigned volume   
00287     );
00288 
00291     int GetOSHandle(
00292       unsigned line     
00293     );
00294 
00300     virtual char ReadDTMF(
00301       unsigned line   
00302     );
00303 
00307     virtual BOOL PlayDTMF(
00308       unsigned line,            
00309       const char * digits,      
00310       DWORD onTime = 90,        
00311       DWORD offTime = 30        
00312     );
00313 
00314 
00317     virtual unsigned IsToneDetected(
00318       unsigned line   
00319     );
00320 
00321     virtual BOOL PlayTone(
00322       unsigned line,          
00323       CallProgressTones tone  
00324     );
00325 
00326     virtual BOOL StopTone(
00327       unsigned line   
00328     );
00329         
00330     virtual BOOL PlayAudio(
00331       unsigned line,            
00332       const PString & filename  
00333     );
00334     
00335     virtual BOOL StopAudio(
00336       unsigned line   
00337     );
00338 
00339   protected:
00340     unsigned cardNumber;
00341     unsigned lineCount;
00342 
00343     enum { MaxLineCount = 8 };
00344 
00345     struct LineState {
00346       BOOL Open(unsigned cardNumber, unsigned lineNumber);
00347       BOOL SetLineOffHook(BOOL newState);
00348       BOOL IsLineRinging(DWORD *);
00349 
00350       int        handle;
00351       BOOL       currentHookState;
00352       PINDEX     readFormat,    writeFormat;
00353       PINDEX     readFrameSize, writeFrameSize;
00354       BOOL       readIdle,      writeIdle;
00355       PMutex     DTMFmutex;
00356       BOOL       DTMFplaying;
00357       ToneThread *myToneThread;
00358     } lineState[MaxLineCount];
00359 };
00360 
00361 
00362 #endif // __OPAL_VPBLID_H
00363 
00364 

Generated on Sun Oct 22 13:32:30 2006 for OpenH323 by  doxygen 1.4.7