PTLib  Version 2.14.3
 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 
65  unsigned maximumSlip = 0,
66  unsigned minimumDelay = 0
67  );
69 
78  void SetMaximumSlip(unsigned maximumSlip)
79  { m_jitterLimit = -(int)maximumSlip; }
80 
83  { return -m_jitterLimit; }
85 
102  PBoolean Delay(int time);
103 
107  void Restart();
109 
110  protected:
115 };
116 
117 
134 {
135  PCLASSINFO(PDelayChannel, PIndirectChannel);
136  public:
139  enum Mode {
143  };
144 
153  Mode mode,
154  unsigned frameDelay,
155  PINDEX frameSize = 0,
156  unsigned maximumSlip = 250,
157  unsigned minimumDelay = 10
158  );
159 
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 
216  unsigned frameDelay;
217  PINDEX frameSize;
220 
223 };
224 
225 
226 #endif // PTLIB_DELAYCHAN_H
227 
228 
229 // End Of File ///////////////////////////////////////////////////////////////