Updated for selecting tracks.
This commit is contained in:
parent
073a80e079
commit
9feb1c95d1
2 changed files with 40 additions and 8 deletions
|
@ -133,8 +133,8 @@ int main(int argc, char** argv){
|
||||||
std::cerr << "Received push - ignoring (" << in_out.Received().get() << ")" << std::endl;
|
std::cerr << "Received push - ignoring (" << in_out.Received().get() << ")" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
in_out.close(); //pushing to VoD makes no sense
|
in_out.close(); //pushing to VoD makes no sense
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'S': { //Stats
|
case 'S': { //Stats
|
||||||
if ( !StatsSocket.connected()){
|
if ( !StatsSocket.connected()){
|
||||||
StatsSocket = Socket::Connection("/tmp/mist/statistics", true);
|
StatsSocket = Socket::Connection("/tmp/mist/statistics", true);
|
||||||
|
@ -165,25 +165,25 @@ int main(int argc, char** argv){
|
||||||
StatsSocket.Send("\n\n");
|
StatsSocket.Send("\n\n");
|
||||||
StatsSocket.flush();
|
StatsSocket.flush();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 's': { //second-seek
|
case 's': { //second-seek
|
||||||
int ms = JSON::Value(in_out.Received().get().substr(2)).asInt();
|
int ms = JSON::Value(in_out.Received().get().substr(2)).asInt();
|
||||||
bool ret = source.seek_time(ms);
|
bool ret = source.seek_time(ms);
|
||||||
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;
|
||||||
in_out.setBlocking(false);
|
in_out.setBlocking(false);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'o': { //once-play
|
case 'o': { //once-play
|
||||||
if (playing <= 0){
|
if (playing <= 0){
|
||||||
playing = 1;
|
playing = 1;
|
||||||
|
@ -191,14 +191,26 @@ int main(int argc, char** argv){
|
||||||
++playing;
|
++playing;
|
||||||
in_out.setBlocking(false);
|
in_out.setBlocking(false);
|
||||||
bench = Util::getMS();
|
bench = Util::getMS();
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'q': { //quit-playing
|
case 'q': { //quit-playing
|
||||||
playing = 0;
|
playing = 0;
|
||||||
in_out.setBlocking(true);
|
in_out.setBlocking(true);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 't': {
|
||||||
|
std::vector<std::string> selected;
|
||||||
|
selected.push_back(in_out.Received().get().substr(2));
|
||||||
|
source.selectTracks(selected);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#if DEBUG >= 4
|
||||||
|
default: {
|
||||||
|
std::cerr << "MistPlayer received an unknown command: " << in_out.Received().get() << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
in_out.Received().get().clear();
|
in_out.Received().get().clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,6 +170,9 @@ namespace Connector_HTTP {
|
||||||
unsigned int lastStats = 0;//Indicates the last time that we have sent stats to the server socket.
|
unsigned int lastStats = 0;//Indicates the last time that we have sent stats to the server socket.
|
||||||
conn.setBlocking(false);//Set the client socket to non-blocking
|
conn.setBlocking(false);//Set the client socket to non-blocking
|
||||||
|
|
||||||
|
JSON::Value allAudio;
|
||||||
|
JSON::Value allVideo;
|
||||||
|
|
||||||
while (conn.connected()){
|
while (conn.connected()){
|
||||||
if (conn.spool() || conn.Received().size()){
|
if (conn.spool() || conn.Received().size()){
|
||||||
//Make sure the received data ends in a newline (\n).
|
//Make sure the received data ends in a newline (\n).
|
||||||
|
@ -211,7 +214,18 @@ namespace Connector_HTTP {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (JSON::ObjIter oIt = Strm.metadata["tracks"].ObjBegin(); oIt != Strm.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 (HTTP_R.url.find("Manifest") == std::string::npos){
|
if (HTTP_R.url.find("Manifest") == std::string::npos){
|
||||||
//We have a non-manifest request, parse it.
|
//We have a non-manifest request, parse it.
|
||||||
Quality = HTTP_R.url.substr(HTTP_R.url.find("/Q(", 8) + 3);
|
Quality = HTTP_R.url.substr(HTTP_R.url.find("/Q(", 8) + 3);
|
||||||
|
@ -259,6 +273,12 @@ 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){
|
||||||
|
sstream << "t " << allVideo.ObjBegin()->first << "\n";
|
||||||
|
}
|
||||||
|
if (wantsAudio){
|
||||||
|
sstream << "t " << allAudio.ObjBegin()->first << "\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());
|
||||||
}else{
|
}else{
|
||||||
|
|
Loading…
Add table
Reference in a new issue