Updated MistConnHTTPSmooth to output a proper Manifest for DTSCv2 files.
This commit is contained in:
parent
e0cbbae6a2
commit
073a80e079
2 changed files with 74 additions and 49 deletions
|
@ -152,10 +152,13 @@ int main(int argc, char** argv){
|
||||||
json_sts["vod"]["start"] = Util::epoch() - sts.conntime;
|
json_sts["vod"]["start"] = Util::epoch() - sts.conntime;
|
||||||
if ( !meta_sent){
|
if ( !meta_sent){
|
||||||
json_sts["vod"]["meta"] = meta;
|
json_sts["vod"]["meta"] = meta;
|
||||||
json_sts["vod"]["meta"]["audio"].removeMember("init");
|
for (JSON::ObjIter oIt = json_sts["vod"]["meta"]["tracks"].ObjBegin(); oIt != json_sts["vod"]["meta"]["tracks"].ObjEnd(); oIt++){
|
||||||
json_sts["vod"]["meta"]["video"].removeMember("init");
|
oIt->second.removeMember("init");
|
||||||
json_sts["vod"]["meta"].removeMember("keytime");
|
oIt->second.removeMember("keytime");
|
||||||
json_sts["vod"]["meta"].removeMember("keybpos");
|
oIt->second.removeMember("keybpos");
|
||||||
|
oIt->second.removeMember("keynum");
|
||||||
|
oIt->second.removeMember("frags");
|
||||||
|
}
|
||||||
meta_sent = true;
|
meta_sent = true;
|
||||||
}
|
}
|
||||||
StatsSocket.Send(json_sts.toString().c_str());
|
StatsSocket.Send(json_sts.toString().c_str());
|
||||||
|
@ -226,7 +229,7 @@ int main(int argc, char** argv){
|
||||||
}else{
|
}else{
|
||||||
lasttime = Util::epoch();
|
lasttime = Util::epoch();
|
||||||
//insert proper header for this type of data
|
//insert proper header for this type of data
|
||||||
in_out.Send("DTPD");
|
in_out.Send("DTP2");
|
||||||
//insert the packet length
|
//insert the packet length
|
||||||
unsigned int size = htonl(source.getPacket().size());
|
unsigned int size = htonl(source.getPacket().size());
|
||||||
in_out.Send((char*) &size, 4);
|
in_out.Send((char*) &size, 4);
|
||||||
|
|
|
@ -48,71 +48,93 @@ namespace Connector_HTTP {
|
||||||
"CanPause=\"TRUE\" ";
|
"CanPause=\"TRUE\" ";
|
||||||
}
|
}
|
||||||
Result << ">\n";
|
Result << ">\n";
|
||||||
|
JSON::Value allAudio;
|
||||||
|
JSON::Value allVideo;
|
||||||
|
long long int maxWidth = 0;
|
||||||
|
long long int maxHeight = 0;
|
||||||
|
long long int minWidth = 99999999;
|
||||||
|
long long int minHeight = 99999999;
|
||||||
|
for (JSON::ObjIter oIt = metadata["tracks"].ObjBegin(); oIt != metadata["tracks"].ObjEnd(); oIt++){
|
||||||
|
if (oIt->second["type"].asString() == "audio"){
|
||||||
|
allAudio[oIt->first] = oIt->second;
|
||||||
|
}
|
||||||
|
if (oIt->second["type"].asString() == "video"){
|
||||||
|
allVideo[oIt->first] = oIt->second;
|
||||||
|
if (oIt->second["width"].asInt() > maxWidth){ maxWidth = oIt->second["width"].asInt(); }
|
||||||
|
if (oIt->second["width"].asInt() < minWidth){ minWidth = oIt->second["width"].asInt(); }
|
||||||
|
if (oIt->second["height"].asInt() > maxHeight){ maxHeight = oIt->second["height"].asInt(); }
|
||||||
|
if (oIt->second["height"].asInt() < minHeight){ minHeight = oIt->second["height"].asInt(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Add audio entries
|
//Add audio entries
|
||||||
if (metadata.isMember("audio") && metadata["audio"]["codec"].asString() == "AAC"){
|
if (allAudio.size()){
|
||||||
Result << "<StreamIndex "
|
Result << "<StreamIndex "
|
||||||
"Type=\"audio\" "
|
"Type=\"audio\" "
|
||||||
"QualityLevels=\"1\" "
|
"QualityLevels=\"" << allAudio.size() << "\" "
|
||||||
"Name=\"audio\" "
|
"Name=\"audio\" "
|
||||||
"Chunks=\"" << metadata["keytime"].size() << "\" "
|
"Chunks=\"" << allAudio.ObjBegin()->second["keytime"].size() << "\" "
|
||||||
"Url=\"Q({bitrate})/A({start time})\">\n";
|
"Url=\"Q({bitrate})/A({start time})\">\n";
|
||||||
//Add audio qualities
|
for (JSON::ObjIter oIt = allAudio.ObjBegin(); oIt != allAudio.ObjEnd(); oIt++){
|
||||||
Result << "<QualityLevel "
|
Result << "<QualityLevel "
|
||||||
"Index=\"0\" "
|
"Index=\"" << oIt->second["trackid"].asInt() << "\" "
|
||||||
"Bitrate=\"" << metadata["audio"]["bps"].asInt() * 8 << "\" "
|
"Bitrate=\"" << oIt->second["bps"].asInt() * 8 << "\" "
|
||||||
"CodecPrivateData=\"" << std::hex;
|
"CodecPrivateData=\"" << std::hex;
|
||||||
for (int i = 0; i < metadata["audio"]["init"].asString().size(); i++){
|
for (int i = 0; i < oIt->second["init"].asString().size(); i++){
|
||||||
Result << std::setfill('0') << std::setw(2) << std::right << (int)metadata["audio"]["init"].asString()[i];
|
Result << std::setfill('0') << std::setw(2) << std::right << (int)oIt->second["init"].asString()[i];
|
||||||
}
|
}
|
||||||
Result << std::dec << "\" "
|
Result << std::dec << "\" "
|
||||||
"SamplingRate=\"" << metadata["audio"]["rate"].asInt() << "\" "
|
"SamplingRate=\"" << oIt->second["rate"].asInt() << "\" "
|
||||||
"Channels=\"2\" "
|
"Channels=\"2\" "
|
||||||
"BitsPerSample=\"16\" "
|
"BitsPerSample=\"16\" "
|
||||||
"PacketSize=\"4\" "
|
"PacketSize=\"4\" "
|
||||||
"AudioTag=\"255\" "
|
"AudioTag=\"255\" "
|
||||||
"FourCC=\"AACL\" />\n";
|
"FourCC=\"AACL\" />\n";
|
||||||
for (unsigned int i = 0; i < metadata["keylen"].size(); i++){
|
}
|
||||||
|
for (unsigned int i = 0; i < allAudio.ObjBegin()->second["keylen"].size(); i++){
|
||||||
Result << "<c ";
|
Result << "<c ";
|
||||||
if (i == 0){
|
if (i == 0){
|
||||||
Result << "t=\"" << metadata["keytime"][i].asInt() * 10000 << "\" ";
|
Result << "t=\"" << allAudio.ObjBegin()->second["keytime"][i].asInt() * 10000 << "\" ";
|
||||||
}
|
}
|
||||||
Result << "d=\"" << metadata["keylen"][i].asInt() * 10000 << "\" />\n";
|
Result << "d=\"" << allAudio.ObjBegin()->second["keylen"][i].asInt() * 10000 << "\" />\n";
|
||||||
}
|
}
|
||||||
Result << "</StreamIndex>\n";
|
Result << "</StreamIndex>\n";
|
||||||
}
|
}
|
||||||
//Add video entries
|
//Add video entries
|
||||||
if (metadata.isMember("video") && metadata["video"]["codec"].asString() == "H264"){
|
if (allVideo.size()){
|
||||||
Result << "<StreamIndex "
|
Result << "<StreamIndex "
|
||||||
"Type=\"video\" "
|
"Type=\"video\" "
|
||||||
"QualityLevels=\"1\" "
|
"QualityLevels=\"" << allVideo.size() << "\" "
|
||||||
"Name=\"video\" "
|
"Name=\"video\" "
|
||||||
"Chunks=\"" << metadata["keytime"].size() << "\" "
|
"Chunks=\"" << allVideo.ObjBegin()->second["keytime"].size() << "\" "
|
||||||
"Url=\"Q({bitrate})/V({start time})\" "
|
"Url=\"Q({bitrate})/V({start time})\" "
|
||||||
"MaxWidth=\"" << metadata["video"]["width"].asInt() << "\" "
|
"MaxWidth=\"" << maxWidth << "\" "
|
||||||
"MaxHeight=\"" << metadata["video"]["height"].asInt() << "\" "
|
"MaxHeight=\"" << maxHeight << "\" "
|
||||||
"DisplayWidth=\"" << metadata["video"]["width"].asInt() << "\" "
|
"DisplayWidth=\"" << maxWidth << "\" "
|
||||||
"DisplayHeight=\"" << metadata["video"]["height"].asInt() << "\">\n";
|
"DisplayHeight=\"" << maxHeight << "\">\n";
|
||||||
|
for (JSON::ObjIter oIt = allVideo.ObjBegin(); oIt != allVideo.ObjEnd(); oIt++){
|
||||||
//Add video qualities
|
//Add video qualities
|
||||||
Result << "<QualityLevel "
|
Result << "<QualityLevel "
|
||||||
"Index=\"0\" "
|
"Index=\"" << oIt->second["trackid"].asInt() << "\" "
|
||||||
"Bitrate=\"" << metadata["video"]["bps"].asInt() * 8 << "\" "
|
"Bitrate=\"" << oIt->second["bps"].asInt() * 8 << "\" "
|
||||||
"CodecPrivateData=\"" << std::hex;
|
"CodecPrivateData=\"" << std::hex;
|
||||||
MP4::AVCC avccbox;
|
MP4::AVCC avccbox;
|
||||||
avccbox.setPayload(metadata["video"]["init"].asString());
|
avccbox.setPayload(oIt->second["init"].asString());
|
||||||
std::string tmpString = avccbox.asAnnexB();
|
std::string tmpString = avccbox.asAnnexB();
|
||||||
for (int i = 0; i < tmpString.size(); i++){
|
for (int i = 0; i < tmpString.size(); i++){
|
||||||
Result << std::setfill('0') << std::setw(2) << std::right << (int)tmpString[i];
|
Result << std::setfill('0') << std::setw(2) << std::right << (int)tmpString[i];
|
||||||
}
|
}
|
||||||
Result << std::dec << "\" "
|
Result << std::dec << "\" "
|
||||||
"MaxWidth=\"" << metadata["video"]["width"].asInt() << "\" "
|
"MaxWidth=\"" << oIt->second["width"].asInt() << "\" "
|
||||||
"MaxHeight=\"" << metadata["video"]["height"].asInt() << "\" "
|
"MaxHeight=\"" << oIt->second["height"].asInt() << "\" "
|
||||||
"FourCC=\"AVC1\" />\n";
|
"FourCC=\"AVC1\" />\n";
|
||||||
for (unsigned int i = 0; i < metadata["keylen"].size(); i++){
|
}
|
||||||
|
for (unsigned int i = 0; i < allVideo.ObjBegin()->second["keylen"].size(); i++){
|
||||||
Result << "<c ";
|
Result << "<c ";
|
||||||
if (i == 0){
|
if (i == 0){
|
||||||
Result << "t=\"" << metadata["keytime"][i].asInt() * 10000 << "\" ";
|
Result << "t=\"" << allVideo.ObjBegin()->second["keytime"][i].asInt() * 10000 << "\" ";
|
||||||
}
|
}
|
||||||
Result << "d=\"" << metadata["keylen"][i].asInt() * 10000 << "\" />\n";
|
Result << "d=\"" << allVideo.ObjBegin()->second["keylen"][i].asInt() * 10000 << "\" />\n";
|
||||||
}
|
}
|
||||||
Result << "</StreamIndex>\n";
|
Result << "</StreamIndex>\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue