|
|
// ########################################################################## // #### #### // #### RTP Audio Server Project #### // #### ============================ #### // #### #### // #### Tools #### // #### #### // #### Version 1.00 -- September 17, 2000 #### // #### #### // #### Copyright (C) 1999 Thomas Dreibholz #### // #### 2000 Universität Bonn, Abt. IV #### // #### EMail: Dreibholz@bigfoot.com #### // #### WWW: http://www.bigfoot.com/~dreibholz #### // #### #### // ########################################################################## #ifndef TOOLS_H #define TOOLS_H #include "system.h" #include "strings.h" namespace Coral { /** * Debug output. * * @param string Debug string to be written to cerr. */ inline void debug(const char* string); /** * Get microseconds since January 01, 1970. * * @return Microseconds since January 01, 1970. */ card64 getMicroTime(); /** * Translate 16-bit value to network byte order. * * @param x Value to be translated. * @return Translated value. */ inline card16 translate16(const card16 x); /** * Translate 32-bit value to network byte order. * * @param x Value to be translated. * @return Translated value. */ inline card32 translate32(const card32 x); /** * Translate 64-bit value to network byte order. * * @param x Value to be translated. * @return Translated value. */ inline card64 translate64(const card64 x); /** * Translate double to 64-bit binary. * * @param x Value to be translated. * @return Translated value. */ inline card64 translateToBinary(const double x); /** * Translate 64-bit binary to double. * * @param x Value to be translated. * @return Translated value. */ inline double translateToDouble(const card64 x); /** * Calculate packets per second. * * Asumption: Every frame has it's own packets. * * @param payloadBytesPerSecond Byte rate of payload data. * @param framesPerSecond Frame rate. * @param maxPacketSize Maximum size of a packet. * @param headerLength Length of header for each frame. * @return Total bytes per second. */ cardinal calculatePacketsPerSecond(const cardinal payloadBytesPerSecond, const cardinal framesPerSecond, const cardinal maxPacketSize, const cardinal headerLength); /** * Calculate frames per second. * * Asumption: Every frame has it's own packets. * * @param payloadBytesPerSecond Byte rate of payload data. * @param framesPerSecond Frame rate. * @param maxPacketSize Maximum size of a packet. * @param headerLength Length of header for each frame. * @return Total frames per second. */ cardinal calculateBytesPerSecond(const cardinal payloadBytesPerSecond, const cardinal framesPerSecond, const cardinal maxPacketSize, const cardinal headerLength); /** * Scan protocol, host and path from an URL string. The protocol my be * missing, if the String "protocol" is initialized with a default. * * @param location String with URL. * @param protocol Place to store the protocol name. * @param host Place to store the host name. * @param path Place to store the path. * @return true on success; false otherwise. */ bool scanURL(const String& location, String& protocol, String& host, String& path); /** * Print time stamp (date and time) to given output stream. * * @param os Output stream. */ void printTimeStamp(ostream& os = cout); } #ifdef USE_EFENCE /** * operator new() replacement for usage with libefence. */ void* operator new(size_t size) throw (std::bad_alloc); /** * operator delete() replacement for usage with libefence. */ void operator delete(void* ptr) throw (); #endif #include "tools.icc" #endif
Generated by: viper@odin on Mon Oct 16 11:49:26 2000, using kdoc 2.0a36. |