OPAL  Version 3.18.8
sdpep.h
Go to the documentation of this file.
1 /*
2  * sdpep.h
3  *
4  * Open Phone Abstraction Library (OPAL)
5  *
6  * Copyright (C) 2014 Vox Lucida Pty. Ltd.
7  *
8  * The contents of this file are subject to the Mozilla Public License
9  * Version 1.0 (the "License"); you may not use this file except in
10  * compliance with the License. You may obtain a copy of the License at
11  * http://www.mozilla.org/MPL/
12  *
13  * Software distributed under the License is distributed on an "AS IS"
14  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
15  * the License for the specific language governing rights and limitations
16  * under the License.
17  *
18  * The Original Code is Open Phone Abstraction Library.
19  *
20  * The Initial Developer of the Original Code is Post Increment
21  *
22  * Contributor(s): ______________________________________.
23  */
24 
25 #ifndef OPAL_OPAL_SDPEP_H
26 #define OPAL_OPAL_SDPEP_H
27 
28 #ifdef P_USE_PRAGMA
29 #pragma interface
30 #endif
31 
32 #include <opal_config.h>
33 
34 #if OPAL_SDP
35 
36 #include <rtp/rtpep.h>
37 #include <rtp/rtpconn.h>
38 #include <sdp/sdp.h>
39 
40 
41 class OpalSDPConnection;
42 class OpalSDPHTTPConnection;
43 
44 
51 #define OPAL_OPT_AV_BUNDLE "AV-Bundle"
52 
59 #define OPAL_OPT_USE_MEDIA_STREAMS "Use-Media-Stream"
60 
70 #define OPAL_OPT_MULTI_SSRC "Multi-SSRC"
71 
80 #define OPAL_OPT_INACTIVE_AUDIO_FLOW "Inactive-Audio-Flow"
81 
82 
86 class OpalSDPEndPoint : public OpalRTPEndPoint
87 {
88  PCLASSINFO(OpalSDPEndPoint, OpalRTPEndPoint);
89  public:
90  static const PCaselessString & ContentType();
91 
92 
97  OpalSDPEndPoint(
98  OpalManager & manager,
99  const PCaselessString & prefix,
100  Attributes attributes
101  );
102 
105  ~OpalSDPEndPoint();
107 
112  virtual PStringList GetAvailableStringOptions() const;
114 
119  virtual SDPSessionDescription * CreateSDP(
120  time_t sessionId,
121  unsigned version,
122  const OpalTransportAddress & address
123  );
125 
127  void SetHoldTimeout(
128  const PTimeInterval & t
129  ) { m_holdTimeout = t; }
130  const PTimeInterval & GetHoldTimeout() const { return m_holdTimeout; }
132 
133  protected:
134  PTimeInterval m_holdTimeout;
135 };
136 
137 
139 
143 class OpalSDPConnection : public OpalRTPConnection
144 {
145  PCLASSINFO(OpalSDPConnection, OpalRTPConnection);
146  public:
151  OpalSDPConnection(
152  OpalCall & call,
153  OpalSDPEndPoint & endpoint,
154  const PString & token,
155  unsigned options = 0,
156  OpalConnection::StringOptions * stringOptions = NULL
157  );
158 
161  ~OpalSDPConnection();
163 
174  virtual bool IsNetworkConnection() const { return true; }
175 
178  virtual OpalMediaFormatList GetMediaFormats() const;
179 
194  virtual bool HoldRemote(
195  bool placeOnHold
196  );
197 
202  virtual bool IsOnHold(
203  bool fromRemote
204  ) const;
206 
209  bool GetOfferSDP(
211  SDPSessionDescription & offer,
212  bool offerOpenMediaStreamsOnly = false
213  );
214 
216  PString GetOfferSDP(
217  bool offerOpenMediaStreamsOnly = false
218  );
219 
221  bool AnswerOfferSDP(
222  const SDPSessionDescription & offer,
223  SDPSessionDescription & answer
224  );
225 
227  PString AnswerOfferSDP(
228  const PString & offer
229  );
230 
232  bool HandleAnswerSDP(
233  const SDPSessionDescription & answer
234  );
235 
237  bool HandleAnswerSDP(
238  const PString & answer
239  );
240 
242  SDPSessionDescription * CreateSDP(
243  const PString & sdp
244  );
245 
247  virtual PString GetMediaInterface() = 0;
248 
250  virtual OpalTransportAddress GetRemoteMediaAddress() = 0;
252 
253  protected:
254  virtual bool OnSendOfferSDP(
255  SDPSessionDescription & sdpOut,
256  bool offerOpenMediaStreamsOnly
257  );
258  virtual bool OnSendOfferSDPSession(
259  unsigned sessionID,
260  SDPSessionDescription & sdpOut,
261  bool offerOpenMediaStreamOnly
262  );
263  virtual bool OnSendOfferSDPSession(
264  OpalMediaSession * mediaSession,
265  SDPMediaDescription * localMedia,
266  bool offerOpenMediaStreamOnly,
267  RTP_SyncSourceId ssrc
268  );
269 
270  virtual bool OnSendAnswerSDP(
271  const SDPSessionDescription & sdpOffer,
272  SDPSessionDescription & sdpAnswer,
273  bool transfer = false
274  );
275 
276  struct BundleMergeInfo;
277  virtual SDPMediaDescription * OnSendAnswerSDPSession(
278  SDPMediaDescription * incomingMedia,
279  unsigned sessionId,
280  bool transfer,
281  SDPMediaDescription::Direction otherSidesDir,
282  BundleMergeInfo & bundleMergeInfo
283  );
284 
285  virtual bool OnReceivedAnswerSDP(
286  const SDPSessionDescription & sdp,
287  bool & multipleFormats
288  );
289 
290  virtual bool OnReceivedAnswerSDPSession(
291  const SDPMediaDescription * mediaDescription,
292  unsigned sessionId,
293  SDPMediaDescription::Direction otherSidesDir,
294  bool & multipleFormats,
295  BundleMergeInfo & bundleMergeInfo
296  );
297 
298  virtual bool OnReceivedSDP(
299  const SDPSessionDescription & sdp
300  );
301 
302  virtual void FinaliseRtx(
303  const OpalMediaStreamPtr & stream,
304  SDPMediaDescription * sdp
305  );
306 
307  virtual bool SetRemoteMediaFormats(
308  const OpalMediaFormatList & formats
309  );
310  virtual bool SetActiveMediaFormats(
311  const OpalMediaFormatList & formats
312  );
313 
314  virtual OpalMediaSession * SetUpMediaSession(
315  const unsigned rtpSessionId,
316  const OpalMediaType & mediaType,
317  const SDPMediaDescription & mediaDescription,
318  OpalTransportAddress & localAddress,
319  BundleMergeInfo & bundleMergeInfo
320  );
321 
322  bool PauseOrCloseMediaStream(OpalMediaStreamPtr & stream, bool changed, bool paused);
323 
324  virtual bool AllowMusicOnHold() const;
325  void RetryHoldRemote(bool placeOnHold);
326  virtual bool OnHoldStateChanged(bool placeOnHold);
327  virtual void OnMediaStreamOpenFailed(bool rx);
328 
329  OpalSDPEndPoint & m_endpoint;
330 
331  OpalMediaFormatList m_remoteFormatList;
332  OpalMediaFormatList m_activeFormatList;
333 
334  atomic<bool> m_offerPending;
335  time_t m_sdpSessionId;
336  unsigned m_sdpVersion; // Really a sequence number
337  unsigned m_sdpVersionFromRemote;
338 
339  enum HoldState {
340  eHoldOff,
341  eRetrieveInProgress,
342 
343  // Order is important!
344  eHoldOn,
345  eHoldInProgress
346  };
347  HoldState m_holdToRemote;
348  bool m_holdFromRemote;
349 };
350 
351 #endif // OPAL_SDP
352 
353 #endif // OPAL_OPAL_SDPEP_H
Definition: manager.h:150
Definition: rtpconn.h:57
Definition: mediasession.h:647
PSafePtr< OpalMediaStream > OpalMediaStreamPtr
Definition: mediastrm.h:493
Definition: mediatype.h:66
virtual bool IsOnHold(bool fromRemote) const
Definition: mediafmt.h:112
OpalEndPoint & m_endpoint
Definition: connection.h:1961
Definition: connection.h:530
Definition: call.h:62
virtual bool HoldRemote(bool placeOnHold)
virtual bool IsNetworkConnection() const =0
Definition: transports.h:151
uint32_t RTP_SyncSourceId
Definition: rtp.h:46
virtual OpalMediaFormatList GetMediaFormats() const
Definition: rtpep.h:77