RTP Audio System  2.0.0
tools.cc File Reference
#include "tdsystem.h"
#include "tdstrings.h"
#include "tools.h"
#include <pwd.h>
#include <time.h>
#include <sys/utsname.h>

Defines

#define PRINT_ALLOCATIONS

Functions

cardinal calculatePacketsPerSecond (const cardinal payloadBytesPerSecond, const cardinal framesPerSecond, const cardinal maxPacketSize, const cardinal headerLength)
cardinal calculateBytesPerSecond (const cardinal payloadBytesPerSecond, const cardinal framesPerSecond, const cardinal maxPacketSize, const cardinal headerLength)
bool scanURL (const String &location, String &protocol, String &host, String &path)
void printTimeStamp (std::ostream &os)
bool getUserName (char *str, const size_t size, const bool realName, uid_t uid)

Define Documentation


Function Documentation

cardinal calculateBytesPerSecond ( const cardinal  payloadBytesPerSecond,
const cardinal  framesPerSecond,
const cardinal  maxPacketSize,
const cardinal  headerLength 
)

Calculate frames per second.

Asumption: Every frame has it's own packets.

Parameters:
payloadBytesPerSecondByte rate of payload data.
framesPerSecondFrame rate.
maxPacketSizeMaximum size of a packet.
headerLengthLength of header for each frame.
Returns:
Total frames per second.
cardinal calculatePacketsPerSecond ( const cardinal  payloadBytesPerSecond,
const cardinal  framesPerSecond,
const cardinal  maxPacketSize,
const cardinal  headerLength 
)

Calculate packets per second.

Asumption: Every frame has it's own packets.

Parameters:
payloadBytesPerSecondByte rate of payload data.
framesPerSecondFrame rate.
maxPacketSizeMaximum size of a packet.
headerLengthLength of header for each frame.
Returns:
Total bytes per second.
bool getUserName ( char *  str,
const size_t  size,
const bool  realName = false,
const uid_t  uid = getuid() 
)

Get user name for given user ID.

Parameters:
strBuffer to store name to.
sizeSize of buffer.
realNametrue to get real name (e.g. John Miller); false to get user name (e.g. jmiller).
uidUser ID.
Returns:
true for success; false otherwise.
void printTimeStamp ( std::ostream &  os = std::cout)

Print time stamp (date and time) to given output stream.

Parameters:
osOutput stream.
bool scanURL ( const String location,
String protocol,
String host,
String path 
)

Scan protocol, host and path from an URL string. The protocol my be missing, if the String "protocol" is initialized with a default.

Parameters:
locationString with URL.
protocolPlace to store the protocol name.
hostPlace to store the host name.
pathPlace to store the path.
Returns:
true on success; false otherwise.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines