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
00041
00042 #include <fstream>
00043
00044
00045
00046 unsigned long streamNo;
00047
00048 bool pageCB(OggPage* inOggPage, void* )
00049 {
00050 if ((inOggPage->numPackets() > 0) && (inOggPage->header()->isBOS())) {
00051 streamNo++;
00052 OggPacket* locFirstPack = inOggPage->getPacket(0);
00053
00054 if (strncmp((char*)locFirstPack->packetData(), "\001vorbis", 7) == 0) {
00055 cout<<"Stream "<<streamNo<<" : Audio/Vorbis "<<endl;
00056 } else if (strncmp((char*)locFirstPack->packetData(), "Speex ", 8) == 0) {
00057 cout<<"Stream "<<streamNo<<" : Audio/Speex "<<endl;
00058 } else if ((strncmp((char*)locFirstPack->packetData(), "fLaC", 4)) == 0) {
00059 cout<<"Stream "<<streamNo<<" : Audio/FLAC "<<endl;
00060 } else if ((strncmp((char*)locFirstPack->packetData(), "\200theora", 7)) == 0) {
00061 cout<<"Stream "<<streamNo<<" : Video/Theora "<<endl;
00062 } else if ((strncmp((char*)locFirstPack->packetData(), "\001video\000\000\000", 9)) == 0) {
00063 unsigned char* locPackData = locFirstPack->packetData();
00064 unsigned char* locFourCCString = new unsigned char[5];
00065 for (int i = 0; i < 4; i++) {
00066 locFourCCString[i] = locPackData[9+i];
00067 }
00068 locFourCCString[4] = 0;
00069
00070 string locPinName = (char*)locFourCCString;
00071 cout<<"Stream "<<streamNo<<" : Video/"<<locPinName<<endl;
00072 } else {
00073 cout<<"Stream "<<streamNo<<" : Unknown Stream"<<endl;
00074 }
00075 }
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 return true;
00093 }
00094
00095 #ifdef WIN32
00096 int __cdecl _tmain(int argc, _TCHAR* argv[])
00097 #else
00098 int main(int argc, char * argv[])
00099 #endif
00100 {
00101
00102
00103
00104 if (argc < 2) {
00105 cout<<"Usage : OOOggStat <filename>"<<endl;
00106 } else {
00107 streamNo = 0;
00108 OggDataBuffer testOggBuff;
00109
00110 const int BUFF_SIZE = 8092;
00111 testOggBuff.registerStaticCallback(&pageCB, NULL);
00112
00113 fstream testFile;
00114 testFile.open(argv[1], ios_base::in | ios_base::binary);
00115 char* locBuff = new char[BUFF_SIZE];
00116 while (!testFile.eof()) {
00117 testFile.read(locBuff, BUFF_SIZE);
00118 unsigned long locBytesRead = testFile.gcount();
00119 testOggBuff.feed((const unsigned char*)locBuff, locBytesRead);
00120 }
00121
00122 delete[] locBuff;
00123 }
00124
00125
00126 return 0;
00127 }
00128
00129