OPAL
Version 3.10.10
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
jitter.h
Go to the documentation of this file.
1
/*
2
* jitter.h
3
*
4
* Jitter buffer support
5
*
6
* Open H323 Library
7
*
8
* Copyright (c) 1999-2001 Equivalence 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 H323 Library.
21
*
22
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23
*
24
* Portions of this code were written with the assisance of funding from
25
* Vovida Networks, Inc. http://www.vovida.com.
26
*
27
* Contributor(s): ______________________________________.
28
*
29
* $Revision: 28053 $
30
* $Author: rjongbloed $
31
* $Date: 2012-07-18 02:50:22 -0500 (Wed, 18 Jul 2012) $
32
*/
33
34
#ifndef OPAL_RTP_JITTER_H
35
#define OPAL_RTP_JITTER_H
36
37
#ifdef P_USE_PRAGMA
38
#pragma interface
39
#endif
40
41
#include <
opal/buildopts.h
>
42
43
#include <
rtp/rtp.h
>
44
45
46
class
RTP_JitterBuffer
;
47
class
RTP_JitterBufferAnalyser;
48
49
51
55
class
OpalJitterBuffer
:
public
PSafeObject
56
{
57
PCLASSINFO(
OpalJitterBuffer
, PSafeObject);
58
59
public
:
65
OpalJitterBuffer
(
66
unsigned
minJitterDelay,
67
unsigned
maxJitterDelay,
68
unsigned
timeUnits = 8,
69
PINDEX packetSize = 2048
70
);
71
74
virtual
~OpalJitterBuffer
();
76
80
void
PrintOn
(
81
ostream & strm
82
)
const
;
84
89
void
SetDelay
(
90
unsigned
minJitterDelay,
91
unsigned
maxJitterDelay,
92
PINDEX packetSize = 2048
93
);
94
97
void
Reset
();
98
101
virtual
PBoolean
WriteData
(
102
const
RTP_DataFrame
& frame,
103
const
PTimeInterval & tick = 0
104
);
105
110
virtual
PBoolean
ReadData
(
111
RTP_DataFrame
& frame,
112
const
PTimeInterval & tick = 0
113
);
114
117
DWORD
GetCurrentJitterDelay
()
const
{
return
m_currentJitterDelay
; }
118
121
DWORD
GetMinJitterDelay
()
const
{
return
m_minJitterDelay
; }
122
125
DWORD
GetMaxJitterDelay
()
const
{
return
m_maxJitterDelay
; }
126
129
unsigned
GetTimeUnits
()
const
{
return
m_timeUnits
; }
130
133
DWORD
GetPacketsTooLate
()
const
{
return
m_packetsTooLate
; }
134
137
DWORD
GetBufferOverruns
()
const
{
return
m_bufferOverruns
; }
138
141
DWORD
GetMaxConsecutiveMarkerBits
()
const
{
return
m_maxConsecutiveMarkerBits
; }
142
145
void
SetMaxConsecutiveMarkerBits
(DWORD max) {
m_maxConsecutiveMarkerBits
= max; }
147
148
protected
:
149
DWORD
CalculateRequiredTimestamp
(DWORD playOutTimestamp)
const
;
150
bool
AdjustCurrentJitterDelay
(
int
delta);
151
152
unsigned
m_timeUnits
;
153
PINDEX
m_packetSize
;
154
DWORD
m_minJitterDelay
;
155
DWORD
m_maxJitterDelay
;
156
int
m_jitterGrowTime
;
157
DWORD
m_jitterShrinkPeriod
;
158
int
m_jitterShrinkTime
;
160
DWORD
m_silenceShrinkPeriod
;
161
int
m_silenceShrinkTime
;
162
DWORD
m_jitterDriftPeriod
;
163
164
int
m_currentJitterDelay
;
165
DWORD
m_packetsTooLate
;
166
DWORD
m_bufferOverruns
;
167
DWORD
m_consecutiveMarkerBits
;
168
DWORD
m_maxConsecutiveMarkerBits
;
169
DWORD
m_consecutiveLatePackets
;
170
171
DWORD
m_averageFrameTime
;
172
DWORD
m_lastTimestamp
;
173
DWORD
m_lastSyncSource
;
174
DWORD
m_bufferFilledTime
;
175
DWORD
m_bufferLowTime
;
176
DWORD
m_bufferEmptiedTime
;
177
int
m_timestampDelta
;
178
179
enum
{
180
e_SynchronisationStart
,
181
e_SynchronisationFill
,
182
e_SynchronisationShrink
,
183
e_SynchronisationDone
184
}
m_synchronisationState
;
185
186
typedef
std::map<DWORD, RTP_DataFrame>
FrameMap
;
187
FrameMap
m_frames
;
188
PMutex
m_bufferMutex
;
189
190
RTP_JitterBufferAnalyser *
m_analyser
;
191
};
192
193
197
class
OpalJitterBufferThread
:
public
OpalJitterBuffer
198
{
199
PCLASSINFO(
OpalJitterBufferThread
,
OpalJitterBuffer
);
200
public
:
201
OpalJitterBufferThread
(
202
unsigned
minJitterDelay,
203
unsigned
maxJitterDelay,
204
unsigned
timeUnits = 8,
205
PINDEX packetSize = 2048
206
);
207
~OpalJitterBufferThread
();
208
215
virtual
PBoolean
ReadData
(
216
RTP_DataFrame
& frame
217
);
218
223
virtual
PBoolean
OnReadPacket
(
224
RTP_DataFrame
& frame
225
) = 0;
226
227
void
StartThread
();
228
229
protected
:
230
PDECLARE_NOTIFIER
(PThread,
OpalJitterBufferThread
, JitterThreadMain);
231
233
void
WaitForThreadTermination
();
234
235
PThread *
m_jitterThread
;
236
bool
m_running
;
237
};
238
239
241
244
class
RTP_JitterBuffer
:
public
OpalJitterBufferThread
245
{
246
PCLASSINFO(
RTP_JitterBuffer
,
OpalJitterBufferThread
);
247
public
:
248
RTP_JitterBuffer
(
249
RTP_Session
& session,
250
unsigned
minJitterDelay,
251
unsigned
maxJitterDelay,
252
unsigned
timeUnits = 8,
253
PINDEX packetSize = 2048
254
);
255
~RTP_JitterBuffer
();
256
261
virtual
PBoolean
OnReadPacket
(
262
RTP_DataFrame
& frame
263
);
264
265
protected
:
267
RTP_Session
&
m_session
;
268
};
269
270
#endif // OPAL_RTP_JITTER_H
271
272
include
rtp
jitter.h
Generated on Fri Sep 13 2013 11:29:26 for OPAL by
1.8.4