RTP Audio System
2.0.0
|
00001 /* 00002 * $Id: tools.h 1259 2011-12-17 13:26:09Z dreibh $ 00003 * 00004 * SocketAPI implementation for the sctplib. 00005 * Copyright (C) 1999-2012 by Thomas Dreibholz 00006 * 00007 * Realized in co-operation between 00008 * - Siemens AG 00009 * - University of Essen, Institute of Computer Networking Technology 00010 * - University of Applied Sciences, Muenster 00011 * 00012 * Acknowledgement 00013 * This work was partially funded by the Bundesministerium fuer Bildung und 00014 * Forschung (BMBF) of the Federal Republic of Germany (Foerderkennzeichen 01AK045). 00015 * The authors alone are responsible for the contents. 00016 * 00017 * This program is free software: you can redistribute it and/or modify 00018 * it under the terms of the GNU General Public License as published by 00019 * the Free Software Foundation, either version 3 of the License, or 00020 * (at your option) any later version. 00021 00022 * This program is distributed in the hope that it will be useful, 00023 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00024 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00025 * GNU General Public License for more details. 00026 * 00027 * You should have received a copy of the GNU General Public License 00028 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00029 * 00030 * Contact: discussion@sctp.de 00031 * dreibh@iem.uni-due.de 00032 * tuexen@fh-muenster.de 00033 * 00034 * Purpose: Tools Implementation 00035 * 00036 */ 00037 00038 00039 #ifndef TOOLS_H 00040 #define TOOLS_H 00041 00042 00043 #include "tdsystem.h" 00044 #include "tdstrings.h" 00045 00046 #ifdef HAVE_SYS_TIME_H 00047 #include <sys/time.h> 00048 #ifdef TIME_WITH_SYS_TIME 00049 #include <time.h> 00050 #endif 00051 #endif 00052 00053 00054 00060 inline void debug(const char* string); 00061 00062 00068 inline card64 getMicroTime(); 00069 00070 00077 inline card16 translate16(const card16 x); 00078 00085 inline card32 translate32(const card32 x); 00086 00093 inline card64 translate64(const card64 x); 00094 00101 inline card64 translateToBinary(const double x); 00102 00109 inline double translateToDouble(const card64 x); 00110 00111 00123 cardinal calculatePacketsPerSecond(const cardinal payloadBytesPerSecond, 00124 const cardinal framesPerSecond, 00125 const cardinal maxPacketSize, 00126 const cardinal headerLength); 00127 00139 cardinal calculateBytesPerSecond(const cardinal payloadBytesPerSecond, 00140 const cardinal framesPerSecond, 00141 const cardinal maxPacketSize, 00142 const cardinal headerLength); 00143 00154 bool scanURL(const String& location, 00155 String& protocol, 00156 String& host, 00157 String& path); 00158 00168 bool getUserName(char* str, 00169 const size_t size, 00170 const bool realName = false, 00171 const uid_t uid = getuid()); 00172 00180 template<class T> void quickSort(T* array, 00181 const integer start, 00182 const integer end); 00183 00193 template<class T> void quickSortPtr(T* array, 00194 const integer start, 00195 const integer end, 00196 bool (*lt)(T,T), 00197 bool (*gt)(T,T)); 00198 00199 00210 template<class T> void quickSortGroupPtr(T* array, 00211 const integer start, 00212 const integer end, 00213 bool (*lt)(T,T), 00214 bool (*gt)(T,T), 00215 bool (*geq)(T,T)); 00216 00217 00224 template<class T> cardinal removeDuplicates(T* array, 00225 const cardinal length); 00226 00227 00233 void printTimeStamp(std::ostream& os = std::cout); 00234 00235 00236 #include "tools.icc" 00237 00238 00239 #endif