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.6  2005/11/30 12:47:37  csoutheren
00028  * Removed tabs, reformatted some code, and changed tags for Doxygen
00029  *
00030  * Revision 1.5  2004/11/11 07:34:50  csoutheren
00031  * Added #include <ptlib.h>
00032  *
00033  * Revision 1.4  2002/09/16 01:08:59  robertj
00034  * Added #define so can select if #pragma interface/implementation is used on
00035  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00036  *
00037  * Revision 1.3  2002/02/25 11:05:02  rogerh
00038  * New Delay code which solves the accumulated error problem. Based on ideas
00039  * by Tomasz Motylewski <T.Motylewski@bfad.de>, Roger and Craig.
00040  *
00041  * Revision 1.2  2002/01/15 03:55:43  craigs
00042  * Added PAdaptiveDelay class
00043  *
00044  * Revision 1.1  2001/07/10 03:07:07  robertj
00045  * Added queue channel and delay channel classes to ptclib.
00046  *
00047  */
00048 
00049 #ifndef _DELAYCHAN_H
00050 #define _DELAYCHAN_H
00051 
00052 
00053 #ifdef P_USE_PRAGMA
00054 #pragma interface
00055 #endif
00056 
00057 #include <ptlib.h>
00058 
00067 class PAdaptiveDelay : public PObject
00068 { 
00069   PCLASSINFO(PAdaptiveDelay, PObject);
00070   
00071   public:
00072     PAdaptiveDelay();
00073     BOOL Delay(int time);
00074     void Restart();
00075  
00076   protected:
00077     BOOL   firstTime;
00078     PTime  targetTime;
00079 };
00080 
00081 
00097 class PDelayChannel : public PIndirectChannel
00098 {
00099     PCLASSINFO(PDelayChannel, PIndirectChannel);
00100   public:
00103     enum Mode {
00104       DelayReadsOnly,
00105       DelayWritesOnly,
00106       DelayReadsAndWrites
00107     };
00108 
00116     PDelayChannel(
00117       Mode mode,                  
00118       unsigned frameDelay,        
00119       PINDEX frameSize = 0,       
00120       unsigned maximumSlip = 250, 
00121       unsigned minimumDelay = 10  
00122     );
00124 
00125 
00139     virtual BOOL Read(
00140       void * buf,   
00141       PINDEX len    
00142     );
00143 
00153     virtual BOOL Write(
00154       const void * buf, 
00155       PINDEX len        
00156     );
00158 
00159 
00160   protected:
00161     virtual void Wait(PINDEX count, PTimeInterval & nextTick);
00162 
00163     Mode          mode;
00164     unsigned      frameDelay;
00165     PINDEX        frameSize;
00166     PTimeInterval maximumSlip;
00167     PTimeInterval minimumDelay;
00168 
00169     PTimeInterval nextReadTick;
00170     PTimeInterval nextWriteTick;
00171 };
00172 
00173 
00174 #endif // _DELAYCHAN_H
00175 
00176 
00177 // End Of File ///////////////////////////////////////////////////////////////

Generated on Fri Sep 21 14:40:11 2007 for PWLib by  doxygen 1.5.3