OPAL
Version 3.12.5
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: 29341 $
30
* $Author: rjongbloed $
31
* $Date: 2013-03-27 02:06:24 -0500 (Wed, 27 Mar 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
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
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
186
unsigned
m_frameTimeCount
;
187
DWORD
m_incomingFrameTime
;
188
int
m_lastFrameTime
[2];
189
DWORD
m_lastSequenceNum
;
190
DWORD
m_lastTimestamp
;
191
DWORD
m_lastSyncSource
;
192
DWORD
m_bufferFilledTime
;
193
DWORD
m_bufferLowTime
;
194
DWORD
m_bufferEmptiedTime
;
195
int
m_timestampDelta
;
196
197
enum
{
198
e_SynchronisationStart
,
199
e_SynchronisationFill
,
200
e_SynchronisationShrink
,
201
e_SynchronisationDone
202
}
m_synchronisationState
;
203
204
typedef
std::map<DWORD, RTP_DataFrame>
FrameMap
;
205
FrameMap
m_frames
;
206
PMutex
m_bufferMutex
;
207
208
RTP_JitterBufferAnalyser *
m_analyser
;
209
};
210
211
215
class
OpalJitterBufferThread
:
public
OpalJitterBuffer
216
{
217
PCLASSINFO(
OpalJitterBufferThread
,
OpalJitterBuffer
);
218
public
:
219
OpalJitterBufferThread
(
220
const
Init
& init
221
);
222
~OpalJitterBufferThread
();
223
225
virtual
void
Start
();
226
233
virtual
PBoolean
ReadData
(
234
RTP_DataFrame
& frame,
235
const
PTimeInterval & tick = 0
236
);
237
242
virtual
PBoolean
OnReadPacket
(
243
RTP_DataFrame
& frame
244
) = 0;
245
246
protected
:
247
PDECLARE_NOTIFIER
(PThread,
OpalJitterBufferThread
, JitterThreadMain);
248
250
void
WaitForThreadTermination
();
251
252
PThread *
m_jitterThread
;
253
bool
m_running
;
254
};
255
256
257
#endif // OPAL_RTP_JITTER_H
258
259
include
rtp
jitter.h
Generated on Tue Sep 3 2013 06:40:22 for OPAL by
1.8.4