bufferLivePacket improvements for generic Outputs

This commit is contained in:
Thulinma 2017-03-16 17:12:54 +01:00
parent bd2f1724f6
commit eef9303e61
8 changed files with 58 additions and 59 deletions

View file

@ -38,7 +38,17 @@ namespace Mist{
cfg->addOption("noinput", option);
}
void Output::bufferLivePacket(DTSC::Packet & packet){
if (nProxy.negTimer > 600){
WARN_MSG("No negotiation response from buffer - reconnecting.");
nProxy.clear();
reconnect();
}
InOutBase::bufferLivePacket(packet);
}
Output::Output(Socket::Connection & conn) : myConn(conn){
pushing = false;
firstTime = 0;
crc = getpid();
parseData = false;
@ -74,8 +84,8 @@ namespace Mist{
}
void Output::updateMeta(){
//cancel if not alive
if (!nProxy.userClient.isAlive()){
//cancel if not alive or pushing a new stream
if (!nProxy.userClient.isAlive() || (isPushing() && myMeta.tracks.size())){
return;
}
//read metadata from page to myMeta variable
@ -144,6 +154,7 @@ namespace Mist{
}
bool Output::isReadyForPlay(){
if (isPushing()){return true;}
if (myMeta.tracks.size()){
if (!selectedTracks.size()){
selectDefaultTracks();
@ -992,6 +1003,9 @@ namespace Mist{
/// Outputs used as an input should return INPUT, outputs used for automation should return OUTPUT, others should return their proper name.
/// The default implementation is usually good enough for all the non-INPUT types.
std::string Output::getStatsName(){
if (isPushing()){
return "INPUT";
}
if (config->hasOption("target") && config->getString("target").size()){
return "OUTPUT";
}else{
@ -1045,7 +1059,7 @@ namespace Mist{
myConn.close();
return;
}
if (!nProxy.trackMap.size()){
if (!isPushing()){
IPC::userConnection userConn(nProxy.userClient.getData());
for (std::set<unsigned long>::iterator it = selectedTracks.begin(); it != selectedTracks.end() && tNum < SIMUL_TRACKS; it++){
userConn.setTrackId(tNum, *it);
@ -1092,6 +1106,7 @@ namespace Mist{
/// Runs all appropriate triggers and checks.
/// Returns true if the push should continue, false otherwise.
bool Output::allowPush(const std::string & passwd){
pushing = true;
std::string strmSource;
// Initialize the stream source if needed, connect to it
@ -1101,18 +1116,22 @@ namespace Mist{
if (!strmSource.size()){
FAIL_MSG("Push rejected - stream %s not configured", streamName.c_str());
pushing = false;
return false;
}
if (strmSource.substr(0, 7) != "push://"){
FAIL_MSG("Push rejected - stream %s not a push-able stream. (%s != push://*)", streamName.c_str(), strmSource.c_str());
pushing = false;
return false;
}
std::string source = strmSource.substr(7);
std::string IP = source.substr(0, source.find('@'));
if (IP != ""){
if (!myConn.isAddress(IP)){
FAIL_MSG("Push from %s to %s rejected - source host not whitelisted", getConnectedHost().c_str(), streamName.c_str());
pushing = false;
return false;
}
}