RTP Audio System  2.0.0
tools.h File Reference
#include "tdsystem.h"
#include "tdstrings.h"
#include "tools.icc"

Go to the source code of this file.

Functions

void debug (const char *string)
card64 getMicroTime ()
card16 translate16 (const card16 x)
card32 translate32 (const card32 x)
card64 translate64 (const card64 x)
card64 translateToBinary (const double x)
double translateToDouble (const card64 x)
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)
bool getUserName (char *str, const size_t size, const bool realName=false, const uid_t uid=getuid())
template<class T >
void quickSort (T *array, const integer start, const integer end)
template<class T >
void quickSortPtr (T *array, const integer start, const integer end, bool(*lt)(T, T), bool(*gt)(T, T))
template<class T >
void quickSortGroupPtr (T *array, const integer start, const integer end, bool(*lt)(T, T), bool(*gt)(T, T), bool(*geq)(T, T))
template<class T >
cardinal removeDuplicates (T *array, const cardinal length)
void printTimeStamp (std::ostream &os=std::cout)

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.
void debug ( const char *  string) [inline]

Debug output.

Parameters:
stringDebug string to be written to cerr.
card64 getMicroTime ( ) [inline]

Get microseconds since January 01, 1970.

Returns:
Microseconds since January 01, 1970.
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.
template<class T >
void quickSort ( T *  array,
const integer  start,
const integer  end 
)

Sort array using QuickSort algorithm.

Parameters:
arrayArray to be sorted.
startStart offset in array.
endEnd offset in array.
template<class T >
void quickSortGroupPtr ( T *  array,
const integer  start,
const integer  end,
bool(*)(T, T)  lt,
bool(*)(T, T)  gt,
bool(*)(T, T)  geq 
)

Sort pointer array using QuickSort algorithm.

Parameters:
arrayArray to be sorted.
startStart offset in array.
endEnd offset in array.
ltLess than comparision routine for sorting.
gtGreater than comparision routine for sorting.
geqEqual routine for separation of groups.
template<class T >
void quickSortPtr ( T *  array,
const integer  start,
const integer  end,
bool(*)(T, T)  lt,
bool(*)(T, T)  gt 
)

Sort pointer array using QuickSort algorithm.

Parameters:
arrayArray to be sorted.
startStart offset in array.
endEnd offset in array.
ltLess than comparision routine.
gtGreater than comparision routine.
template<class T >
cardinal removeDuplicates ( T *  array,
const cardinal  length 
)

Remove duplicates from *sorted* array.

Parameters:
arrayArray to be sorted.
lengthLength of array.
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.
card16 translate16 ( const card16  x) [inline]

Translate 16-bit value to network byte order.

Parameters:
xValue to be translated.
Returns:
Translated value.
card32 translate32 ( const card32  x) [inline]

Translate 32-bit value to network byte order.

Parameters:
xValue to be translated.
Returns:
Translated value.
card64 translate64 ( const card64  x) [inline]

Translate 64-bit value to network byte order.

Parameters:
xValue to be translated.
Returns:
Translated value.
card64 translateToBinary ( const double  x) [inline]

Translate double to 64-bit binary.

Parameters:
xValue to be translated.
Returns:
Translated value.
double translateToDouble ( const card64  x) [inline]

Translate 64-bit binary to double.

Parameters:
xValue to be translated.
Returns:
Translated value.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines