Commit Graph

383 Commits

Author SHA1 Message Date
Isaac Connor
7215756fed Introduce a method update the noteSetMap after event creation (addNote). 2022-01-03 19:03:04 -05:00
Isaac Connor
e2a81cc2c5 make max_score an int to get rid of the casts. Move assignment of it above the event UPDATE sql so that it is immediately accurate. 2022-01-02 19:25:52 -05:00
Isaac Connor
c927ef4b52 Aim to do db updates every 5 seconds instead of 1 second 2021-11-29 18:34:19 -05:00
Isaac Connor
036d47a832 proper fix to memleak 2021-11-11 14:42:08 -05:00
Isaac Connor
6cd1f6b5f3 Fix memleak on event creation due to not freeing storage object 2021-11-11 13:50:18 -05:00
Isaac Connor
38105c6796 Spacing 2021-11-09 13:59:14 -05:00
Isaac Connor
814eca2b4f Include the codec in the resulting mp4 filename. Remove event update setting the mp4 filename after insert, do it on event completing instead. Saves 1 db update. 2021-11-03 17:02:02 -04:00
Isaac Connor
8619971864 Better debug messages 2021-11-02 17:24:05 -04:00
Isaac Connor
c78e035057 Fix crash due to int64 cast to a %ld format. 2021-09-23 19:07:07 -04:00
Isaac Connor
b0cf3a4732 Merge pull request #3314 from Carbenium/path-max
Fix Wformat for stringtf and convert path buffers depending on PATH_MAX to std::string
2021-07-07 11:34:03 -04:00
Peter Keresztes Schmidt
eaf2e51b0c utils: Make sure the compiler can emit format warnings for stringtf
Unfortunately the compilers can't emit Wformat warnings for variadic templates
and those can't be annotated with the format attribute.
Use a variadic function which can be annotated and thus warns on format string-args mismatches.

Ref 0796a2262e
2021-07-06 10:33:17 +02:00
Peter Keresztes Schmidt
65656de6ce db: Adjust the query methods to accept std::strings 2021-07-06 10:20:46 +02:00
Peter Keresztes Schmidt
fc15afefcf Event: Remove unused and broken prepared statement code 2021-07-06 10:20:45 +02:00
Peter Keresztes Schmidt
cf9c47149f db: Add helper for escaping strings and use it 2021-07-06 10:20:45 +02:00
Peter Keresztes Schmidt
707975e567 Monitor: Convert API to std::chrono 2021-06-13 23:22:49 +02:00
Peter Keresztes Schmidt
dff5452f11 Event: Convert API to std::chrono 2021-06-13 23:20:24 +02:00
Peter Keresztes Schmidt
335e950654 Frame: Convert API to std::chrono 2021-06-13 23:20:24 +02:00
Peter Keresztes Schmidt
ff8c9f67c1 Image: Convert API to std::chrono
Utils: Remove TimespecDiff. It is not used anymore
2021-06-13 14:50:16 +02:00
Peter Keresztes Schmidt
e1fe53338c BaseStream: Convert internals to std::chrono 2021-06-13 11:29:59 +02:00
Peter Keresztes Schmidt
44ace34593 Event: Convert internals to std::chrono 2021-06-08 19:41:11 +02:00
Peter Keresztes Schmidt
d8d27bcc92 Time: Replace remaining DeltaTimeval usage with std::chrono 2021-06-07 23:53:53 +02:00
Peter Keresztes Schmidt
6c68397249 Time: Convert some timeval operations to std::chrono
Also remove now defunct timeval helper methods.
2021-06-07 23:53:53 +02:00
Peter Keresztes Schmidt
7474294ac3 Time: Remove DELTA_TIMEVAL macro and replace usage with proper std::chrono::duration operations 2021-06-06 16:41:36 +02:00
Isaac Connor
72d07d1428 Add a bunch of debugging about snapshot writing 2021-06-04 15:00:16 -04:00
Peter Keresztes Schmidt
8f685b3d66 Box+Poly: Remove direct accessors to {Hi,Lo}{X,Y} 2021-05-16 16:42:58 +02:00
Isaac Connor
2cf6ad8089 Switch ZMPacket * to a shared_ptr<ZMPacket>. This is so that in LockedPacket we can unlock and then notify and be confident that packet_ won't have been deleted. Change ZMPacket->timestamp to be a timeval instead of timeval *. This might not have been necessary but I like it. No longer cuse the ZMPacket object to wrap the shared image buffers and timestamps. Use a vector for image_buffers. 2021-05-08 21:14:20 -04:00
Isaac Connor
260fcaadde remove debug 2021-05-02 14:07:29 -04:00
Peter Keresztes Schmidt
68bedfe48f Fix logging format string mismatches
* Remove SZFMTD format macro and use %zu instead for size_t. %zu is understood by every compiler nowadays.
2021-04-30 00:26:24 +02:00
Peter Keresztes Schmidt
eb51408ef9 ZMPacket+Frame: Use vector to store ZoneStats
We don't any of the usage patterns that would warrant a std::list (random insert/deletion). Switch to vector which has much lower overhead for this kind of usage.
2021-04-25 22:29:18 +02:00
Peter Keresztes Schmidt
ad32a94931 ZoneStats: Rename members according to Google style guide 2021-04-25 17:18:07 +02:00
Isaac Connor
b9fb08745c Cleanup, fix length test for stats insert 2021-04-23 09:18:56 -04:00
Isaac Connor
27d200d376 Switch to using std::string for inserting frames and stats. We just can't know how long the sql will be and we aren't going to waste 2MB of ram on it. Remove unused functions. 2021-04-22 22:30:45 -04:00
Isaac Connor
8671e65517 More work on flushing out ZoneStats. Use references to avoid copying 2021-04-21 21:40:39 -04:00
Isaac Connor
be9c5d3f95 Introduce a ZoneStats structure/class and implement a list of them in packet, frame. Store the stats in a list in the packet until it is time to write them to the db in the event. Hence implement batched queuing of stats. 2021-04-21 17:51:43 -04:00
Isaac Connor
c48b42c2df alarm frames without an image are still alarm frames. Count them in alarm count 2021-04-20 23:05:52 -04:00
Isaac Connor
e5d4665a42 Quiet cpp-check complaints 2021-04-20 11:00:13 -04:00
Isaac Connor
b6fcadf31b Put dbrow and fetch into a scope so that it goes away quick 2021-04-20 10:55:39 -04:00
Isaac Connor
0343642c42 duplicate test for neagtive timestamp 2021-04-20 10:54:24 -04:00
Isaac Connor
6f28c16915 Uwse the db queue for event updates 2021-04-09 19:45:55 -04:00
Isaac Connor
6c428c0156 Properly print out timeval 2021-03-29 09:58:09 -04:00
Peter Keresztes Schmidt
4e8c7d1f7c Eliminate non-thread-safe calls to localtime
localtime uses an internal static storage to which a pointer is given as return value.
Due to this it is not safe to call localtime from multiple threads since the same static storage is used.

Use localtime_r instead which allows to pass in a tm struct.

Fixes:
https://github.com/ZoneMinder/zoneminder/security/code-scanning/24
https://github.com/ZoneMinder/zoneminder/security/code-scanning/25
https://github.com/ZoneMinder/zoneminder/security/code-scanning/26
https://github.com/ZoneMinder/zoneminder/security/code-scanning/27
https://github.com/ZoneMinder/zoneminder/security/code-scanning/28
https://github.com/ZoneMinder/zoneminder/security/code-scanning/30
https://github.com/ZoneMinder/zoneminder/security/code-scanning/31
https://github.com/ZoneMinder/zoneminder/security/code-scanning/33
https://github.com/ZoneMinder/zoneminder/security/code-scanning/58
https://github.com/ZoneMinder/zoneminder/security/code-scanning/59
https://github.com/ZoneMinder/zoneminder/security/code-scanning/63
https://github.com/ZoneMinder/zoneminder/security/code-scanning/64
https://github.com/ZoneMinder/zoneminder/security/code-scanning/65
2021-03-21 21:42:02 +01:00
Isaac Connor
28490816dc Use new zmDbDoUpdate to end the event 2021-03-11 13:48:42 -05:00
Isaac Connor
0a8b34843c Merge pull request #3188 from Carbenium/drop-zm-thread
Drop our custom threading code
2021-03-04 13:02:51 -05:00
Isaac Connor
5259b78065 Fix event notes not getting populated. 2021-03-04 11:12:27 -05:00
Peter Keresztes Schmidt
d9568a98c0 Drop zm_thread which has been replaced by STL implementations 2021-03-04 10:55:46 +01:00
Isaac Connor
f8b7ec8cb9 Save frames when in ALARM state so that pre-event frames get stored 2021-03-02 11:47:38 -05:00
Peter Keresztes Schmidt
403061a39c Fix warnings reported by -Wmissing-field-initializers 2021-02-26 22:46:09 +01:00
Isaac Connor
8aeb4ab758 Switch db_mutex to a std::mutex. Use modern locking with it. Use zmDbDo or dbQueue.push where appropriate. code cleanup. 2021-02-25 12:26:26 -05:00
Isaac Connor
7c042c7837 If doing encoding, we don't care about keyframe 2021-02-21 20:24:36 -05:00
Isaac Connor
d8afd58072 Remove 1 seconds sleeps from db timeout loops. 1 second is a long time. Remove UpdateFramesDelta code which is no longer needed 2021-02-19 12:07:59 -05:00