Various updates

This commit is contained in:
Erik Zandvliet 2013-05-27 13:47:44 +02:00
parent 1452ccc179
commit a7edacd720
4 changed files with 46 additions and 15 deletions

View file

@ -173,11 +173,13 @@ int main(int argc, char** argv){
lastTime = 0; lastTime = 0;
break; break;
} }
/*
case 'f': { //frame-seek case 'f': { //frame-seek
bool ret = source.seek_frame(JSON::Value(in_out.Received().get().substr(2)).asInt()); bool ret = source.seek_frame(JSON::Value(in_out.Received().get().substr(2)).asInt());
lastTime = 0; lastTime = 0;
break; break;
} }
*/
case 'p': { //play case 'p': { //play
playing = -1; playing = -1;
lastTime = 0; lastTime = 0;

View file

@ -42,6 +42,11 @@ namespace Connector_HTTP {
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. 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()){ while (conn.connected()){
//Only attempt to parse input when not yet init'ed. //Only attempt to parse input when not yet init'ed.
@ -123,19 +128,36 @@ namespace Connector_HTTP {
} }
} }
int byterate = 0; int byterate = 0;
if (Strm.metadata.isMember("video") && !isMP3){ for (JSON::ObjIter objIt = Strm.metadata["tracks"].ObjBegin(); objIt != Strm.metadata["tracks"].ObjEnd(); objIt++){
byterate += Strm.metadata["video"]["bps"].asInt(); if (videoID == -1 && objIt->second["type"].asString() == "video"){
videoID = objIt->second["trackid"].asInt();
videoName = objIt->first;
}
if (audioID == -1 && objIt->second["type"].asString() == "audio"){
audioID = objIt->second["trackid"].asInt();
audioName = objIt->first;
}
} }
if (Strm.metadata.isMember("audio")){ if (videoID != -1 && !isMP3){
byterate += Strm.metadata["audio"]["bps"].asInt(); byterate += Strm.metadata["tracks"][videoName]["bps"].asInt();
}
if (audioID != -1){
byterate += Strm.metadata["tracks"][audioName]["bps"].asInt();
} }
seek_sec = (seek_byte / byterate) * 1000; seek_sec = (seek_byte / byterate) * 1000;
} }
if (seek_sec){ std::stringstream cmd;
std::stringstream cmd; cmd << "t";
cmd << "s " << seek_sec << "\n"; if (videoID != -1){
ss.SendNow(cmd.str().c_str()); 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"); ss.SendNow("p\n");
inited = true; inited = true;
} }
@ -144,6 +166,7 @@ namespace Connector_HTTP {
lastStats = now; lastStats = now;
ss.SendNow(conn.getStats("HTTP_Progressive").c_str()); ss.SendNow(conn.getStats("HTTP_Progressive").c_str());
} }
///\todo UPDATE THIS TO DTSCv2 too
if (ss.spool()){ if (ss.spool()){
while (Strm.parsePacket(ss.Received())){ while (Strm.parsePacket(ss.Received())){
if ( !progressive_has_sent_header){ if ( !progressive_has_sent_header){
@ -159,16 +182,16 @@ namespace Connector_HTTP {
if ( !isMP3){ if ( !isMP3){
conn.SendNow(FLV::Header, 13); //write FLV header conn.SendNow(FLV::Header, 13); //write FLV header
//write metadata //write metadata
tag.DTSCMetaInit(Strm); tag.DTSCMetaInit(Strm,videoName, audioName);
conn.SendNow(tag.data, tag.len); conn.SendNow(tag.data, tag.len);
//write video init data, if needed //write video init data, if needed
if (Strm.metadata.isMember("video") && Strm.metadata["video"].isMember("init")){ if (videoID != -1 && Strm.metadata["video"].isMember("init")){
tag.DTSCVideoInit(Strm); tag.DTSCVideoInit(Strm.metadata["tracks"][videoName]);
conn.SendNow(tag.data, tag.len); conn.SendNow(tag.data, tag.len);
} }
//write audio init data, if needed //write audio init data, if needed
if (Strm.metadata.isMember("audio") && Strm.metadata["audio"].isMember("init")){ if (audioID != -1 && Strm.metadata["audio"].isMember("init")){
tag.DTSCAudioInit(Strm); tag.DTSCAudioInit(Strm.metadata["tracks"][audioName]);
conn.SendNow(tag.data, tag.len); conn.SendNow(tag.data, tag.len);
} }
} }

View file

@ -274,10 +274,10 @@ namespace Connector_HTTP {
//Seek to the right place and send a play-once for a single fragment. //Seek to the right place and send a play-once for a single fragment.
std::stringstream sstream; std::stringstream sstream;
if (wantsVideo){ if (wantsVideo){
sstream << "t " << allVideo.ObjBegin()->first << "\n"; sstream << "t " << allVideo.ObjBegin()->second["trackid"].asInt() << "\n";
} }
if (wantsAudio){ if (wantsAudio){
sstream << "t " << allAudio.ObjBegin()->first << "\n"; sstream << "t " << allAudio.ObjBegin()->second["trackid"].asInt() << "\n";
} }
sstream << "s " << (requestedTime / 10000) << "\no \n"; sstream << "s " << (requestedTime / 10000) << "\no \n";
ss.SendNow(sstream.str().c_str()); ss.SendNow(sstream.str().c_str());

View file

@ -61,7 +61,10 @@ namespace Converters {
std::string currentID; std::string currentID;
int nextFreeID = 0; int nextFreeID = 0;
std::set<int> tmp;
for (JSON::ObjIter it = meta["tracks"].ObjBegin(); it != meta["tracks"].ObjEnd(); it++){ 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())); trackIDs.insert(std::pair<std::string,int>(it->first,it->second["trackid"].asInt()));
trackData[it->first].type = it->second["type"].asString(); trackData[it->first].type = it->second["type"].asString();
trackData[it->first].trackID = it->second["trackid"].asInt(); trackData[it->first].trackID = it->second["trackid"].asInt();
@ -70,6 +73,9 @@ namespace Converters {
} }
} }
F.selectTracks(tmp);
F.seek_time(0);
F.seekNext(); F.seekNext();
while ( !F.getJSON().isNull()){ while ( !F.getJSON().isNull()){
currentID = ""; currentID = "";