Merged non-LTS code from LTS branch into other repositories.

This commit is contained in:
Thulinma 2013-11-25 12:21:51 +01:00
parent c69347f4e0
commit 088b917b52
2 changed files with 29 additions and 32 deletions

View file

@ -80,15 +80,26 @@ namespace Buffer {
waiting_ip = ip; waiting_ip = ip;
} }
/// Check if this is the IP address to accept push data from. ///\brief Check if this is the IP address to accept push data from.
/// \param ip The IP address to check. ///\param ip The IP address to check, followed by a space and the password to check.
/// \return True if it is the correct address, false otherwise. ///\return True if it is the correct address or password, false otherwise.
bool Stream::checkWaitingIP(std::string ip){ bool Stream::checkWaitingIP(std::string push_request){
if (ip == waiting_ip || ip == "::ffff:" + waiting_ip){ std::string ip = push_request.substr(0, push_request.find(' '));
return true; std::string pass = push_request.substr(push_request.find(' ') + 1);
if (waiting_ip.length() > 0 && waiting_ip[0] == '@'){
if (pass == waiting_ip.substr(1)){
return true;
}else{
std::cout << "Password '" << pass << "' incorrect" << std::endl;
return false;
}
}else{ }else{
std::cout << ip << " != (::ffff:)" << waiting_ip << std::endl; if (ip == waiting_ip || ip == "::ffff:" + waiting_ip){
return false; return true;
}else{
std::cout << ip << " != (::ffff:)" << waiting_ip << std::endl;
return false;
}
} }
} }

View file

@ -42,21 +42,21 @@ namespace Controller {
if (data.isMember("source")){ if (data.isMember("source")){
URL = data["source"].asString(); URL = data["source"].asString();
} }
std::string cmd1, cmd2, cmd3; std::string buffcmd;
if (URL == ""){ if (URL == ""){
Log("STRM", "Error for stream " + name + "! Source parameter missing."); Log("STRM", "Error for stream " + name + "! Source parameter missing.");
data["error"] = "Missing source parameter!"; data["error"] = "Missing source parameter!";
return; return;
} }
buffcmd = "MistBuffer";
if (data.isMember("DVR") && data["DVR"].asInt() > 0){
data["DVR"] = data["DVR"].asInt();
buffcmd += " -t " + data["DVR"].asString();
}
buffcmd += " -s " + name;
if (URL.substr(0, 4) == "push"){ if (URL.substr(0, 4) == "push"){
std::string pusher = URL.substr(7); std::string pusher = URL.substr(7);
if (data.isMember("DVR") && data["DVR"].asInt() > 0){ Util::Procs::Start(name, Util::getMyPath() + buffcmd + " " + pusher);
data["DVR"] = data["DVR"].asInt();
cmd2 = "MistBuffer -t " + data["DVR"].asString() + " -s " + name + " " + pusher;
}else{
cmd2 = "MistBuffer -s " + name + " " + pusher;
}
Util::Procs::Start(name, Util::getMyPath() + cmd2);
Log("BUFF", "(re)starting stream buffer " + name + " for push data from " + pusher); Log("BUFF", "(re)starting stream buffer " + name + " for push data from " + pusher);
}else{ }else{
if (URL.substr(0, 1) == "/"){ if (URL.substr(0, 1) == "/"){
@ -123,23 +123,9 @@ namespace Controller {
data["online"] = 1; data["online"] = 1;
} }
return; //MistPlayer handles VoD return; //MistPlayer handles VoD
}else{
cmd1 = "ffmpeg -re -async 2 -i " + URL + " -f flv -";
cmd2 = "MistFLV2DTSC";
}
if (data.isMember("DVR") && data["DVR"].asInt() > 0){
data["DVR"] = data["DVR"].asInt();
cmd3 = "MistBuffer -t " + data["DVR"].asString() + " -s " + name;
}else{
cmd3 = "MistBuffer -s " + name;
}
if (cmd2 != ""){
Util::Procs::Start(name, cmd1, Util::getMyPath() + cmd2, Util::getMyPath() + cmd3);
Log("BUFF", "(re)starting stream buffer " + name + " for ffmpeg data: " + cmd1);
}else{
Util::Procs::Start(name, cmd1, Util::getMyPath() + cmd3);
Log("BUFF", "(re)starting stream buffer " + name + " using input file " + URL);
} }
Util::Procs::Start(name, "ffmpeg -re -async 2 -i " + URL + " -f flv -", Util::getMyPath() + "MistFLV2DTSC", Util::getMyPath() + buffcmd);
Log("BUFF", "(re)starting stream buffer " + name + " for ffmpeg data: ffmpeg -re -async 2 -i " + URL + " -f flv -");
} }
} }