Various updates
This commit is contained in:
parent
1452ccc179
commit
a7edacd720
4 changed files with 46 additions and 15 deletions
|
@ -173,11 +173,13 @@ int main(int argc, char** argv){
|
|||
lastTime = 0;
|
||||
break;
|
||||
}
|
||||
/*
|
||||
case 'f': { //frame-seek
|
||||
bool ret = source.seek_frame(JSON::Value(in_out.Received().get().substr(2)).asInt());
|
||||
lastTime = 0;
|
||||
break;
|
||||
}
|
||||
*/
|
||||
case 'p': { //play
|
||||
playing = -1;
|
||||
lastTime = 0;
|
||||
|
|
|
@ -43,6 +43,11 @@ namespace Connector_HTTP {
|
|||
|
||||
bool isMP3 = false;//Indicates whether the request is audio-only mp3.
|
||||
|
||||
std::string videoName;
|
||||
int videoID = -1;
|
||||
std::string audioName;
|
||||
int audioID = -1;
|
||||
|
||||
while (conn.connected()){
|
||||
//Only attempt to parse input when not yet init'ed.
|
||||
if ( !inited){
|
||||
|
@ -123,19 +128,36 @@ namespace Connector_HTTP {
|
|||
}
|
||||
}
|
||||
int byterate = 0;
|
||||
if (Strm.metadata.isMember("video") && !isMP3){
|
||||
byterate += Strm.metadata["video"]["bps"].asInt();
|
||||
for (JSON::ObjIter objIt = Strm.metadata["tracks"].ObjBegin(); objIt != Strm.metadata["tracks"].ObjEnd(); objIt++){
|
||||
if (videoID == -1 && objIt->second["type"].asString() == "video"){
|
||||
videoID = objIt->second["trackid"].asInt();
|
||||
videoName = objIt->first;
|
||||
}
|
||||
if (Strm.metadata.isMember("audio")){
|
||||
byterate += Strm.metadata["audio"]["bps"].asInt();
|
||||
if (audioID == -1 && objIt->second["type"].asString() == "audio"){
|
||||
audioID = objIt->second["trackid"].asInt();
|
||||
audioName = objIt->first;
|
||||
}
|
||||
}
|
||||
if (videoID != -1 && !isMP3){
|
||||
byterate += Strm.metadata["tracks"][videoName]["bps"].asInt();
|
||||
}
|
||||
if (audioID != -1){
|
||||
byterate += Strm.metadata["tracks"][audioName]["bps"].asInt();
|
||||
}
|
||||
seek_sec = (seek_byte / byterate) * 1000;
|
||||
}
|
||||
if (seek_sec){
|
||||
std::stringstream cmd;
|
||||
cmd << "t";
|
||||
if (videoID != -1){
|
||||
cmd << " " << videoID;
|
||||
}
|
||||
if (audioID != -1){
|
||||
cmd << " " << audioID;
|
||||
}
|
||||
ss.SendNow(cmd.str().c_str());
|
||||
cmd.str() = "";
|
||||
cmd << "s " << seek_sec << "\n";
|
||||
ss.SendNow(cmd.str().c_str());
|
||||
}
|
||||
ss.SendNow("p\n");
|
||||
inited = true;
|
||||
}
|
||||
|
@ -144,6 +166,7 @@ namespace Connector_HTTP {
|
|||
lastStats = now;
|
||||
ss.SendNow(conn.getStats("HTTP_Progressive").c_str());
|
||||
}
|
||||
///\todo UPDATE THIS TO DTSCv2 too
|
||||
if (ss.spool()){
|
||||
while (Strm.parsePacket(ss.Received())){
|
||||
if ( !progressive_has_sent_header){
|
||||
|
@ -159,16 +182,16 @@ namespace Connector_HTTP {
|
|||
if ( !isMP3){
|
||||
conn.SendNow(FLV::Header, 13); //write FLV header
|
||||
//write metadata
|
||||
tag.DTSCMetaInit(Strm);
|
||||
tag.DTSCMetaInit(Strm,videoName, audioName);
|
||||
conn.SendNow(tag.data, tag.len);
|
||||
//write video init data, if needed
|
||||
if (Strm.metadata.isMember("video") && Strm.metadata["video"].isMember("init")){
|
||||
tag.DTSCVideoInit(Strm);
|
||||
if (videoID != -1 && Strm.metadata["video"].isMember("init")){
|
||||
tag.DTSCVideoInit(Strm.metadata["tracks"][videoName]);
|
||||
conn.SendNow(tag.data, tag.len);
|
||||
}
|
||||
//write audio init data, if needed
|
||||
if (Strm.metadata.isMember("audio") && Strm.metadata["audio"].isMember("init")){
|
||||
tag.DTSCAudioInit(Strm);
|
||||
if (audioID != -1 && Strm.metadata["audio"].isMember("init")){
|
||||
tag.DTSCAudioInit(Strm.metadata["tracks"][audioName]);
|
||||
conn.SendNow(tag.data, tag.len);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,10 +274,10 @@ namespace Connector_HTTP {
|
|||
//Seek to the right place and send a play-once for a single fragment.
|
||||
std::stringstream sstream;
|
||||
if (wantsVideo){
|
||||
sstream << "t " << allVideo.ObjBegin()->first << "\n";
|
||||
sstream << "t " << allVideo.ObjBegin()->second["trackid"].asInt() << "\n";
|
||||
}
|
||||
if (wantsAudio){
|
||||
sstream << "t " << allAudio.ObjBegin()->first << "\n";
|
||||
sstream << "t " << allAudio.ObjBegin()->second["trackid"].asInt() << "\n";
|
||||
}
|
||||
sstream << "s " << (requestedTime / 10000) << "\no \n";
|
||||
ss.SendNow(sstream.str().c_str());
|
||||
|
|
|
@ -61,7 +61,10 @@ namespace Converters {
|
|||
std::string currentID;
|
||||
int nextFreeID = 0;
|
||||
|
||||
std::set<int> tmp;
|
||||
|
||||
for (JSON::ObjIter it = meta["tracks"].ObjBegin(); it != meta["tracks"].ObjEnd(); it++){
|
||||
tmp.insert(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].trackID = it->second["trackid"].asInt();
|
||||
|
@ -70,6 +73,9 @@ namespace Converters {
|
|||
}
|
||||
}
|
||||
|
||||
F.selectTracks(tmp);
|
||||
F.seek_time(0);
|
||||
|
||||
F.seekNext();
|
||||
while ( !F.getJSON().isNull()){
|
||||
currentID = "";
|
||||
|
|
Loading…
Add table
Reference in a new issue