OPAL  Version 3.18.8
rtp_stream.h
Go to the documentation of this file.
1 /*
2  * rtp_stream.h
3  *
4  * Media Stream classes
5  *
6  * Open Phone Abstraction Library (OPAL)
7  *
8  * Copyright (C) 2014 Vox Lucida Pty. Ltd.
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 Equivalence Pty. Ltd.
23  *
24  * Contributor(s): ______________________________________.
25  */
26 
27 #ifndef OPAL_RTP_RTP_STREAM_H
28 #define OPAL_RTP_RTP_STREAM_H
29 
30 #ifdef P_USE_PRAGMA
31 #pragma interface
32 #endif
33 
34 #include <opal_config.h>
35 
36 #include <opal/mediastrm.h>
37 
38 
39 class OpalRTPSession;
40 class OpalRTPConnection;
42 
43 
48 {
50  public:
57  OpalRTPConnection & conn,
58  const OpalMediaFormat & mediaFormat,
59  bool isSource,
60  OpalRTPSession & rtpSession
61  );
62 
68 
75  virtual PBoolean Open();
76 
79  virtual bool IsOpen() const;
80 
83  virtual bool IsEstablished() const;
84 
90  virtual PBoolean Start();
91 
95  virtual void OnStartMediaPatch();
96 
100  virtual bool SetMediaPassThrough(
101  OpalMediaStream & otherStream,
102  bool bypass
103  );
104 
108  virtual PBoolean ReadPacket(
109  RTP_DataFrame & packet
110  );
111 
115  virtual PBoolean WritePacket(
116  RTP_DataFrame & packet
117  );
118 
121  virtual PBoolean SetDataSize(
122  PINDEX dataSize,
123  PINDEX frameTime
124  );
125 
129  virtual PBoolean IsSynchronous() const;
130 
138  virtual PBoolean RequiresPatchThread() const;
139 
142  virtual PBoolean SetPatch(
143  OpalMediaPatch * patch
144  );
145 
148  virtual OpalRTPSession & GetRtpSession() const
149  { return m_rtpSession; }
150 
153  virtual void GetJitterBufferDelay(OpalJitterBuffer::Init & info) const;
154 
157  virtual void SetJitterBufferDelay(const OpalJitterBuffer::Init & info);
158 
159 #if OPAL_STATISTICS
160  virtual void GetStatistics(OpalMediaStatistics & statistics, bool fromPatch = false) const;
161 #endif
162 
163 
164  virtual void PrintDetail(
165  ostream & strm,
166  const char * prefix = NULL,
167  Details details = Details::All()
168  ) const;
169 
170  virtual PString GetPatchThreadName() const;
171 
173  void SetSyncSource(RTP_SyncSourceId ssrc);
174 
175  const PTimeInterval & GetReadTimeout() const { return m_readTimeout; }
176  void SetReadTimeout(const PTimeInterval & t);
177 
178  void SetRewriteHeaders(bool v) { m_rewriteHeaders = v; }
179 
180 #if OPAL_VIDEO
181 
184  void SetVideoUpdateThrottleTime(const PTimeInterval & time) { m_videoUpdateThrottleTime = time; }
185 
189  void SetPictureLossThrottleTime(const PTimeInterval & time) { m_pictureLossThrottleTime = time; }
190 #endif
191 
192 protected:
193  virtual void InternalClose();
194  virtual bool InternalSetJitterBuffer(const OpalJitterBuffer::Init & init);
195  virtual bool InternalUpdateMediaFormat(const OpalMediaFormat & mediaFormat);
196  virtual bool InternalSetPaused(bool pause, bool fromUser, bool fromPatch);
197  virtual bool InternalExecuteCommand(const OpalMediaCommand & command);
198 
205  PTimeInterval m_readTimeout;
206 
207 #if OPAL_VIDEO
214 #endif
215 
216  PDECLARE_RTPDataNotifier(OpalRTPMediaStream, OnReceivedPacket);
218 
219 #if OPAL_JITTER_BUFFER_LATENCY_CHECK
220  PTimeInterval m_jbLatencyAccumulator;
221  unsigned m_jbLatencySampleCount;
222 #endif
223 
224  PTRACE_THROTTLE(m_throttleWriteData,3,500);
225  PTRACE_THROTTLE(m_throttleSendReport,3,500);
226 };
227 
228 
229 
230 #endif //OPAL_RTP_RTP_STREAM_H
231 
232 
233 // End of File ///////////////////////////////////////////////////////////////
virtual bool InternalExecuteCommand(const OpalMediaCommand &command)
PTimeInterval m_pictureLossThrottleTime
Definition: rtp_stream.h:213
PDECLARE_RTPDataNotifier(OpalRTPMediaStream, OnReceivedPacket)
virtual PBoolean SetPatch(OpalMediaPatch *patch)
virtual PBoolean IsSynchronous() const
virtual void InternalClose()
Definition: rtpconn.h:57
OpalRTPMediaStream(OpalRTPConnection &conn, const OpalMediaFormat &mediaFormat, bool isSource, OpalRTPSession &rtpSession)
virtual bool InternalSetPaused(bool pause, bool fromUser, bool fromPatch)
virtual void GetJitterBufferDelay(OpalJitterBuffer::Init &info) const
virtual void GetStatistics(OpalMediaStatistics &statistics, bool fromPatch=false) const
virtual OpalRTPSession & GetRtpSession() const
Definition: rtp_stream.h:148
Definition: mediacmd.h:43
virtual void SetJitterBufferDelay(const OpalJitterBuffer::Init &info)
PTRACE_THROTTLE(m_throttleWriteData, 3, 500)
OpalRTPSession::DataNotifier m_receiveNotifier
Definition: rtp_stream.h:217
PSimpleTimer m_pictureLossThrottleTimer
Definition: rtp_stream.h:212
PSafePtr< OpalMediaStream > OpalMediaStreamPtr
Definition: mediastrm.h:493
OpalMediaStreamPtr m_passThruStream
Definition: rtp_stream.h:203
OpalRTPSession & m_rtpSession
Definition: rtp_stream.h:199
virtual PBoolean WritePacket(RTP_DataFrame &packet)
virtual void PrintDetail(ostream &strm, const char *prefix=NULL, Details details=Details::All()) const
virtual bool IsEstablished() const
PNotifierTemplate< Data & > DataNotifier
Definition: rtp_session.h:249
virtual bool SetMediaPassThrough(OpalMediaStream &otherStream, bool bypass)
RTP_SyncSourceId SetSyncSource() const
Definition: rtp_stream.h:172
PTimeInterval m_videoUpdateThrottleTime
Definition: rtp_stream.h:211
Definition: rtp_stream.h:47
Initialisation information.
Definition: jitter.h:86
PSimpleTimer m_forceIntraFrameTimer
Definition: rtp_stream.h:209
virtual PBoolean ReadPacket(RTP_DataFrame &packet)
RTP_SyncSourceId m_syncSource
Definition: rtp_stream.h:201
Definition: rtp.h:540
Definition: jitter.h:51
Definition: patch.h:56
Definition: mediafmt.h:806
virtual PBoolean SetDataSize(PINDEX dataSize, PINDEX frameTime)
void SetRewriteHeaders(bool v)
Definition: rtp_stream.h:178
OpalJitterBuffer * m_jitterBuffer
Definition: rtp_stream.h:204
virtual PBoolean Start()
Definition: rtp_session.h:90
virtual PString GetPatchThreadName() const
const PTimeInterval & GetReadTimeout() const
Definition: rtp_stream.h:175
void SetPictureLossThrottleTime(const PTimeInterval &time)
Definition: rtp_stream.h:189
bool m_rewriteHeaders
Definition: rtp_stream.h:200
PSimpleTimer m_videoUpdateThrottleTimer
Definition: rtp_stream.h:210
virtual void OnStartMediaPatch()
Definition: mediastrm.h:110
unsigned m_notifierPriority
Definition: rtp_stream.h:202
virtual PBoolean RequiresPatchThread() const
virtual PBoolean Open()
Definition: mediasession.h:210
uint32_t RTP_SyncSourceId
Definition: rtp.h:46
virtual bool IsOpen() const
virtual bool InternalUpdateMediaFormat(const OpalMediaFormat &mediaFormat)
void SetReadTimeout(const PTimeInterval &t)
virtual bool InternalSetJitterBuffer(const OpalJitterBuffer::Init &init)
void SetVideoUpdateThrottleTime(const PTimeInterval &time)
Definition: rtp_stream.h:184
PTimeInterval m_readTimeout
Definition: rtp_stream.h:205
bool m_forceIntraFrameFlag
Definition: rtp_stream.h:208