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 OpalLIDEndPoint : public OpalEndPoint
00055 {
00056 PCLASSINFO(OpalLIDEndPoint, OpalEndPoint);
00057
00058 public:
00063 OpalLIDEndPoint(
00064 OpalManager & manager,
00065 const PString & prefix,
00066 unsigned attributes
00067 );
00068
00070 ~OpalLIDEndPoint();
00072
00104 virtual PBoolean MakeConnection(
00105 OpalCall & call,
00106 const PString & party,
00107 void * userData = NULL,
00108 unsigned int options = 0,
00109 OpalConnection::StringOptions * stringOptions = NULL
00110 );
00111
00115 virtual PBoolean OnSetUpConnection(OpalLineConnection &connection);
00116
00126 virtual OpalMediaFormatList GetMediaFormats() const;
00128
00131 virtual OpalLineConnection * CreateConnection(
00132 OpalCall & call,
00133 OpalLine & line,
00134 void * userData,
00135 const PString & number
00136 );
00138
00145 PSafePtr<OpalLineConnection> GetLIDConnectionWithLock(
00146 const PString & token,
00147 PSafetyMode mode = PSafeReadWrite
00148 ) { return PSafePtrCast<OpalConnection, OpalLineConnection>(GetConnectionWithLock(token, mode)); }
00149
00157 PBoolean AddLine(
00158 OpalLine * line
00159 );
00160
00164 void RemoveLine(
00165 OpalLine * line
00166 );
00167
00168
00173 const PList<OpalLine> & GetLines() const { return lines;};
00174
00178 void RemoveLine(
00179 const PString & token
00180 );
00181
00186 void RemoveAllLines();
00187
00197 virtual PBoolean AddLinesFromDevice(
00198 OpalLineInterfaceDevice & device
00199 );
00200
00204 void RemoveLinesFromDevice(
00205 OpalLineInterfaceDevice & device
00206 );
00207
00213 PBoolean AddDeviceNames(
00214 const PStringArray & descriptors
00215 );
00216
00226 PBoolean AddDeviceName(
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 PBoolean enableAudio = PFalse
00266 );
00267
00271 void SetDefaultLine(
00272 const PString & lineName
00273 );
00275
00276
00277 protected:
00278 PDECLARE_NOTIFIER(PThread, OpalLIDEndPoint, 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
00294 class OpalPSTNEndPoint : public OpalLIDEndPoint
00295 {
00296 PCLASSINFO(OpalLIDEndPoint, OpalLIDEndPoint);
00297
00298 public:
00303 OpalPSTNEndPoint(
00304 OpalManager & manager,
00305 const char * prefix = "pstn"
00306 ) : OpalLIDEndPoint(manager, prefix, HasLineInterface) { }
00308 };
00309
00310
00315 class OpalPOTSEndPoint : public OpalLIDEndPoint
00316 {
00317 PCLASSINFO(OpalPOTSEndPoint, OpalLIDEndPoint);
00318
00319 public:
00324 OpalPOTSEndPoint(
00325 OpalManager & manager,
00326 const char * prefix = "pots"
00327 ) : OpalLIDEndPoint(manager, prefix, CanTerminateCall) { }
00329 };
00330
00331
00334 class OpalLineConnection : public OpalConnection
00335 {
00336 PCLASSINFO(OpalLineConnection, OpalConnection);
00337
00338 public:
00343 OpalLineConnection(
00344 OpalCall & call,
00345 OpalLIDEndPoint & endpoint,
00346 OpalLine & line,
00347 const PString & number
00348 );
00350
00359 virtual PBoolean SetUpConnection();
00363 virtual PBoolean OnSetUpConnection();
00364
00375 virtual PBoolean SetAlerting(
00376 const PString & calleeName,
00377 PBoolean withMedia
00378 );
00379
00384 virtual PBoolean SetConnected();
00385
00404 virtual void OnReleased();
00405
00412 virtual PString GetDestinationAddress();
00413
00420 virtual OpalMediaFormatList GetMediaFormats() const;
00421
00436 virtual OpalMediaStream * CreateMediaStream(
00437 const OpalMediaFormat & mediaFormat,
00438 unsigned sessionID,
00439 PBoolean isSource
00440 );
00441
00454 virtual PBoolean OnOpenMediaStream(
00455 OpalMediaStream & stream
00456 );
00457
00460 virtual PBoolean SetAudioVolume(
00461 PBoolean source,
00462 unsigned percentage
00463 );
00464
00468 virtual unsigned GetAudioSignalLevel(
00469 PBoolean source
00470 );
00471
00479 virtual PBoolean SendUserInputString(
00480 const PString & value
00481 );
00482
00489 virtual PBoolean SendUserInputTone(
00490 char tone,
00491 int duration
00492 );
00493
00500 virtual PBoolean PromptUserInput(
00501 PBoolean play
00502 );
00504
00509 void StartIncoming();
00510
00513 virtual void Monitor(
00514 PBoolean offHook
00515 );
00517
00518
00522 void setDialDelay(unsigned int uiDialDelay){ m_uiDialDelay = uiDialDelay;};
00523
00527 unsigned int getDialDelay() const { return m_uiDialDelay;};
00528
00529
00530 protected:
00531 OpalLIDEndPoint & endpoint;
00532 OpalLine & line;
00533 PBoolean wasOffHook;
00534 unsigned answerRingCount;
00535 PBoolean requireTonesForDial;
00536
00537 unsigned m_uiDialDelay;
00538
00539 PDECLARE_NOTIFIER(PThread, OpalLineConnection, HandleIncoming);
00540 PThread * handlerThread;
00541 };
00542
00543
00547 class OpalLineMediaStream : public OpalMediaStream
00548 {
00549 PCLASSINFO(OpalLineMediaStream, OpalMediaStream);
00550 public:
00555 OpalLineMediaStream(
00556 OpalLineConnection & conn,
00557 const OpalMediaFormat & mediaFormat,
00558 unsigned sessionID,
00559 PBoolean isSource,
00560 OpalLine & line
00561 );
00563
00571 virtual PBoolean Open();
00572
00577 virtual PBoolean Close();
00578
00582 virtual PBoolean ReadData(
00583 BYTE * data,
00584 PINDEX size,
00585 PINDEX & length
00586 );
00587
00591 virtual PBoolean WriteData(
00592 const BYTE * data,
00593 PINDEX length,
00594 PINDEX & written
00595 );
00596
00602 virtual PBoolean SetDataSize(
00603 PINDEX dataSize
00604 );
00605
00609 virtual PBoolean IsSynchronous() const;
00611
00616 OpalLine & GetLine() { return line; }
00618
00619 protected:
00620 OpalLine & line;
00621 PBoolean useDeblocking;
00622 unsigned missedCount;
00623 BYTE lastSID[4];
00624 PBoolean lastFrameWasSignal;
00625 };
00626
00627
00628 class OpalLineSilenceDetector : public OpalSilenceDetector
00629 {
00630 PCLASSINFO(OpalLineSilenceDetector, OpalSilenceDetector);
00631 public:
00636 OpalLineSilenceDetector(
00637 OpalLine & line
00638 );
00640
00651 virtual unsigned GetAverageSignalLevel(
00652 const BYTE * buffer,
00653 PINDEX size
00654 );
00656
00657 protected:
00658 OpalLine & line;
00659 };
00660
00661
00662 #endif // __LIDS_LIDEP_H
00663
00664
00665