HLS now sends unique session IDs for splitting sessions from each other.

This commit is contained in:
Thulinma 2016-04-22 14:06:03 +02:00
parent b6d879369f
commit dbe2b1f661
3 changed files with 11 additions and 6 deletions

View file

@ -31,7 +31,7 @@ namespace Mist {
if (audioId != -1) { if (audioId != -1) {
result << "_" << audioId; result << "_" << audioId;
} }
result << "/index.m3u8\r\n"; result << "/index.m3u8?sessId=" << getpid() << "\r\n";
} }
} }
if (!vidTracks && audioId) { if (!vidTracks && audioId) {
@ -134,7 +134,7 @@ namespace Mist {
} }
std::string OutHLS::liveIndex(int tid) { std::string OutHLS::liveIndex(int tid, std::string & sessId) {
updateMeta(); updateMeta();
std::stringstream result; std::stringstream result;
//parse single track //parse single track
@ -161,7 +161,11 @@ namespace Mist {
duration = myMeta.tracks[tid].lastms - starttime; duration = myMeta.tracks[tid].lastms - starttime;
} }
char lineBuf[400]; char lineBuf[400];
snprintf(lineBuf, 400, "#EXTINF:%lld, no desc\r\n%lld_%lld,ts\r\n", ((duration + 500) / 1000), starttime, starttime + duration); if (sessId.size()){
snprintf(lineBuf, 400, "#EXTINF:%lld, no desc\r\n%lld_%lld.ts?sessId=%s\r\n", ((duration + 500) / 1000), starttime, starttime + duration, sessId.c_str());
}else{
snprintf(lineBuf, 400, "#EXTINF:%lld, no desc\r\n%lld_%lld.ts\r\n", ((duration + 500) / 1000), starttime, starttime + duration);
}
lines.push_back(lineBuf); lines.push_back(lineBuf);
} }
unsigned int skippedLines = 0; unsigned int skippedLines = 0;
@ -311,6 +315,7 @@ namespace Mist {
void OutHLS::onHTTP() { void OutHLS::onHTTP() {
std::string method = H.method; std::string method = H.method;
std::string sessId = H.GetVar("sessId");
if (H.url == "/crossdomain.xml") { if (H.url == "/crossdomain.xml") {
H.Clean(); H.Clean();
@ -500,7 +505,7 @@ namespace Mist {
manifest = liveIndex(); manifest = liveIndex();
} else { } else {
int selectId = atoi(request.substr(0, request.find("/")).c_str()); int selectId = atoi(request.substr(0, request.find("/")).c_str());
manifest = liveIndex(selectId); manifest = liveIndex(selectId, sessId);
} }
H.SetBody(manifest); H.SetBody(manifest);
H.SendResponse("200", "OK", myConn); H.SendResponse("200", "OK", myConn);

View file

@ -11,7 +11,7 @@ namespace Mist {
void onHTTP(); void onHTTP();
protected: protected:
std::string liveIndex(); std::string liveIndex();
std::string liveIndex(int tid); std::string liveIndex(int tid, std::string & sessId);
std::string pushLiveIndex(); std::string pushLiveIndex();

View file

@ -211,7 +211,7 @@ namespace Mist {
void HTTPOutput::onRequest(){ void HTTPOutput::onRequest(){
while (H.Read(myConn)){ while (H.Read(myConn)){
std::string ua = H.GetHeader("User-Agent") + H.GetHeader("X-Playback-Session-Id"); std::string ua = H.GetHeader("User-Agent") + H.GetHeader("X-Playback-Session-Id") + H.GetVar("sessId");
crc = checksum::crc32(0, ua.data(), ua.size()); crc = checksum::crc32(0, ua.data(), ua.size());
INFO_MSG("Received request %s", H.getUrl().c_str()); INFO_MSG("Received request %s", H.getUrl().c_str());
selectedTracks.clear(); selectedTracks.clear();