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
00039 #include <iostream>
00040 #include <fstream>
00041
00042 unsigned long bytePos;
00043 vector<unsigned long> streamSerials;
00044 vector<unsigned long*> maxPacks;
00045
00046 bool pageCB(OggPage* inOggPage, void* inUserData ) {
00047 bool locFoundStream = false;
00048 size_t locFoundPos = 0;
00049
00050 unsigned long locSerialNo = inOggPage->header()->StreamSerialNo();
00051 for (size_t i = 0; i < streamSerials.size(); i++) {
00052 if (locSerialNo == streamSerials[i]) {
00053 locFoundStream = true;
00054 locFoundPos = i;
00055 break;
00056 }
00057 }
00058
00059 if (!locFoundStream) {
00060 streamSerials.push_back(locSerialNo);
00061 maxPacks.push_back(new unsigned long(0));
00062 }
00063 unsigned long locNumPacks = 0;
00064 for (size_t i = 0; i < streamSerials.size(); i++) {
00065
00066 if (locSerialNo == streamSerials[i]) {
00067 locFoundPos = i;
00068 cout << "Stream "<<(unsigned long)i<<" : Granule = "<<inOggPage->header()->GranulePos()<<" - ";
00069 locNumPacks = 0;
00070 if (inOggPage->numPackets() == 0) {
00071 cout<<"EMPTY PAGE"<<endl;
00072 } else if (inOggPage->numPackets() == 1) {
00073 if (inOggPage->getPacket(0)->isContinuation() || inOggPage->getPacket(0)->isTruncated()) {
00074 cout<<" 1 Partial Packet";
00075 } else {
00076 cout<<" 1 Full Packet";
00077 locNumPacks = 1;
00078 }
00079 } else {
00080 locNumPacks = inOggPage->numPackets();
00081
00082 unsigned long locPartials = 0;
00083 if (inOggPage->getPacket(0)->isContinuation()) {
00084 locNumPacks--;
00085 locPartials++;
00086 }
00087
00088 if (inOggPage->getPacket(inOggPage->numPackets() - 1)->isTruncated()) {
00089 locNumPacks--;
00090 locPartials++;
00091 }
00092
00093 if (locPartials == 1) {
00094 cout << " 1 Partial Packet";
00095 } else if (locPartials >= 2) {
00096 cout<<" "<<locPartials<<" Full Packets";
00097 }
00098
00099 if (locNumPacks == 1) {
00100 cout<<" 1 Full Packet";
00101 } else if (locNumPacks >= 2) {
00102 cout<<" "<<locNumPacks<<" Full Packets";
00103 }
00104 }
00105 cout<<endl;
00106
00107 break;
00108 }
00109 }
00110
00111
00112 if (*maxPacks[locFoundPos] < locNumPacks) {
00113 *maxPacks[locFoundPos] = locNumPacks;
00114 }
00115
00116 return true;
00117 }
00118
00119
00120 #ifdef WIN32
00121 int __cdecl _tmain(int argc, _TCHAR* argv[])
00122 #else
00123 int main (int argc, char * argv[])
00124 #endif
00125 {
00126
00127
00128
00129
00130
00131 bytePos = 0;
00132
00133 if (argc < 2) {
00134 cout<<"Usage : OOOggPageInfo <filename>"<<endl;
00135 } else {
00136 OggDataBuffer testOggBuff;
00137
00138 testOggBuff.registerStaticCallback(&pageCB, NULL);
00139
00140 fstream testFile;
00141 testFile.open(argv[1], ios_base::in | ios_base::binary);
00142
00143 const unsigned short BUFF_SIZE = 8092;
00144 char* locBuff = new char[BUFF_SIZE];
00145 while (!testFile.eof()) {
00146 testFile.read(locBuff, BUFF_SIZE);
00147 unsigned long locBytesRead = testFile.gcount();
00148 testOggBuff.feed((const unsigned char*)locBuff, locBytesRead);
00149 }
00150
00151 cout<<endl;
00152 cout<<endl;
00153
00154 for (size_t i = 0; i < maxPacks.size(); i++) {
00155 cout<<"Stream "<<(unsigned long)i<<" max Packets = "<<*maxPacks[i]<<endl;
00156 }
00157
00158
00159 for (size_t i = 0; i < maxPacks.size(); i++) {
00160 delete maxPacks[i];
00161 }
00162
00163 delete[] locBuff;
00164 }
00165
00166 return 0;
00167 }
00168