OPAL  Version 3.10.10
rtpconn.h
Go to the documentation of this file.
1 /*
2  * rtpconn.h
3  *
4  * Connection abstraction
5  *
6  * Open Phone Abstraction Library (OPAL)
7  *
8  * Copyright (C) 2007 Post Increment
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Open Phone Abstraction Library.
21  *
22  * The Initial Developer of the Original Code is Post Increment
23  *
24  * Contributor(s): ______________________________________.
25  *
26  * $Revision: 26728 $
27  * $Author: rjongbloed $
28  * $Date: 2011-12-01 22:59:14 -0600 (Thu, 01 Dec 2011) $
29  */
30 
31 #ifndef OPAL_OPAL_RTPCONN_H
32 #define OPAL_OPAL_RTPCONN_H
33 
34 #ifdef P_USE_PRAGMA
35 #pragma interface
36 #endif
37 
38 #include <opal/buildopts.h>
39 
40 #include <opal/connection.h>
41 #include <opal/mediatype.h>
42 
43 #ifdef OPAL_ZRTP
44 
45 class OpalZRTPStreamInfo {
46  public:
47  virtual bool Open() = 0;
48  virtual RTP_UDP * CreateRTPSession(OpalConnection & conn, unsigned sessionId, bool remoteIsNat) = 0;
49 };
50 
51 class OpalZRTPConnectionInfo {
52  public:
53  virtual bool Open() = 0;
54  virtual RTP_UDP * CreateRTPSession(OpalConnection & conn, unsigned sessionId, bool remoteIsNat) = 0;
55 
56  PMutex mutex;
57 };
58 
59 #endif // OPAL_ZRTP
60 
61 
62 class OpalRTPEndPoint;
63 
64 //#ifdef HAS_LIBZRTP
65 //#ifndef __ZRTP_TYPES_H__
66 //struct zrtp_conn_ctx_t;
67 //#endif
68 //#endif
69 
72 class OpalMediaSession : public PObject
73 {
74  PCLASSINFO(OpalMediaSession, PObject);
75  public:
76  OpalMediaSession(OpalConnection & conn, const OpalMediaType & _mediaType, unsigned sessionId);
77  OpalMediaSession(const OpalMediaSession & _obj);
78 
79  virtual void Close() = 0;
80 
81  virtual PObject * Clone() const = 0;
82 
83  virtual bool IsActive() const = 0;
84 
85  virtual bool IsRTP() const = 0;
86 
87  virtual bool HasFailed() const = 0;
88 
89  virtual OpalTransportAddress GetLocalMediaAddress() const = 0;
90 
92 
93 #if OPAL_SIP
94  virtual SDPMediaDescription * CreateSDPMediaDescription(
95  const OpalTransportAddress & localAddress
96  ) = 0;
97 #endif
98 
99  virtual OpalMediaStream * CreateMediaStream(
100  const OpalMediaFormat & mediaFormat,
101  unsigned sessionID,
102  PBoolean isSource
103  ) = 0;
104 
106  OpalMediaType mediaType; // media type for session
107  unsigned sessionId; // unique session ID
108 };
109 
110 
114 {
116  public:
118  OpalConnection & conn,
119  const OpalMediaType & mediaType,
120  unsigned sessionId
121  );
124 
125  PObject * Clone() const { return new OpalRTPMediaSession(*this); }
126 
127  void Attach(RTP_Session * rtpSession);
128 
129  virtual void Close();
130 
131  virtual bool IsActive() const { return rtpSession != NULL; }
132 
133  virtual bool IsRTP() const { return true; }
134 
135  virtual bool HasFailed() const { return (rtpSession != NULL) && (rtpSession->HasFailed() || (rtpSession->GetPacketsReceived() == 0)); }
136 
137  virtual OpalTransportAddress GetLocalMediaAddress() const;
138 
139 #if OPAL_SIP
140  virtual SDPMediaDescription * CreateSDPMediaDescription(
141  const OpalTransportAddress & localAddress
142  );
143 #endif
144 
145  virtual OpalMediaStream * CreateMediaStream(
146  const OpalMediaFormat & mediaFormat,
147  unsigned sessionID,
148  PBoolean isSource
149  );
150 
151  RTP_Session * GetSession() const { return rtpSession; }
152 
153  protected:
154  RTP_Session * rtpSession; // RTP session
155 };
156 
159 class OpalRTPSessionManager : public PObject
160 {
161  PCLASSINFO(OpalRTPSessionManager , PObject);
162  public:
168  OpalRTPConnection & connection
169  );
170 
173 
176 
178  void operator=(const OpalRTPSessionManager & other) { sessions = other.sessions; }
180 
185  unsigned GetNextSessionID();
186 
193  void AddSession(
194  RTP_Session * session,
195  const OpalMediaType & mediaType
196  );
197  void AddMediaSession(
198  OpalMediaSession * session,
199  const OpalMediaType & mediaType
200  );
201 
204  virtual void CloseSession(
205  unsigned sessionID
206  );
207 
210  RTP_Session * GetSession(
211  unsigned sessionID
212  ) const;
213  OpalMediaSession * GetMediaSession(
214  unsigned sessionID
215  ) const;
216 
222  bool ChangeSessionID(
223  unsigned fromSessionID,
224  unsigned toSessionID
225  );
227 
228  PMutex & GetMutex() { return m_mutex; }
229 
230  virtual bool AllSessionsFailing();
231 
232  protected:
234  PMutex m_mutex;
235 
236  PDICTIONARY(SessionDict, POrdinalKey, OpalMediaSession);
237  SessionDict sessions;
238 };
239 
240 
242 
243 
248 {
249  PCLASSINFO(OpalRTPConnection, OpalConnection);
250  public:
256  OpalCall & call,
257  OpalRTPEndPoint & endpoint,
258  const PString & token,
259  unsigned options = 0,
260  OpalConnection::StringOptions * stringOptions = NULL
261  );
262 
266 
284  virtual void OnReleased();
286 
287 
292  virtual unsigned GetNextSessionID(
293  const OpalMediaType & mediaType,
294  bool isSource
295  );
296 
300  virtual RTP_Session * GetSession(
301  unsigned sessionID
302  ) const;
303  virtual OpalMediaSession * GetMediaSession(
304  unsigned sessionID
305  ) const;
306 
315  virtual RTP_Session * UseSession(
316  const OpalTransport & transport,
317  unsigned sessionID,
318  const OpalMediaType & mediatype,
319  RTP_QOS * rtpqos = NULL
320  );
321 
324  virtual void CloseSession(
325  unsigned sessionID
326  );
327 
332  virtual RTP_Session * CreateSession(
333  const OpalTransport & transport,
334  unsigned sessionID,
335  const OpalMediaType & mediaType,
336  RTP_QOS * rtpqos
337  );
338 
341  virtual RTP_UDP * CreateRTPSession(
342  unsigned sessionId,
343  const OpalMediaType & mediaType,
344  bool remoteIsNat
345  );
346 
352  virtual bool ChangeSessionID(
353  unsigned fromSessionID,
354  unsigned toSessionID
355  );
357 
362  virtual PBoolean RemoteIsNAT() const
363  { return remoteIsNAT; }
364 
382  virtual PBoolean IsRTPNATEnabled(
383  const PIPSocket::Address & localAddr,
384  const PIPSocket::Address & peerAddr,
385  const PIPSocket::Address & signalAddr,
386  PBoolean incoming
387  );
389 
394  virtual void AttachRFC2833HandlerToPatch(PBoolean isSource, OpalMediaPatch & patch);
395 
396  virtual PBoolean SendUserInputTone(
397  char tone,
398  unsigned duration = 0
399  );
400 
407  }
408 
413  };
415 
426  virtual PBoolean GetMediaInformation(
427  unsigned sessionID,
428  MediaInformation & info
429  ) const;
430 
435  virtual PBoolean IsMediaBypassPossible(
436  unsigned sessionID
437  ) const;
438 
451  virtual OpalMediaStream * CreateMediaStream(
452  const OpalMediaFormat & mediaFormat,
453  unsigned sessionID,
454  PBoolean isSource
455  );
456 
470  virtual void AdjustMediaFormats(
471  bool local,
472  const OpalConnection * otherConnection,
473  OpalMediaFormatList & mediaFormats
474  ) const;
475 
484  virtual void OnPatchMediaStream(
485  PBoolean isSource,
486  OpalMediaPatch & patch
487  );
488 
494  virtual bool OnMediaCommand(
495  OpalMediaStream & stream,
496  const OpalMediaCommand & command
497  );
499 
500  virtual void SessionFailing(RTP_Session & session);
501 
502  protected:
503  PDECLARE_NOTIFIER(OpalRFC2833Info, OpalRTPConnection, OnUserInputInlineRFC2833);
504  PDECLARE_NOTIFIER(OpalRFC2833Info, OpalRTPConnection, OnUserInputInlineCiscoNSE);
505 
508 #if OPAL_T38_CAPABILITY
509  OpalRFC2833Proto * ciscoNSEHandler;
510 #endif
511 
512  PBoolean remoteIsNAT;
514 
515 #ifdef OPAL_ZRTP
516  bool zrtpEnabled;
517  PMutex zrtpConnInfoMutex;
518  OpalZRTPConnectionInfo * zrtpConnInfo;
519 #endif
520 };
521 
522 
523 class RTP_UDP;
524 
525 class OpalSecurityMode : public PObject
526 {
527  PCLASSINFO(OpalSecurityMode, PObject);
528  public:
529  virtual RTP_UDP * CreateRTPSession(
530  OpalRTPConnection & connection,
531  const RTP_Session::Params & options
532  ) = 0;
533  virtual PBoolean Open() = 0;
534 };
535 
536 #endif // OPAL_OPAL_RTPCONN_H
Definition: rtpconn.h:525
Definition: rtpconn.h:247
virtual bool IsRTP() const
Definition: rtpconn.h:133
Definition: rtp.h:502
RTP_DataFrame::PayloadTypes rfc2833
Payload type for RFC2833.
Definition: rtpconn.h:411
void operator=(const OpalRTPSessionManager &other)
Assignment of RTP session managers.
Definition: rtpconn.h:178
OpalRFC2833Proto * rfc2833Handler
Definition: rtpconn.h:507
bool HasFailed() const
Definition: rtp.h:976
OpalRTPSessionManager m_rtpSessions
Definition: rtpconn.h:506
Definition: mediacmd.h:43
OpalTransportAddress control
Control channel address.
Definition: rtpconn.h:410
Definition: rtpconn.h:72
Definition: transports.h:703
Definition: rtpconn.h:159
OpalTransportAddress data
Data channel address.
Definition: rtpconn.h:409
Definition: mediatype.h:57
Definition: rtp.h:58
OpalMediaType mediaType
Definition: rtpconn.h:106
PayloadTypes
Definition: rtp.h:86
PBoolean remoteIsNAT
Definition: rtpconn.h:512
Definition: rfc2833.h:65
PBoolean useRTPAggregation
Definition: rtpconn.h:513
Definition: mediafmt.h:72
OpalConnection & connection
Definition: rtpconn.h:105
Definition: connection.h:462
virtual PBoolean RemoteIsNAT() const
Definition: rtpconn.h:362
PMutex m_mutex
Definition: rtpconn.h:234
Definition: patch.h:60
MediaInformation()
Definition: rtpconn.h:404
Definition: mediafmt.h:724
RTP_Session * rtpSession
Definition: rtpconn.h:154
Definition: sdp.h:119
Definition: call.h:65
virtual bool IsActive() const
Definition: rtpconn.h:131
Definition: rtp.h:509
Definition: rtpconn.h:403
DWORD GetPacketsReceived() const
Definition: rtp.h:843
Definition: rfc2833.h:112
virtual bool HasFailed() const
Definition: rtpconn.h:135
PMutex & GetMutex()
Definition: rtpconn.h:228
unsigned sessionId
Definition: rtpconn.h:107
virtual void SetRemoteMediaAddress(const OpalTransportAddress &, const OpalMediaFormatList &)
Definition: rtpconn.h:91
OpalRTPConnection & m_connection
Definition: rtpconn.h:233
PDICTIONARY(H323CallIdentityDict, PString, H323Connection)
Definition: mediastrm.h:111
Definition: connection.h:353
Definition: rtpconn.h:113
PObject * Clone() const
Definition: rtpconn.h:125
Definition: transports.h:149
RTP_DataFrame::PayloadTypes ciscoNSE
Payload type for RFC2833.
Definition: rtpconn.h:412
OpalRTPSessionManager RTP_SessionManager
Definition: rtpconn.h:241
Definition: rtpep.h:44
SessionDict sessions
Definition: rtpconn.h:237
RTP_Session * GetSession() const
Definition: rtpconn.h:151
Definition: rtp.h:1098