RTP Audio System
2.0.0
|
Traffic Shaper. More...
#include <trafficshaper.h>
Classes | |
struct | TrafficShaperPacket |
Public Member Functions | |
TrafficShaper () | |
TrafficShaper (Socket *socket) | |
~TrafficShaper () | |
void | init (Socket *socket) |
void | setSocket (Socket *socket) |
card64 | getBandwidth () const |
void | setBandwidth (const card64 bandwidth) |
double | getBufferDelay () const |
void | setBufferDelay (const double bufferDelay) |
void | flush () |
bool | refreshBuffer (const card8 trafficClass, const bool doRemapping) |
cardinal | getLastSeqNum () |
ssize_t | sendTo (const void *buffer, const size_t length, const cardinal seqNum, const cardinal flags, const InternetFlow &receiver, const card8 trafficClass=0) |
ssize_t | send (const void *buffer, const size_t length, const cardinal seqNum, const cardinal flags=0, const card8 trafficClass=0) |
ssize_t | write (const void *buffer, const size_t length, const cardinal seqNum) |
Private Types | |
enum | TrafficShaperCommand { TSC_Write = 0, TSC_Send = 1, TSC_SendTo = 2 } |
Private Member Functions | |
void | sendAll () |
ssize_t | addPacket (const void *data, const cardinal bytes, const cardinal seqNum, InternetFlow &destination, const cardinal flags, const cardinal command) |
Private Attributes | |
std::deque< TrafficShaperPacket > | Queue |
Socket * | SenderSocket |
card64 | SendTimeStamp |
card64 | Bandwidth |
double | BufferDelay |
integer | LastError |
cardinal | LastSeqNum |
Static Private Attributes | |
static TrafficShaperSingleton | Singleton |
Friends | |
class | TrafficShaperSingleton |
Traffic Shaper.
This class is a traffic shaper.
enum TrafficShaper::TrafficShaperCommand [private] |
Constructor.
TrafficShaper::TrafficShaper | ( | Socket * | socket | ) |
Constructor.
Destructor.
ssize_t TrafficShaper::addPacket | ( | const void * | data, |
const cardinal | bytes, | ||
const cardinal | seqNum, | ||
InternetFlow & | destination, | ||
const cardinal | flags, | ||
const cardinal | command | ||
) | [private] |
void TrafficShaper::flush | ( | ) |
Flush buffer.
card64 TrafficShaper::getBandwidth | ( | ) | const [inline] |
Get bandwidth for following packets.
double TrafficShaper::getBufferDelay | ( | ) | const [inline] |
Get maximum buffer delay for following packets.
cardinal TrafficShaper::getLastSeqNum | ( | ) | [inline] |
Get sequence number of last packet sent.
void TrafficShaper::init | ( | Socket * | socket | ) |
Initialize.
socket | Socket. |
bool TrafficShaper::refreshBuffer | ( | const card8 | trafficClass, |
const bool | doRemapping | ||
) |
Adapt buffer's contents to changed bandwidth and delay settings.
trafficClass | Traffic class to remap packets to. |
doRemapping | true, to do traffic class remapping; false otherwise. |
ssize_t TrafficShaper::send | ( | const void * | buffer, |
const size_t | length, | ||
const cardinal | seqNum, | ||
const cardinal | flags = 0 , |
||
const card8 | trafficClass = 0 |
||
) |
Wrapper for send(). send() will set the packet's traffic class, if trafficClass is not 0. In this case, the packet will be sent by sendto() to the destination address, the socket is connected to!
buffer | Buffer with data to send. |
length | Length of data to send. |
seqNum | Packet's sequence number (-1 for none). |
flags | Flags for sendto(). |
trafficClass | Traffic class for packet. |
void TrafficShaper::sendAll | ( | ) | [private] |
ssize_t TrafficShaper::sendTo | ( | const void * | buffer, |
const size_t | length, | ||
const cardinal | seqNum, | ||
const cardinal | flags, | ||
const InternetFlow & | receiver, | ||
const card8 | trafficClass = 0 |
||
) |
Wrapper for sendto(). sendto() will set the packet's traffic class, if trafficClass is not 0.
buffer | Buffer with data to send. |
length | Length of data to send. |
seqNum | Packet's sequence number (-1 for none). |
flags | Flags for sendto(). |
receiver | Address of receiver. |
void TrafficShaper::setBandwidth | ( | const card64 | bandwidth | ) | [inline] |
Set bandwidth for following packets.
bandwidth | Bandwidth. |
void TrafficShaper::setBufferDelay | ( | const double | bufferDelay | ) | [inline] |
Set maximum buffer delay for following packets.
bufferDelay | Maximum buffer delay in microseconds. |
void TrafficShaper::setSocket | ( | Socket * | socket | ) | [inline] |
Set socket to send shaped traffic to.
socket | Socket. |
ssize_t TrafficShaper::write | ( | const void * | buffer, |
const size_t | length, | ||
const cardinal | seqNum | ||
) |
Wrapper for write().
buffer | Buffer with data to write |
length | Length of data to write |
seqNum | Packet's sequence number (-1 for none). |
friend class TrafficShaperSingleton [friend] |
card64 TrafficShaper::Bandwidth [private] |
double TrafficShaper::BufferDelay [private] |
integer TrafficShaper::LastError [private] |
cardinal TrafficShaper::LastSeqNum [private] |
std::deque<TrafficShaperPacket> TrafficShaper::Queue [private] |
Socket* TrafficShaper::SenderSocket [private] |
card64 TrafficShaper::SendTimeStamp [private] |
TrafficShaperSingleton TrafficShaper::Singleton [static, private] |