XCube Stream Reader SDK
|
00001 /* 00002 * CFileReader.h 00003 * 00004 * Created on: Nov 21, 2011 00005 * Author: mtaveniku 00006 * 00007 * This file defines class of file reader. A file reader is responsible 00008 * for reading data from file to the packet buffer. 00009 */ 00010 00011 #ifndef CFILEREADER_H_ 00012 #define CFILEREADER_H_ 00013 00014 // C headers 00015 #include <stdio.h> 00016 #include <stdlib.h> 00017 #include <pthread.h> 00018 #include <unistd.h> 00019 #include <string.h> 00020 #include <errno.h> 00021 #include <string> 00022 00023 // Project Headers 00024 #include "X3cPacket.h" 00025 #include "X3cFileBuf.h" 00026 #include "exceptions/IoException.h" 00027 #include "CPacketBuffer.h" 00028 00030 00040 class CFileReader{ 00041 00042 public: 00044 00050 CFileReader(const char * inFileName, CPacketBuffer *pktBuf, 00051 size_t chunkSz); 00052 00054 00057 virtual ~CFileReader(); 00058 00060 00064 void init(UINT64 offset) throw (IoException); 00065 00066 void initWithTimeFilter(UINT64 timeVal) throw (IoException); 00067 00068 00070 void start(); 00071 00073 void stop(); 00074 00076 00083 void reset(UINT64 timeVal); 00084 00086 void resume(); 00087 00088 private: 00089 UINT64 getFPosFromTime(UINT64 timeVal); 00090 00092 00096 static void * threadHandler(void* arg); 00097 00099 00103 void bufferWriter(); 00104 00106 00107 CPacketBuffer *mPktBuf; 00108 00110 00111 std::string mFileName; 00112 00114 00115 FILE *mFile; 00116 00118 00119 int mFileNo; 00120 00122 00123 X3C_HEADER mX3CFileHeader; 00124 00126 00127 size_t mChunkSz; 00128 00130 00132 bool mDoRun; 00133 00135 00136 pthread_t mBufWrThread; 00137 00139 00140 size_t mFileOffset; 00141 00143 bool mIsInitialized; 00144 00146 bool mResetting; 00147 00149 pthread_mutex_t mResetLock; 00150 00152 pthread_cond_t mResetCond; 00153 }; 00154 00155 #endif /* CFILEREADER_H_ */