Ogg fixing
This commit is contained in:
parent
4cf03e2361
commit
03d4d58cbe
2 changed files with 58 additions and 12 deletions
|
@ -9,15 +9,17 @@
|
||||||
namespace Analysers{
|
namespace Analysers{
|
||||||
int analyseOGG(){
|
int analyseOGG(){
|
||||||
std::string oggBuffer;
|
std::string oggBuffer;
|
||||||
|
OGG::Page oggPage;
|
||||||
//Read all of std::cin to oggBuffer
|
//Read all of std::cin to oggBuffer
|
||||||
|
//while stream busy
|
||||||
while (std::cin.good()){
|
while (std::cin.good()){
|
||||||
|
for (unsigned int i = 0; (i < 1024) && (std::cin.good()); i++){
|
||||||
oggBuffer += std::cin.get();
|
oggBuffer += std::cin.get();
|
||||||
}
|
}
|
||||||
oggBuffer.erase(oggBuffer.size() - 1, 1);
|
//while OGG::page check function read
|
||||||
|
while (oggPage.read(oggBuffer)){//reading ogg to string
|
||||||
OGG::Page oggData;
|
std::cout << oggPage.toPrettyString() << std::endl;
|
||||||
while (oggData.read(oggBuffer)){
|
}
|
||||||
std::cerr << oggData.toPrettyString() << std::endl;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,20 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <vector>
|
||||||
#include <mist/dtsc.h>
|
#include <mist/dtsc.h>
|
||||||
#include <mist/ogg.h>
|
#include <mist/ogg.h>
|
||||||
#include <mist/config.h>
|
#include <mist/config.h>
|
||||||
#include <mist/json.h>
|
#include <mist/json.h>
|
||||||
|
|
||||||
namespace Converters{
|
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(){
|
int OGG2DTSC(){
|
||||||
std::string oggBuffer;
|
std::string oggBuffer;
|
||||||
OGG::Page oggPage;
|
OGG::Page oggPage;
|
||||||
|
@ -16,15 +24,51 @@ namespace Converters{
|
||||||
//Read all of std::cin to oggBuffer
|
//Read all of std::cin to oggBuffer
|
||||||
|
|
||||||
//while stream busy
|
//while stream busy
|
||||||
|
JSON::Value DTSCOut;
|
||||||
|
std::vector<oggTrack> trackData;
|
||||||
|
long long int lastTrackID = 1;
|
||||||
while (std::cin.good()){
|
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();
|
oggBuffer += std::cin.get();
|
||||||
}
|
}
|
||||||
//while OGG::page check functie{ read
|
//while OGG::page check functie{ read
|
||||||
while (oggPage.read(oggBuffer)){//reading ogg to string
|
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
|
//ogg page 2 DTSC packet
|
||||||
std::cout << oggPage.typeBOS();
|
//for elk segment
|
||||||
std::cout << "inner" << std::endl;
|
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;
|
//std::cout << "outer" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue