#include <delaychan.h>
Inheritance diagram for PDelayChannel:
Construction | |
enum | Mode { DelayReadsOnly, DelayWritesOnly, DelayReadsAndWrites } |
PDelayChannel (Mode mode, unsigned frameDelay, PINDEX frameSize=0, unsigned maximumSlip=250, unsigned minimumDelay=10) | |
PDelayChannel (PChannel &channel, Mode mode, unsigned frameDelay, PINDEX frameSize=0, unsigned maximumSlip=250, unsigned minimumDelay=10) | |
Public Member Functions | |
Overrides from class PChannel | |
virtual BOOL | Read (void *buf, PINDEX len) |
virtual BOOL | Write (const void *buf, PINDEX len) |
Protected Member Functions | |
virtual void | Wait (PINDEX count, PTimeInterval &nextTick) |
Protected Attributes | |
Mode | mode |
unsigned | frameDelay |
PINDEX | frameSize |
PTimeInterval | maximumSlip |
PTimeInterval | minimumDelay |
PTimeInterval | nextReadTick |
PTimeInterval | nextWriteTick |
There are two modes of operation. In stream more, data can be read/written no faster than a fixed time for a fixed number of bytes. So, for example, you can say than 320 bytes must take 20 milliseconds, and thus if the application writes 640 byets it will delay 40 milliseconds before the next write.
In frame mode, the rate limiting applies to individual read or write operations. So you can say that each read takes 30 milliseconds even if on 4 bytes is read, and the same time if 24 bytes are read.
enum PDelayChannel::Mode |
PDelayChannel::PDelayChannel | ( | Mode | mode, | |
unsigned | frameDelay, | |||
PINDEX | frameSize = 0 , |
|||
unsigned | maximumSlip = 250 , |
|||
unsigned | minimumDelay = 10 | |||
) |
Create a new delay channel with the specified delays. A value of zero for the numBytes parameter indicates that the delay is in frame mode.
The maximum skip time is the number of milliseconds that the delay may "catch up" by using zero delays. This is caused by the Read() or Write() not being called for a time by external factors.
mode | Mode for delay channel |
frameDelay | Delay time in milliseconds |
frameSize | Bytes to apply to the delay time. |
maximumSlip | Maximum slip time in milliseconds |
minimumDelay | Minimim delay (usually OS time slice) |
PDelayChannel::PDelayChannel | ( | PChannel & | channel, | |
Mode | mode, | |||
unsigned | frameDelay, | |||
PINDEX | frameSize = 0 , |
|||
unsigned | maximumSlip = 250 , |
|||
unsigned | minimumDelay = 10 | |||
) |
Create a new delay channel with the specified delays and channel. A value of zero for the numBytes parameter indicates that the delay is in frame mode.
The maximum skip time is the number of milliseconds that the delay may "catch up" by using zero delays. This is caused by the Read() or Write() not being called for a time by external factors.
channel | channel to use |
mode | Mode for delay channel |
frameDelay | Delay time in milliseconds |
frameSize | Bytes to apply to the delay time. |
maximumSlip | Maximum slip time in milliseconds |
minimumDelay | Minimim delay (usually OS time slice) |
virtual BOOL PDelayChannel::Read | ( | void * | buf, | |
PINDEX | len | |||
) | [virtual] |
Low level read from the file channel. The read timeout is ignored for file I/O. The GetLastReadCount() function returns the actual number of bytes read.
The GetErrorCode() function should be consulted after Read() returns FALSE to determine what caused the failure.
buf | Pointer to a block of memory to receive the read bytes. |
len | Maximum number of bytes to read into the buffer. |
Reimplemented from PIndirectChannel.
virtual BOOL PDelayChannel::Write | ( | const void * | buf, | |
PINDEX | len | |||
) | [virtual] |
Low level write to the file channel. The write timeout is ignored for file I/O. The GetLastWriteCount() function returns the actual number of bytes written.
The GetErrorCode() function should be consulted after Write() returns FALSE to determine what caused the failure.
buf | Pointer to a block of memory to write. |
len | Number of bytes to write. |
Reimplemented from PIndirectChannel.
virtual void PDelayChannel::Wait | ( | PINDEX | count, | |
PTimeInterval & | nextTick | |||
) | [protected, virtual] |
Mode PDelayChannel::mode [protected] |
unsigned PDelayChannel::frameDelay [protected] |
PINDEX PDelayChannel::frameSize [protected] |
PTimeInterval PDelayChannel::maximumSlip [protected] |
PTimeInterval PDelayChannel::minimumDelay [protected] |
PTimeInterval PDelayChannel::nextReadTick [protected] |
PTimeInterval PDelayChannel::nextWriteTick [protected] |