Commit Graph

6211 Commits

Author SHA1 Message Date
Ben Dailey
3ee2ab6dde refactor: simplify ONVIF timeout options to use seconds instead of ISO 8601
- Change pull_timeout and subscription_timeout from std::string (ISO 8601)
  to int (seconds) for simpler configuration and cleaner code
- Add deprecation warning when PT prefix is detected in option values
- Add FormatDurationSeconds() helper to construct ISO 8601 strings for SOAP
- Use zm_utils.h functions: Split(), PairSplit(), StartsWith()
- Remove unused parse_iso8601_duration_seconds() function

New option format: pull_timeout=5,subscription_timeout=300
Old format (deprecated): pull_timeout=PT5S,subscription_timeout=PT300S

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 12:58:21 -05:00
Ben Dailey
620814fd06 fix: adjust ONVIF timing parameters and fix pull_timeout validation
- Increase ONVIF_RENEWAL_ADVANCE_SECONDS from 20s to 60s to give more
  buffer time before subscription expiration
- Reduce default pull_timeout from PT10S to PT5S for more responsive
  event polling
- Fix pull_timeout adjustment logic to dynamically construct the timeout
  string based on ONVIF_RENEWAL_ADVANCE_SECONDS instead of hardcoding
- Update fallback timeout from PT8S to PT5S for consistency
- Clean up SOAP_STRINGS array formatting

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 12:40:32 -05:00
Ben Dailey
872cd59c8d fix: add thread safety for ONVIF alarmed and healthy flags
Convert alarmed and healthy from plain bool to std::atomic<bool> to
fix data races between the ONVIF polling thread and the analysis thread.

Changes:
- Rename alarmed -> alarmed_, healthy -> healthy_ (atomic naming convention)
- Use memory_order_acquire for loads, memory_order_release for stores
- Remove unnecessary mutex lock from isAlarmed() (atomic is sufficient)
- Add const qualifier to isAlarmed() and isHealthy() accessors

The alarms_mutex is retained for protecting the alarms map operations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 08:46:02 -05:00
Ben Dailey
0079ee0107 feat: add dedicated polling thread for ONVIF events
Move ONVIF polling from shared Poll() loop (10s cadence) to dedicated
thread with 500ms cadence. This reduces worst-case ONVIF event latency
from ~10 seconds to ~500ms.

Changes:
- Add thread management to ONVIF class (thread_, terminate_, Run())
- Launch polling thread in start() after successful subscription
- Stop thread in destructor before SOAP cleanup
- Remove ONVIF handling from Monitor::Poll()
- Call onvif->start() immediately after creation in Monitor::connect()
- Increase default pull_timeout from PT5S to PT10S for better listening window

