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
00113 virtual PBoolean OnSetUpConnection(OpalLineConnection &connection);
00114
00124 virtual OpalMediaFormatList GetMediaFormats() const;
00126
00129 virtual OpalLineConnection * CreateConnection(
00130 OpalCall & call,
00131 OpalLine & line,
00132 void * userData,
00133 const PString & number
00134 );
00136
00143 PSafePtr<OpalLineConnection> GetLIDConnectionWithLock(
00144 const PString & token,
00145 PSafetyMode mode = PSafeReadWrite
00146 ) { return PSafePtrCast<OpalConnection, OpalLineConnection>(GetConnectionWithLock(token, mode)); }
00147
00155 PBoolean AddLine(
00156 OpalLine * line
00157 );
00158
00162 void RemoveLine(
00163 OpalLine * line
00164 );
00165
00166
00171 const PList<OpalLine> & GetLines() const { return lines;};
00172
00176 void RemoveLine(
00177 const PString & token
00178 );
00179
00184 void RemoveAllLines();
00185
00195 virtual PBoolean AddLinesFromDevice(
00196 OpalLineInterfaceDevice & device
00197 );
00198
00202 void RemoveLinesFromDevice(
00203 OpalLineInterfaceDevice & device
00204 );
00205
00211 PBoolean AddDeviceNames(
00212 const PStringArray & descriptors
00213 );
00214
00224 PBoolean AddDeviceName(
00225 const PString & descriptor
00226 );
00227
00239 virtual PBoolean AddDevice(
00240 OpalLineInterfaceDevice * device
00241 );
00242
00246 void RemoveDevice(
00247 OpalLineInterfaceDevice * device
00248 );
00249
00252 void RemoveDevices() { RemoveAllLines(); }
00253
00261 OpalLine * GetLine(
00262 const PString & lineName,
00263 bool enableAudio = false,
00264 bool terminating = true
00265 );
00266
00270 void SetDefaultLine(
00271 const PString & lineName
00272 );
00274
00275
00276 protected:
00277 PDECLARE_NOTIFIER(PThread, OpalLineEndPoint, MonitorLines);
00278 virtual void MonitorLine(OpalLine & line);
00279
00280 OpalLIDList devices;
00281 OpalLineList lines;
00282 PString defaultLine;
00283 PMutex linesMutex;
00284 PThread * monitorThread;
00285 PSyncPoint exitFlag;
00286 };
00287
00288
00291 class OpalLineConnection : public OpalConnection
00292 {
00293 PCLASSINFO(OpalLineConnection, OpalConnection);
00294
00295 public:
00300 OpalLineConnection(
00301 OpalCall & call,
00302 OpalLineEndPoint & endpoint,
00303 OpalLine & line,
00304 const PString & number
00305 );
00307
00316 virtual PBoolean SetUpConnection();
00320 virtual PBoolean OnSetUpConnection();
00321
00332 virtual PBoolean SetAlerting(
00333 const PString & calleeName,
00334 PBoolean withMedia
00335 );
00336
00341 virtual PBoolean SetConnected();
00342
00361 virtual void OnReleased();
00362
00369 virtual PString GetDestinationAddress();
00370
00377 virtual OpalMediaFormatList GetMediaFormats() const;
00378
00393 virtual OpalMediaStream * CreateMediaStream(
00394 const OpalMediaFormat & mediaFormat,
00395 unsigned sessionID,
00396 PBoolean isSource
00397 );
00398
00411 virtual PBoolean OnOpenMediaStream(
00412 OpalMediaStream & stream
00413 );
00414
00417 virtual PBoolean SetAudioVolume(
00418 PBoolean source,
00419 unsigned percentage
00420 );
00421
00425 virtual unsigned GetAudioSignalLevel(
00426 PBoolean source
00427 );
00428
00436 virtual PBoolean SendUserInputString(
00437 const PString & value
00438 );
00439
00446 virtual PBoolean SendUserInputTone(
00447 char tone,
00448 int duration
00449 );
00450
00457 virtual PBoolean PromptUserInput(
00458 PBoolean play
00459 );
00461
00466 void StartIncoming();
00467
00470 virtual void Monitor(
00471 PBoolean offHook
00472 );
00474
00475
00479 void setDialDelay(unsigned int uiDialDelay){ m_uiDialDelay = uiDialDelay;};
00480
00484 unsigned int getDialDelay() const { return m_uiDialDelay;};
00485
00486
00487 protected:
00488 OpalLineEndPoint & endpoint;
00489 OpalLine & line;
00490 PBoolean wasOffHook;
00491 unsigned answerRingCount;
00492 PBoolean requireTonesForDial;
00493
00494 unsigned m_uiDialDelay;
00495
00496 PDECLARE_NOTIFIER(PThread, OpalLineConnection, HandleIncoming);
00497 PThread * handlerThread;
00498 };
00499
00500
00504 class OpalLineMediaStream : public OpalMediaStream
00505 {
00506 PCLASSINFO(OpalLineMediaStream, OpalMediaStream);
00507 public:
00512 OpalLineMediaStream(
00513 OpalLineConnection & conn,
00514 const OpalMediaFormat & mediaFormat,
00515 unsigned sessionID,
00516 PBoolean isSource,
00517 OpalLine & line
00518 );
00520
00528 virtual PBoolean Open();
00529
00534 virtual PBoolean Close();
00535
00541 virtual PBoolean ReadPacket(
00542 RTP_DataFrame & packet
00543 );
00544
00550 virtual PBoolean WritePacket(
00551 RTP_DataFrame & packet
00552 );
00553
00557 virtual PBoolean ReadData(
00558 BYTE * data,
00559 PINDEX size,
00560 PINDEX & length
00561 );
00562
00566 virtual PBoolean WriteData(
00567 const BYTE * data,
00568 PINDEX length,
00569 PINDEX & written
00570 );
00571
00577 virtual PBoolean SetDataSize(
00578 PINDEX dataSize
00579 );
00580
00584 virtual PBoolean IsSynchronous() const;
00586
00591 OpalLine & GetLine() { return line; }
00593
00594 protected:
00595 OpalLine & line;
00596 bool notUsingRTP;
00597 bool useDeblocking;
00598 unsigned missedCount;
00599 BYTE lastSID[4];
00600 bool lastFrameWasSignal;
00601 };
00602
00603
00604 class OpalLineSilenceDetector : public OpalSilenceDetector
00605 {
00606 PCLASSINFO(OpalLineSilenceDetector, OpalSilenceDetector);
00607 public:
00612 OpalLineSilenceDetector(
00613 OpalLine & line
00614 );
00616
00627 virtual unsigned GetAverageSignalLevel(
00628 const BYTE * buffer,
00629 PINDEX size
00630 );
00632
00633 protected:
00634 OpalLine & line;
00635 };
00636
00637
00638 #endif // __LIDS_LIDEP_H
00639
00640
00641