Include MonitorId as second argument of EventStartCommand and EventEndCOmmand at @baudneo's request.

This commit is contained in:
Isaac Connor 2022-02-19 15:33:05 -05:00
parent dc8f1bc8ed
commit fe69261f10
3 changed files with 14 additions and 2 deletions

View File

@ -699,3 +699,6 @@ Debug(1, "wakeing");
} }
} }
} }
int Event::MonitorId() {
return monitor->Id();
}

View File

@ -192,5 +192,6 @@ class Event {
void SavePreAlarmFrames() { void SavePreAlarmFrames() {
EmptyPreAlarmFrames(); EmptyPreAlarmFrames();
} }
int MonitorId();
}; };
#endif // ZM_EVENT_H #endif // ZM_EVENT_H

View File

@ -2768,7 +2768,11 @@ Event * Monitor::openEvent(
if (!event_start_command.empty()) { if (!event_start_command.empty()) {
if (fork() == 0) { if (fork() == 0) {
execlp(event_start_command.c_str(), event_start_command.c_str(), std::to_string(event->Id()).c_str(), nullptr); execlp(event_start_command.c_str(),
event_start_command.c_str(),
std::to_string(event->Id()).c_str(),
std::to_string(event->MonitorId()).c_str(),
nullptr);
Error("Error execing %s", event_start_command.c_str()); Error("Error execing %s", event_start_command.c_str());
} }
} }
@ -2808,11 +2812,15 @@ void Monitor::closeEvent() {
Debug(1, "Starting thread to close event"); Debug(1, "Starting thread to close event");
close_event_thread = std::thread([](Event *e, const std::string &command){ close_event_thread = std::thread([](Event *e, const std::string &command){
int64_t event_id = e->Id(); int64_t event_id = e->Id();
int monitor_id = e->MonitorId();
delete e; delete e;
if (!command.empty()) { if (!command.empty()) {
if (fork() == 0) { if (fork() == 0) {
execlp(command.c_str(), command.c_str(), std::to_string(event_id).c_str(), nullptr); execlp(command.c_str(), command.c_str(),
std::to_string(event_id).c_str(),
std::to_string(monitor_id).c_str(), // monitor id
nullptr);
Error("Error execing %s", command.c_str()); Error("Error execing %s", command.c_str());
} }
} }