Made single bitrate files in DTSCv2 style work on HTTP Smooth.
This commit is contained in:
parent
48fad86c26
commit
46fed13161
3 changed files with 31 additions and 16 deletions
|
@ -75,9 +75,10 @@ namespace Connector_HTTP {
|
||||||
"Name=\"audio\" "
|
"Name=\"audio\" "
|
||||||
"Chunks=\"" << allAudio.ObjBegin()->second["keytime"].size() << "\" "
|
"Chunks=\"" << allAudio.ObjBegin()->second["keytime"].size() << "\" "
|
||||||
"Url=\"Q({bitrate})/A({start time})\">\n";
|
"Url=\"Q({bitrate})/A({start time})\">\n";
|
||||||
|
int index = 1;
|
||||||
for (JSON::ObjIter oIt = allAudio.ObjBegin(); oIt != allAudio.ObjEnd(); oIt++){
|
for (JSON::ObjIter oIt = allAudio.ObjBegin(); oIt != allAudio.ObjEnd(); oIt++){
|
||||||
Result << "<QualityLevel "
|
Result << "<QualityLevel "
|
||||||
"Index=\"" << oIt->second["trackid"].asInt() << "\" "
|
"Index=\"" << index << "\" "
|
||||||
"Bitrate=\"" << oIt->second["bps"].asInt() * 8 << "\" "
|
"Bitrate=\"" << oIt->second["bps"].asInt() * 8 << "\" "
|
||||||
"CodecPrivateData=\"" << std::hex;
|
"CodecPrivateData=\"" << std::hex;
|
||||||
for (int i = 0; i < oIt->second["init"].asString().size(); i++){
|
for (int i = 0; i < oIt->second["init"].asString().size(); i++){
|
||||||
|
@ -90,6 +91,7 @@ namespace Connector_HTTP {
|
||||||
"PacketSize=\"4\" "
|
"PacketSize=\"4\" "
|
||||||
"AudioTag=\"255\" "
|
"AudioTag=\"255\" "
|
||||||
"FourCC=\"AACL\" />\n";
|
"FourCC=\"AACL\" />\n";
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < allAudio.ObjBegin()->second["keylen"].size(); i++){
|
for (unsigned int i = 0; i < allAudio.ObjBegin()->second["keylen"].size(); i++){
|
||||||
Result << "<c ";
|
Result << "<c ";
|
||||||
|
@ -112,10 +114,11 @@ namespace Connector_HTTP {
|
||||||
"MaxHeight=\"" << maxHeight << "\" "
|
"MaxHeight=\"" << maxHeight << "\" "
|
||||||
"DisplayWidth=\"" << maxWidth << "\" "
|
"DisplayWidth=\"" << maxWidth << "\" "
|
||||||
"DisplayHeight=\"" << maxHeight << "\">\n";
|
"DisplayHeight=\"" << maxHeight << "\">\n";
|
||||||
|
int index = 1;
|
||||||
for (JSON::ObjIter oIt = allVideo.ObjBegin(); oIt != allVideo.ObjEnd(); oIt++){
|
for (JSON::ObjIter oIt = allVideo.ObjBegin(); oIt != allVideo.ObjEnd(); oIt++){
|
||||||
//Add video qualities
|
//Add video qualities
|
||||||
Result << "<QualityLevel "
|
Result << "<QualityLevel "
|
||||||
"Index=\"" << oIt->second["trackid"].asInt() << "\" "
|
"Index=\"" << index << "\" "
|
||||||
"Bitrate=\"" << oIt->second["bps"].asInt() * 8 << "\" "
|
"Bitrate=\"" << oIt->second["bps"].asInt() * 8 << "\" "
|
||||||
"CodecPrivateData=\"" << std::hex;
|
"CodecPrivateData=\"" << std::hex;
|
||||||
MP4::AVCC avccbox;
|
MP4::AVCC avccbox;
|
||||||
|
@ -128,6 +131,7 @@ namespace Connector_HTTP {
|
||||||
"MaxWidth=\"" << oIt->second["width"].asInt() << "\" "
|
"MaxWidth=\"" << oIt->second["width"].asInt() << "\" "
|
||||||
"MaxHeight=\"" << oIt->second["height"].asInt() << "\" "
|
"MaxHeight=\"" << oIt->second["height"].asInt() << "\" "
|
||||||
"FourCC=\"AVC1\" />\n";
|
"FourCC=\"AVC1\" />\n";
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < allVideo.ObjBegin()->second["keylen"].size(); i++){
|
for (unsigned int i = 0; i < allVideo.ObjBegin()->second["keylen"].size(); i++){
|
||||||
Result << "<c ";
|
Result << "<c ";
|
||||||
|
@ -273,11 +277,22 @@ namespace Connector_HTTP {
|
||||||
}
|
}
|
||||||
//Seek to the right place and send a play-once for a single fragment.
|
//Seek to the right place and send a play-once for a single fragment.
|
||||||
std::stringstream sstream;
|
std::stringstream sstream;
|
||||||
|
long long int selectedQuality = atoll(Quality.c_str()) / 8;
|
||||||
if (wantsVideo){
|
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){
|
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";
|
sstream << "s " << (requestedTime / 10000) << "\no \n";
|
||||||
ss.SendNow(sstream.str().c_str());
|
ss.SendNow(sstream.str().c_str());
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
namespace Converters {
|
namespace Converters {
|
||||||
class HeaderEntryDTSC {
|
class HeaderEntryDTSC {
|
||||||
public:
|
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 unsigned int totalSize;
|
||||||
long long int lastKeyTime;
|
long long int lastKeyTime;
|
||||||
long long int trackID;
|
long long int trackID;
|
||||||
|
@ -68,6 +68,7 @@ namespace Converters {
|
||||||
trackIDs.insert(std::pair<std::string,int>(it->first,it->second["trackid"].asInt()));
|
trackIDs.insert(std::pair<std::string,int>(it->first,it->second["trackid"].asInt()));
|
||||||
trackData[it->first].type = it->second["type"].asString();
|
trackData[it->first].type = it->second["type"].asString();
|
||||||
trackData[it->first].trackID = it->second["trackid"].asInt();
|
trackData[it->first].trackID = it->second["trackid"].asInt();
|
||||||
|
trackData[it->first].type = it->second["type"].asString();
|
||||||
if (it->second["trackid"].asInt() >= nextFreeID){
|
if (it->second["trackid"].asInt() >= nextFreeID){
|
||||||
nextFreeID = it->second["trackid"].asInt() + 1;
|
nextFreeID = it->second["trackid"].asInt() + 1;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +121,7 @@ namespace Converters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( currentID == "" ) {
|
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();
|
F.seekNext();
|
||||||
continue;
|
continue;
|
||||||
//should create new track but this shouldnt be needed...
|
//should create new track but this shouldnt be needed...
|
||||||
|
|
|
@ -117,23 +117,22 @@ namespace Converters {
|
||||||
outFile.writeHeader(tmpWrite,true);
|
outFile.writeHeader(tmpWrite,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::set<int> trackSelector;
|
||||||
for (std::multimap<int,keyframeInfo>::iterator sortIt = allSorted.begin(); sortIt != allSorted.end(); sortIt++){
|
for (std::multimap<int,keyframeInfo>::iterator sortIt = allSorted.begin(); sortIt != allSorted.end(); sortIt++){
|
||||||
inFiles[sortIt->second.fileName].seek_bpos(sortIt->second.keyBPos);
|
trackSelector.clear();
|
||||||
while (inFiles[sortIt->second.fileName].getBytePos() < sortIt->second.endBPos){
|
trackSelector.insert(sortIt->second.trackID);
|
||||||
JSON::Value translate = inFiles[sortIt->second.fileName].getJSON();
|
inFiles[sortIt->second.fileName].selectTracks(trackSelector);
|
||||||
if (translate["trackid"].asInt() == sortIt->second.trackID){
|
inFiles[sortIt->second.fileName].seek_time(sortIt->second.keyTime);
|
||||||
translate["trackid"] = trackMapping[sortIt->second.fileName][translate["trackid"].asInt()];
|
inFiles[sortIt->second.fileName].seekNext();
|
||||||
outFile.writePacket(translate);
|
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();
|
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();
|
std::string writeMeta = newMeta.toPacked();
|
||||||
meta["moreheader"] = outFile.addHeader(writeMeta);
|
meta["moreheader"] = outFile.addHeader(writeMeta);
|
||||||
fprintf(stderr, "Newheader (%d):\n%s\n", meta.toPacked().size(), meta.toPrettyString().c_str());
|
|
||||||
writeMeta = meta.toPacked();
|
writeMeta = meta.toPacked();
|
||||||
outFile.writeHeader(writeMeta);
|
outFile.writeHeader(writeMeta);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue