00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
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 #if OPAL_LID
00044
00045 #include <opal/endpoint.h>
00046 #include <lids/lid.h>
00047 #include <codec/silencedetect.h>
00048
00049
00050 class OpalLineConnection;
00051
00052
00057 class OpalLineEndPoint : public OpalEndPoint
00058 {
00059 PCLASSINFO(OpalLineEndPoint, OpalEndPoint);
00060
00061 public:
00066 OpalLineEndPoint(
00067 OpalManager & manager
00068 );
00069
00071 ~OpalLineEndPoint();
00073
00105 virtual PSafePtr<OpalConnection> MakeConnection(
00106 OpalCall & call,
00107 const PString & party,
00108 void * userData = NULL,
00109 unsigned int options = 0,
00110 OpalConnection::StringOptions * stringOptions = NULL
00111 );
00112
00122 virtual OpalMediaFormatList GetMediaFormats() const;
00124
00127 virtual OpalLineConnection * CreateConnection(
00128 OpalCall & call,
00129 OpalLine & line,
00130 void * userData,
00131 const PString & number
00132 );
00134
00141 PSafePtr<OpalLineConnection> GetLIDConnectionWithLock(
00142 const PString & token,
00143 PSafetyMode mode = PSafeReadWrite
00144 ) { return PSafePtrCast<OpalConnection, OpalLineConnection>(GetConnectionWithLock(token, mode)); }
00145
00153 PBoolean AddLine(
00154 OpalLine * line
00155 );
00156
00160 void RemoveLine(
00161 OpalLine * line
00162 );
00163
00164
00169 const PList<OpalLine> & GetLines() const { return lines;};
00170
00174 void RemoveLine(
00175 const PString & token
00176 );
00177
00182 void RemoveAllLines();
00183
00193 virtual PBoolean AddLinesFromDevice(
00194 OpalLineInterfaceDevice & device
00195 );
00196
00200 void RemoveLinesFromDevice(
00201 OpalLineInterfaceDevice & device
00202 );
00203
00209 PBoolean AddDeviceNames(
00210 const PStringArray & descriptors
00211 );
00212
00222 PBoolean AddDeviceName(
00223 const PString & descriptor
00224 );
00225
00228 const OpalLineInterfaceDevice * GetDeviceByName(
00229 const PString & descriptor
00230 );
00231
00243 virtual PBoolean AddDevice(
00244 OpalLineInterfaceDevice * device
00245 );
00246
00250 void RemoveDevice(
00251 OpalLineInterfaceDevice * device
00252 );
00253
00256 void RemoveDevices() { RemoveAllLines(); }
00257
00265 OpalLine * GetLine(
00266 const PString & lineName,
00267 bool enableAudio = false,
00268 bool terminating = true
00269 );
00270
00274 void SetDefaultLine(
00275 const PString & lineName
00276 );
00277
00283 bool SetCountryCode(
00284 OpalLineInterfaceDevice::T35CountryCodes country
00285 );
00286
00289 bool SetCountryCodeName(
00290 const PString & countryName
00291 );
00293
00294
00295 protected:
00296 PDECLARE_NOTIFIER(PThread, OpalLineEndPoint, MonitorLines);
00297 virtual void MonitorLine(OpalLine & line);
00298
00299 OpalLIDList devices;
00300 OpalLineList lines;
00301 PString defaultLine;
00302 PMutex linesMutex;
00303 PThread * monitorThread;
00304 PSyncPoint exitFlag;
00305 };
00306
00307
00310 class OpalLineConnection : public OpalConnection
00311 {
00312 PCLASSINFO(OpalLineConnection, OpalConnection);
00313
00314 public:
00319 OpalLineConnection(
00320 OpalCall & call,
00321 OpalLineEndPoint & endpoint,
00322 OpalLine & line,
00323 const PString & number
00324 );
00326
00331 virtual PString GetPrefixName() const;
00332
00341 virtual bool IsNetworkConnection() const { return !line.IsTerminal(); }
00342
00349 virtual PBoolean SetUpConnection();
00350
00361 virtual PBoolean SetAlerting(
00362 const PString & calleeName,
00363 PBoolean withMedia
00364 );
00365
00370 virtual PBoolean SetConnected();
00371
00390 virtual void OnReleased();
00391
00398 virtual PString GetDestinationAddress();
00399
00406 virtual OpalMediaFormatList GetMediaFormats() const;
00407
00422 virtual OpalMediaStream * CreateMediaStream(
00423 const OpalMediaFormat & mediaFormat,
00424 unsigned sessionID,
00425 PBoolean isSource
00426 );
00427
00440 virtual PBoolean OnOpenMediaStream(
00441 OpalMediaStream & stream
00442 );
00443
00451 virtual void OnClosedMediaStream(
00452 const OpalMediaStream & stream
00453 );
00454
00457 virtual PBoolean SetAudioVolume(
00458 PBoolean source,
00459 unsigned percentage
00460 );
00461
00465 virtual unsigned GetAudioSignalLevel(
00466 PBoolean source
00467 );
00468
00476 virtual PBoolean SendUserInputString(
00477 const PString & value
00478 );
00479
00486 virtual PBoolean SendUserInputTone(
00487 char tone,
00488 int duration
00489 );
00490
00497 virtual PBoolean PromptUserInput(
00498 PBoolean play
00499 );
00501
00506 void StartIncoming();
00507
00510 virtual void Monitor();
00512
00513
00518 OpalLine & GetLine() { return line; }
00519
00523 OpalLineInterfaceDevice::CallProgressTones GetPromptTone() const { return m_promptTone; }
00524
00527 void SetPromptTone(OpalLineInterfaceDevice::CallProgressTones tone) { m_promptTone = tone; }
00528
00531 void setDialDelay(
00532 unsigned int uiDialDelay
00533 ) { m_dialParams.m_dialStartDelay = uiDialDelay;}
00534
00538 unsigned int getDialDelay() const { return m_dialParams.m_dialStartDelay; }
00540
00541 protected:
00542 OpalLineEndPoint & endpoint;
00543 OpalLine & line;
00544 bool wasOffHook;
00545 unsigned minimumRingCount;
00546 PString m_dialedNumber;
00547 OpalLineInterfaceDevice::DialParams m_dialParams;
00548 OpalLineInterfaceDevice::CallProgressTones m_promptTone;
00549
00550 PDECLARE_NOTIFIER(PThread, OpalLineConnection, HandleIncoming);
00551 PThread * handlerThread;
00552 };
00553
00554
00558 class OpalLineMediaStream : public OpalMediaStream
00559 {
00560 PCLASSINFO(OpalLineMediaStream, OpalMediaStream);
00561 public:
00566 OpalLineMediaStream(
00567 OpalLineConnection & conn,
00568 const OpalMediaFormat & mediaFormat,
00569 unsigned sessionID,
00570 PBoolean isSource,
00571 OpalLine & line
00572 );
00574
00575 ~OpalLineMediaStream();
00576
00577
00585 virtual PBoolean Open();
00586
00592 virtual PBoolean ReadPacket(
00593 RTP_DataFrame & packet
00594 );
00595
00601 virtual PBoolean WritePacket(
00602 RTP_DataFrame & packet
00603 );
00604
00608 virtual PBoolean ReadData(
00609 BYTE * data,
00610 PINDEX size,
00611 PINDEX & length
00612 );
00613
00617 virtual PBoolean WriteData(
00618 const BYTE * data,
00619 PINDEX length,
00620 PINDEX & written
00621 );
00622
00628 virtual PBoolean SetDataSize(
00629 PINDEX dataSize,
00630 PINDEX frameTime
00631 );
00632
00636 virtual PBoolean IsSynchronous() const;
00637
00648 virtual PBoolean RequiresPatchThread(
00649 OpalMediaStream * stream
00650 ) const;
00652
00657 OpalLine & GetLine() { return line; }
00659
00660 protected:
00661 virtual void InternalClose();
00662
00663 OpalLine & line;
00664 bool notUsingRTP;
00665 bool useDeblocking;
00666 unsigned missedCount;
00667 BYTE lastSID[4];
00668 bool lastFrameWasSignal;
00669 unsigned directLineNumber;
00670 };
00671
00672
00673 class OpalLineSilenceDetector : public OpalSilenceDetector
00674 {
00675 PCLASSINFO(OpalLineSilenceDetector, OpalSilenceDetector);
00676 public:
00681 OpalLineSilenceDetector(
00682 OpalLine & line,
00683 const Params & newParam
00684 );
00686
00697 virtual unsigned GetAverageSignalLevel(
00698 const BYTE * buffer,
00699 PINDEX size
00700 );
00702
00703 protected:
00704 OpalLine & line;
00705 };
00706
00707
00708 #endif // OPAL_LID
00709
00710 #endif // OPAL_LIDS_LIDEP_H
00711
00712
00713