Commit Graph

987 Commits

Author SHA1 Message Date
Isaac Connor 5ace2ca082 Fix loading Importance in sql. Change zones to a std::list<Zone> 2021-04-17 12:50:26 -04:00
Isaac Connor ab356a3695 Add a warning when connecting without disconnecting which can cause memleaks 2021-04-12 15:59:31 -04:00
Isaac Connor 939a0f40e6 Include image_count in debug line 2021-04-11 13:22:37 -04:00
Isaac Connor ed29021179 Rough in an importance setting in monitor that we can use to decrease the log level of certain events like PrimeCapture for cameras that we don't care about 2021-04-11 12:59:18 -04:00
Isaac Connor 1ccc416224 Merge branch 'release-1.34' 2021-04-09 20:00:47 -04:00
Isaac Connor d9dc61265d Fix DisableAlarms. Use signal when capture fails instead of erroneously using TRIGGER_OFF. Add status to DumpSettings so that we can query it with zmu. 2021-04-09 17:46:11 -04:00
Isaac Connor 4bd490d121 Set signal=true if capture succeeds. 2021-04-08 11:37:27 -04:00
Isaac Connor 2d7479cb59 reintroduce Start() methods to analysis and decoding thread 2021-04-07 20:36:38 -04:00
Isaac Connor a63186444b Replace char arrays with std::strings in monitor class. 2021-04-07 14:15:55 -04:00
Peter Keresztes Schmidt 817da4e621 Monitor: Make decoder a unique_ptr
The DecoderThread object is owned by the Monitor. Signal this by using unique_ptr.
2021-04-06 12:50:05 +02:00
Peter Keresztes Schmidt fee5ecd72f Monitor: Make analysis_thread a unique_ptr
The AnalysisThread object is owned by the Monitor. Signal this by using unique_ptr.
2021-04-06 12:50:05 +02:00
Isaac Connor 4c988860d5 Close events in a background thread. Add a ton more debugging 2021-04-05 12:56:13 -04:00
Isaac Connor 405be70430 Use packetqueue unlock to also notify 2021-04-02 21:26:01 -04:00
Isaac Connor 87fc35dbe6 Add LOW_PRIORITY to fps status updates 2021-04-02 13:09:32 -04:00
Isaac Connor bcd0e84a31 do sws_scale from decoded image to Image using a member context and avframe to save a few cycles 2021-04-01 13:22:57 -04:00
Isaac Connor 0e00cb0289 use the new packetqueue::unlock to unlock packets and wake up decoding thread 2021-04-01 11:52:47 -04:00
Isaac Connor fd23b3e284 Adjust debug levels 2021-03-31 16:49:19 -04:00
Isaac Connor c73393579d Handle event creation failing gracefullyish 2021-03-31 12:06:33 -04:00
Isaac Connor 8c6f03a4e4 Move waiting for decoding down into motion detection section. Add a test for successful decode. Decode may not provide an image. 2021-03-30 09:16:45 -04:00
Isaac Connor 3202db1b33 Move waiting for decoding down into motion detection part, which is what needs it. Not sure why it was up so high. This should allow more ram freeing for people with analysis fps set to something. 2021-03-30 09:16:44 -04:00
Isaac Connor 0bfbdd6121 Use our new CODEC define to cleanup the code 2021-03-30 09:15:28 -04:00
Isaac Connor 9463cf8565 I can't imagine what fps_report_interval has to do with event being longer than section_length. Use analysis_image_count in log 2021-03-29 09:57:57 -04:00
Isaac Connor 52cb182ae3 Load max_image_buffer_count in monitor and set it in packetqueue. rename max_video_packet_count to pre_event_video_count in packetqueue and adjust logic. When queuing packets check to ensure that we aren't going over. Delete packets from front if possible, do not queue packet if not possible 2021-03-26 14:26:37 -04:00
Isaac Connor b8b20917be setKeepKeyframes when not PASSTHROUGH 2021-03-22 12:05:22 -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 7c9eb42ebb
Merge branch 'master' into 3197-record-event-close-mode 2021-03-21 13:03:26 -04:00
Isaac Connor a042e4bf77 spacing 2021-03-20 19:27:18 -04:00
SirLouen db7e9edcab Issue #3197 Improvement 2021-03-21 00:00:36 +01:00
SirLouen 33f98a0d40 Issue #3197 Add RECORD to Event_Close_Mode time 2021-03-20 20:02:52 +01:00
Isaac Connor edefbfcad6 Remove assumptions about Analysis being about motion detection. Fixes mem leaks in Monitor mode 2021-03-18 09:24:27 -04:00
Isaac Connor f4506a8f35 We always need an analysis thread. 2021-03-17 23:41:00 -04:00
Isaac Connor ccb1bc1a7d Have to wait until we are finished with the packet before unlocking. 2021-03-17 16:11:31 -04:00
Isaac Connor fb28c6b365 Fix login in Decode for non-ffmpeg monitors 2021-03-17 15:53:14 -04:00
Isaac Connor 284fe52b5f fix double stop/free of decoder and analysis threads 2021-03-17 12:57:45 -04:00
Isaac Connor dca34544ec move analysis thread into monitor. populate analysis_it and decoder_it in Prime instead of constantly checking for them. Handle cases where LockedPacket are null due to shutdown 2021-03-17 12:47:52 -04:00
Isaac Connor 657a5edda4 If decoding disabled, set signal and last_write_time in the Capture thread. So that zm_watch knows we are alive 2021-03-17 10:11:06 -04:00
Isaac Connor 74616d1061 Update CaptureFPS SQL to just do an update and don't use static sql. TThis may fix a signal 6 crash that we have been seeing 2021-03-17 10:06:45 -04:00
Isaac Connor 12ed02a5b0 Move trigger detection before motion detection. Only wait for decoding if decoding is enabled 2021-03-16 20:07:59 -04:00
Isaac Connor 5e54a63bd5 Only load zones if doing something other than QUERY. Only delete decoder if there is one. 2021-03-16 13:26:40 -04:00
Isaac Connor 76267bc57f put back deleting the raw image when not saving jpegs. We only need it for the snapshot and that should be the alarmed image anyways. 2021-03-16 12:08:11 -04:00
Isaac Connor 9903e909af Rework locking in ZMPacket by using a new class called ZMLockedPacket. 2021-03-15 17:05:30 -04:00
Isaac Connor b238a2bc25 Implement decoder thread, locking is broken 2021-03-15 15:08:43 -04:00
Isaac Connor 644d6d34a4 Must init video_stream_id and audio_stream_id 2021-03-10 17:23:44 -05:00
Isaac Connor 41085c9e5c Remove final bits of zm_video writer. 2021-03-08 22:14:13 -05:00
Isaac Connor e38e8a2775 Actually use zmc_heartbeat_time. Set it on every capture and use it in ShmValid to determine if zmc has gone away. 2021-03-08 09:30:53 -05: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
Admin fa22129966
Make last_alarm_count last alarmed frame while only in ALARM state to make post_event_count counts since here not alone alarmed frames that don't shot alarms. 2021-03-04 20:20:02 +01:00
Peter Keresztes Schmidt e67626b4e2 logger: Move log_mutex to std::recursive_mutex 2021-03-03 23:31:53 +01:00
Isaac Connor 20fe6153d5 Don't treat data packets as video 2021-03-03 15:52:39 -05:00
Isaac Connor b87d859f72 Set the packet's stream_index to the packetqueue stream. Rename get_ functions to get 2021-03-03 12:06:34 -05:00
Isaac Connor a01a24ec36 Add loading SecondPath in monitor 2021-03-03 09:56:33 -05:00
Isaac Connor 46ec4e75d4 Check codec type instead of stream_index to determine video/audio 2021-03-03 09:52:27 -05:00
Admin 4ff016c991
Make capturing/analysing log lines follow same pattern 2021-03-02 20:51:16 +01:00
Isaac Connor be1b439dcc Add State_Strings and code cleanup. Fix not going into alarm state when already recording. Fixes #3184 2021-03-02 14:42:54 -05:00
Isaac Connor f35a1c70c0 fix build with old avcodec for xenial 2021-03-02 12:07:51 -05:00
Isaac Connor c03d9b2987 Set state before we write packets to event so that the event knows that it is alarmed 2021-03-02 11:47:55 -05:00
Isaac Connor 71d65685b9 Can't clear image data early. Might be needed for snapshot and pre alarm farmes 2021-03-02 11:12:57 -05:00
Isaac Connor 46743ebaab Silence compile warning 2021-03-02 10:00:48 -05:00
Isaac Connor 832eabbd79 Don't both updating analysis fps unless we are doing motion detection 2021-03-02 09:59:32 -05:00
Isaac Connor 1bc5abb9e9 Only include video packets in analysis_image_count 2021-03-01 17:07:09 -05:00
Isaac Connor 51c19912f8 Use analysis_image_count in opening new event log line 2021-03-01 16:56:47 -05:00
Isaac Connor 9302c9506e Add audio_frequency and audio_channels to shared mem and set them in PrimeCapture 2021-03-01 16:49:27 -05:00
Isaac Connor 6e73c08a21 add fifo's for video and audio. Write the packet data to them. Update FifoStream->Fifo 2021-03-01 16:49:26 -05:00
Isaac Connor 6c6d6c51b0 Add RTSPSTreamName loading and write packet data to the video and audio fifos 2021-03-01 16:46:48 -05:00
Isaac Connor 33dbcc449a
Merge pull request #3181 from Carbenium/rgb-const
rgb: Convert some constant defines to constexpr
2021-03-01 09:40:39 -05:00
Isaac Connor 71d864d77b
Merge pull request #3182 from Carbenium/monitor-includes
monitor: Move system includes back to their original location
2021-03-01 09:40:08 -05:00
Peter Keresztes Schmidt 3b3ecb89b2 monitor: Move system includes back to their original location
41dc0212e0 moved the system includes to work around some compilation problems.
The underlying cause has been fixed in cf9406a1e8.
Thus we can move the includes back so the follow the project-wide order.
2021-03-01 00:45:57 +01:00
Peter Keresztes Schmidt 76e6c468e8 rgb: Convert some constant defines to constexpr
Using defines interferes with fmt.
Also rename them according to the Google styleguide.
2021-03-01 00:38:21 +01:00
Admin 741e67e8cd
ALERT also mean warming up with alarm_frame_count value before returning to ALARM.... 2021-02-28 22:42:29 +01:00
Peter Keresztes Schmidt 6a47780f60 Fix a warning reported by -Wextra
/home/peterke/DEV/zoneminder/src/zm_monitor.h: In member function ‘Monitor::TriggerState Monitor::GetTriggerState() const’:
/home/peterke/DEV/zoneminder/src/zm_monitor.h:499:76: warning: enumerated and non-enumerated type in conditional expression [-Wextra]
  499 |   TriggerState GetTriggerState() const { return (TriggerState)(trigger_data?trigger_data->trigger_state:TRIGGER_CANCEL); }
      |                                                                ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-02-27 01:27:58 +01:00
Peter Keresztes Schmidt 403061a39c Fix warnings reported by -Wmissing-field-initializers 2021-02-26 22:46:09 +01:00
Isaac Connor 3ce4b3e657 Keep capture_delay in useconds instead of msecs. Fix fps by adding back in the previous sleep_time. Fix crash due to capture_image not being asigned for local cameras 2021-02-25 16:58:54 -05:00
Isaac Connor 224fcd2cd3 Merge branch 'master' of github.com:ZoneMinder/zoneminder 2021-02-25 14:58:45 -05: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 6c013f0e65 Put back includes needed on FreeBSD. Fixes #3165 2021-02-22 08:03:10 -05:00
Isaac Connor 86d424baf0 Move closeEvent to Close(). If we are closing the camera, we have to close the event as well. 2021-02-19 20:42:36 -05:00
Isaac Connor b9669ad69f Log new signal on signal change 2021-02-19 15:56:30 -05:00
Isaac Connor 4ba290a9ca Use zmDbDo where appropriate and fix some logging while holding the lock 2021-02-19 12:08:19 -05:00
Isaac Connor 045cd219f8 Move clear packetqueue logic to it's own function and call it from the analysis thread. 2021-02-18 19:25:40 -05:00
Isaac Connor 0b0df96271 Merge branch 'master' of github.com:ZoneMinder/zoneminder 2021-02-18 16:05:10 -05:00
Isaac Connor c7dede0083 Cleanups in connect/disconnect 2021-02-18 13:47:27 -05:00
Isaac Connor b1f337b6e7 Move setMaxVideoPackets down to where pre_event_count has a value 2021-02-18 11:54:32 -05:00
Isaac Connor 2a49bd124f Add VNC monitor type 2021-02-17 16:39:16 -05:00
Isaac Connor 33b9dae0f2 fix use of uint32_t for buffer indexes 2021-02-17 13:38:52 -05:00
Isaac Connor 59cdf971fa convert last_read_index and last_write_index to int32_t so that we can have -1 as a value in other functions. 2021-02-16 14:43:52 -05:00
Isaac Connor 41dc0212e0 Move include of algorithm up to top to hopefully fix issues with min and max being defined elsewhere and so compile fails 2021-02-16 10:39:04 -05:00
Isaac Connor a82247b105 Some cleanups in disconnect 2021-02-16 10:39:04 -05:00
Isaac Connor 5a910c4a4b use lock_guard instead of unique_lock 2021-02-12 10:45:32 -05:00
Isaac Connor 2cb6d21faf get rid of while loop in ::Analyze. Switch login on if Ready() to bail early so we don't indent so much. 2021-02-12 10:38:21 -05:00
Isaac Connor 4915e940b7 clean out old mutex. Add event_mutex to protect around event creation/deletion 2021-02-12 10:14:35 -05:00
Peter Keresztes Schmidt 3d759e1fe0 Monitor: Some reformatting of previously touched lines 2021-02-11 20:02:08 +01:00
Peter Keresztes Schmidt c0151caa64 Monitor: Signal by making the camera a unique_ptr the ownership relation
In addition we get RAII and thus automatic destruction of the camera when the monitor is destructed.

