Working OGG and MP4

This commit is contained in:
Oswald Auguste de Bruin 2013-11-28 15:16:51 +01:00 committed by Thulinma
parent 4ad866cc61
commit 62f1e25e8b
5 changed files with 21 additions and 6 deletions

View file

@ -98,7 +98,7 @@ namespace Connector_HTTP {
HTTP_S.SetHeader("Content-Type", "video/MP4"); //Send the correct content-type for FLV files
HTTP_S.protocol = "HTTP/1.0";
conn.SendNow(HTTP_S.BuildResponse("200", "OK")); //no SetBody = unknown length - this is intentional, we will stream the entire file
conn.SendNow(Conv.DTSCMeta2MP4Header(Strm.metadata.toJSON()));//SENDING MP4HEADER
conn.SendNow(Conv.DTSCMeta2MP4Header(Strm.metadata));//SENDING MP4HEADER
keyPartIt = Conv.keyParts.begin();
{//using scope to have cmd not declared after action
std::stringstream cmd;

View file

@ -163,7 +163,7 @@ namespace Connector_HTTP {
HTTP_S.protocol = "HTTP/1.0";
conn.SendNow(HTTP_S.BuildResponse("200", "OK")); //no SetBody = unknown length - this is intentional, we will stream the entire file
//Fill in ogg header here
oggMeta.readDTSCHeader(Strm.metadata.toJSON());
oggMeta.readDTSCHeader(Strm.metadata);
conn.SendNow((char*)oggMeta.parsedPages.c_str(), oggMeta.parsedPages.size());
progressive_has_sent_header = true;
//setting sendReady to not ready

View file

@ -23,8 +23,12 @@ namespace Converters {
///\return The return code for the converter.
int DTSC2MP4(Util::Config & conf){
DTSC::File input(conf.getString("filename"));//DTSC input
//DTSC::readOnlyMeta fileMeta = input.getMeta();
DTSC::Meta giveMeta(input.getMeta());
MP4::DTSC2MP4Converter Conv;//DTSC to MP4 converter class will handle header creation and media parsing
std::cout << Conv.DTSCMeta2MP4Header(input.getMeta().toJSON());//Creating and outputting MP4 header from DTSC file
std::cout << Conv.DTSCMeta2MP4Header(giveMeta);//Creating and outputting MP4 header from DTSC file
//initialising JSON input
std::set<int> selector;
@ -40,11 +44,12 @@ namespace Converters {
while (input.getJSON()){//as long as the file goes
Conv.parseDTSC(input.getJSON());//parse 1 file DTSC packet
if(Conv.sendReady()){//if the converter has a part to send out
std::cout << Conv.sendString();//send out and clear Convverter buffer
std::cout << Conv.sendString();//send out and clear Converter buffer
}
input.seekNext();//get next DTSC packet
}
//output remaining buffer
std::cout << Conv.purgeBuffer();
return 0;
} //DTSC2MP4

View file

@ -20,7 +20,17 @@ namespace Converters{
char* curNewPayload;
OGG::headerPages oggMeta;
//Creating ID headers for theora and vorbis
oggMeta.readDTSCHeader(DTSCFile.getMeta().toJSON());
DTSC::readOnlyMeta fileMeta = DTSCFile.getMeta();
DTSC::Meta giveMeta;
for ( std::map<int,DTSC::readOnlyTrack>::iterator it = fileMeta.tracks.begin(); it != fileMeta.tracks.end(); it ++) {
std::cerr << "TrackID: " << it->first << std::endl;
giveMeta.tracks[it->first].trackID = fileMeta.tracks[it->first].trackID;
giveMeta.tracks[it->first].idHeader = fileMeta.tracks[it->first].idHeader;
giveMeta.tracks[it->first].init = fileMeta.tracks[it->first].init;
giveMeta.tracks[it->first].commentHeader = fileMeta.tracks[it->first].commentHeader;
}
oggMeta.readDTSCHeader(giveMeta);
std::cout << oggMeta.parsedPages;//outputting header pages
//create DTSC in OGG pages

View file

@ -89,7 +89,7 @@ namespace Converters{
if (trackData[sNum].codec == THEORA){
trackData[sNum].lastTime += (mspft / 4);
}else{
trackData[sNum].lastTime += (mspfv / 4);
trackData[sNum].lastTime += (mspfv / 16);
}
DTSCOut["data"] = std::string(oggPage.getFullPayload()+offset, (*it)); //segment content put in JSON
if (trackData[sNum].codec == THEORA){