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

@ -75,9 +75,10 @@ namespace Connector_HTTP {
"Name=\"audio\" "
"Chunks=\"" << allAudio.ObjBegin()->second["keytime"].size() << "\" "
"Url=\"Q({bitrate})/A({start time})\">\n";
int index = 1;
for (JSON::ObjIter oIt = allAudio.ObjBegin(); oIt != allAudio.ObjEnd(); oIt++){
Result << "<QualityLevel "
"Index=\"" << oIt->second["trackid"].asInt() << "\" "
"Index=\"" << index << "\" "
"Bitrate=\"" << oIt->second["bps"].asInt() * 8 << "\" "
"CodecPrivateData=\"" << std::hex;
for (int i = 0; i < oIt->second["init"].asString().size(); i++){
@ -90,6 +91,7 @@ namespace Connector_HTTP {
"PacketSize=\"4\" "
"AudioTag=\"255\" "
"FourCC=\"AACL\" />\n";
index++;
}
for (unsigned int i = 0; i < allAudio.ObjBegin()->second["keylen"].size(); i++){
Result << "<c ";
@ -112,10 +114,11 @@ namespace Connector_HTTP {
"MaxHeight=\"" << maxHeight << "\" "
"DisplayWidth=\"" << maxWidth << "\" "
"DisplayHeight=\"" << maxHeight << "\">\n";
int index = 1;
for (JSON::ObjIter oIt = allVideo.ObjBegin(); oIt != allVideo.ObjEnd(); oIt++){
//Add video qualities
Result << "<QualityLevel "
"Index=\"" << oIt->second["trackid"].asInt() << "\" "
"Index=\"" << index << "\" "
"Bitrate=\"" << oIt->second["bps"].asInt() * 8 << "\" "
"CodecPrivateData=\"" << std::hex;
MP4::AVCC avccbox;
@ -128,6 +131,7 @@ namespace Connector_HTTP {
"MaxWidth=\"" << oIt->second["width"].asInt() << "\" "
"MaxHeight=\"" << oIt->second["height"].asInt() << "\" "
"FourCC=\"AVC1\" />\n";
index++;
}
for (unsigned int i = 0; i < allVideo.ObjBegin()->second["keylen"].size(); i++){
Result << "<c ";
@ -273,11 +277,22 @@ namespace Connector_HTTP {
}
//Seek to the right place and send a play-once for a single fragment.
std::stringstream sstream;
long long int selectedQuality = atoll(Quality.c_str()) / 8;
if (wantsVideo){
sstream << "t " << allVideo.ObjBegin()->second["trackid"].asInt() << "\n";
//Select the correct track ID
for (JSON::ObjIter vIt = allVideo.ObjBegin(); vIt != allVideo.ObjEnd(); vIt++){
if (vIt->second["bps"].asInt() == selectedQuality){
sstream << "t " << vIt->second["trackid"].asInt() << "\n";
}
}
}
if (wantsAudio){
sstream << "t " << allAudio.ObjBegin()->second["trackid"].asInt() << "\n";
//Select the correct track ID
for (JSON::ObjIter aIt = allAudio.ObjBegin(); aIt != allAudio.ObjEnd(); aIt++){
if (aIt->second["bps"].asInt() == selectedQuality){
sstream << "t " << aIt->second["trackid"].asInt() << "\n";
}
}
}
sstream << "s " << (requestedTime / 10000) << "\no \n";
ss.SendNow(sstream.str().c_str());

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);