Ogg fixing

This commit is contained in:
Oswald de Bruin 2013-06-12 14:53:41 +02:00 committed by Thulinma
parent 4cf03e2361
commit 03d4d58cbe
2 changed files with 58 additions and 12 deletions

View file

@ -9,15 +9,17 @@
namespace Analysers{
int analyseOGG(){
std::string oggBuffer;
OGG::Page oggPage;
//Read all of std::cin to oggBuffer
//while stream busy
while (std::cin.good()){
oggBuffer += std::cin.get();
}
oggBuffer.erase(oggBuffer.size() - 1, 1);
OGG::Page oggData;
while (oggData.read(oggBuffer)){
std::cerr << oggData.toPrettyString() << std::endl;
for (unsigned int i = 0; (i < 1024) && (std::cin.good()); i++){
oggBuffer += std::cin.get();
}
//while OGG::page check function read
while (oggPage.read(oggBuffer)){//reading ogg to string
std::cout << oggPage.toPrettyString() << std::endl;
}
}
return 0;
}

View file

@ -3,12 +3,20 @@
#include <fstream>
#include <string>
#include <string.h>
#include <vector>
#include <mist/dtsc.h>
#include <mist/ogg.h>
#include <mist/config.h>
#include <mist/json.h>
namespace Converters{
struct oggTrack{
long unsigned int serialNumber; //serial number in read OGG file
long unsigned int lastSequenceNumber;//error checking for lost pages in OGG
long long int dtscID; //track ID for in the written DTSC file
DTSC::datatype type; //type of stream in DTSC
};
int OGG2DTSC(){
std::string oggBuffer;
OGG::Page oggPage;
@ -16,15 +24,51 @@ namespace Converters{
//Read all of std::cin to oggBuffer
//while stream busy
JSON::Value DTSCOut;
std::vector<oggTrack> trackData;
long long int lastTrackID = 1;
while (std::cin.good()){
for (unsigned int i; (i < 1024) && (std::cin.good()); i++){
for (unsigned int i = 0; (i < 1024) && (std::cin.good()); i++){
oggBuffer += std::cin.get();
}
//while OGG::page check functie{ read
while (oggPage.read(oggBuffer)){//reading ogg to string
//ogg page 2 DTSC packet
std::cout << oggPage.typeBOS();
std::cout << "inner" << std::endl;
while (oggPage.read(oggBuffer)){//reading ogg to ogg::page
//on succes, we handle one page
if (oggPage.typeBOS()){//defines a new track
//std::cout << oggPage.getFullPayload() << std::endl;
oggTrack temp;
temp.serialNumber = oggPage.getBitstreamSerialNumber();
std::cerr << "Begin "<< temp.serialNumber << std::endl;
temp.lastSequenceNumber = oggPage.getPageSequenceNumber();
temp.dtscID = lastTrackID;
lastTrackID++;
if (memcmp(oggPage.getFullPayload()+1, "theora", 6)){
temp.type = DTSC::VIDEO;
std::cerr << "Snr " << temp.serialNumber << "=theora" << std::endl;
}else if(memcmp(oggPage.getFullPayload()+2, "vorbis", 6)){
std::cerr << "Snr " << temp.serialNumber << "=vorbis" << std::endl;
temp.type = DTSC::AUDIO;
}else{
std::cerr << "Unknown Codec!" << std::endl;
}
trackData.insert(trackData.end(), temp);
}else if (oggPage.typeEOS()){//ending page
std::cerr << std::hex << oggPage.getGranulePosition() <<std::dec << "ending" << std::endl;
}else{//normal page
std::cerr << std::hex << oggPage.getGranulePosition() <<std::dec<< std::endl;
/*
//ogg page 2 DTSC packet
//for elk segment
DTSCOut.null();//clearing DTSC buffer
DTSCOut["trackid"] = 1; //video
DTSCOut["trackid"] = 2; //audio
DTSCOut["time"] = 0; //timestamp
DTSCOut["data"] = 0; //segment inhoud
DTSCOut["keyframe"] = "x"; //Aanmaken als eerste segment = keyframe
//std::cout << "inner" << std::endl;
*/
}
}
//std::cout << "outer" << std::endl;
}