Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

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.16  2003/08/13 22:02:03  dereksmithies
00026  * Apply patch from Daniel Bichara to GetOSHandle() for VPB devices. Thanks.
00027  *
00028  * Revision 1.15  2003/03/05 06:26:41  robertj
00029  * Added function to play a WAV file to LID, thanks Pietro Ravasio
00030  *
00031  * Revision 1.14  2002/09/16 01:14:15  robertj
00032  * Added #define so can select if #pragma interface/implementation is used on
00033  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00034  *
00035  * Revision 1.13  2002/09/03 06:19:37  robertj
00036  * Normalised the multi-include header prevention ifdef/define symbol.
00037  *
00038  * Revision 1.12  2002/08/05 10:03:47  robertj
00039  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00040  *
00041  * Revision 1.11  2002/07/02 03:20:37  dereks
00042  * Fix check for line disconnected state.   Remove timer on line ringing.
00043  *
00044  * Revision 1.10  2001/11/19 06:35:59  robertj
00045  * Added tone generation handling
00046  *
00047  * Revision 1.9  2001/09/13 05:27:46  robertj
00048  * Fixed incorrect return type in virtual function, thanks Vjacheslav Andrejev
00049  *
00050  * Revision 1.8  2001/02/09 05:16:24  robertj
00051  * Added #pragma interface for GNU C++.
00052  *
00053  * Revision 1.7  2001/01/25 07:27:14  robertj
00054  * Major changes to add more flexible OpalMediaFormat class to normalise
00055  *   all information about media types, especially codecs.
00056  *
00057  * Revision 1.6  2001/01/24 05:34:49  robertj
00058  * Altered volume control range to be percentage, ie 100 is max volume.
00059  *
00060  * Revision 1.5  2000/11/24 10:50:52  robertj
00061  * Modified the ReadFrame/WriteFrame functions to allow for variable length codecs.
00062  *
00063  * Revision 1.4  2000/11/20 04:35:40  robertj
00064  * Changed tone detection API slightly to allow detection of multiple
00065  * simultaneous tones
00066  *
00067  * Revision 1.3  2000/05/02 04:32:25  robertj
00068  * Fixed copyright notice comment.
00069  *
00070  * Revision 1.2  2000/01/07 08:28:09  robertj
00071  * Additions and changes to line interface device base class.
00072  *
00073  * Revision 1.1  1999/12/23 23:02:35  robertj
00074  * File reorganision for separating RTP from H.323 and creation of LID for VPB support.
00075  *
00076  */
00077 
00078 #ifndef __OPAL_VPBLID_H
00079 #define __OPAL_VPBLID_H
00080 
00081 #ifdef P_USE_PRAGMA
00082 #pragma interface
00083 #endif
00084 
00085 
00086 #include "lid.h"
00087 #include <vpbapi.h>
00088 
00089 
00091 // DR - this thread is needed to keep tones playing indefinately, as VPB
00092 // tones normally end after a defined period.
00093 class ToneThread : public PThread
00094 {
00095   PCLASSINFO(PThread, ToneThread);
00096 
00097   public:
00098     ToneThread(int handle, VPB_TONE tone);
00099     ~ToneThread();
00100     void Main();
00101 
00102   private:
00103     int        handle;   // VPB handle to play tone on
00104     VPB_TONE   vpbtone;  // tone parameters of tone to play
00105     PSyncPoint shutdown; // used to signal Main() to finish
00106 };
00107 
00108 
00111 class OpalVpbDevice : public OpalLineInterfaceDevice
00112 {
00113   PCLASSINFO(OpalVpbDevice, OpalLineInterfaceDevice);
00114 
00115   public:
00118     OpalVpbDevice();
00119 
00123     ~OpalVpbDevice() { Close(); }
00124 
00127     virtual BOOL Open(
00128       const PString & device      
00129     );
00130 
00133     virtual BOOL Close();
00134 
00137     virtual PString GetName() const;
00138 
00141     virtual unsigned GetLineCount();
00142 
00143 
00148     virtual BOOL IsLineOffHook(
00149       unsigned line   
00150     );
00151 
00155     virtual BOOL SetLineOffHook(
00156       unsigned line,        
00157       BOOL newState = TRUE  
00158     );
00159 
00160 
00163     virtual BOOL IsLineRinging(
00164       unsigned line,          
00165       DWORD * cadence = NULL  
00166     );
00167 
00171     virtual BOOL IsLineDisconnected(
00172       unsigned line,   
00173       BOOL checkForWink = TRUE
00174     );
00175 
00178     virtual OpalMediaFormat::List GetMediaFormats() const;
00179 
00182     virtual BOOL SetReadFormat(
00183       unsigned line,    
00184       const OpalMediaFormat & mediaFormat   
00185     );
00186 
00189     virtual BOOL SetWriteFormat(
00190       unsigned line,    
00191       const OpalMediaFormat & mediaFormat   
00192     );
00193 
00196     virtual OpalMediaFormat GetReadFormat(
00197       unsigned line    
00198     );
00199 
00202     virtual OpalMediaFormat GetWriteFormat(
00203       unsigned line    
00204     );
00205 
00208     virtual BOOL StopReadCodec(
00209       unsigned line   
00210     );
00211 
00214     virtual BOOL StopWriteCodec(
00215       unsigned line   
00216     );
00217 
00222     virtual BOOL SetReadFrameSize(
00223       unsigned line,    
00224       PINDEX frameSize  
00225     );
00226 
00231     virtual BOOL SetWriteFrameSize(
00232       unsigned line,    
00233       PINDEX frameSize  
00234     );
00235 
00239     virtual PINDEX GetReadFrameSize(
00240       unsigned line   
00241     );
00242 
00246     virtual PINDEX GetWriteFrameSize(
00247       unsigned line   
00248     );
00249 
00252     virtual BOOL ReadFrame(
00253       unsigned line,    
00254       void * buf,   
00255       PINDEX & count    
00256     );
00257 
00260     virtual BOOL WriteFrame(
00261       unsigned line,    
00262       const void * buf, 
00263       PINDEX count,     
00264       PINDEX & written  
00265     );
00266 
00267 
00272     virtual BOOL SetRecordVolume(
00273       unsigned line,    
00274       unsigned volume   
00275     );
00276 
00281     virtual BOOL SetPlayVolume(
00282       unsigned line,    
00283       unsigned volume   
00284     );
00285 
00288     int GetOSHandle(
00289       unsigned line     
00290     );
00291 
00297     virtual char ReadDTMF(
00298       unsigned line   
00299     );
00300 
00304     virtual BOOL PlayDTMF(
00305       unsigned line,            
00306       const char * digits,      
00307       DWORD onTime = 90,        
00308       DWORD offTime = 30        
00309     );
00310 
00311 
00314     virtual unsigned IsToneDetected(
00315       unsigned line   
00316     );
00317 
00318     virtual BOOL PlayTone(
00319       unsigned line,          
00320       CallProgressTones tone  
00321     );
00322 
00323     virtual BOOL StopTone(
00324       unsigned line   
00325     );
00326         
00327     virtual BOOL PlayAudio(
00328       unsigned line,            
00329       const PString & filename  
00330     );
00331     
00332     virtual BOOL StopAudio(
00333       unsigned line   
00334     );
00335 
00336   protected:
00337     unsigned cardNumber;
00338     unsigned lineCount;
00339 
00340     enum { MaxLineCount = 8 };
00341 
00342     struct LineState {
00343       BOOL Open(unsigned cardNumber, unsigned lineNumber);
00344       BOOL SetLineOffHook(BOOL newState);
00345       BOOL IsLineRinging(DWORD *);
00346 
00347       int        handle;
00348       BOOL       currentHookState;
00349       PINDEX     readFormat,    writeFormat;
00350       PINDEX     readFrameSize, writeFrameSize;
00351       BOOL       readIdle,      writeIdle;
00352       PMutex     DTMFmutex;
00353       BOOL       DTMFplaying;
00354       ToneThread *myToneThread;
00355     } lineState[MaxLineCount];
00356 };
00357 
00358 
00359 #endif // __OPAL_VPBLID_H
00360 
00361 

Generated on Mon Sep 26 15:44:50 2005 for OpenH323 by  doxygen 1.4.4