Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members
global.hpp
00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: global.hpp * 00006 * * 00007 * * 00008 * * 00009 * ITEC institute of the University of Klagenfurt (Austria) * 00010 * http://www.itec.uni-klu.ac.at * 00011 * * 00012 * * 00013 * For more information visit the ViTooKi homepage: * 00014 * http://ViTooKi.sourceforge.net * 00015 * vitooki-user@lists.sourceforge.net * 00016 * vitooki-devel@lists.sourceforge.net * 00017 * * 00018 * This file is part of ViTooKi, a free video toolkit. * 00019 * ViTooKi is free software; you can redistribute it and/or * 00020 * modify it under the terms of the GNU General Public License * 00021 * as published by the Free Software Foundation; either version 2 * 00022 * of the License, or (at your option) any later version. * 00023 * * 00024 * This program is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU General Public License * 00030 * along with this program; if not, write to the Free Software * 00031 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 00032 * MA 02111-1307, USA. * 00033 * * 00034 ***********************************************************************/ 00035 00036 /*********************************************************************** 00037 * * 00038 * REVISION HISTORY: * 00039 * * 00040 * * 00041 * * 00042 ***********************************************************************/ 00043 00044 #ifndef __global_hpp__ 00045 #define __global_hpp__ 00046 00047 // c++ includes 00048 00049 #ifndef WINCE 00050 #include <iostream> 00051 #endif 00052 00053 #include <cmath> 00054 #include <cstdio> 00055 #include <cstdlib> 00056 #include <queue> 00057 #include <list> 00058 #include <map> 00059 #include <string> 00060 #include "debug.hpp" 00061 using namespace std; 00062 00063 // qt includes 00064 #ifdef USE_QT 00065 #include <qstring.h> 00066 #include <qcstring.h> 00067 #include <qfile.h> 00068 #include <qglobal.h> 00069 #if ((WIN32) && ((QT_VERSION >> 16) < 3)) 00070 #define QPtrList QList 00071 #define QMemArray QArray 00072 #include <qlist.h> 00073 #define QPtrVector QVector 00074 #define QPtrCollection QCollection 00075 #else 00076 #include <qptrlist.h> 00077 #endif 00078 #else 00079 typedef unsigned int uint; 00080 #endif // USE_QT 00081 00082 #include "VThread.hpp" 00083 00084 #include <time.h> 00085 #ifdef WIN32 00086 #ifndef WINCE 00087 #include <sys/timeb.h> 00088 #endif /* wince */ 00089 #include <winsock2.h> // timeval type 00090 #define snprintf _snprintf 00091 #else 00092 #include <sys/time.h> 00093 #include <unistd.h> 00094 #endif 00095 00096 #ifdef linux 00097 #define LINUX 00098 #endif 00099 00100 // some constants for convenience 00101 #define NEW_LINE "\n" 00102 #define NEW_LINE1 "\n" 00103 #define NEW_LINE2 "\n\n" 00104 #define NEW_LINE3 "\n\n" 00105 #define TAB_CHAR "\t" 00106 00107 #define MAX_BUFFER_SIZE 65536*8 00108 #define MSG_BUFFER_SIZE 65536 00109 #define MAX_FRAME_SIZE 65536*8 //512KByte per frame 00110 #define MAX_STR_LEN 1024 00111 #define MAX_IOD_SIZE 1024 00112 #define MAX_HEADERS_SIZE 8196 00113 00114 #ifdef WIN32 00115 #define DEMUX_PATH "demux\\" 00116 #define PATHSEPARATOR "\\" 00117 #define PATHSEPARATORCHAR '\\' 00118 #else 00119 #define DEMUX_PATH "demux/" 00120 #define PATHSEPARATOR "/" 00121 #define PATHSEPARATORCHAR '/' 00122 #endif 00123 00124 #define ASSERT_ALREADY_DEF 00125 #define VERSION_ALREADY_DEF 00126 #define PACKAGE_ALREADY_DEF 00127 00128 #ifndef MAX 00129 #define MAX(A,B) ( ((A)>(B)) ? (A) : (B) ) 00130 #endif 00131 #ifndef MIN 00132 #define MIN(A,B) ( ((A)<(B)) ? (A) : (B) ) 00133 #endif 00134 00135 // error codes 00136 #define ERR_OK 0 00137 #define ERR -1 00138 #define ERR_FILE -500 00139 #define ERR_PSNR -600 00140 00141 00142 /* Prints a debug message. 00143 * @param L Debug level 00144 * @param X File 00145 */ 00146 #ifdef ISOMP4 00147 #include "ISOMovies.h" 00148 #endif 00149 00151 // definition of Data types 00153 #ifndef ISOMP4 00154 #if defined(_MSC_VER) && !defined(__MWERKS__) 00155 typedef _int64 u64; 00156 typedef _int64 s64; 00157 #else 00158 typedef unsigned long long u64; 00159 typedef signed long long s64; 00160 #endif 00161 typedef unsigned int u32; 00162 typedef unsigned short u16; 00163 typedef unsigned char u8; 00164 typedef int s32; 00165 typedef short s16; 00166 typedef char s8; 00167 #define MP4VisualHandlerType (('v'<<24)|('i'<<16)|('d'<<8)| 'e') 00168 #define MP4AudioHandlerType (('s'<<24)|('o'<<16)|('u'<<8)| 'n') 00169 #define MP4SceneDescriptionHandlerType (('s'<<24)|('d'<<16)|('s'<<8)| 'm') 00170 #define MP4ObjectDescriptorHandlerType (('o'<<24)|('d'<<16)|('s'<<8)| 'm') 00171 #endif 00172 00173 #define SERVER_ID "ItecMP4Server" 00174 #define PLAYER_ID "ItecMP4Player" 00175 #define QT_PLAYER_ID "QTS" 00176 #define OLD_BFRAMES_DISABLED_QT_PLAYER "qtver=6" 00177 #define REAL_PLAYER_ID "RealMedia Player" 00178 00180 // Konstruktion/Destruktion 00182 00183 #ifdef WIN32 00184 00185 #include <windows.h> 00186 inline void msleep(long ms) { Sleep(ms);}; 00187 inline void sleep(long sec) { Sleep(1000*sec);}; 00188 00189 #ifdef WINCE 00190 static long gettimeofday(struct timeval *tp, void *tz) 00191 { 00192 DWORD timemillis = timeGetTime(); 00193 00194 tp->tv_sec = timemillis/1000; 00195 tp->tv_usec = (timemillis - (tp->tv_sec*1000)) * 1000; 00196 00197 return 0; 00198 }; 00199 static char *getMonthName(int nr) 00200 { 00201 switch(nr) { 00202 case 1: return "Jan"; break; 00203 case 2: return "Feb"; break; 00204 case 3: return "Mar"; break; 00205 case 4: return "Apr"; break; 00206 case 5: return "May"; break; 00207 case 6: return "Jun"; break; 00208 case 7: return "Jul"; break; 00209 case 8: return "Aug"; break; 00210 case 9: return "Sep"; break; 00211 case 10: return "Oct"; break; 00212 case 11: return "Nov"; break; 00213 case 12: return "Dec"; break; 00214 default: return ""; 00215 } 00216 } 00217 static char *addLeadingZeros(int nr) 00218 { 00219 char *snr = new char[3]; 00220 00221 if (nr >= 10) 00222 sprintf(snr, "%d", nr); 00223 else 00224 sprintf(snr, "0%d", nr); 00225 00226 return snr; 00227 } 00228 #else //WINCE 00229 static long gettimeofday(struct timeval *tp, void *tz) 00230 { 00231 struct _timeb timebuffer; 00232 00233 _ftime( &timebuffer ); 00234 tp->tv_sec = timebuffer.time; 00235 tp->tv_usec = timebuffer.millitm * 1000; 00236 return 0; 00237 }; 00238 #endif //WINCE 00239 00240 00241 00242 #else //win32 00243 inline void msleep(long ms) { usleep(1000*ms);}; 00244 00245 #endif //win32 00246 00247 00248 00249 bool getTimeString(char *timestr, int len); 00250 00251 unsigned int getFilesize(const char *filename); 00252 00253 struct intCompare { 00254 bool operator() (const int a, const int b) const { 00255 return (a<b); 00256 }; 00257 }; 00258 00259 struct stringCompare { 00260 bool operator() (const char* a, const char* b) const { 00261 return (strcmp(a,b)<0); 00262 }; 00263 }; 00264 00265 #endif // __global_hpp__ 00266 00267 00268 00269 //****************************************** 00270 // Windows CE definitions 00271 //****************************************** 00272 00273 #ifdef WINCE 00274 #include <mstimeid.h> 00275 #define srand48 srand 00276 #define lrand48 rand 00277 #endif //WINCE 00278