Add last_viewed_time and accessor functions

This commit is contained in:
Isaac Connor 2021-10-24 17:42:39 -04:00
parent 8cbd401dee
commit 6992644fc3
1 changed files with 32 additions and 9 deletions

View File

@ -195,7 +195,11 @@ protected:
time_t last_read_time; time_t last_read_time;
uint64_t extrapad4; uint64_t extrapad4;
}; };
uint8_t control_state[256]; /* +104 */ union { /* +104 */
time_t last_viewed_time;
uint64_t extrapad5;
};
uint8_t control_state[256]; /* +112 */
char alarm_cause[256]; char alarm_cause[256];
char video_fifo_path[64]; char video_fifo_path[64];
@ -518,6 +522,25 @@ public:
return false; return false;
return (enabled && shared_data->active); return (enabled && shared_data->active);
} }
int64_t getLastViewed() {
if (shared_data && shared_data->valid)
return shared_data->last_viewed_time;
return 0;
}
void setLastViewed(SystemTimePoint new_time) {
if (shared_data && shared_data->valid)
shared_data->last_viewed_time =
static_cast<int64>(std::chrono::duration_cast<Seconds>(new_time.time_since_epoch()).count());
}
bool hasViewers() {
if (shared_data && shared_data->valid) {
TimePoint now = std::chrono::steady_clock::now();;
return (
(shared_data->last_viewed_time - static_cast<int64>(std::chrono::duration_cast<Seconds>(now.time_since_epoch()).count())
) > 1 ? false : true);
}
return false;
}
inline bool Exif() const { return embed_exif; } inline bool Exif() const { return embed_exif; }
inline bool RTSPServer() const { return rtsp_server; } inline bool RTSPServer() const { return rtsp_server; }
inline bool RecordAudio() const { return record_audio; } inline bool RecordAudio() const { return record_audio; }