Made single bitrate files in DTSCv2 style work on HTTP Smooth.

This commit is contained in:
Erik Zandvliet 2013-05-30 11:47:51 +02:00
parent 48fad86c26
commit 46fed13161
3 changed files with 31 additions and 16 deletions

View file

@ -10,7 +10,7 @@
namespace Converters {
class HeaderEntryDTSC {
public:
HeaderEntryDTSC() : totalSize(0), lastKeyTime(-1000), trackID(0), firstms(-1), lastms(0), keynum(0) {}
HeaderEntryDTSC() : totalSize(0), lastKeyTime(-5000), trackID(0), firstms(-1), lastms(0), keynum(0) {}
long long unsigned int totalSize;
long long int lastKeyTime;
long long int trackID;
@ -68,6 +68,7 @@ namespace Converters {
trackIDs.insert(std::pair<std::string,int>(it->first,it->second["trackid"].asInt()));
trackData[it->first].type = it->second["type"].asString();
trackData[it->first].trackID = it->second["trackid"].asInt();
trackData[it->first].type = it->second["type"].asString();
if (it->second["trackid"].asInt() >= nextFreeID){
nextFreeID = it->second["trackid"].asInt() + 1;
}
@ -120,7 +121,7 @@ namespace Converters {
}
}
if( currentID == "" ) {
fprintf(stderr, "Found a v2 packet with id %d\n", F.getJSON()["trackid"].asInt());
fprintf(stderr, "Found an unknown v2 packet with id %d\n", F.getJSON()["trackid"].asInt());
F.seekNext();
continue;
//should create new track but this shouldnt be needed...

View file

@ -117,23 +117,22 @@ namespace Converters {
outFile.writeHeader(tmpWrite,true);
}
std::set<int> trackSelector;
for (std::multimap<int,keyframeInfo>::iterator sortIt = allSorted.begin(); sortIt != allSorted.end(); sortIt++){
inFiles[sortIt->second.fileName].seek_bpos(sortIt->second.keyBPos);
while (inFiles[sortIt->second.fileName].getBytePos() < sortIt->second.endBPos){
JSON::Value translate = inFiles[sortIt->second.fileName].getJSON();
if (translate["trackid"].asInt() == sortIt->second.trackID){
translate["trackid"] = trackMapping[sortIt->second.fileName][translate["trackid"].asInt()];
outFile.writePacket(translate);
}
trackSelector.clear();
trackSelector.insert(sortIt->second.trackID);
inFiles[sortIt->second.fileName].selectTracks(trackSelector);
inFiles[sortIt->second.fileName].seek_time(sortIt->second.keyTime);
inFiles[sortIt->second.fileName].seekNext();
while (inFiles[sortIt->second.fileName].getJSON() && inFiles[sortIt->second.fileName].getBytePos() < sortIt->second.endBPos && !inFiles[sortIt->second.fileName].reachedEOF()){
inFiles[sortIt->second.fileName].getJSON()["trackid"] = trackMapping[sortIt->second.fileName][inFiles[sortIt->second.fileName].getJSON()["trackid"].asInt()];
outFile.writePacket(inFiles[sortIt->second.fileName].getJSON());
inFiles[sortIt->second.fileName].seekNext();
}
}
fprintf(stderr, "%s\n", newMeta.toPrettyString().c_str());
fprintf(stderr, "Oldheader (%d):\n%s\n", meta.toPacked().size(), meta.toPrettyString().c_str());
std::string writeMeta = newMeta.toPacked();
meta["moreheader"] = outFile.addHeader(writeMeta);
fprintf(stderr, "Newheader (%d):\n%s\n", meta.toPacked().size(), meta.toPrettyString().c_str());
writeMeta = meta.toPacked();
outFile.writeHeader(writeMeta);