Fixed data inspection for progressive connectors.

This commit is contained in:
Erik Zandvliet 2013-08-23 14:33:37 +02:00 committed by Thulinma
parent 9540273f19
commit 4f96d6ddef
3 changed files with 26 additions and 17 deletions

View file

@ -74,8 +74,10 @@ namespace Connector_HTTP {
//under 3 hours we assume seconds, otherwise byte position //under 3 hours we assume seconds, otherwise byte position
if (start < 10800){ if (start < 10800){
seek_sec = start * 1000; //ms, not s seek_sec = start * 1000; //ms, not s
seek_byte = 0;
}else{ }else{
seek_byte = start; //divide by 1mbit, then *1000 for ms. seek_byte = start; //divide by 1mbit, then *1000 for ms.
seek_sec = 0;
} }
ready4data = true; ready4data = true;
HTTP_R.Clean(); //clean for any possible next requests HTTP_R.Clean(); //clean for any possible next requests
@ -158,8 +160,16 @@ namespace Connector_HTTP {
} }
progressive_has_sent_header = true; progressive_has_sent_header = true;
} }
tag.DTSCLoader(Strm); if (Strm.lastType() == DTSC::PAUSEMARK){
conn.SendNow(tag.data, tag.len); //write the tag contents conn.close();
}
if (Strm.lastType() == DTSC::AUDIO || Strm.lastType() == DTSC::VIDEO){
std::string codec = Strm.getTrackById(Strm.getPacket()["trackid"].asInt())["codec"].asString();
if (codec == "AAC" || codec == "MP3" || codec == "H264"){
tag.DTSCLoader(Strm);
conn.SendNow(tag.data, tag.len); //write the tag contents
}
}
} }
}else{ }else{
Util::sleep(1); Util::sleep(1);

View file

@ -40,7 +40,6 @@ namespace Connector_HTTP {
unsigned int seek_sec = 0;//Seek position in ms unsigned int seek_sec = 0;//Seek position in ms
unsigned int seek_byte = 0;//Seek position in bytes unsigned int seek_byte = 0;//Seek position in bytes
int videoID = -1;
int audioID = -1; int audioID = -1;
while (conn.connected()){ while (conn.connected()){
@ -98,10 +97,7 @@ namespace Connector_HTTP {
Strm.waitForMeta(ss); Strm.waitForMeta(ss);
int byterate = 0; int byterate = 0;
for (JSON::ObjIter objIt = Strm.metadata["tracks"].ObjBegin(); objIt != Strm.metadata["tracks"].ObjEnd(); objIt++){ for (JSON::ObjIter objIt = Strm.metadata["tracks"].ObjBegin(); objIt != Strm.metadata["tracks"].ObjEnd(); objIt++){
if (videoID == -1 && objIt->second["type"].asString() == "video"){ if (audioID == -1 && objIt->second["codec"].asString() == "MP3"){
videoID = objIt->second["trackid"].asInt();
}
if (audioID == -1 && objIt->second["type"].asString() == "audio"){
audioID = objIt->second["trackid"].asInt(); audioID = objIt->second["trackid"].asInt();
} }
} }
@ -114,9 +110,6 @@ namespace Connector_HTTP {
} }
std::stringstream cmd; std::stringstream cmd;
cmd << "t"; cmd << "t";
if (videoID != -1){
cmd << " " << videoID;
}
if (audioID != -1){ if (audioID != -1){
cmd << " " << audioID; cmd << " " << audioID;
} }
@ -139,6 +132,9 @@ namespace Connector_HTTP {
conn.SendNow(HTTP_S.BuildResponse("200", "OK")); //no SetBody = unknown length - this is intentional, we will stream the entire file conn.SendNow(HTTP_S.BuildResponse("200", "OK")); //no SetBody = unknown length - this is intentional, we will stream the entire file
progressive_has_sent_header = true; progressive_has_sent_header = true;
} }
if(Strm.lastType() == DTSC::PAUSEMARK){
conn.close();
}
if(Strm.lastType() == DTSC::AUDIO){ if(Strm.lastType() == DTSC::AUDIO){
conn.SendNow(Strm.lastData()); //write the MP3 contents conn.SendNow(Strm.lastData()); //write the MP3 contents
} }

View file

@ -46,8 +46,6 @@ namespace Connector_HTTP {
unsigned int seek_sec = 0;//Seek position in ms unsigned int seek_sec = 0;//Seek position in ms
unsigned int seek_byte = 0;//Seek position in bytes unsigned int seek_byte = 0;//Seek position in bytes
bool isMP3 = false;//Indicates whether the request is audio-only mp3.
int videoID = -1; int videoID = -1;
int audioID = -1; int audioID = -1;
@ -106,10 +104,10 @@ namespace Connector_HTTP {
Strm.waitForMeta(ss); Strm.waitForMeta(ss);
int byterate = 0; int byterate = 0;
for (JSON::ObjIter objIt = Strm.metadata["tracks"].ObjBegin(); objIt != Strm.metadata["tracks"].ObjEnd(); objIt++){ for (JSON::ObjIter objIt = Strm.metadata["tracks"].ObjBegin(); objIt != Strm.metadata["tracks"].ObjEnd(); objIt++){
if (videoID == -1 && objIt->second["type"].asString() == "video"){ if (videoID == -1 && objIt->second["codec"].asString() == "THEORA"){
videoID = objIt->second["trackid"].asInt(); videoID = objIt->second["trackid"].asInt();
} }
if (audioID == -1 && objIt->second["type"].asString() == "audio"){ if (audioID == -1 && objIt->second["codec"].asString() == "VORBIS"){
audioID = objIt->second["trackid"].asInt(); audioID = objIt->second["trackid"].asInt();
} }
} }
@ -160,9 +158,14 @@ namespace Connector_HTTP {
conn.SendNow((char*)curOggPage.getPage(), curOggPage.getPageSize()); conn.SendNow((char*)curOggPage.getPage(), curOggPage.getPageSize());
DTSCBuffer[temp].clear(); DTSCBuffer[temp].clear();
} }
//long long unsigned int prevID = Strm.getPacket()["trackid"].asInt(); if (Strm.lastType() == DTSC::PAUSEMARK){
DTSCBuffer[temp].push_back(Strm.getPacket()); conn.close();
prevGran[temp] = Strm.getPacket()["granule"].asInt(); }
if (Strm.lastType() == DTSC::AUDIO || Strm.lastType() == DTSC::VIDEO){
//long long unsigned int prevID = Strm.getPacket()["trackid"].asInt();
DTSCBuffer[temp].push_back(Strm.getPacket());
prevGran[temp] = Strm.getPacket()["granule"].asInt();
}
} }
}else{ }else{
Util::sleep(1); Util::sleep(1);