Skip to content

feat(shm): add ZM 1.38 SharedData struct support with size-based auto-detection #59

@pliablepixels

Description

@pliablepixels

Summary

ZoneMinder 1.38 changed the SharedData struct layout in shared memory, adding new fields (image_count, latitude, longitude, capturing, analysing, recording, janus_pin, etc.) and renaming activecapturing. The struct size grew from 760 to 872 bytes.

Changes

  • Replace inline Perl comment blocks with declarative _LAYOUT_760 and _LAYOUT_872 tuple lists
  • Add _build_struct_info() helper to derive format string, field names, and string-field list from layouts
  • Build a _REGISTRY dict keyed by struct.calcsize() for automatic version detection
  • Auto-detect ZM version by reading the size field (first uint32) from shared memory and looking it up in the registry
  • Extract TriggerData format to module-level constants
  • Add backward-compatibility alias: activecapturing for ZM 1.38

Design

Adding support for a future ZM version requires only:

  1. Define a new _LAYOUT_xxx list
  2. Append it to the registry loop

No if/else branches, no duplicate format strings.

Related: PR #58 by @jantman

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions