00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include "stdafx.h"
00036 #include <libOOOgg/libOOOgg.h>
00037 #include <libOOOgg/dllstuff.h>
00038 #include <libOOOgg/OggPacketiser.h>
00039 #include "OOOggPacketDumper.h"
00040 #include <iostream>
00041
00042 #include <map>
00043 #include <fstream>
00044
00045
00046
00047
00048
00049 typedef map<unsigned long, OggPacketiser*> tStreamMap;
00050
00051 tStreamMap streamMap;
00052 OOOggPacketDumper testPacketDumper;
00053
00054
00055
00056 bool pageCB(OggPage* inOggPage, void *inUserData ) {
00057
00058 tStreamMap::iterator locIt = streamMap.find(inOggPage->header()->StreamSerialNo());
00059
00060 if (locIt == streamMap.end()) {
00061
00062 OggPacketiser* locPacketiser = new OggPacketiser(&testPacketDumper);
00063
00064 streamMap.insert(tStreamMap::value_type(inOggPage->header()->StreamSerialNo(), locPacketiser));
00065 locIt = streamMap.find(inOggPage->header()->StreamSerialNo());
00066 }
00067
00068 if (locIt == streamMap.end()) {
00069 cout<<"FAILED !!!!!!!!"<<endl;
00070 }
00071
00072
00073
00074 cout<<"======================================="<<endl;
00075 cout << "Stream : "<<inOggPage->header()->StreamSerialNo()
00076 << " Gran : "<<inOggPage->header()->GranulePos()<<endl<<endl;
00077
00078 (*locIt).second->acceptOggPage(inOggPage);
00079
00080 return true;
00081
00082
00083
00084
00085
00086 }
00087
00088 #ifdef WIN32
00089 int __cdecl _tmain(int argc, _TCHAR* argv[])
00090 #else
00091 int main (int argc, char * argv[])
00092 #endif
00093 {
00094
00095
00096 int x;
00097 cin>>x;
00098
00099
00100
00101
00102 if (argc < 2) {
00103 cout<<"Usage : OOOggPacketise <filename>"<<endl;
00104 } else {
00105
00106 OggDataBuffer testOggBuff;
00107
00108
00109
00110
00111
00112
00113 const BUFF_SIZE = 8092;
00114 testOggBuff.registerStaticCallback(&pageCB, NULL);
00115
00116 fstream testFile;
00117 testFile.open(argv[1], ios_base::in | ios_base::binary);
00118 char* locBuff = new char[BUFF_SIZE];
00119 while (!testFile.eof()) {
00120 testFile.read(locBuff, BUFF_SIZE);
00121 unsigned long locBytesRead = testFile.gcount();
00122 testOggBuff.feed((const unsigned char*)locBuff, locBytesRead);
00123 }
00124
00125 delete locBuff;
00126 }
00127
00128
00129 return 0;
00130 }
00131
00132