PTLib
Version 2.14.3
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
delaychan.h
Go to the documentation of this file.
1
/*
2
* delaychan.h
3
*
4
* Class for implementing a serial queue channel in memory.
5
*
6
* Portable Windows Library
7
*
8
* Copyright (c) 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 Portable Windows Library.
21
*
22
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23
*
24
* Contributor(s): ______________________________________.
25
*
26
* $Revision: 28992 $
27
* $Author: rjongbloed $
28
* $Date: 2013-01-25 18:22:47 +1100 (Fri, 25 Jan 2013) $
29
*/
30
31
#ifndef PTLIB_DELAYCHAN_H
32
#define PTLIB_DELAYCHAN_H
33
#include <
ptlib/contain.h
>
34
#include <
ptlib/object.h
>
35
#include <
ptlib/timeint.h
>
36
#include <
ptlib/ptime.h
>
37
#include <
ptlib/indchan.h
>
38
39
#ifdef P_USE_PRAGMA
40
#pragma interface
41
#endif
42
43
52
class
PAdaptiveDelay
:
public
PObject
53
{
54
PCLASSINFO(
PAdaptiveDelay
,
PObject
);
55
56
public
:
57
64
PAdaptiveDelay
(
65
unsigned
maximumSlip = 0,
66
unsigned
minimumDelay = 0
67
);
69
78
void
SetMaximumSlip
(
unsigned
maximumSlip)
79
{
m_jitterLimit
= -(int)maximumSlip; }
80
82
PTimeInterval
GetMaximumSlip
()
const
83
{
return
-
m_jitterLimit
; }
85
102
PBoolean
Delay
(
int
time);
103
107
void
Restart
();
109
110
protected
:
111
PTimeInterval
m_jitterLimit
;
112
PTimeInterval
m_minimumDelay
;
113
PTime
m_targetTime
;
114
bool
m_firstTime
;
115
};
116
117
133
class
PDelayChannel
:
public
PIndirectChannel
134
{
135
PCLASSINFO(
PDelayChannel
,
PIndirectChannel
);
136
public
:
139
enum
Mode
{
140
DelayReadsOnly
,
141
DelayWritesOnly
,
142
DelayReadsAndWrites
143
};
144
152
PDelayChannel
(
153
Mode
mode
,
154
unsigned
frameDelay
,
155
PINDEX
frameSize
= 0,
156
unsigned
maximumSlip
= 250,
157
unsigned
minimumDelay
= 10
158
);
159
167
PDelayChannel
(
168
PChannel
&channel,
169
Mode
mode
,
170
unsigned
frameDelay
,
171
PINDEX
frameSize
= 0,
172
unsigned
maximumSlip
= 250,
173
unsigned
minimumDelay
= 10
174
);
176
177
191
virtual
PBoolean
Read
(
192
void
* buf,
193
PINDEX len
194
);
195
205
virtual
PBoolean
Write
(
206
const
void
* buf,
207
PINDEX len
208
);
210
211
212
protected
:
213
virtual
void
Wait
(PINDEX count,
PTimeInterval
& nextTick);
214
215
Mode
mode
;
216
unsigned
frameDelay
;
217
PINDEX
frameSize
;
218
PTimeInterval
maximumSlip
;
219
PTimeInterval
minimumDelay
;
220
221
PTimeInterval
nextReadTick
;
222
PTimeInterval
nextWriteTick
;
223
};
224
225
226
#endif // PTLIB_DELAYCHAN_H
227
228
229
// End Of File ///////////////////////////////////////////////////////////////
include
ptclib
delaychan.h
Generated on Fri Oct 10 2014 21:15:12 for PTLib by
1.8.3.1