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 __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
00119 virtual OpalMediaFormatList GetMediaFormats() const;
00121
00124 virtual OpalLineConnection * CreateConnection(
00125 OpalCall & call,
00126 OpalLine & line,
00127 void * userData,
00128 const PString & number
00129 );
00131
00138 PSafePtr<OpalLineConnection> GetLIDConnectionWithLock(
00139 const PString & token,
00140 PSafetyMode mode = PSafeReadWrite
00141 ) { return PSafePtrCast<OpalConnection, OpalLineConnection>(GetConnectionWithLock(token, mode)); }
00142
00150 PBoolean AddLine(
00151 OpalLine * line
00152 );
00153
00157 void RemoveLine(
00158 OpalLine * line
00159 );
00160
00161
00166 const PList<OpalLine> & GetLines() const { return lines;};
00167
00171 void RemoveLine(
00172 const PString & token
00173 );
00174
00179 void RemoveAllLines();
00180
00190 virtual PBoolean AddLinesFromDevice(
00191 OpalLineInterfaceDevice & device
00192 );
00193
00197 void RemoveLinesFromDevice(
00198 OpalLineInterfaceDevice & device
00199 );
00200
00206 PBoolean AddDeviceNames(
00207 const PStringArray & descriptors
00208 );
00209
00219 PBoolean AddDeviceName(
00220 const PString & descriptor
00221 );
00222
00225 const OpalLineInterfaceDevice * GetDeviceByName(
00226 const PString & descriptor
00227 );
00228
00240 virtual PBoolean AddDevice(
00241 OpalLineInterfaceDevice * device
00242 );
00243
00247 void RemoveDevice(
00248 OpalLineInterfaceDevice * device
00249 );
00250
00253 void RemoveDevices() { RemoveAllLines(); }
00254
00262 OpalLine * GetLine(
00263 const PString & lineName,
00264 bool enableAudio = false,
00265 bool terminating = true
00266 );
00267
00271 void SetDefaultLine(
00272 const PString & lineName
00273 );
00275
00276
00277 protected:
00278 PDECLARE_NOTIFIER(PThread, OpalLineEndPoint, MonitorLines);
00279 virtual void MonitorLine(OpalLine & line);
00280
00281 OpalLIDList devices;
00282 OpalLineList lines;
00283 PString defaultLine;
00284 PMutex linesMutex;
00285 PThread * monitorThread;
00286 PSyncPoint exitFlag;
00287 };
00288
00289
00292 class OpalLineConnection : public OpalConnection
00293 {
00294 PCLASSINFO(OpalLineConnection, OpalConnection);
00295
00296 public:
00301 OpalLineConnection(
00302 OpalCall & call,
00303 OpalLineEndPoint & endpoint,
00304 OpalLine & line,
00305 const PString & number
00306 );
00308
00313 virtual PString GetPrefixName() const;
00314
00323 virtual bool IsNetworkConnection() const { return !line.IsTerminal(); }
00324
00331 virtual PBoolean SetUpConnection();
00332
00343 virtual PBoolean SetAlerting(
00344 const PString & calleeName,
00345 PBoolean withMedia
00346 );
00347
00352 virtual PBoolean SetConnected();
00353
00372 virtual void OnReleased();
00373
00380 virtual PString GetDestinationAddress();
00381
00388 virtual OpalMediaFormatList GetMediaFormats() const;
00389
00404 virtual OpalMediaStream * CreateMediaStream(
00405 const OpalMediaFormat & mediaFormat,
00406 unsigned sessionID,
00407 PBoolean isSource
00408 );
00409
00422 virtual PBoolean OnOpenMediaStream(
00423 OpalMediaStream & stream
00424 );
00425
00428 virtual PBoolean SetAudioVolume(
00429 PBoolean source,
00430 unsigned percentage
00431 );
00432
00436 virtual unsigned GetAudioSignalLevel(
00437 PBoolean source
00438 );
00439
00447 virtual PBoolean SendUserInputString(
00448 const PString & value
00449 );
00450
00457 virtual PBoolean SendUserInputTone(
00458 char tone,
00459 int duration
00460 );
00461
00468 virtual PBoolean PromptUserInput(
00469 PBoolean play
00470 );
00472
00477 void StartIncoming();
00478
00481 virtual void Monitor();
00483
00484
00488 void setDialDelay(unsigned int uiDialDelay) { m_dialParams.m_dialStartDelay = uiDialDelay;}
00489
00493 unsigned int getDialDelay() const { return m_dialParams.m_dialStartDelay; }
00494
00495
00496 protected:
00497 OpalLineEndPoint & endpoint;
00498 OpalLine & line;
00499 bool wasOffHook;
00500 unsigned minimumRingCount;
00501 OpalLineInterfaceDevice::DialParams m_dialParams;
00502
00503 PDECLARE_NOTIFIER(PThread, OpalLineConnection, HandleIncoming);
00504 PThread * handlerThread;
00505 };
00506
00507
00511 class OpalLineMediaStream : public OpalMediaStream
00512 {
00513 PCLASSINFO(OpalLineMediaStream, OpalMediaStream);
00514 public:
00519 OpalLineMediaStream(
00520 OpalLineConnection & conn,
00521 const OpalMediaFormat & mediaFormat,
00522 unsigned sessionID,
00523 PBoolean isSource,
00524 OpalLine & line
00525 );
00527
00535 virtual PBoolean Open();
00536
00541 virtual PBoolean Close();
00542
00548 virtual PBoolean ReadPacket(
00549 RTP_DataFrame & packet
00550 );
00551
00557 virtual PBoolean WritePacket(
00558 RTP_DataFrame & packet
00559 );
00560
00564 virtual PBoolean ReadData(
00565 BYTE * data,
00566 PINDEX size,
00567 PINDEX & length
00568 );
00569
00573 virtual PBoolean WriteData(
00574 const BYTE * data,
00575 PINDEX length,
00576 PINDEX & written
00577 );
00578
00584 virtual PBoolean SetDataSize(
00585 PINDEX dataSize
00586 );
00587
00591 virtual PBoolean IsSynchronous() const;
00592
00602 virtual PBoolean RequiresPatchThread(
00603 OpalMediaStream * sinkStream
00604 ) const;
00606
00611 OpalLine & GetLine() { return line; }
00613
00614 protected:
00615 OpalLine & line;
00616 bool notUsingRTP;
00617 bool useDeblocking;
00618 unsigned missedCount;
00619 BYTE lastSID[4];
00620 bool lastFrameWasSignal;
00621 unsigned directLineNumber;
00622 };
00623
00624
00625 class OpalLineSilenceDetector : public OpalSilenceDetector
00626 {
00627 PCLASSINFO(OpalLineSilenceDetector, OpalSilenceDetector);
00628 public:
00633 OpalLineSilenceDetector(
00634 OpalLine & line,
00635 const Params & newParam
00636 );
00638
00649 virtual unsigned GetAverageSignalLevel(
00650 const BYTE * buffer,
00651 PINDEX size
00652 );
00654
00655 protected:
00656 OpalLine & line;
00657 };
00658
00659
00660 #endif // __LIDS_LIDEP_H
00661
00662
00663