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
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141 #ifndef __LIDS_LIDEP_H
00142 #define __LIDS_LIDEP_H
00143
00144 #ifdef P_USE_PRAGMA
00145 #pragma interface
00146 #endif
00147
00148
00149 #include <opal/endpoint.h>
00150 #include <lids/lid.h>
00151 #include <codec/silencedetect.h>
00152
00153
00154 class OpalLineConnection;
00155
00156
00161 class OpalLIDEndPoint : public OpalEndPoint
00162 {
00163 PCLASSINFO(OpalLIDEndPoint, OpalEndPoint);
00164
00165 public:
00170 OpalLIDEndPoint(
00171 OpalManager & manager,
00172 const PString & prefix,
00173 unsigned attributes
00174 );
00175
00177 ~OpalLIDEndPoint();
00179
00211 virtual BOOL MakeConnection(
00212 OpalCall & call,
00213 const PString & party,
00214 void * userData = NULL,
00215 unsigned int options = 0,
00216 OpalConnection::StringOptions * stringOptions = NULL
00217 );
00218
00222 virtual BOOL OnSetUpConnection(OpalLineConnection &connection);
00223
00233 virtual OpalMediaFormatList GetMediaFormats() const;
00235
00238 virtual OpalLineConnection * CreateConnection(
00239 OpalCall & call,
00240 OpalLine & line,
00241 void * userData,
00242 const PString & number
00243 );
00245
00252 PSafePtr<OpalLineConnection> GetLIDConnectionWithLock(
00253 const PString & token,
00254 PSafetyMode mode = PSafeReadWrite
00255 ) { return PSafePtrCast<OpalConnection, OpalLineConnection>(GetConnectionWithLock(token, mode)); }
00256
00264 BOOL AddLine(
00265 OpalLine * line
00266 );
00267
00271 void RemoveLine(
00272 OpalLine * line
00273 );
00274
00275
00280 const PList<OpalLine> & GetLines() const { return lines;};
00281
00285 void RemoveLine(
00286 const PString & token
00287 );
00288
00293 void RemoveAllLines();
00294
00304 virtual BOOL AddLinesFromDevice(
00305 OpalLineInterfaceDevice & device
00306 );
00307
00311 void RemoveLinesFromDevice(
00312 OpalLineInterfaceDevice & device
00313 );
00314
00320 BOOL AddDeviceNames(
00321 const PStringArray & descriptors
00322 );
00323
00333 BOOL AddDeviceName(
00334 const PString & descriptor
00335 );
00336
00348 virtual BOOL AddDevice(
00349 OpalLineInterfaceDevice * device
00350 );
00351
00355 void RemoveDevice(
00356 OpalLineInterfaceDevice * device
00357 );
00358
00366 OpalLine * GetLine(
00367 const PString & lineName,
00368 BOOL enableAudio = FALSE
00369 ) const;
00370
00374 void SetDefaultLine(
00375 const PString & lineName
00376 );
00378
00379
00380 protected:
00381 PDECLARE_NOTIFIER(PThread, OpalLIDEndPoint, MonitorLines);
00382 virtual void MonitorLine(OpalLine & line);
00383
00384 OpalLIDList devices;
00385 OpalLineList lines;
00386 PString defaultLine;
00387 PMutex linesMutex;
00388 PThread * monitorThread;
00389 PSyncPoint exitFlag;
00390 };
00391
00392
00397 class OpalPSTNEndPoint : public OpalLIDEndPoint
00398 {
00399 PCLASSINFO(OpalLIDEndPoint, OpalLIDEndPoint);
00400
00401 public:
00406 OpalPSTNEndPoint(
00407 OpalManager & manager,
00408 const char * prefix = "pstn"
00409 ) : OpalLIDEndPoint(manager, prefix, HasLineInterface) { }
00411 };
00412
00413
00418 class OpalPOTSEndPoint : public OpalLIDEndPoint
00419 {
00420 PCLASSINFO(OpalPOTSEndPoint, OpalLIDEndPoint);
00421
00422 public:
00427 OpalPOTSEndPoint(
00428 OpalManager & manager,
00429 const char * prefix = "pots"
00430 ) : OpalLIDEndPoint(manager, prefix, CanTerminateCall) { }
00432 };
00433
00434
00437 class OpalLineConnection : public OpalConnection
00438 {
00439 PCLASSINFO(OpalLineConnection, OpalConnection);
00440
00441 public:
00446 OpalLineConnection(
00447 OpalCall & call,
00448 OpalLIDEndPoint & endpoint,
00449 OpalLine & line,
00450 const PString & number
00451 );
00453
00462 virtual BOOL SetUpConnection();
00466 virtual BOOL OnSetUpConnection();
00467
00478 virtual BOOL SetAlerting(
00479 const PString & calleeName,
00480 BOOL withMedia
00481 );
00482
00487 virtual BOOL SetConnected();
00488
00507 virtual void OnReleased();
00508
00515 virtual PString GetDestinationAddress();
00516
00523 virtual OpalMediaFormatList GetMediaFormats() const;
00524
00539 virtual OpalMediaStream * CreateMediaStream(
00540 const OpalMediaFormat & mediaFormat,
00541 unsigned sessionID,
00542 BOOL isSource
00543 );
00544
00557 virtual BOOL OnOpenMediaStream(
00558 OpalMediaStream & stream
00559 );
00560
00563 virtual BOOL SetAudioVolume(
00564 BOOL source,
00565 unsigned percentage
00566 );
00567
00571 virtual unsigned GetAudioSignalLevel(
00572 BOOL source
00573 );
00574
00582 virtual BOOL SendUserInputString(
00583 const PString & value
00584 );
00585
00592 virtual BOOL SendUserInputTone(
00593 char tone,
00594 int duration
00595 );
00596
00603 virtual BOOL PromptUserInput(
00604 BOOL play
00605 );
00607
00612 void StartIncoming();
00613
00616 virtual void Monitor(
00617 BOOL offHook
00618 );
00620
00621
00625 void setDialDelay(unsigned int uiDialDelay){ m_uiDialDelay = uiDialDelay;};
00626
00630 unsigned int getDialDelay() const { return m_uiDialDelay;};
00631
00632
00633 protected:
00634 OpalLIDEndPoint & endpoint;
00635 OpalLine & line;
00636 BOOL wasOffHook;
00637 unsigned answerRingCount;
00638 BOOL requireTonesForDial;
00639
00640 unsigned m_uiDialDelay;
00641
00642 PDECLARE_NOTIFIER(PThread, OpalLineConnection, HandleIncoming);
00643 PThread * handlerThread;
00644 };
00645
00646
00650 class OpalLineMediaStream : public OpalMediaStream
00651 {
00652 PCLASSINFO(OpalLineMediaStream, OpalMediaStream);
00653 public:
00658 OpalLineMediaStream(
00659 OpalLineConnection & conn,
00660 const OpalMediaFormat & mediaFormat,
00661 unsigned sessionID,
00662 BOOL isSource,
00663 OpalLine & line
00664 );
00666
00674 virtual BOOL Open();
00675
00680 virtual BOOL Close();
00681
00685 virtual BOOL ReadData(
00686 BYTE * data,
00687 PINDEX size,
00688 PINDEX & length
00689 );
00690
00694 virtual BOOL WriteData(
00695 const BYTE * data,
00696 PINDEX length,
00697 PINDEX & written
00698 );
00699
00705 virtual BOOL SetDataSize(
00706 PINDEX dataSize
00707 );
00708
00712 virtual BOOL IsSynchronous() const;
00714
00719 OpalLine & GetLine() { return line; }
00721
00722 protected:
00723 OpalLine & line;
00724 BOOL useDeblocking;
00725 unsigned missedCount;
00726 BYTE lastSID[4];
00727 BOOL lastFrameWasSignal;
00728 };
00729
00730
00731 class OpalLineSilenceDetector : public OpalSilenceDetector
00732 {
00733 PCLASSINFO(OpalLineSilenceDetector, OpalSilenceDetector);
00734 public:
00739 OpalLineSilenceDetector(
00740 OpalLine & line
00741 );
00743
00754 virtual unsigned GetAverageSignalLevel(
00755 const BYTE * buffer,
00756 PINDEX size
00757 );
00759
00760 protected:
00761 OpalLine & line;
00762 };
00763
00764
00765 #endif // __LIDS_LIDEP_H
00766
00767
00768