PTLib  Version 2.10.4
 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 ///////////////////////////////////////////////////////////////