OPAL
Version 3.10.4
|
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: 24766 $ 00030 * $Author: rjongbloed $ 00031 * $Date: 2010-09-30 02:18:52 -0500 (Thu, 30 Sep 2010) $ 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 PSafePtr<OpalConnection> 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 ); 00275 00281 bool SetCountryCode( 00282 OpalLineInterfaceDevice::T35CountryCodes country 00283 ); 00284 00287 bool SetCountryCodeName( 00288 const PString & countryName 00289 ); 00291 00292 00293 protected: 00294 PDECLARE_NOTIFIER(PThread, OpalLineEndPoint, MonitorLines); 00295 virtual void MonitorLine(OpalLine & line); 00296 00297 OpalLIDList devices; 00298 OpalLineList lines; 00299 PString defaultLine; 00300 PMutex linesMutex; 00301 PThread * monitorThread; 00302 PSyncPoint exitFlag; 00303 }; 00304 00305 00308 class OpalLineConnection : public OpalConnection 00309 { 00310 PCLASSINFO(OpalLineConnection, OpalConnection); 00311 00312 public: 00317 OpalLineConnection( 00318 OpalCall & call, 00319 OpalLineEndPoint & endpoint, 00320 OpalLine & line, 00321 const PString & number 00322 ); 00324 00329 virtual PString GetPrefixName() const; 00330 00339 virtual bool IsNetworkConnection() const { return !line.IsTerminal(); } 00340 00347 virtual PBoolean SetUpConnection(); 00348 00359 virtual PBoolean SetAlerting( 00360 const PString & calleeName, 00361 PBoolean withMedia 00362 ); 00363 00368 virtual PBoolean SetConnected(); 00369 00388 virtual void OnReleased(); 00389 00396 virtual PString GetDestinationAddress(); 00397 00404 virtual OpalMediaFormatList GetMediaFormats() const; 00405 00420 virtual OpalMediaStream * CreateMediaStream( 00421 const OpalMediaFormat & mediaFormat, 00422 unsigned sessionID, 00423 PBoolean isSource 00424 ); 00425 00438 virtual PBoolean OnOpenMediaStream( 00439 OpalMediaStream & stream 00440 ); 00441 00449 virtual void OnClosedMediaStream( 00450 const OpalMediaStream & stream 00451 ); 00452 00455 virtual PBoolean SetAudioVolume( 00456 PBoolean source, 00457 unsigned percentage 00458 ); 00459 00463 virtual unsigned GetAudioSignalLevel( 00464 PBoolean source 00465 ); 00466 00474 virtual PBoolean SendUserInputString( 00475 const PString & value 00476 ); 00477 00484 virtual PBoolean SendUserInputTone( 00485 char tone, 00486 int duration 00487 ); 00488 00495 virtual PBoolean PromptUserInput( 00496 PBoolean play 00497 ); 00499 00504 void StartIncoming(); 00505 00508 virtual void Monitor(); 00510 00511 00516 OpalLine & GetLine() { return line; } 00517 00521 OpalLineInterfaceDevice::CallProgressTones GetPromptTone() const { return m_promptTone; } 00522 00525 void SetPromptTone(OpalLineInterfaceDevice::CallProgressTones tone) { m_promptTone = tone; } 00526 00529 void setDialDelay( 00530 unsigned int uiDialDelay 00531 ) { m_dialParams.m_dialStartDelay = uiDialDelay;} 00532 00536 unsigned int getDialDelay() const { return m_dialParams.m_dialStartDelay; } 00538 00539 protected: 00540 OpalLineEndPoint & endpoint; 00541 OpalLine & line; 00542 bool wasOffHook; 00543 unsigned minimumRingCount; 00544 OpalLineInterfaceDevice::DialParams m_dialParams; 00545 OpalLineInterfaceDevice::CallProgressTones m_promptTone; 00546 00547 PDECLARE_NOTIFIER(PThread, OpalLineConnection, HandleIncoming); 00548 PThread * handlerThread; 00549 }; 00550 00551 00555 class OpalLineMediaStream : public OpalMediaStream 00556 { 00557 PCLASSINFO(OpalLineMediaStream, OpalMediaStream); 00558 public: 00563 OpalLineMediaStream( 00564 OpalLineConnection & conn, 00565 const OpalMediaFormat & mediaFormat, 00566 unsigned sessionID, 00567 PBoolean isSource, 00568 OpalLine & line 00569 ); 00571 00572 ~OpalLineMediaStream(); 00573 00574 00582 virtual PBoolean Open(); 00583 00588 virtual PBoolean Close(); 00589 00595 virtual PBoolean ReadPacket( 00596 RTP_DataFrame & packet 00597 ); 00598 00604 virtual PBoolean WritePacket( 00605 RTP_DataFrame & packet 00606 ); 00607 00611 virtual PBoolean ReadData( 00612 BYTE * data, 00613 PINDEX size, 00614 PINDEX & length 00615 ); 00616 00620 virtual PBoolean WriteData( 00621 const BYTE * data, 00622 PINDEX length, 00623 PINDEX & written 00624 ); 00625 00631 virtual PBoolean SetDataSize( 00632 PINDEX dataSize, 00633 PINDEX frameTime 00634 ); 00635 00639 virtual PBoolean IsSynchronous() const; 00640 00651 virtual PBoolean RequiresPatchThread( 00652 OpalMediaStream * stream 00653 ) const; 00655 00660 OpalLine & GetLine() { return line; } 00662 00663 protected: 00664 OpalLine & line; 00665 bool notUsingRTP; 00666 bool useDeblocking; 00667 unsigned missedCount; 00668 BYTE lastSID[4]; 00669 bool lastFrameWasSignal; 00670 unsigned directLineNumber; 00671 }; 00672 00673 00674 class OpalLineSilenceDetector : public OpalSilenceDetector 00675 { 00676 PCLASSINFO(OpalLineSilenceDetector, OpalSilenceDetector); 00677 public: 00682 OpalLineSilenceDetector( 00683 OpalLine & line, 00684 const Params & newParam 00685 ); 00687 00698 virtual unsigned GetAverageSignalLevel( 00699 const BYTE * buffer, 00700 PINDEX size 00701 ); 00703 00704 protected: 00705 OpalLine & line; 00706 }; 00707 00708 00709 #endif // OPAL_LIDS_LIDEP_H 00710 00711 00712 // End of File ///////////////////////////////////////////////////////////////