PTLib  Version 2.10.10
 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 
65  unsigned maximumSlip = 0,
66  unsigned minimumDelay = 0
67  );
69 
78  void SetMaximumSlip(PTimeInterval maximumSlip)
79  { jitterLimit = maximumSlip; }
80 
83  { return jitterLimit; }
85 
102  PBoolean Delay(int time);
103 
107  void Restart();
109 
110  protected:
113 
116 };
117 
118 
135 {
136  PCLASSINFO(PDelayChannel, PIndirectChannel);
137  public:
140  enum Mode {
144  };
145 
154  Mode mode,
155  unsigned frameDelay,
156  PINDEX frameSize = 0,
157  unsigned maximumSlip = 250,
158  unsigned minimumDelay = 10
159  );
160 
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 
217  unsigned frameDelay;
218  PINDEX frameSize;
221 
224 };
225 
226 
227 #endif // PTLIB_DELAYCHAN_H
228 
229 
230 // End Of File ///////////////////////////////////////////////////////////////
virtual PBoolean Write(const void *buf, PINDEX len)
Low level write to the file channel.
PAdaptiveDelay(unsigned maximumSlip=0, unsigned minimumDelay=0)
Create a new adaptive delay with the specified parameters.
This class defines an arbitrary time interval to millisecond accuracy.
Definition: timeint.h:55
PINDEX frameSize
Definition: delaychan.h:218
virtual void Wait(PINDEX count, PTimeInterval &nextTick)
This class defines an absolute time and date.
Definition: ptime.h:53
Mode
Definition: delaychan.h:140
This is a channel that operates indirectly through another channel(s).
Definition: indchan.h:49
PDelayChannel(Mode mode, unsigned frameDelay, PINDEX frameSize=0, unsigned maximumSlip=250, unsigned minimumDelay=10)
Create a new delay channel with the specified delays.
Definition: delaychan.h:142
PTime targetTime
Definition: delaychan.h:112
PTimeInterval GetMaximumSlip() const
Get the current slip time.
Definition: delaychan.h:82
PTimeInterval minimumDelay
Definition: delaychan.h:115
BOOL PBoolean
Definition: object.h:102
void SetMaximumSlip(PTimeInterval maximumSlip)
Set the number of milliseconds that the delay may &quot;catch up&quot; by using zero delays.
Definition: delaychan.h:78
Class for implementing a &quot;delay line&quot; channel.
Definition: delaychan.h:134
Definition: delaychan.h:143
Abstract class defining I/O channel semantics.
Definition: channel.h:107
Definition: delaychan.h:141
Class for implementing an &quot;adaptive&quot; delay.
Definition: delaychan.h:52
PTimeInterval maximumSlip
Definition: delaychan.h:219
PBoolean Delay(int time)
Wait until the specified number of milliseconds have elapsed from the previous call (on average)...
virtual PBoolean Read(void *buf, PINDEX len)
Low level read from the file channel.
PTimeInterval nextWriteTick
Definition: delaychan.h:223
void Restart()
Invalidate the timer.
unsigned frameDelay
Definition: delaychan.h:217
PBoolean firstTime
Definition: delaychan.h:111
PTimeInterval minimumDelay
Definition: delaychan.h:220
PTimeInterval jitterLimit
Definition: delaychan.h:114
PTimeInterval nextReadTick
Definition: delaychan.h:222
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
Mode mode
Definition: delaychan.h:216