Commit Graph

158 Commits

Author SHA1 Message Date
Isaac Connor
2d73a083b5 curr_frame_id should never be 0. So set it to 1 instead 2024-01-29 13:30:17 -05:00
Isaac Connor
39e03e6a3c Fix infinite loop in the event there is only the initial frame in the db. 2024-01-18 14:16:38 -05:00
Isaac Connor
7280329e6e Split long line 2024-01-17 17:09:43 -05:00
Isaac Connor
bc11f5cdac Fix never gapless events not working. Put mutex around status sending because event_data may change at any moment. Fix 100% cpu use when at end of event and not moving to next event, hence paused. 2023-11-01 17:27:56 -04:00
Isaac Connor
5bb7529c3e Just code cleanups, but also add a mysqL-free_result which should fix a mem leak 2023-11-01 17:27:56 -04:00
Isaac Connor
b7424b5bea Test for seek beyond event length and frame_id > last_frame_id 2023-10-16 14:33:57 -04:00
Isaac Connor
61791c76a3 Adjust debug level of no event change required line as it repeats a billion times.. 2023-10-16 14:05:12 -04:00
Isaac Connor
277f856452 Move lock lower down to where it is crucial. When debugging offsets, use %.6f instead of %.2f 2023-10-16 12:14:38 -04:00
Isaac Connor
f39b3f0583 Reduce debug levels. Pass along Width and Height when instantiating Image from AVFrame so that it can scale to a lower res. 2023-08-02 13:56:06 -04:00
Isaac Connor
01b886ef49 Add scale to status and fix cast on elapsed 2023-04-06 15:15:36 -04:00
Isaac Connor
7e489f7fa2 When there are NO frames in the db, populate the list of frames by 1/fps. 2022-12-07 12:26:51 -05:00
Isaac Connor
c2680f7f77 Turn failure to send into a debug. When running under fpm etc we may not get SIGPIPE. 2022-10-17 17:22:23 -04:00
Isaac Connor
319904ab80 When we increment past the event, fix the curr_frame_id so we reference the last image. 2022-09-14 18:30:39 -04:00
Isaac Connor
4668ffcaa9 rework event stream. Fixes seeking. Fixes event not completing due to not have Frame records for every frame. Adds send_twice to deal with browsers not showing the last sent image. Use locking around anything to do with curr_frame_id as commandQueue is it's own thread now. 2022-09-13 16:16:54 -04:00
Isaac Connor
8549cdf317 Implement a mutex/locks around changing event data, curr_frame_id, etc. also contains a fix for seeking due to > instead of <. In general fixes seeking 2022-09-12 16:17:42 -04:00
Isaac Connor
8558ade8f1 Merge branch 'master' into misc_fixes 2022-08-25 18:33:06 -04:00
Isaac Connor
b9c97e6795 Fix crash due to deplicated join. Don't output BOUNDARY unless image loading suceeds 2022-08-16 15:15:01 -04:00
Isaac Connor
aa030afcb6 Make checkCommandQueue it's own thread, meaning we use blocking I/O and will still respond when it takes forever to send a jpeg. Make warning about broken stream into a Debug. The signal doesn't set zm_terminate fast enough. 2022-08-15 17:58:56 -04:00
Doug Nazar
9385127b50 Consolidate temp_img_buffer resizing and use correct delete[] operator 2022-07-30 22:27:41 -04:00
Doug Nazar
f4dd897ef4 Convert AVFrame* to custom unique_ptr (av_frame_ptr).
Switch all owning AVFrame* variables to av_frame_ptr for
automatic cleanup.

Use AVBufferRef to store frame data in AVFrame where appropriate
so that it can be freed automatically with it's AVFrame.

Handle allocation errors.
2022-07-30 13:21:11 -04:00
Doug Nazar
3b21153757 Fix various printf formats for 32bit, 32bit w/_FILE_OFFSET_BITS=64 and 64-bit 2022-07-16 03:18:18 -04:00
Isaac Connor
a4621b3ade Zoom in/out by increments of 10. Implement handling of ZOOMSTOP command 2022-06-17 15:12:47 -04:00
Isaac Connor
cd2c977ed8 Merge branch 'master' into replace_function_concept 2022-02-16 14:25:38 -05:00
Isaac Connor
2336926d90 Rework to remove static temp_img_buffer. Is now a class member. Must be allocated as needed. Use new reworked zm_sendfile and handle if not all bytes are sent. Fixes #3437. 2022-02-16 14:16:01 -05:00
Isaac Connor
33f23cbd84 Sync up n_frames, frame_count, curr_frame_id on int instead of a mix of long int, int and unsigned long int 2022-02-15 18:52:46 -05:00
Isaac Connor
552974c5b7 Pass full packet to AddFrame so that we can also write other contents out 2022-02-12 22:14:21 -05:00
Isaac Connor
d2d9721c4e spacing, remove redundant debug 2022-01-18 23:02:26 -05:00
Isaac Connor
5f17cb6e9a Debug the size returned as compared to the file size 2022-01-15 17:19:35 -05:00
Isaac Connor
16964cf327 fix zms running past end of event 2022-01-07 12:30:56 -05:00
Isaac Connor
698fe14453 set zm_terminate instead of exit() so that all the cleanup code happens 2022-01-01 17:55:18 -05:00
Isaac Connor
60d2186ff4 Move from SystemTimePoint to SteadyTimePoint where possible. Implement MAXFPS command. Change the logic of calculating sleep time to make more sense. Get rid of frame_mod use in favour of calculating when then next frame should get sent and just waiting till then. 2021-12-16 16:35:20 -05:00
Isaac Connor
8c2dec03b6 Default to now instead of ... epoch? when endtime is null. Fixes video playing when event is incomplete 2021-11-09 13:59:14 -05:00
Isaac Connor
e063f0715f reset starttime when changing events. Fixes super fast playback after switch to next event. Also, skip some unneeded calculations and logging. 2021-10-28 13:00:41 -04:00
Mike Dussault
d38a6adec4 No behavior change. Added non-const versions of Image::Buffer and fixed a few places that were casting away the constness. 2021-10-12 21:54:49 +00: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
80b08a2075 Convert path buffers depending on PATH_MAX to std::string 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
b2ee71c96e EventStream: Finalize conversion of internals to std::chrono 2021-06-13 11:30:22 +02:00
Peter Keresztes Schmidt
e1fe53338c BaseStream: Convert internals to std::chrono 2021-06-13 11:29:59 +02:00
Peter Keresztes Schmidt
a9ad5c5eee Build: Promote libavcodec to a required dependency
FFmpeg is an integral component of ZM. Promote the appropriate libraries to required dependencies.
This reduces the possible build configurations greatly and thus maintenance burden.
2021-06-05 14:25:54 +02:00
Isaac Connor
510b3e606b Continue if frame file not found. Output useful text jpeg 2021-05-11 09:33:33 -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
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
Peter Keresztes Schmidt
9e77324de4 Replace raw mysql_query calls with the zmDb* functions
With this we can make sure we have proper locking of our DB connection at all times.
2021-03-06 00:12:18 +01: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
6c013f0e65 Put back includes needed on FreeBSD. Fixes #3165 2021-02-22 08:03:10 -05:00
Isaac Connor
9b3d423f3d Separate duration==endtime-starttime from Frames Duration 2021-02-09 14:22:23 -05:00
Peter Keresztes Schmidt
f43507dce0 Use the power of smart pointers to manage Monitor instances 2021-02-07 21:20:45 +01:00
Isaac Connor
87c3a862e2 remove our copies of min() and max(). Use std::min() and std::max() 2021-02-06 16:02:09 -05:00