lidep.h

Go to the documentation of this file.
00001 /*
00002  * lidep.h
00003  *
00004  * Line Interface Device EndPoint
00005  *
00006  * Open Phone Abstraction Library
00007  *
00008  * Copyright (c) 2001 Equivalence Pty. Ltd.
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Open H323 Library.
00021  *
00022  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00023  *
00024  * Portions of this code were written with the assisance of funding from 
00025  * Quicknet Technologies, Inc. http://www.quicknet.net.
00026  * 
00027  * Contributor(s): ______________________________________.
00028  *
00029  * $Log: lidep.h,v $
00030  * Revision 2.18  2005/11/30 13:35:26  csoutheren
00031  * Changed tags for Doxygen
00032  *
00033  * Revision 2.17  2004/10/06 13:03:41  rjongbloed
00034  * Added "configure" support for known LIDs
00035  * Changed LID GetName() function to be normalised against the GetAllNames()
00036  *   return values and fixed the pre-factory registration system.
00037  * Added a GetDescription() function to do what the previous GetName() did.
00038  *
00039  * Revision 2.16  2004/08/14 07:56:29  rjongbloed
00040  * Major revision to utilise the PSafeCollection classes for the connections and calls.
00041  *
00042  * Revision 2.15  2004/07/11 12:42:09  rjongbloed
00043  * Added function on endpoints to get the list of all media formats any
00044  *   connection the endpoint may create can support.
00045  *
00046  * Revision 2.14  2004/05/17 13:24:17  rjongbloed
00047  * Added silence suppression.
00048  *
00049  * Revision 2.13  2003/06/02 02:56:17  rjongbloed
00050  * Moved LID specific media stream class to LID source file.
00051  *
00052  * Revision 2.12  2003/03/24 07:18:29  robertj
00053  * Added registration system for LIDs so can work with various LID types by
00054  *   name instead of class instance.
00055  *
00056  * Revision 2.11  2003/03/17 10:26:59  robertj
00057  * Added video support.
00058  *
00059  * Revision 2.10  2003/03/06 03:57:46  robertj
00060  * IVR support (work in progress) requiring large changes everywhere.
00061  *
00062  * Revision 2.9  2002/09/16 02:52:34  robertj
00063  * Added #define so can select if #pragma interface/implementation is used on
00064  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00065  *
00066  * Revision 2.8  2002/09/04 05:27:55  robertj
00067  * Added ability to set default line name to be used when the destination
00068  *   does not match any lines configured.
00069  *
00070  * Revision 2.7  2002/01/22 05:00:54  robertj
00071  * Revamp of user input API triggered by RFC2833 support
00072  *
00073  * Revision 2.6  2001/11/13 06:25:56  robertj
00074  * Changed SetUpConnection() so returns BOOL as returning
00075  *   pointer to connection is not useful.
00076  *
00077  * Revision 2.5  2001/10/15 04:29:35  robertj
00078  * Removed answerCall signal and replaced with state based functions.
00079  *
00080  * Revision 2.4  2001/10/03 05:56:15  robertj
00081  * Changes abndwidth management API.
00082  *
00083  * Revision 2.3  2001/08/17 01:11:52  robertj
00084  * Added ability to add whole LID's to LID endpoint.
00085  * Added ability to change the prefix on POTS and PSTN endpoints.
00086  *
00087  * Revision 2.2  2001/08/01 06:23:55  robertj
00088  * Changed to use separate mutex for LIDs structure to avoid Unix nested mutex problem.
00089  *
00090  * Revision 2.1  2001/08/01 05:18:51  robertj
00091  * Made OpalMediaFormatList class global to help with documentation.
00092  *
00093  * Revision 2.0  2001/07/27 15:48:24  robertj
00094  * Conversion of OpenH323 to Open Phone Abstraction Library (OPAL)
00095  *
00096  */
00097 
00098 #ifndef __LIDS_LIDEP_H
00099 #define __LIDS_LIDEP_H
00100 
00101 #ifdef P_USE_PRAGMA
00102 #pragma interface
00103 #endif
00104 
00105 
00106 #include <opal/endpoint.h>
00107 #include <lids/lid.h>
00108 #include <codec/silencedetect.h>
00109 
00110 
00111 class OpalLineConnection;
00112 
00113 
00118 class OpalLIDEndPoint : public OpalEndPoint
00119 {
00120   PCLASSINFO(OpalLIDEndPoint, OpalEndPoint);
00121 
00122   public:
00127     OpalLIDEndPoint(
00128       OpalManager & manager,  
00129       const PString & prefix, 
00130       unsigned attributes     
00131     );
00132 
00134     ~OpalLIDEndPoint();
00136 
00168     virtual BOOL MakeConnection(
00169       OpalCall & call,        
00170       const PString & party,  
00171       void * userData = NULL  
00172     );
00173 
00183     virtual OpalMediaFormatList GetMediaFormats() const;
00185 
00188     OpalLineConnection * CreateConnection(
00189       OpalCall & call,        
00190       OpalLine & line,        
00191       void * userData,        
00192       const PString & number  
00193     );
00195 
00202     PSafePtr<OpalLineConnection> GetLIDConnectionWithLock(
00203       const PString & token,     
00204       PSafetyMode mode = PSafeReadWrite
00205     ) { return PSafePtrCast<OpalConnection, OpalLineConnection>(GetConnectionWithLock(token, mode)); }
00206 
00214     BOOL AddLine(
00215       OpalLine * line
00216     );
00217 
00221     void RemoveLine(
00222       OpalLine * line
00223     );
00224 
00228     void RemoveLine(
00229       const PString & token
00230     );
00231 
00236     void RemoveAllLines();
00237 
00247     BOOL AddLinesFromDevice(
00248       OpalLineInterfaceDevice & device  
00249     );
00250 
00254     void RemoveLinesFromDevice(
00255       OpalLineInterfaceDevice & device  
00256     );
00257 
00263     BOOL AddDeviceNames(
00264       const PStringArray & descriptors  
00265     );
00266 
00276     BOOL AddDeviceName(
00277       const PString & descriptor  
00278     );
00279 
00291     BOOL AddDevice(
00292       OpalLineInterfaceDevice * device    
00293     );
00294 
00298     void RemoveDevice(
00299       OpalLineInterfaceDevice * device  
00300     );
00301 
00309     OpalLine * GetLine(
00310       const PString & lineName,  
00311       BOOL enableAudio = FALSE   
00312     ) const;
00313 
00317     void SetDefaultLine(
00318       const PString & lineName  
00319     );
00321 
00322   protected:
00323     PDECLARE_NOTIFIER(PThread, OpalLIDEndPoint, MonitorLines);
00324     virtual void MonitorLine(OpalLine & line);
00325 
00326     OpalLIDList  devices;
00327     OpalLineList lines;
00328     PString      defaultLine;
00329     PMutex       linesMutex;
00330     PThread    * monitorThread;
00331     PSyncPoint   exitFlag;
00332 };
00333 
00334 
00339 class OpalPSTNEndPoint : public OpalLIDEndPoint
00340 {
00341   PCLASSINFO(OpalLIDEndPoint, OpalLIDEndPoint);
00342 
00343   public:
00348     OpalPSTNEndPoint(
00349       OpalManager & manager,  
00350       const char * prefix = "pstn" 
00351     ) : OpalLIDEndPoint(manager, prefix, HasLineInterface) { }
00353 };
00354 
00355 
00360 class OpalPOTSEndPoint : public OpalLIDEndPoint
00361 {
00362   PCLASSINFO(OpalPOTSEndPoint, OpalLIDEndPoint);
00363 
00364   public:
00369     OpalPOTSEndPoint(
00370       OpalManager & manager,  
00371       const char * prefix = "pots" 
00372     ) : OpalLIDEndPoint(manager, prefix, CanTerminateCall) { }
00374 };
00375 
00376 
00379 class OpalLineConnection : public OpalConnection
00380 {
00381   PCLASSINFO(OpalLineConnection, OpalConnection);
00382 
00383   public:
00388     OpalLineConnection(
00389       OpalCall & call,              
00390       OpalLIDEndPoint & endpoint,   
00391       OpalLine & line,              
00392       const PString & number        
00393     );
00395 
00404     virtual BOOL SetUpConnection();
00405 
00416     virtual BOOL SetAlerting(
00417       const PString & calleeName,   
00418       BOOL withMedia                
00419     );
00420 
00425     virtual BOOL SetConnected();
00426 
00445     virtual void OnReleased();
00446 
00453     virtual PString GetDestinationAddress();
00454 
00461     virtual OpalMediaFormatList GetMediaFormats() const;
00462 
00477     virtual OpalMediaStream * CreateMediaStream(
00478       const OpalMediaFormat & mediaFormat, 
00479       unsigned sessionID,                  
00480       BOOL isSource                        
00481     );
00482 
00495     virtual BOOL OnOpenMediaStream(
00496       OpalMediaStream & stream    
00497     );
00498 
00506     virtual BOOL SendUserInputString(
00507       const PString & value                   
00508     );
00509 
00516     virtual BOOL SendUserInputTone(
00517       char tone,    
00518       int duration  
00519     );
00520 
00527     virtual BOOL PromptUserInput(
00528       BOOL play   
00529     );
00531 
00536     void StartIncoming();
00537 
00540     void Monitor(
00541       BOOL offHook
00542     );
00544 
00545 
00546   protected:
00547     OpalLIDEndPoint & endpoint;
00548     OpalLine        & line;
00549     BOOL              wasOffHook;
00550     unsigned          answerRingCount;
00551     BOOL              requireTonesForDial;
00552 
00553     PDECLARE_NOTIFIER(PThread, OpalLineConnection, HandleIncoming);
00554     PThread         * handlerThread;
00555 };
00556 
00557 
00561 class OpalLineMediaStream : public OpalMediaStream
00562 {
00563     PCLASSINFO(OpalLineMediaStream, OpalMediaStream);
00564   public:
00569     OpalLineMediaStream(
00570       const OpalMediaFormat & mediaFormat, 
00571       unsigned sessionID,                  
00572       BOOL isSource,                       
00573       OpalLine & line                      
00574     );
00576 
00584     virtual BOOL Open();
00585 
00590     virtual BOOL Close();
00591 
00595     virtual BOOL ReadData(
00596       BYTE * data,      
00597       PINDEX size,      
00598       PINDEX & length   
00599     );
00600 
00604     virtual BOOL WriteData(
00605       const BYTE * data,   
00606       PINDEX length,       
00607       PINDEX & written     
00608     );
00609 
00613     virtual BOOL IsSynchronous() const;
00615 
00616   protected:
00617     OpalLine & line;
00618     BOOL       useDeblocking;
00619     unsigned   missedCount;
00620     BYTE       lastSID[4];
00621     BOOL       lastFrameWasSignal;
00622 };
00623 
00624 
00625 class OpalLineSilenceDetector : public OpalSilenceDetector
00626 {
00627     PCLASSINFO(OpalLineSilenceDetector, OpalSilenceDetector);
00628   public:
00633     OpalLineSilenceDetector(
00634       OpalLine & line
00635     );
00637 
00648     virtual unsigned GetAverageSignalLevel(
00649       const BYTE * buffer,  
00650       PINDEX size           
00651     );
00653 
00654   protected:
00655     OpalLine & line;
00656 };
00657 
00658 
00659 #endif // __LIDS_LIDEP_H
00660 
00661 
00662 // End of File ///////////////////////////////////////////////////////////////

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