Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

EXPERIMENT.h

Go to the documentation of this file.
00001 /* Copyright (C) 2000 KOM/Darmstadt University of Technology 00002 * 00003 * You are allowed to use all other parts of the code under the following terms: 00004 * 00005 * For non-commercial use, code may be used in unmodified form provided 00006 * that this copyright notice and this permission notice appear in 00007 * supporting documentation. 00008 * 00009 * This software is provided "as is" and without any express or implied 00010 * warranties, including, without limitation, the implied warranty of 00011 * fitness for a particular purpose. 00012 * 00013 * The code may be subjected to the GNU General Public License, Version 2, 00014 * and re-distributed under the terms of this license. 00015 * As a special exception, permission is granted to link this code 00016 * with the Qt library and distribute executables, as long as you 00017 * follow the requirements of the GNU GPL in regard to all of the 00018 * software in the executable aside from Qt. 00019 * 00020 * Commercial use other than under the terms of the GNU General Public 00021 * License is allowed only after express negotiation of conditions 00022 * with the authors. 00023 */ 00024 #ifndef EXPERIMENT_H 00025 #define EXPERIMENT_H 00026 00027 #define NO_MN 00028 #ifdef NO_MN 00029 #ifdef linux 00030 typedef unsigned long u_int64; 00031 #endif 00032 typedef unsigned int u_int32; 00033 typedef unsigned int u_int32_t; 00034 typedef int stream_event_t; 00035 #define EV_OK 0 00036 #define EV_EOF -1 00037 #define EV_ERROR -2 00038 #define RTPCODEC_READ_ERROR -3 00039 #define OPTIONAL 00040 #endif 00041 00042 class PlainPacket; 00043 00044 class MNRTPCodecH261 00045 { 00046 struct GOB 00047 { 00048 int _head_drop; 00049 int _tail_drop; 00050 unsigned char* _buf; 00051 int _size; 00052 int _number; 00053 bool _picture; 00054 int _tempref; 00055 GOB* _next; 00056 00057 GOB( int head_drop ) 00058 { 00059 _head_drop = head_drop; 00060 _tail_drop = 0; 00061 _buf = new unsigned char[4096]; 00062 _size = 0; 00063 _number = 0; 00064 _next = NULL; 00065 _picture = false; 00066 _tempref = 0; 00067 } 00068 00069 ~GOB() 00070 { 00071 delete [] _buf; 00072 } 00073 00074 inline int size() const { return _size; } 00075 inline int max() const { return 4096; } 00076 inline void add( int byte ) 00077 { 00078 _buf[_size] = byte; 00079 _size++; 00080 } 00081 00082 inline int getTempRef() const { return _tempref; } 00083 00084 void checkPicture( ); 00085 bool isPicture( ); 00086 00087 inline int copy(char* dest) 00088 { 00089 memcpy(dest,_buf,_size); 00090 return _size; 00091 } 00092 00093 void fillHeader( char* buffer ); 00094 }; 00095 00096 struct Frame 00097 { 00098 int timestamp; 00099 GOB* head; 00100 GOB* tail; 00101 00102 Frame() 00103 { 00104 timestamp = 0; 00105 head = NULL; 00106 tail = NULL; 00107 } 00108 00109 void append( GOB* g ) 00110 { 00111 assert( head != tail ); // not intended for picture headers 00112 tail->_next = g; 00113 tail = g; 00114 } 00115 00116 void set_picture_header( GOB* g, int tempref ) 00117 { 00118 timestamp = g->getTempRef(); 00119 head = g; 00120 tail = g; 00121 } 00122 00123 void drop_head() 00124 { 00125 if ( head == tail ) 00126 { 00127 delete head; 00128 head = tail = NULL; 00129 } 00130 else 00131 { 00132 GOB* t = head; 00133 head = head->_next; 00134 delete t; 00135 } 00136 } 00137 }; 00138 00139 class Movie 00140 { 00141 Frame* _current; 00142 Frame* _next; 00143 00144 public: 00145 Movie() 00146 { 00147 _current = NULL; 00148 _next = NULL; 00149 } 00150 00151 bool first() const 00152 { 00153 return ( _current == NULL ); 00154 } 00155 00156 void setFrame( Frame* f ) 00157 { 00158 if ( _current == NULL ) _current = f; 00159 else _next = f; 00160 } 00161 00162 bool needData() const 00163 { 00164 return ( _next == NULL ); 00165 } 00166 00167 void addToCurrent( GOB* g ) 00168 { 00169 assert( _current ); 00170 _current->append(g); 00171 } 00172 00173 int hasMoreData() const 00174 { 00175 return ( _next != NULL ); 00176 } 00177 00178 int nextGopSize() const 00179 { 00180 return _current->head->size(); 00181 } 00182 00183 inline void fillHeader( char* buffer ) 00184 { 00185 _current->head->fillHeader( buffer ); 00186 } 00187 00188 int copyGop(char* dest) 00189 { 00190 int size = _current->head->copy(dest); 00191 _current->drop_head(); 00192 if ( _current->head == NULL ) 00193 { 00194 delete _current; 00195 _current = _next; 00196 _next = NULL; 00197 } 00198 return size; 00199 } 00200 }; 00201 00202 Movie _movie; 00203 00204 bool _ok; 00205 bool _first; 00206 int _last_tail_drop; 00207 unsigned int _last_gob_marker; 00208 int _last_temp_ref; 00209 unsigned int _bb; 00210 00211 PlainPacket* _file; 00212 00213 void callInitializer( int fd ); 00214 00215 void fillHeader( char* buffer, 00216 int previous_head_drop, 00217 int tail_drop, 00218 int gob_number ); 00219 void getGobInfo( char* buffer, 00220 int head_drop, 00221 int* gob_number ); 00222 void updateTimeRef( int newTimeRef ); 00223 int currentTimeRef( ); 00224 00225 public: 00226 MNRTPCodecH261(); 00227 00228 virtual ~MNRTPCodecH261(); 00229 00230 bool ok() const; 00231 00232 int get(); 00233 00234 int startCode( int& head_drop ); 00235 00236 /* 00237 * fillBuffer gives us exactly one GOB 00238 */ 00239 int initFirst( ); 00240 00241 int fillBuffer( GOB* g ); 00242 int fillBuffer( char* buffer, int max, 00243 int* head_drop, int* tail_drop ); 00244 00245 int fillPacket( int fd, char* buffer, int max ); 00246 00247 virtual u_int32_t get_std_bw(int fd) { return 1000; } 00248 virtual u_int32_t get_std_packetsize(int fd) { return 1400; } 00249 virtual struct timeval get_std_timeout(int fd); 00250 00251 virtual int get_data( int fd, 00252 u_int64 maxlength, 00253 char* buffer, 00254 u_int64* fpos, 00255 int* marker, 00256 int* ts, 00257 struct timeval* codec_next_timeout, 00258 bool seekable, 00259 stream_event_t* except, 00260 int packetsize, 00261 u_int32 time_offset, 00262 u_int32 ts_offset ); 00263 00264 /* standard write functions */ 00265 virtual int write_next_data(int fd, char* buffer, int len) { return -1; } 00266 int write_blank(int fd, u_int32 blank_size) { return -1; } 00267 }; 00268 00269 #endif /* EXPERIMENT_H */ 00270

Generated on Sun Mar 6 13:35:49 2005 for Komssys by doxygen 1.3.8