delaychan.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef PTLIB_DELAYCHAN_H
00032 #define PTLIB_DELAYCHAN_H
00033
00034
00035 #ifdef P_USE_PRAGMA
00036 #pragma interface
00037 #endif
00038
00039
00048 class PAdaptiveDelay : public PObject
00049 {
00050 PCLASSINFO(PAdaptiveDelay, PObject);
00051
00052 public:
00053
00060 PAdaptiveDelay(
00061 unsigned maximumSlip = 0,
00062 unsigned minimumDelay = 0
00063 );
00065
00074 void SetMaximumSlip(PTimeInterval maximumSlip)
00075 { jitterLimit = maximumSlip; }
00076
00078 PTimeInterval GetMaximumSlip() const
00079 { return jitterLimit; }
00081
00098 PBoolean Delay(int time);
00099
00103 void Restart();
00105
00106 protected:
00107 PBoolean firstTime;
00108 PTime targetTime;
00109
00110 PTimeInterval jitterLimit;
00111 PTimeInterval minimumDelay;
00112 };
00113
00114
00130 class PDelayChannel : public PIndirectChannel
00131 {
00132 PCLASSINFO(PDelayChannel, PIndirectChannel);
00133 public:
00136 enum Mode {
00137 DelayReadsOnly,
00138 DelayWritesOnly,
00139 DelayReadsAndWrites
00140 };
00141
00149 PDelayChannel(
00150 Mode mode,
00151 unsigned frameDelay,
00152 PINDEX frameSize = 0,
00153 unsigned maximumSlip = 250,
00154 unsigned minimumDelay = 10
00155 );
00156
00164 PDelayChannel(
00165 PChannel &channel,
00166 Mode mode,
00167 unsigned frameDelay,
00168 PINDEX frameSize = 0,
00169 unsigned maximumSlip = 250,
00170 unsigned minimumDelay = 10
00171 );
00173
00174
00188 virtual PBoolean Read(
00189 void * buf,
00190 PINDEX len
00191 );
00192
00202 virtual PBoolean Write(
00203 const void * buf,
00204 PINDEX len
00205 );
00207
00208
00209 protected:
00210 virtual void Wait(PINDEX count, PTimeInterval & nextTick);
00211
00212 Mode mode;
00213 unsigned frameDelay;
00214 PINDEX frameSize;
00215 PTimeInterval maximumSlip;
00216 PTimeInterval minimumDelay;
00217
00218 PTimeInterval nextReadTick;
00219 PTimeInterval nextWriteTick;
00220 };
00221
00222
00223 #endif // PTLIB_DELAYCHAN_H
00224
00225
00226