Smooth streaming fixed
This commit is contained in:
parent
c6172a96ff
commit
132aea4536
1 changed files with 12 additions and 14 deletions
|
@ -43,7 +43,11 @@ std::string toUTF16(std::string original) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Converts bytes per second and track ID into a single bits per second value, where the last two digits are the track ID.
|
||||||
|
/// Breaks for track IDs > 99. But really, this is MS-SS, so who cares..?
|
||||||
|
uint64_t bpsAndIdToBitrate(uint32_t bps, uint64_t tid){
|
||||||
|
return ((uint64_t)((bps*8)/100))*100+tid;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Mist {
|
namespace Mist {
|
||||||
OutHSS::OutHSS(Socket::Connection & conn) : HTTPOutput(conn){
|
OutHSS::OutHSS(Socket::Connection & conn) : HTTPOutput(conn){
|
||||||
|
@ -104,12 +108,12 @@ namespace Mist {
|
||||||
|
|
||||||
void OutHSS::sendHeader() {
|
void OutHSS::sendHeader() {
|
||||||
//We have a non-manifest request, parse it.
|
//We have a non-manifest request, parse it.
|
||||||
std::string Quality = H.url.substr(H.url.find("TrackID=", 8) + 8);
|
std::string Quality = H.url.substr(H.url.find("Q(", 2) + 2);
|
||||||
Quality = Quality.substr(0, Quality.find(")"));
|
Quality = Quality.substr(0, Quality.find(")"));
|
||||||
std::string parseString = H.url.substr(H.url.find(")/") + 2);
|
std::string parseString = H.url.substr(H.url.find(")/") + 2);
|
||||||
parseString = parseString.substr(parseString.find("(") + 1);
|
parseString = parseString.substr(parseString.find("(") + 1);
|
||||||
long long int seekTime = atoll(parseString.substr(0, parseString.find(")")).c_str()) / 10000;
|
long long int seekTime = atoll(parseString.substr(0, parseString.find(")")).c_str()) / 10000;
|
||||||
unsigned int tid = atoll(Quality.c_str());
|
unsigned int tid = atoll(Quality.c_str()) % 100;
|
||||||
selectedTracks.clear();
|
selectedTracks.clear();
|
||||||
selectedTracks.insert(tid);
|
selectedTracks.insert(tid);
|
||||||
if (myMeta.live) {
|
if (myMeta.live) {
|
||||||
|
@ -415,7 +419,7 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
DEBUG_MSG(DLVL_DONTEVEN, "Buffer window here %lld", myMeta.bufferWindow);
|
DEBUG_MSG(DLVL_DONTEVEN, "Buffer window here %lld", myMeta.bufferWindow);
|
||||||
if (myMeta.vod) {
|
if (myMeta.vod) {
|
||||||
Result << "Duration=\"" << (*videoIters.begin())->second.lastms << "0000\"";
|
Result << "Duration=\"" << ((*videoIters.begin())->second.lastms - (*videoIters.begin())->second.firstms) << "0000\"";
|
||||||
} else {
|
} else {
|
||||||
Result << "Duration=\"0\" "
|
Result << "Duration=\"0\" "
|
||||||
"IsLive=\"TRUE\" "
|
"IsLive=\"TRUE\" "
|
||||||
|
@ -433,12 +437,12 @@ namespace Mist {
|
||||||
"QualityLevels=\"" << audioIters.size() << "\" "
|
"QualityLevels=\"" << audioIters.size() << "\" "
|
||||||
"Name=\"audio\" "
|
"Name=\"audio\" "
|
||||||
"Chunks=\"" << (*audioIters.begin())->second.keys.size() << "\" "
|
"Chunks=\"" << (*audioIters.begin())->second.keys.size() << "\" "
|
||||||
"Url=\"Q({bitrate},{CustomAttributes})/A({start time})\">\n";
|
"Url=\"Q({bitrate})/A({start time})\">\n";
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (std::deque<std::map<unsigned int, DTSC::Track>::iterator>::iterator it = audioIters.begin(); it != audioIters.end(); it++) {
|
for (std::deque<std::map<unsigned int, DTSC::Track>::iterator>::iterator it = audioIters.begin(); it != audioIters.end(); it++) {
|
||||||
Result << "<QualityLevel "
|
Result << "<QualityLevel "
|
||||||
"Index=\"" << index << "\" "
|
"Index=\"" << index << "\" "
|
||||||
"Bitrate=\"" << (*it)->second.bps * 8 << "\" "
|
"Bitrate=\"" << bpsAndIdToBitrate((*it)->second.bps, (*it)->first) << "\" "
|
||||||
"CodecPrivateData=\"" << std::hex;
|
"CodecPrivateData=\"" << std::hex;
|
||||||
for (unsigned int i = 0; i < (*it)->second.init.size(); i++) {
|
for (unsigned int i = 0; i < (*it)->second.init.size(); i++) {
|
||||||
Result << std::setfill('0') << std::setw(2) << std::right << (int)(*it)->second.init[i];
|
Result << std::setfill('0') << std::setw(2) << std::right << (int)(*it)->second.init[i];
|
||||||
|
@ -450,9 +454,6 @@ namespace Mist {
|
||||||
"PacketSize=\"4\" "
|
"PacketSize=\"4\" "
|
||||||
"AudioTag=\"255\" "
|
"AudioTag=\"255\" "
|
||||||
"FourCC=\"AACL\" >\n";
|
"FourCC=\"AACL\" >\n";
|
||||||
Result << "<CustomAttributes>\n"
|
|
||||||
"<Attribute Name = \"TrackID\" Value = \"" << (*it)->first << "\" />"
|
|
||||||
"</CustomAttributes>";
|
|
||||||
Result << "</QualityLevel>\n";
|
Result << "</QualityLevel>\n";
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
@ -474,7 +475,7 @@ namespace Mist {
|
||||||
"QualityLevels=\"" << videoIters.size() << "\" "
|
"QualityLevels=\"" << videoIters.size() << "\" "
|
||||||
"Name=\"video\" "
|
"Name=\"video\" "
|
||||||
"Chunks=\"" << (*videoIters.begin())->second.keys.size() << "\" "
|
"Chunks=\"" << (*videoIters.begin())->second.keys.size() << "\" "
|
||||||
"Url=\"Q({bitrate},{CustomAttributes})/V({start time})\" "
|
"Url=\"Q({bitrate})/V({start time})\" "
|
||||||
"MaxWidth=\"" << maxWidth << "\" "
|
"MaxWidth=\"" << maxWidth << "\" "
|
||||||
"MaxHeight=\"" << maxHeight << "\" "
|
"MaxHeight=\"" << maxHeight << "\" "
|
||||||
"DisplayWidth=\"" << maxWidth << "\" "
|
"DisplayWidth=\"" << maxWidth << "\" "
|
||||||
|
@ -484,7 +485,7 @@ namespace Mist {
|
||||||
//Add video qualities
|
//Add video qualities
|
||||||
Result << "<QualityLevel "
|
Result << "<QualityLevel "
|
||||||
"Index=\"" << index << "\" "
|
"Index=\"" << index << "\" "
|
||||||
"Bitrate=\"" << (*it)->second.bps * 8 << "\" "
|
"Bitrate=\"" << bpsAndIdToBitrate((*it)->second.bps, (*it)->first) << "\" "
|
||||||
"CodecPrivateData=\"" << std::hex;
|
"CodecPrivateData=\"" << std::hex;
|
||||||
MP4::AVCC avccbox;
|
MP4::AVCC avccbox;
|
||||||
avccbox.setPayload((*it)->second.init);
|
avccbox.setPayload((*it)->second.init);
|
||||||
|
@ -496,9 +497,6 @@ namespace Mist {
|
||||||
"MaxWidth=\"" << (*it)->second.width << "\" "
|
"MaxWidth=\"" << (*it)->second.width << "\" "
|
||||||
"MaxHeight=\"" << (*it)->second.height << "\" "
|
"MaxHeight=\"" << (*it)->second.height << "\" "
|
||||||
"FourCC=\"AVC1\" >\n";
|
"FourCC=\"AVC1\" >\n";
|
||||||
Result << "<CustomAttributes>\n"
|
|
||||||
"<Attribute Name = \"TrackID\" Value = \"" << (*it)->first << "\" />"
|
|
||||||
"</CustomAttributes>";
|
|
||||||
Result << "</QualityLevel>\n";
|
Result << "</QualityLevel>\n";
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue