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  * $Revision: 19748 $
00030  * $Author: rjongbloed $
00031  * $Date: 2008-03-14 06:40:04 +0000 (Fri, 14 Mar 2008) $
00032  */
00033 
00034 #ifndef __LIDS_LIDEP_H
00035 #define __LIDS_LIDEP_H
00036 
00037 #ifdef P_USE_PRAGMA
00038 #pragma interface
00039 #endif
00040 
00041 
00042 #include <opal/endpoint.h>
00043 #include <lids/lid.h>
00044 #include <codec/silencedetect.h>
00045 
00046 
00047 class OpalLineConnection;
00048 
00049 
00054 class OpalLineEndPoint : public OpalEndPoint
00055 {
00056   PCLASSINFO(OpalLineEndPoint, OpalEndPoint);
00057 
00058   public:
00063     OpalLineEndPoint(
00064       OpalManager & manager   
00065     );
00066 
00068     ~OpalLineEndPoint();
00070 
00102     virtual PBoolean MakeConnection(
00103       OpalCall & call,          
00104       const PString & party,    
00105       void * userData = NULL,   
00106       unsigned int options = 0,  
00107       OpalConnection::StringOptions * stringOptions  = NULL
00108     );
00109 
00113     virtual PBoolean OnSetUpConnection(OpalLineConnection &connection);
00114     
00124     virtual OpalMediaFormatList GetMediaFormats() const;
00126 
00129     virtual OpalLineConnection * CreateConnection(
00130       OpalCall & call,        
00131       OpalLine & line,        
00132       void * userData,        
00133       const PString & number  
00134     );
00136 
00143     PSafePtr<OpalLineConnection> GetLIDConnectionWithLock(
00144       const PString & token,     
00145       PSafetyMode mode = PSafeReadWrite
00146     ) { return PSafePtrCast<OpalConnection, OpalLineConnection>(GetConnectionWithLock(token, mode)); }
00147 
00155     PBoolean AddLine(
00156       OpalLine * line
00157     );
00158 
00162     void RemoveLine(
00163       OpalLine * line
00164     );
00165 
00166     
00171     const PList<OpalLine> & GetLines() const { return lines;};
00172     
00176     void RemoveLine(
00177       const PString & token
00178     );
00179 
00184     void RemoveAllLines();
00185 
00195     virtual PBoolean AddLinesFromDevice(
00196       OpalLineInterfaceDevice & device  
00197     );
00198 
00202     void RemoveLinesFromDevice(
00203       OpalLineInterfaceDevice & device  
00204     );
00205 
00211     PBoolean AddDeviceNames(
00212       const PStringArray & descriptors  
00213     );
00214 
00224     PBoolean AddDeviceName(
00225       const PString & descriptor  
00226     );
00227 
00239     virtual PBoolean AddDevice(
00240       OpalLineInterfaceDevice * device    
00241     );
00242 
00246     void RemoveDevice(
00247       OpalLineInterfaceDevice * device  
00248     );
00249 
00252     void RemoveDevices() { RemoveAllLines(); }
00253 
00261     OpalLine * GetLine(
00262       const PString & lineName,  
00263       bool enableAudio = false,  
00264       bool terminating = true    
00265     );
00266 
00270     void SetDefaultLine(
00271       const PString & lineName  
00272     );
00274 
00275 
00276   protected:
00277     PDECLARE_NOTIFIER(PThread, OpalLineEndPoint, MonitorLines);
00278     virtual void MonitorLine(OpalLine & line);
00279 
00280     OpalLIDList  devices;
00281     OpalLineList lines;
00282     PString      defaultLine;
00283     PMutex       linesMutex;
00284     PThread    * monitorThread;
00285     PSyncPoint   exitFlag;
00286 };
00287 
00288 
00291 class OpalLineConnection : public OpalConnection
00292 {
00293   PCLASSINFO(OpalLineConnection, OpalConnection);
00294 
00295   public:
00300     OpalLineConnection(
00301       OpalCall & call,              
00302       OpalLineEndPoint & endpoint,   
00303       OpalLine & line,              
00304       const PString & number        
00305     );
00307 
00316     virtual PBoolean SetUpConnection();
00320     virtual PBoolean OnSetUpConnection();
00321 
00332     virtual PBoolean SetAlerting(
00333       const PString & calleeName,   
00334       PBoolean withMedia                
00335     );
00336 
00341     virtual PBoolean SetConnected();
00342 
00361     virtual void OnReleased();
00362 
00369     virtual PString GetDestinationAddress();
00370 
00377     virtual OpalMediaFormatList GetMediaFormats() const;
00378 
00393     virtual OpalMediaStream * CreateMediaStream(
00394       const OpalMediaFormat & mediaFormat, 
00395       unsigned sessionID,                  
00396       PBoolean isSource                        
00397     );
00398 
00411     virtual PBoolean OnOpenMediaStream(
00412       OpalMediaStream & stream    
00413     );
00414 
00417     virtual PBoolean SetAudioVolume(
00418       PBoolean source,                  
00419       unsigned percentage           
00420     );
00421 
00425     virtual unsigned GetAudioSignalLevel(
00426       PBoolean source                   
00427     );
00428 
00436     virtual PBoolean SendUserInputString(
00437       const PString & value                   
00438     );
00439 
00446     virtual PBoolean SendUserInputTone(
00447       char tone,    
00448       int duration  
00449     );
00450 
00457     virtual PBoolean PromptUserInput(
00458       PBoolean play   
00459     );
00461 
00466     void StartIncoming();
00467 
00470     virtual void Monitor(
00471       PBoolean offHook
00472     );
00474 
00475 
00479     void setDialDelay(unsigned int uiDialDelay){ m_uiDialDelay = uiDialDelay;};
00480     
00484     unsigned int getDialDelay() const { return m_uiDialDelay;};
00485 
00486         
00487   protected:
00488     OpalLineEndPoint & endpoint;
00489     OpalLine        & line;
00490     PBoolean              wasOffHook;
00491     unsigned          answerRingCount;
00492     PBoolean              requireTonesForDial;
00493     /* time in msec to wait between the dial tone detection and dialing the dtmf */
00494     unsigned          m_uiDialDelay; 
00495 
00496     PDECLARE_NOTIFIER(PThread, OpalLineConnection, HandleIncoming);
00497     PThread         * handlerThread;
00498 };
00499 
00500 
00504 class OpalLineMediaStream : public OpalMediaStream
00505 {
00506     PCLASSINFO(OpalLineMediaStream, OpalMediaStream);
00507   public:
00512     OpalLineMediaStream(
00513       OpalLineConnection & conn,
00514       const OpalMediaFormat & mediaFormat, 
00515       unsigned sessionID,                  
00516       PBoolean isSource,                       
00517       OpalLine & line                      
00518     );
00520 
00528     virtual PBoolean Open();
00529 
00534     virtual PBoolean Close();
00535 
00541     virtual PBoolean ReadPacket(
00542       RTP_DataFrame & packet
00543     );
00544 
00550     virtual PBoolean WritePacket(
00551       RTP_DataFrame & packet
00552     );
00553 
00557     virtual PBoolean ReadData(
00558       BYTE * data,      
00559       PINDEX size,      
00560       PINDEX & length   
00561     );
00562 
00566     virtual PBoolean WriteData(
00567       const BYTE * data,   
00568       PINDEX length,       
00569       PINDEX & written     
00570     );
00571 
00577     virtual PBoolean SetDataSize(
00578       PINDEX dataSize  
00579     );
00580 
00584     virtual PBoolean IsSynchronous() const;
00586 
00591     OpalLine & GetLine() { return line; }
00593 
00594   protected:
00595     OpalLine & line;
00596     bool       notUsingRTP;
00597     bool       useDeblocking;
00598     unsigned   missedCount;
00599     BYTE       lastSID[4];
00600     bool       lastFrameWasSignal;
00601 };
00602 
00603 
00604 class OpalLineSilenceDetector : public OpalSilenceDetector
00605 {
00606     PCLASSINFO(OpalLineSilenceDetector, OpalSilenceDetector);
00607   public:
00612     OpalLineSilenceDetector(
00613       OpalLine & line
00614     );
00616 
00627     virtual unsigned GetAverageSignalLevel(
00628       const BYTE * buffer,  
00629       PINDEX size           
00630     );
00632 
00633   protected:
00634     OpalLine & line;
00635 };
00636 
00637 
00638 #endif // __LIDS_LIDEP_H
00639 
00640 
00641 // End of File ///////////////////////////////////////////////////////////////

Generated on Wed May 7 00:56:00 2008 for OPAL by  doxygen 1.5.1