Add AnalysisSource, Recording, RecordingSource, Capturing to monitor load. Also in loading Linked Monitors, don't care about set function, as it might change during runtime

This commit is contained in:
Isaac Connor 2021-10-17 13:36:14 -04:00
parent c81f3d9c61
commit d55ada339c
1 changed files with 11 additions and 9 deletions

View File

@ -69,7 +69,7 @@
// This is the official SQL (and ordering of the fields) to load a Monitor. // This is the official SQL (and ordering of the fields) to load a Monitor.
// It will be used whereever a Monitor dbrow is needed. WHERE conditions can be appended // It will be used whereever a Monitor dbrow is needed. WHERE conditions can be appended
std::string load_monitor_sql = std::string load_monitor_sql =
"SELECT `Id`, `Name`, `ServerId`, `StorageId`, `Type`, `Function`+0, `Enabled`, `DecodingEnabled`, " "SELECT `Id`, `Name`, `ServerId`, `StorageId`, `Type`, `Function`+0, `Capturing`+0, `Analysing`+0, `AnalysisSource`, `Recording`+0, `RecordingSource`, `Enabled`, `DecodingEnabled`, "
"`LinkedMonitors`, `AnalysisFPSLimit`, `AnalysisUpdateDelay`, `MaxFPS`, `AlarmMaxFPS`," "`LinkedMonitors`, `AnalysisFPSLimit`, `AnalysisUpdateDelay`, `MaxFPS`, `AlarmMaxFPS`,"
"`Device`, `Channel`, `Format`, `V4LMultiBuffer`, `V4LCapturesPerFrame`, " // V4L Settings "`Device`, `Channel`, `Format`, `V4LMultiBuffer`, `V4LCapturesPerFrame`, " // V4L Settings
"`Protocol`, `Method`, `Options`, `User`, `Pass`, `Host`, `Port`, `Path`, `SecondPath`, `Width`, `Height`, `Colours`, `Palette`, `Orientation`+0, `Deinterlacing`, " "`Protocol`, `Method`, `Options`, `User`, `Pass`, `Host`, `Port`, `Path`, `SecondPath`, `Width`, `Height`, `Colours`, `Palette`, `Orientation`+0, `Deinterlacing`, "
@ -423,8 +423,8 @@ Monitor::Monitor()
/* /*
std::string load_monitor_sql = std::string load_monitor_sql =
"SELECT Id, Name, ServerId, StorageId, Type, Function+0, Enabled, DecodingEnabled, LinkedMonitors, " "SELECT `Id`, `Name`, `ServerId`, `StorageId`, `Type`, `Function`+0, `Capturing`+0, `Analysing`+0, `AnalysisSource`, `Recording`+0, `RecordingSource`, `Enabled`, `DecodingEnabled`, "
"AnalysisFPSLimit, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS," , LinkedMonitors, AnalysisFPSLimit, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS,"
"Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, " // V4L Settings "Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, " // V4L Settings
"Protocol, Method, Options, User, Pass, Host, Port, Path, SecondPath, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, RTSPDescribe, " "Protocol, Method, Options, User, Pass, Host, Port, Path, SecondPath, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, RTSPDescribe, "
"SaveJPEGs, VideoWriter, EncoderParameters, "SaveJPEGs, VideoWriter, EncoderParameters,
@ -472,6 +472,12 @@ void Monitor::Load(MYSQL_ROW dbrow, bool load_zones=true, Purpose p = QUERY) {
Debug(1, "Have camera type %s", CameraType_Strings[type].c_str()); Debug(1, "Have camera type %s", CameraType_Strings[type].c_str());
col++; col++;
function = (Function)atoi(dbrow[col]); col++; function = (Function)atoi(dbrow[col]); col++;
capturing = (CapturingOption)atoi(dbrow[col]); col++;
analysing = (AnalysingOption)atoi(dbrow[col]); col++;
analysis_source = (AnalysisSourceOption)atoi(dbrow[col]); col++;
recording = (RecordingOption)atoi(dbrow[col]); col++;
recording_source = (RecordingSourceOption)atoi(dbrow[col]); col++;
enabled = dbrow[col] ? atoi(dbrow[col]) : false; col++; enabled = dbrow[col] ? atoi(dbrow[col]) : false; col++;
decoding_enabled = dbrow[col] ? atoi(dbrow[col]) : false; col++; decoding_enabled = dbrow[col] ? atoi(dbrow[col]) : false; col++;
decoding_enabled = !( decoding_enabled = !(
@ -2388,11 +2394,7 @@ void Monitor::ReloadLinkedMonitors(const char *p_linked_monitors) {
Debug(1, "Checking linked monitor %d", link_ids[i]); Debug(1, "Checking linked monitor %d", link_ids[i]);
std::string sql = stringtf( std::string sql = stringtf(
"SELECT `Id`, `Name` FROM `Monitors`" "SELECT `Id`, `Name` FROM `Monitors` WHERE `Id` = %d",
" WHERE `Id` = %d"
" AND `Function` != 'None'"
" AND `Function` != 'Monitor'"
" AND `Enabled`=1",
link_ids[i]); link_ids[i]);
MYSQL_RES *result = zmDbFetch(sql); MYSQL_RES *result = zmDbFetch(sql);
@ -2401,7 +2403,7 @@ void Monitor::ReloadLinkedMonitors(const char *p_linked_monitors) {
} }
int n_monitors = mysql_num_rows(result); int n_monitors = mysql_num_rows(result);
if ( n_monitors == 1 ) { if (n_monitors == 1) {
MYSQL_ROW dbrow = mysql_fetch_row(result); MYSQL_ROW dbrow = mysql_fetch_row(result);
Debug(1, "Linking to monitor %d %s", atoi(dbrow[0]), dbrow[1]); Debug(1, "Linking to monitor %d %s", atoi(dbrow[0]), dbrow[1]);
linked_monitors[count++] = new MonitorLink(link_ids[i], dbrow[1]); linked_monitors[count++] = new MonitorLink(link_ids[i], dbrow[1]);