Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

delaychan.h

Go to the documentation of this file.
00001 /*
00002  * delaychan.h
00003  *
00004  * Class for implementing a serial queue channel in memory.
00005  *
00006  * Portable Windows Library
00007  *
00008  * Copyright (c) 2001 Equivalence Pty. Ltd.
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Portable Windows Library.
00021  *
00022  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00023  *
00024  * Contributor(s): ______________________________________.
00025  *
00026  * $Log: delaychan.h,v $
00027  * Revision 1.5  2004/11/11 07:34:50  csoutheren
00028  * Added #include <ptlib.h>
00029  *
00030  * Revision 1.4  2002/09/16 01:08:59  robertj
00031  * Added #define so can select if #pragma interface/implementation is used on
00032  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00033  *
00034  * Revision 1.3  2002/02/25 11:05:02  rogerh
00035  * New Delay code which solves the accumulated error problem. Based on ideas
00036  * by Tomasz Motylewski <T.Motylewski@bfad.de>, Roger and Craig.
00037  *
00038  * Revision 1.2  2002/01/15 03:55:43  craigs
00039  * Added PAdaptiveDelay class
00040  *
00041  * Revision 1.1  2001/07/10 03:07:07  robertj
00042  * Added queue channel and delay channel classes to ptclib.
00043  *
00044  */
00045 
00046 #ifndef _DELAYCHAN_H
00047 #define _DELAYCHAN_H
00048 
00049 
00050 #ifdef P_USE_PRAGMA
00051 #pragma interface
00052 #endif
00053 
00054 #include <ptlib.h>
00055 
00064 class PAdaptiveDelay : public PObject
00065 { 
00066   PCLASSINFO(PAdaptiveDelay, PObject);
00067   
00068   public:
00069     PAdaptiveDelay();
00070     BOOL Delay(int time);
00071     void Restart();
00072  
00073   protected:
00074     BOOL   firstTime;
00075     PTime  targetTime;
00076 };
00077 
00078 
00094 class PDelayChannel : public PIndirectChannel
00095 {
00096     PCLASSINFO(PDelayChannel, PIndirectChannel);
00097   public:
00100     enum Mode {
00101       DelayReadsOnly,
00102       DelayWritesOnly,
00103       DelayReadsAndWrites
00104     };
00105 
00113     PDelayChannel(
00114       Mode mode,                  
00115       unsigned frameDelay,        
00116       PINDEX frameSize = 0,       
00117       unsigned maximumSlip = 250, 
00118       unsigned minimumDelay = 10  
00119     );
00121 
00122 
00136     virtual BOOL Read(
00137       void * buf,   
00138       PINDEX len    
00139     );
00140 
00150     virtual BOOL Write(
00151       const void * buf, 
00152       PINDEX len        
00153     );
00155 
00156 
00157   protected:
00158     virtual void Wait(PINDEX count, PTimeInterval & nextTick);
00159 
00160     Mode          mode;
00161     unsigned      frameDelay;
00162     PINDEX        frameSize;
00163     PTimeInterval maximumSlip;
00164     PTimeInterval minimumDelay;
00165 
00166     PTimeInterval nextReadTick;
00167     PTimeInterval nextWriteTick;
00168 };
00169 
00170 
00171 #endif // _DELAYCHAN_H
00172 
00173 
00174 // End Of File ///////////////////////////////////////////////////////////////

Generated on Mon Feb 21 20:43:08 2005 for PWLib by  doxygen 1.4.1