Fix STREAM_END trigger
This commit is contained in:
parent
3422b1dbcd
commit
0083df681d
1 changed files with 18 additions and 10 deletions
|
@ -101,6 +101,7 @@ struct streamTotals{
|
||||||
uint64_t currOuts;
|
uint64_t currOuts;
|
||||||
uint64_t currViews;
|
uint64_t currViews;
|
||||||
uint64_t currUnspecified;
|
uint64_t currUnspecified;
|
||||||
|
uint64_t currSessions;
|
||||||
uint8_t status;
|
uint8_t status;
|
||||||
uint64_t viewSeconds;
|
uint64_t viewSeconds;
|
||||||
uint64_t packSent;
|
uint64_t packSent;
|
||||||
|
@ -142,6 +143,7 @@ static void createEmptyStatsIfNeeded(const std::string & streamName){
|
||||||
sT.currIns = 0;
|
sT.currIns = 0;
|
||||||
sT.currOuts = 0;
|
sT.currOuts = 0;
|
||||||
sT.currUnspecified = 0;
|
sT.currUnspecified = 0;
|
||||||
|
sT.currSessions = 0;
|
||||||
sT.currViews = 0;
|
sT.currViews = 0;
|
||||||
sT.status = 0;
|
sT.status = 0;
|
||||||
sT.viewSeconds = 0;
|
sT.viewSeconds = 0;
|
||||||
|
@ -377,7 +379,6 @@ void Controller::SharedMemStats(void *config){
|
||||||
HIGH_MSG("Starting stats thread");
|
HIGH_MSG("Starting stats thread");
|
||||||
statComm.reload(true);
|
statComm.reload(true);
|
||||||
statCommActive = true;
|
statCommActive = true;
|
||||||
std::set<std::string> inactiveStreams;
|
|
||||||
Controller::initState();
|
Controller::initState();
|
||||||
bool shiftWrites = true;
|
bool shiftWrites = true;
|
||||||
bool firstRun = true;
|
bool firstRun = true;
|
||||||
|
@ -466,6 +467,7 @@ void Controller::SharedMemStats(void *config){
|
||||||
it->second.currIns = 0;
|
it->second.currIns = 0;
|
||||||
it->second.currOuts = 0;
|
it->second.currOuts = 0;
|
||||||
it->second.currUnspecified = 0;
|
it->second.currUnspecified = 0;
|
||||||
|
it->second.currSessions = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// wipe old statistics and set session type counters
|
// wipe old statistics and set session type counters
|
||||||
|
@ -480,6 +482,7 @@ void Controller::SharedMemStats(void *config){
|
||||||
cutOffPoint = 0;
|
cutOffPoint = 0;
|
||||||
}
|
}
|
||||||
for (std::map<std::string, statSession>::iterator it = sessions.begin(); it != sessions.end(); it++){
|
for (std::map<std::string, statSession>::iterator it = sessions.begin(); it != sessions.end(); it++){
|
||||||
|
streamStats[it->second.getStreamName()].currSessions++;
|
||||||
// This part handles ending sessions, keeping them in cache for now
|
// This part handles ending sessions, keeping them in cache for now
|
||||||
if (it->second.getEnd() < cutOffPoint){
|
if (it->second.getEnd() < cutOffPoint){
|
||||||
viewSecondsTotal += it->second.getConnTime();
|
viewSecondsTotal += it->second.getConnTime();
|
||||||
|
@ -529,20 +532,25 @@ void Controller::SharedMemStats(void *config){
|
||||||
strmPos = strmStats->getDeleted();
|
strmPos = strmStats->getDeleted();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
std::set<std::string> inactiveStreams;
|
||||||
if (streamStats.size()){
|
if (streamStats.size()){
|
||||||
for (std::map<std::string, struct streamTotals>::iterator it = streamStats.begin();
|
for (std::map<std::string, struct streamTotals>::iterator it = streamStats.begin();
|
||||||
it != streamStats.end(); ++it){
|
it != streamStats.end(); ++it){
|
||||||
uint8_t newState = Util::getStreamStatus(it->first);
|
// Ignore blank stream name; these are generic and we don't track stream status for them
|
||||||
uint8_t oldState = it->second.status;
|
if (it->first.size()){
|
||||||
if (newState != oldState){
|
uint8_t newState = Util::getStreamStatus(it->first);
|
||||||
it->second.status = newState;
|
uint8_t oldState = it->second.status;
|
||||||
if (newState == STRMSTAT_READY){
|
if (newState != oldState){
|
||||||
streamStarted(it->first);
|
it->second.status = newState;
|
||||||
}else{
|
if (newState == STRMSTAT_READY){
|
||||||
if (oldState == STRMSTAT_READY){streamStopped(it->first);}
|
streamStarted(it->first);
|
||||||
|
}else{
|
||||||
|
if (oldState == STRMSTAT_READY){streamStopped(it->first);}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// No active sessions? Mark it as inactive for cleanup.
|
||||||
|
if (!it->second.currSessions){inactiveStreams.insert(it->first);}
|
||||||
}
|
}
|
||||||
if (newState == STRMSTAT_OFF){inactiveStreams.insert(it->first);}
|
|
||||||
if (strmStats){
|
if (strmStats){
|
||||||
if (shiftWrites){strmStats->setString("stream", it->first, strmPos);}
|
if (shiftWrites){strmStats->setString("stream", it->first, strmPos);}
|
||||||
strmStats->setInt("status", it->second.status, strmPos);
|
strmStats->setInt("status", it->second.status, strmPos);
|
||||||
|
|
Loading…
Add table
Reference in a new issue