Added stream status shared memory page (temporary system)

This commit is contained in:
Thulinma 2017-06-22 14:03:35 +02:00
parent 76b5a91da6
commit 25699ef8b2
6 changed files with 27 additions and 0 deletions

View file

@ -114,6 +114,10 @@ namespace Mist {
DEBUG_MSG(DLVL_DEVEL, "A player for stream %s is already running", streamName.c_str());
return 1;
}
char pageName[NAME_BUFFER_SIZE];
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_STATE, streamName.c_str());
streamStatus.init(pageName, 1, true, false);
if (streamStatus){streamStatus.mapped[0] = STRMSTAT_INIT;}
}
config->activate();
uint64_t reTimer = 0;
@ -142,6 +146,7 @@ namespace Mist {
MEDIUM_MSG("Input for stream %s shut down cleanly", streamName.c_str());
break;
}
if (streamStatus){streamStatus.mapped[0] = STRMSTAT_INVALID;}
#if DEBUG >= DLVL_DEVEL
WARN_MSG("Aborting autoclean; this is a development build.");
INFO_MSG("Input for stream %s uncleanly shut down! Aborting restart; this is a development build.", streamName.c_str());
@ -162,6 +167,7 @@ namespace Mist {
}
int Input::run() {
if (streamStatus){streamStatus.mapped[0] = STRMSTAT_BOOT;}
checkHeaderTimes(config->getString("input"));
if (!readHeader()){
std::cerr << "Reading header for " << config->getString("input") << " failed." << std::endl;
@ -256,6 +262,7 @@ namespace Mist {
char userPageName[NAME_BUFFER_SIZE];
snprintf(userPageName, NAME_BUFFER_SIZE, SHM_USERS, streamName.c_str());
userPage.init(userPageName, PLAY_EX_SIZE, true);
if (streamStatus){streamStatus.mapped[0] = STRMSTAT_READY;}
DEBUG_MSG(DLVL_DEVEL, "Input for stream %s started", streamName.c_str());
activityCounter = Util::bootSecs();
@ -279,6 +286,7 @@ namespace Mist {
Util::wait(1000);
}
}
if (streamStatus){streamStatus.mapped[0] = STRMSTAT_SHUTDOWN;}
config->is_active = false;
finish();
DEBUG_MSG(DLVL_DEVEL, "Input for stream %s closing clean", streamName.c_str());

View file

@ -69,6 +69,7 @@ namespace Mist {
//Create server for user pages
IPC::sharedServer userPage;
IPC::sharedPage streamStatus;
std::map<unsigned int, std::map<unsigned int, unsigned int> > pageCounter;

View file

@ -394,6 +394,7 @@ namespace Mist {
}
}
updateMeta();
if (streamStatus){streamStatus.mapped[0] = hasPush ? STRMSTAT_READY : STRMSTAT_WAIT;}
static bool everHadPush = false;
if (hasPush) {
hasPush = false;