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: 23148 $
00030  * $Author: rjongbloed $
00031  * $Date: 2009-07-28 12:42:40 +0000 (Tue, 28 Jul 2009) $
00032  */
00033 
00034 #ifndef OPAL_LIDS_LIDEP_H
00035 #define OPAL_LIDS_LIDEP_H
00036 
00037 #ifdef P_USE_PRAGMA
00038 #pragma interface
00039 #endif
00040 
00041 #include <opal/buildopts.h>
00042 
00043 #include <opal/endpoint.h>
00044 #include <lids/lid.h>
00045 #include <codec/silencedetect.h>
00046 
00047 
00048 class OpalLineConnection;
00049 
00050 
00055 class OpalLineEndPoint : public OpalEndPoint
00056 {
00057   PCLASSINFO(OpalLineEndPoint, OpalEndPoint);
00058 
00059   public:
00064     OpalLineEndPoint(
00065       OpalManager & manager   
00066     );
00067 
00069     ~OpalLineEndPoint();
00071 
00103     virtual PBoolean MakeConnection(
00104       OpalCall & call,          
00105       const PString & party,    
00106       void * userData = NULL,   
00107       unsigned int options = 0,  
00108       OpalConnection::StringOptions * stringOptions  = NULL
00109     );
00110 
00120     virtual OpalMediaFormatList GetMediaFormats() const;
00122 
00125     virtual OpalLineConnection * CreateConnection(
00126       OpalCall & call,        
00127       OpalLine & line,        
00128       void * userData,        
00129       const PString & number  
00130     );
00132 
00139     PSafePtr<OpalLineConnection> GetLIDConnectionWithLock(
00140       const PString & token,     
00141       PSafetyMode mode = PSafeReadWrite
00142     ) { return PSafePtrCast<OpalConnection, OpalLineConnection>(GetConnectionWithLock(token, mode)); }
00143 
00151     PBoolean AddLine(
00152       OpalLine * line
00153     );
00154 
00158     void RemoveLine(
00159       OpalLine * line
00160     );
00161 
00162     
00167     const PList<OpalLine> & GetLines() const { return lines;};
00168     
00172     void RemoveLine(
00173       const PString & token
00174     );
00175 
00180     void RemoveAllLines();
00181 
00191     virtual PBoolean AddLinesFromDevice(
00192       OpalLineInterfaceDevice & device  
00193     );
00194 
00198     void RemoveLinesFromDevice(
00199       OpalLineInterfaceDevice & device  
00200     );
00201 
00207     PBoolean AddDeviceNames(
00208       const PStringArray & descriptors  
00209     );
00210 
00220     PBoolean AddDeviceName(
00221       const PString & descriptor  
00222     );
00223 
00226     const OpalLineInterfaceDevice * GetDeviceByName(
00227       const PString & descriptor  
00228     );
00229 
00241     virtual PBoolean AddDevice(
00242       OpalLineInterfaceDevice * device    
00243     );
00244 
00248     void RemoveDevice(
00249       OpalLineInterfaceDevice * device  
00250     );
00251 
00254     void RemoveDevices() { RemoveAllLines(); }
00255 
00263     OpalLine * GetLine(
00264       const PString & lineName,  
00265       bool enableAudio = false,  
00266       bool terminating = true    
00267     );
00268 
00272     void SetDefaultLine(
00273       const PString & lineName  
00274     );
00276 
00277 
00278   protected:
00279     PDECLARE_NOTIFIER(PThread, OpalLineEndPoint, MonitorLines);
00280     virtual void MonitorLine(OpalLine & line);
00281 
00282     OpalLIDList  devices;
00283     OpalLineList lines;
00284     PString      defaultLine;
00285     PMutex       linesMutex;
00286     PThread    * monitorThread;
00287     PSyncPoint   exitFlag;
00288 };
00289 
00290 
00293 class OpalLineConnection : public OpalConnection
00294 {
00295   PCLASSINFO(OpalLineConnection, OpalConnection);
00296 
00297   public:
00302     OpalLineConnection(
00303       OpalCall & call,              
00304       OpalLineEndPoint & endpoint,   
00305       OpalLine & line,              
00306       const PString & number        
00307     );
00309 
00314     virtual PString GetPrefixName() const;
00315 
00324     virtual bool IsNetworkConnection() const { return !line.IsTerminal(); }
00325 
00332     virtual PBoolean SetUpConnection();
00333 
00344     virtual PBoolean SetAlerting(
00345       const PString & calleeName,   
00346       PBoolean withMedia                
00347     );
00348 
00353     virtual PBoolean SetConnected();
00354 
00373     virtual void OnReleased();
00374 
00381     virtual PString GetDestinationAddress();
00382 
00389     virtual OpalMediaFormatList GetMediaFormats() const;
00390 
00405     virtual OpalMediaStream * CreateMediaStream(
00406       const OpalMediaFormat & mediaFormat, 
00407       unsigned sessionID,                  
00408       PBoolean isSource                        
00409     );
00410 
00423     virtual PBoolean OnOpenMediaStream(
00424       OpalMediaStream & stream    
00425     );
00426 
00429     virtual PBoolean SetAudioVolume(
00430       PBoolean source,                  
00431       unsigned percentage           
00432     );
00433 
00437     virtual unsigned GetAudioSignalLevel(
00438       PBoolean source                   
00439     );
00440 
00448     virtual PBoolean SendUserInputString(
00449       const PString & value                   
00450     );
00451 
00458     virtual PBoolean SendUserInputTone(
00459       char tone,    
00460       int duration  
00461     );
00462 
00469     virtual PBoolean PromptUserInput(
00470       PBoolean play   
00471     );
00473 
00478     void StartIncoming();
00479 
00482     virtual void Monitor();
00484 
00485 
00490     OpalLine & GetLine() { return line; }
00491 
00495     void setDialDelay(unsigned int uiDialDelay) { m_dialParams.m_dialStartDelay = uiDialDelay;}
00496     
00500     unsigned int getDialDelay() const { return m_dialParams.m_dialStartDelay; }
00502         
00503   protected:
00504     OpalLineEndPoint & endpoint;
00505     OpalLine        & line;
00506     bool              wasOffHook;
00507     unsigned          minimumRingCount;
00508     OpalLineInterfaceDevice::DialParams m_dialParams;
00509 
00510     PDECLARE_NOTIFIER(PThread, OpalLineConnection, HandleIncoming);
00511     PThread         * handlerThread;
00512 };
00513 
00514 
00518 class OpalLineMediaStream : public OpalMediaStream
00519 {
00520     PCLASSINFO(OpalLineMediaStream, OpalMediaStream);
00521   public:
00526     OpalLineMediaStream(
00527       OpalLineConnection & conn,
00528       const OpalMediaFormat & mediaFormat, 
00529       unsigned sessionID,                  
00530       PBoolean isSource,                       
00531       OpalLine & line                      
00532     );
00534 
00542     virtual PBoolean Open();
00543 
00548     virtual PBoolean Close();
00549 
00555     virtual PBoolean ReadPacket(
00556       RTP_DataFrame & packet
00557     );
00558 
00564     virtual PBoolean WritePacket(
00565       RTP_DataFrame & packet
00566     );
00567 
00571     virtual PBoolean ReadData(
00572       BYTE * data,      
00573       PINDEX size,      
00574       PINDEX & length   
00575     );
00576 
00580     virtual PBoolean WriteData(
00581       const BYTE * data,   
00582       PINDEX length,       
00583       PINDEX & written     
00584     );
00585 
00591     virtual PBoolean SetDataSize(
00592       PINDEX dataSize,  
00593       PINDEX frameTime  
00594     );
00595 
00599     virtual PBoolean IsSynchronous() const;
00600 
00610     virtual PBoolean RequiresPatchThread(
00611       OpalMediaStream * sinkStream  
00612     ) const;
00614 
00619     OpalLine & GetLine() { return line; }
00621 
00622   protected:
00623     OpalLine & line;
00624     bool       notUsingRTP;
00625     bool       useDeblocking;
00626     unsigned   missedCount;
00627     BYTE       lastSID[4];
00628     bool       lastFrameWasSignal;
00629     unsigned   directLineNumber;
00630 };
00631 
00632 
00633 class OpalLineSilenceDetector : public OpalSilenceDetector
00634 {
00635     PCLASSINFO(OpalLineSilenceDetector, OpalSilenceDetector);
00636   public:
00641     OpalLineSilenceDetector(
00642       OpalLine & line,        
00643       const Params & newParam 
00644     );
00646 
00657     virtual unsigned GetAverageSignalLevel(
00658       const BYTE * buffer,  
00659       PINDEX size           
00660     );
00662 
00663   protected:
00664     OpalLine & line;
00665 };
00666 
00667 
00668 #endif // OPAL_LIDS_LIDEP_H
00669 
00670 
00671 // End of File ///////////////////////////////////////////////////////////////

Generated on Mon Feb 1 00:25:49 2010 for OPAL by  doxygen 1.5.1