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;
 | 
			
		||||
#endif
 | 
			
		||||
              in_out.close(); //pushing to VoD makes no sense
 | 
			
		||||
            }
 | 
			
		||||
              break;
 | 
			
		||||
            }
 | 
			
		||||
            case 'S': { //Stats
 | 
			
		||||
              if ( !StatsSocket.connected()){
 | 
			
		||||
                StatsSocket = Socket::Connection("/tmp/mist/statistics", true);
 | 
			
		||||
| 
						 | 
				
			
			@ -165,25 +165,25 @@ int main(int argc, char** argv){
 | 
			
		|||
                StatsSocket.Send("\n\n");
 | 
			
		||||
                StatsSocket.flush();
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
              break;
 | 
			
		||||
            }
 | 
			
		||||
            case 's': { //second-seek
 | 
			
		||||
              int ms = JSON::Value(in_out.Received().get().substr(2)).asInt();
 | 
			
		||||
              bool ret = source.seek_time(ms);
 | 
			
		||||
              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;
 | 
			
		||||
              in_out.setBlocking(false);
 | 
			
		||||
            }
 | 
			
		||||
              break;
 | 
			
		||||
            }
 | 
			
		||||
            case 'o': { //once-play
 | 
			
		||||
              if (playing <= 0){
 | 
			
		||||
                playing = 1;
 | 
			
		||||
| 
						 | 
				
			
			@ -191,13 +191,25 @@ int main(int argc, char** argv){
 | 
			
		|||
              ++playing;
 | 
			
		||||
              in_out.setBlocking(false);
 | 
			
		||||
              bench = Util::getMS();
 | 
			
		||||
            }
 | 
			
		||||
              break;
 | 
			
		||||
            }
 | 
			
		||||
            case 'q': { //quit-playing
 | 
			
		||||
              playing = 0;
 | 
			
		||||
              in_out.setBlocking(true);
 | 
			
		||||
            }
 | 
			
		||||
              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();
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -170,6 +170,9 @@ namespace Connector_HTTP {
 | 
			
		|||
    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
 | 
			
		||||
 | 
			
		||||
    JSON::Value allAudio;
 | 
			
		||||
    JSON::Value allVideo;
 | 
			
		||||
 | 
			
		||||
    while (conn.connected()){
 | 
			
		||||
      if (conn.spool() || conn.Received().size()){
 | 
			
		||||
        //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){
 | 
			
		||||
            //We have a non-manifest request, parse it.
 | 
			
		||||
            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.
 | 
			
		||||
            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";
 | 
			
		||||
            ss.SendNow(sstream.str().c_str());
 | 
			
		||||
          }else{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue