PTLib
Version 2.10.4
Main Page
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: 24177 $
27
* $Author: rjongbloed $
28
* $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
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
(
PTimeInterval
maximumSlip)
79
{
jitterLimit
= maximumSlip; }
80
82
PTimeInterval
GetMaximumSlip
()
const
83
{
return
jitterLimit
; }
85
102
PBoolean
Delay
(
int
time);
103
107
void
Restart
();
109
110
protected
:
111
PBoolean
firstTime
;
112
PTime
targetTime
;
113
114
PTimeInterval
jitterLimit
;
115
PTimeInterval
minimumDelay
;
116
};
117
118
134
class
PDelayChannel
:
public
PIndirectChannel
135
{
136
PCLASSINFO(
PDelayChannel
,
PIndirectChannel
);
137
public
:
140
enum
Mode
{
141
DelayReadsOnly
,
142
DelayWritesOnly
,
143
DelayReadsAndWrites
144
};
145
153
PDelayChannel
(
154
Mode
mode
,
155
unsigned
frameDelay
,
156
PINDEX
frameSize
= 0,
157
unsigned
maximumSlip
= 250,
158
unsigned
minimumDelay
= 10
159
);
160
168
PDelayChannel
(
169
PChannel
&channel,
170
Mode
mode
,
171
unsigned
frameDelay
,
172
PINDEX
frameSize
= 0,
173
unsigned
maximumSlip
= 250,
174
unsigned
minimumDelay
= 10
175
);
177
178
192
virtual
PBoolean
Read
(
193
void
* buf,
194
PINDEX len
195
);
196
206
virtual
PBoolean
Write
(
207
const
void
* buf,
208
PINDEX len
209
);
211
212
213
protected
:
214
virtual
void
Wait
(PINDEX count,
PTimeInterval
& nextTick);
215
216
Mode
mode
;
217
unsigned
frameDelay
;
218
PINDEX
frameSize
;
219
PTimeInterval
maximumSlip
;
220
PTimeInterval
minimumDelay
;
221
222
PTimeInterval
nextReadTick
;
223
PTimeInterval
nextWriteTick
;
224
};
225
226
227
#endif // PTLIB_DELAYCHAN_H
228
229
230
// End Of File ///////////////////////////////////////////////////////////////
include
ptclib
delaychan.h
Generated on Tue Mar 11 2014 15:09:29 for PTLib by
1.8.1.2