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, size_t chunkSz); 00051 00053 00056 virtual ~CFileReader(); 00057 00059 00063 void init(UINT64 offset) throw (IoException); 00064 00065 void initWithTimeFilter(UINT64 timeVal) throw (IoException); 00066 00067 00069 void start(); 00070 00072 void stop(); 00073 00075 00079 int seek(UINT64 pos); 00080 00081 // /** 00082 // * Get the current file position 00083 // * @return 00084 // */ 00085 // size_t getFilePosition(); 00086 00087 private: 00088 UINT64 getFPosFromTime(UINT64 timeVal); 00089 00091 00095 static void * threadHandler(void* arg); 00096 00098 00102 void bufferWriter(); 00103 00104 private: 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 00144 bool mIsInitialized; 00145 }; 00146 00147 #endif /* CFILEREADER_H_ */