From 335e9506544c9240df79396153201ed48eb6ce35 Mon Sep 17 00:00:00 2001 From: Peter Keresztes Schmidt Date: Sun, 13 Jun 2021 16:03:05 +0200 Subject: [PATCH] Frame: Convert API to std::chrono --- src/zm_event.cpp | 10 ++++++++-- src/zm_frame.cpp | 2 +- src/zm_frame.h | 6 ++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 03aca0594..fc0d18f1f 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -456,7 +456,7 @@ void Event::WriteDbFrames() { frame_insert_sql += stringtf("\n( %" PRIu64 ", %d, '%s', from_unixtime( %ld ), %.2f, %d ),", id, frame->frame_id, frame_type_names[frame->type], - frame->timestamp.tv_sec, + std::chrono::system_clock::to_time_t(frame->timestamp), std::chrono::duration_cast(frame->delta).count(), frame->score); if (config.record_event_stats and frame->zone_stats.size()) { @@ -588,7 +588,13 @@ void Event::AddFrame( zone_stats.size()); // The idea is to write out 1/sec - frame_data.push(new Frame(id, frames, frame_type, timestamp, delta_time, score, zone_stats)); + frame_data.push(new Frame(id, + frames, + frame_type, + SystemTimePoint(zm::chrono::duration_cast(timestamp)), + delta_time, + score, + zone_stats)); double fps = monitor->get_capture_fps(); if (write_to_db or diff --git a/src/zm_frame.cpp b/src/zm_frame.cpp index d333d04e1..aadd20f8d 100644 --- a/src/zm_frame.cpp +++ b/src/zm_frame.cpp @@ -3,7 +3,7 @@ Frame::Frame(event_id_t p_event_id, int p_frame_id, FrameType p_type, - struct timeval p_timestamp, + SystemTimePoint p_timestamp, Microseconds p_delta, int p_score, std::vector p_stats) diff --git a/src/zm_frame.h b/src/zm_frame.h index 5b3792093..77c7a0398 100644 --- a/src/zm_frame.h +++ b/src/zm_frame.h @@ -23,8 +23,6 @@ #include "zm_event.h" #include "zm_time.h" #include "zm_zone.h" - -#include #include enum FrameType { @@ -41,7 +39,7 @@ class Frame { Frame(event_id_t p_event_id, int p_frame_id, FrameType p_type, - struct timeval p_timestamp, + SystemTimePoint p_timestamp, Microseconds p_delta, int p_score, std::vector p_stats @@ -50,7 +48,7 @@ class Frame { event_id_t event_id; int frame_id; FrameType type; - struct timeval timestamp; + SystemTimePoint timestamp; Microseconds delta; int score; std::vector zone_stats;