Fix ONVIF driver crashes on continuous-only PTZ cameras#172
Open
cam-s-hunt wants to merge 1 commit intoopensensorhub:masterfrom
Open
Fix ONVIF driver crashes on continuous-only PTZ cameras#172cam-s-hunt wants to merge 1 commit intoopensensorhub:masterfrom
cam-s-hunt wants to merge 1 commit intoopensensorhub:masterfrom
Conversation
…olink) Four bugs fixed: 1. IllegalArgumentException when camera lacks absolute PTZ: When absolute pan/tilt is unsupported, ptzPos is removed from commandData. The zoom removal then crashes trying to access the already-removed ptzPos item. Added a guard flag to skip the nested removal when ptzPos was already removed. 2. NullPointerException in execCommand when getPosition() returns null: Some cameras return null from getStatus() or getPosition() instead of throwing. Added null checks with a fallback to empty PTZVector. 3. NullPointerException on autoRemoteHost.clear() during init: GSON deserializes missing/null JSON fields as null, overriding Java field defaults. Added null-check before clear(), initializing with new TreeSet<>() when null. 4. H.264 WebCodecs decoder failure for late-joining viewers: Enabled setInjectVideoExtradata(true) on MpegTsProcessor so SPS/PPS NAL units are prepended before keyframes. Without this, WebCodecs VideoDecoder cannot initialize when joining mid-stream. Tested with Reolink RLC-823A (continuous PTZ only, H.264). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes four bugs in the ONVIF driver that cause crashes or failures when used with cameras that only support continuous PTZ (no absolute/relative), such as Reolink models.
Fix
IllegalArgumentExceptiononptzPosaccess after removal: When a camera lacks absolute pan/tilt, theptzPoscomponent is removed fromcommandData. The subsequent zoom-removal code then crashes trying to access the already-removed item. Added a guard flag (absolutePtRemoved) to skip the nested removal.Fix
NullPointerExceptioninexecCommandwhen position is null: Some cameras returnnullfromgetStatus()orgetPosition()rather than throwing an exception. Added null checks with a fallback to an emptyPTZVector.Fix
NullPointerExceptiononautoRemoteHost.clear()during init: GSON deserializes missing/null JSON fields asnull, overriding Java field initializers. Added a null-check beforeclear(), initializing withnew TreeSet<>()when null.Enable H.264 extradata injection for WebCodecs compatibility: Calls
mpegTsProcessor.setInjectVideoExtradata(true)so SPS/PPS NAL units are prepended before keyframes. Without this, browser-based viewers using the WebCodecsVideoDecoderAPI cannot decode the H.264 stream when joining mid-stream (they require a keyframe with SPS/PPS to initialize).Test plan
IllegalArgumentExceptionDataError