OPAL
Version 3.12.9
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: 31114 $
30
* $Author: rjongbloed $
31
* $Date: 2013-12-19 11:28:31 +1100 (Thu, 19 Dec 2013) $
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
#include <ptlib/safecoll.h>
45
46
47
class
RTP_JitterBuffer;
48
class
RTP_JitterBufferAnalyser;
49
class
OpalRTPSession
;
50
51
53
57
class
OpalJitterBuffer
:
public
PSafeObject
58
{
59
PCLASSINFO(
OpalJitterBuffer
, PSafeObject);
60
61
public
:
63
struct
Init
{
64
Init
(
unsigned
minDelay = 0,
unsigned
maxDelay = 0)
65
:
m_minJitterDelay
(minDelay)
66
,
m_maxJitterDelay
(maxDelay != 0 ? maxDelay : minDelay)
67
,
m_timeUnits
(8)
68
,
m_packetSize
(2048)
69
{ }
70
71
unsigned
m_minJitterDelay
;
72
unsigned
m_maxJitterDelay
;
73
unsigned
m_timeUnits
;
74
PINDEX
m_packetSize
;
75
};
76
82
OpalJitterBuffer
(
83
const
Init
& init
84
);
85
88
virtual
~OpalJitterBuffer
();
90
94
void
PrintOn
(
95
ostream & strm
96
)
const
;
98
101
102
virtual
void
Start
() { }
103
106
void
SetDelay
(
107
const
Init & init
108
);
109
112
void
Reset
();
113
116
virtual
PBoolean
WriteData
(
117
const
RTP_DataFrame
& frame,
118
const
PTimeInterval & tick = 0
119
);
120
125
virtual
PBoolean
ReadData
(
126
RTP_DataFrame
& frame,
127
const
PTimeInterval & tick = 0
128
);
129
132
DWORD
GetCurrentJitterDelay
()
const
{
return
m_currentJitterDelay
; }
133
136
DWORD
GetMinJitterDelay
()
const
{
return
m_minJitterDelay
; }
137
140
DWORD
GetMaxJitterDelay
()
const
{
return
m_maxJitterDelay
; }
141
144
unsigned
GetTimeUnits
()
const
{
return
m_timeUnits
; }
145
148
DWORD
GetPacketsTooLate
()
const
{
return
m_packetsTooLate
; }
149
152
DWORD
GetBufferOverruns
()
const
{
return
m_bufferOverruns
; }
153
156
DWORD
GetMaxConsecutiveMarkerBits
()
const
{
return
m_maxConsecutiveMarkerBits
; }
157
160
void
SetMaxConsecutiveMarkerBits
(DWORD max) {
m_maxConsecutiveMarkerBits
= max; }
162
163
protected
:
164
DWORD
CalculateRequiredTimestamp
(DWORD playOutTimestamp)
const
;
165
bool
AdjustCurrentJitterDelay
(
int
delta);
166
167
unsigned
m_timeUnits
;
168
PINDEX
m_packetSize
;
169
DWORD
m_minJitterDelay
;
170
DWORD
m_maxJitterDelay
;
171
int
m_jitterGrowTime
;
172
DWORD
m_jitterShrinkPeriod
;
173
174
int
m_jitterShrinkTime
;
175
DWORD
m_silenceShrinkPeriod
;
176
int
m_silenceShrinkTime
;
177
DWORD
m_jitterDriftPeriod
;
178
179
int
m_currentJitterDelay
;
180
DWORD
m_packetsTooLate
;
181
DWORD
m_bufferOverruns
;
182
DWORD
m_consecutiveMarkerBits
;
183
DWORD
m_maxConsecutiveMarkerBits
;
184
DWORD
m_consecutiveLatePackets
;
185
DWORD
m_consecutiveOverflows
;
186
DWORD
m_consecutiveEmpty
;
187
188
unsigned
m_frameTimeCount
;
189
uint64_t
m_frameTimeSum
;
190
DWORD
m_incomingFrameTime
;
191
DWORD
m_lastSequenceNum
;
192
DWORD
m_lastTimestamp
;
193
DWORD
m_lastSyncSource
;
194
DWORD
m_bufferFilledTime
;
195
DWORD
m_bufferLowTime
;
196
DWORD
m_bufferEmptiedTime
;
197
int
m_timestampDelta
;
198
199
enum
{
200
e_SynchronisationStart
,
201
e_SynchronisationFill
,
202
e_SynchronisationShrink
,
203
e_SynchronisationDone
204
}
m_synchronisationState
;
205
206
typedef
std::map<DWORD, RTP_DataFrame>
FrameMap
;
207
FrameMap
m_frames
;
208
PMutex
m_bufferMutex
;
209
210
RTP_JitterBufferAnalyser *
m_analyser
;
211
};
212
213
217
class
OpalJitterBufferThread
:
public
OpalJitterBuffer
218
{
219
PCLASSINFO(
OpalJitterBufferThread
,
OpalJitterBuffer
);
220
public
:
221
OpalJitterBufferThread
(
222
const
Init
& init
223
);
224
~OpalJitterBufferThread
();
225
227
virtual
void
Start
();
228
235
virtual
PBoolean
ReadData
(
236
RTP_DataFrame
& frame,
237
const
PTimeInterval & tick = 0
238
);
239
244
virtual
PBoolean
OnReadPacket
(
245
RTP_DataFrame
& frame
246
) = 0;
247
248
protected
:
249
PDECLARE_NOTIFIER
(PThread,
OpalJitterBufferThread
, JitterThreadMain);
250
252
void
WaitForThreadTermination
();
253
254
PThread *
m_jitterThread
;
255
bool
m_running
;
256
};
257
258
259
#endif // OPAL_RTP_JITTER_H
260
261
include
rtp
jitter.h
Generated on Mon Feb 17 2014 13:37:50 for OPAL by
1.8.3.1