OOOggSeekFileQuery.cpp

Go to the documentation of this file.
00001 // OOOggSeekFileQuery.cpp : Defines the entry point for the console application.
00002 //
00003 // OOOggSeekFileReader.cpp : Defines the entry point for the console application.
00004 //
00005 
00006 #include "stdafx.h"
00007 
00008 #include <libilliCore/illicoreconfig.h>
00009 #include <libilliCore/iLE_Math.h>
00010 #include <libilliCore/StringHelper.h>
00011 #include <libOOOggSeek/OggSeekTable.h>
00012 #include <iostream>
00013 #include <fstream>
00014 using namespace std;
00015 
00016 #ifdef WIN32
00017 int __cdecl _tmain(int argc, _TCHAR* argv[])
00018 #else
00019 int main(int argc, char *argv[])
00020 #endif
00021 {
00022 
00023         if (argc < 2) {
00024                 cout << "Usage : OOOggSeekFileQuery <seek_table_file>"<<endl;
00025 
00026         } else {
00027                 LOOG_INT64 timePoint;
00028                 unsigned long bytePos;
00029 
00030                 fstream seekFile;
00031                 seekFile.open(argv[1], ios_base::in | ios_base::binary);
00032         
00033                 unsigned char* buff = new unsigned char[16];
00034                 unsigned long pointCount = 0;
00035 
00036                 OggSeekTable seekTable;
00037                 while (!seekFile.eof()) {
00038                         //Read the time
00039                         seekFile.read((char*)buff, 8);
00040                         if (seekFile.gcount() == 8) {
00041                                 timePoint = iLE_Math::CharArrToInt64(buff);
00042 
00043 
00044                                 seekFile.read((char*)buff, 4);
00045                                 bytePos = iLE_Math::charArrToULong(buff);
00046 
00047                                 seekTable.addSeekPoint(timePoint, bytePos);
00048                                 pointCount++;
00049                         }
00050                 }
00051 
00052                 delete [] buff;
00053 
00054                 cout<<"Constructed seek table with "<<pointCount<<" points."<<endl;
00055                 cout<<endl;
00056                 string query = "";
00057                 LOOG_INT64 queryInt;
00058                 OggSeekTable::tSeekPair response;
00059                 while (true) {
00060                         cout<<"Enter a time : ";
00061                         cin>>query;
00062                         
00063                         if (query == "") {
00064                                 break;
00065                         }
00066 
00067                         queryInt = StringHelper::stringToNum(query);
00068                         cout<<endl;
00069                         response = seekTable.getStartPos(queryInt);
00070                         cout<<"Query - "<<queryInt<<" : closest time  "<<response.first<<" maps to byte position "<<response.second<<endl;
00071 
00072                 }
00073         }
00074         return 0;
00075 }

Generated on Tue Feb 15 14:54:23 2005 for oggdsf by  doxygen 1.3.9