Monitor API change: getCamera -> LoadCamera
If additional properties of the camera are needed externally they should be exposed directly via Monitor.
2021-02-11 19:22:22 +01:00
Peter Keresztes Schmidt 91aeb325dd Monitor: Close monitor on destruction
This ensures the proper shutdown sequence when not calling Close() externally (e.g when reconnecting).
2021-02-11 19:22:22 +01:00
Peter Keresztes Schmidt 0a665c0710 Monitor: Close the associated camera when closing the monitor
The camera is owned by the monitor. There is no reason to keep the camera open, when the owner is closed.
2021-02-11 19:22:22 +01:00
Isaac Connor cca4d18d26 need <algorithm> for std::max 2021-02-10 17:29:51 -05:00
Isaac Connor 51f2d120e4 Free raw image after motion detection when doing passthrough and not saving jpegs 2021-02-10 17:07:58 -05:00
Isaac Connor 393e8b582a Move the logic of whether to queue a packet into packetqueue::queuePacket 2021-02-10 14:11:00 -05:00
Isaac Connor 0a1bd3537d ready_count is now max(warmup_count,pre_event_count). This should ensure that we have enough packets in the packet queue when creating an event. 2021-02-10 13:54:20 -05:00
Peter Keresztes Schmidt 2f5dff7244 Monitor: Don't push packets into the packet queue when in Monitor mode
There is no consumer for the packets in this mode, so don't queue them up. This saves quite a bit of RAM for mode of operation.
2021-02-10 16:13:47 +01:00
Isaac Connor fab7efa003 Fix PrimeCapture on local cams. We need to be able to call it for each monitor 2021-02-09 20:29:37 -05:00