The ONVIF thread handles its own reconnection when unhealthy. Other
managers (Amcrest, RTSP2Web, Go2RTC, Janus) remain on 10s Poll() cadence.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 08:37:37 -05:00
Isaac Connor
f4a6227132 Fix comment. long long is 64bits 2026-01-20 16:29:40 -05:00
Isaac Connor
8fbe4be2c0 Fix SQL loading groups 2026-01-20 16:26:41 -05:00
Isaac Connor
e663605b56 Use correct, non-truncating cast to test success of shmat 2026-01-20 16:26:12 -05:00
Isaac Connor
b64520649d Use std::shared_ptr to fix memory leak due to use of GetSnapshot and not freeing the returned packet. 2026-01-20 16:18:43 -05:00
Isaac Connor
5c4afc9532 Only blend if y_image exists 2026-01-19 15:03:58 -06:00
Isaac Connor
4335da096a Remove debug 2026-01-19 14:41:04 -06:00
Isaac Connor
51334e8d18 Don't crash when decoding=keyframes due to y_image not being defined 2026-01-19 14:40:53 -06:00
Isaac Connor
32a842e81e Return instead of panic in Delta and Blend 2026-01-19 14:40:28 -06:00
Isaac Connor
94c7ef7a27 INcrease renewal advance seconds to give a little more room 2026-01-18 17:37:07 -06:00
Isaac Connor
a33cdd4444 Reduce logging. Renew will log a warning on any failure, so don't need to warn again. 2026-01-17 08:45:45 -05:00
Isaac Connor
47cc713eaa Re-enable analysis image viewing 2026-01-16 16:02:19 -05:00
Isaac Connor
4db0a431f8 Use packet->analyzed to keep event behind analysis. 2026-01-16 16:02:01 -05:00
Isaac Connor
b696d5edcd Re-enable copying the analysis_image to shm so that zms can show it. 2026-01-16 16:01:10 -05:00
Isaac Connor
db4cb94455 Add analyzed to zm_packet 2026-01-16 15:48:56 -05:00
Isaac Connor
9ee497f708 Add toString 2026-01-16 15:44:30 -05:00
Isaac Connor
17a633087c Create a constructor that takes an allocation parameter so that we can give a larger allocation than buffer size 2026-01-16 15:37:10 -05:00
Isaac Connor
ec913cfc50 When overlaying a greyscale onto rgb32, only set the red field so we don't get white. 2026-01-16 15:29:39 -05:00
Isaac Connor
d53f3ca971 Merge branch 'master' of github.com:ZoneMinder/zoneminder 2026-01-16 14:24:59 -05:00
Isaac Connor
d4d01cb0d9 Use RAII for packet_counts 2026-01-16 12:28:57 -05:00
Isaac Connor
7a94717cf4 Add locking to size() and packet_count() and has_out_of_order_packets 2026-01-16 12:22:33 -05:00
Isaac Connor
5561041c70 Add a lambda to prevent spurious wakeups 2026-01-16 12:11:42 -05:00
Isaac Connor
1a3e36424e Set frames_since_last_keyrrame = 0 instead of 1 2026-01-16 12:06:22 -05:00
Isaac Connor
9f0b5c8cd6 Handle impossible case where snapshot-it points to end. Can't -- on end. WOuld need to be a reverse iterator. 2026-01-16 12:02:42 -05:00
Isaac Connor
5204a24345 Fix doulbe free of it. 2026-01-16 11:55:35 -05:00
Isaac Connor
80fab1dbf2 Test for packet_, which really should never be null 2026-01-16 11:55:17 -05:00
Isaac Connor
509e189bfd Handle unlocking an unlocked packet 2026-01-16 11:55:03 -05:00
Isaac Connor
2e2690c7c6 Move lock guards to protect deleting basically to satisfy AI. It is technically correct. 2026-01-16 10:49:31 -05:00
Isaac Connor
2f73e0591d feat: add last_analysis_viewed_time tracking for analysis image viewers
Add SharedData field and methods to track when analysis images are being
viewed, mirroring the existing last_viewed_time functionality. This allows
the analysis process to know if someone is actively viewing analysis images.

- Add last_analysis_viewed_time to SharedData struct
- Add getLastAnalysisViewed(), setLastAnalysisViewed(), hasAnalysisViewers()
- Update MonitorStream to set flag when streaming FRAME_ANALYSIS

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 10:13:23 -05:00
Isaac Connor
a90ce3b076 Merge pull request #4556 from BHMSD-bdailey/ONVIF_Parsing
Onvif parsing
2026-01-15 16:35:36 -05:00
Isaac Connor
14bb739c00 DOn't need to lock the new keyframe, just frames before it. Fix not break if it is locked 2026-01-15 16:32:32 -05:00
Isaac Connor
9615969314 We may need () 2026-01-15 16:32:32 -05:00
Isaac Connor
0de8c7b4ad Only warn about being at end of queue in incremement_it if we are not deleting to prevent red herring logging 2026-01-15 16:32:32 -05:00
Isaac Connor
448056a809 Use lock_guard instead of unique_lock where appropriate 2026-01-15 16:32:32 -05:00
Isaac Connor
37d5430adc Turn off a debug 2026-01-15 16:32:32 -05:00
nvme
792fb4de75 Reduce logging 2026-01-15 16:32:32 -05:00
Isaac Connor
7c5b24cbab Must start at second packet. Cleanup 2026-01-15 16:32:32 -05:00
nvme
6b424088e3 When every frame is a keyframe, need to set max_keyframe_interval=1 2026-01-15 16:32:32 -05:00
Isaac Connor
d82bfbfb5e Remove dead code, fix not deleting packets when full 2026-01-15 16:32:32 -05:00
Isaac Connor
ed2f809df0 Improve debug 2026-01-15 16:32:32 -05:00
Isaac Connor
0932ab71dd Maybe fix not freeing audio packets 2026-01-15 16:32:32 -05:00
Isaac Connor
f173deae29 Notify while holding the lock 2026-01-15 16:32:32 -05:00
Isaac Connor
c05a9462da Get lock earlier 2026-01-15 16:32:32 -05:00
Isaac Connor
56628240b8 Optimise std_shared_ptr accesses 2026-01-15 16:32:32 -05:00
Isaac Connor
6e6b3d097b Fix lock around deleting causinganalysis to hang 2026-01-15 16:32:32 -05:00
Isaac Connor
cb23ce65e8 We don't need to lock the packets to delete them. 2026-01-15 16:32:32 -05:00
Isaac Connor
a10f65d574 Always delete frames when we don't care about keyframes 2026-01-15 16:32:32 -05:00