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 #ifndef OPAL_OPAL_LOCALEP_H
00033 #define OPAL_OPAL_LOCALEP_H
00034
00035 #ifdef P_USE_PRAGMA
00036 #pragma interface
00037 #endif
00038
00039 #include <opal/buildopts.h>
00040
00041 #include <opal/endpoint.h>
00042
00043 class OpalLocalConnection;
00044
00045
00050 class OpalLocalEndPoint : public OpalEndPoint
00051 {
00052 PCLASSINFO(OpalLocalEndPoint, OpalEndPoint);
00053 public:
00058 OpalLocalEndPoint(
00059 OpalManager & manager,
00060 const char * prefix = "local"
00061 );
00062
00065 ~OpalLocalEndPoint();
00067
00080 virtual OpalMediaFormatList GetMediaFormats() const;
00081
00111 virtual PSafePtr<OpalConnection> MakeConnection(
00112 OpalCall & call,
00113 const PString & party,
00114 void * userData = NULL,
00115 unsigned int options = 0,
00116 OpalConnection::StringOptions * stringOptions = NULL
00117 );
00119
00128 PSafePtr<OpalLocalConnection> GetLocalConnectionWithLock(
00129 const PString & token,
00130 PSafetyMode mode = PSafeReadWrite
00131 ) { return GetConnectionWithLockAs<OpalLocalConnection>(token, mode); }
00132
00136 virtual OpalLocalConnection * CreateConnection(
00137 OpalCall & call,
00138 void * userData,
00139 unsigned options,
00140 OpalConnection::StringOptions * stringOptions
00141 );
00142
00148 virtual bool OnOutgoingCall(
00149 const OpalLocalConnection & connection
00150 );
00151
00160 virtual bool OnIncomingCall(
00161 OpalLocalConnection & connection
00162 );
00163
00168 virtual bool AlertingIncomingCall(
00169 const PString & token,
00170 OpalConnection::StringOptions * options = NULL
00171 );
00172
00177 virtual bool AcceptIncomingCall(
00178 const PString & token,
00179 OpalConnection::StringOptions * options = NULL
00180 );
00181
00186 virtual bool RejectIncomingCall(
00187 const PString & token,
00188 const OpalConnection::CallEndReason & reason = OpalConnection::EndedByAnswerDenied
00189 );
00190
00196 virtual bool OnUserInput(
00197 const OpalLocalConnection & connection,
00198 const PString & indication
00199 );
00200
00206 virtual bool OnReadMediaFrame(
00207 const OpalLocalConnection & connection,
00208 const OpalMediaStream & mediaStream,
00209 RTP_DataFrame & frame
00210 );
00211
00218 virtual bool OnWriteMediaFrame(
00219 const OpalLocalConnection & connection,
00220 const OpalMediaStream & mediaStream,
00221 RTP_DataFrame & frame
00222 );
00223
00229 virtual bool OnReadMediaData(
00230 const OpalLocalConnection & connection,
00231 const OpalMediaStream & mediaStream,
00232 void * data,
00233 PINDEX size,
00234 PINDEX & length
00235 );
00236
00242 virtual bool OnWriteMediaData(
00243 const OpalLocalConnection & connection,
00244 const OpalMediaStream & mediaStream,
00245 const void * data,
00246 PINDEX length,
00247 PINDEX & written
00248 );
00249
00262 virtual bool IsSynchronous() const;
00263
00266 bool IsDeferredAlerting() const { return m_deferredAlerting; }
00267
00270 void SetDeferredAlerting(bool defer) { m_deferredAlerting = defer; }
00271
00274 bool IsDeferredAnswer() const { return m_deferredAnswer; }
00275
00278 void SetDeferredAnswer(bool defer) { m_deferredAnswer = defer; }
00280
00281 protected:
00282 bool m_deferredAlerting;
00283 bool m_deferredAnswer;
00284
00285 private:
00286 P_REMOVE_VIRTUAL(OpalLocalConnection *, CreateConnection(OpalCall &, void *), 0);
00287 };
00288
00289
00294 class OpalLocalConnection : public OpalConnection
00295 {
00296 PCLASSINFO(OpalLocalConnection, OpalConnection);
00297 public:
00302 OpalLocalConnection(
00303 OpalCall & call,
00304 OpalLocalEndPoint & endpoint,
00305 void * userData,
00306 unsigned options,
00307 OpalConnection::StringOptions * stringOptions,
00308 char tokenPrefix = 'L'
00309 );
00310
00313 ~OpalLocalConnection();
00315
00326 virtual PBoolean IsNetworkConnection() const { return false; }
00327
00329 virtual void OnApplyStringOptions();
00330
00337 virtual PBoolean SetUpConnection();
00338
00349 virtual PBoolean SetAlerting(
00350 const PString & calleeName,
00351 PBoolean withMedia
00352 );
00353
00364 virtual PBoolean SetConnected();
00365
00380 virtual OpalMediaStream * CreateMediaStream(
00381 const OpalMediaFormat & mediaFormat,
00382 unsigned sessionID,
00383 PBoolean isSource
00384 );
00385
00388 virtual OpalMediaStreamPtr OpenMediaStream(
00389 const OpalMediaFormat & mediaFormat,
00390 unsigned sessionID,
00391 bool isSource
00392 );
00393
00401 virtual PBoolean SendUserInputString(
00402 const PString & value
00403 );
00405
00410 virtual void AlertingIncoming();
00411
00414 virtual void AcceptIncoming();
00416
00419
00420 void * GetUserData() const { return userData; }
00421
00423 void SetUserData(void * v) { userData = v; }
00425
00426 protected:
00427 OpalLocalEndPoint & endpoint;
00428 void * userData;
00429 };
00430
00431
00436 class OpalLocalMediaStream : public OpalMediaStream, public OpalMediaStreamPacing
00437 {
00438 PCLASSINFO(OpalLocalMediaStream, OpalMediaStream);
00439 public:
00444 OpalLocalMediaStream(
00445 OpalLocalConnection & conn,
00446 const OpalMediaFormat & mediaFormat,
00447 unsigned sessionID,
00448 bool isSource,
00449 bool isSynchronous
00450 );
00452
00460 virtual PBoolean ReadPacket(
00461 RTP_DataFrame & packet
00462 );
00463
00469 virtual PBoolean WritePacket(
00470 RTP_DataFrame & packet
00471 );
00472
00476 virtual PBoolean ReadData(
00477 BYTE * data,
00478 PINDEX size,
00479 PINDEX & length
00480 );
00481
00485 virtual PBoolean WriteData(
00486 const BYTE * data,
00487 PINDEX length,
00488 PINDEX & written
00489 );
00490
00494 virtual PBoolean IsSynchronous() const;
00496
00497 protected:
00498 virtual void InternalClose() { }
00499
00500 bool m_isSynchronous;
00501 };
00502
00503
00504 #endif // OPAL_OPAL_LOCALEP_H
00505
00506
00507