Roadmap M2: Dahua adapter #6

Merged
coding-agent-marvin8 merged 0 commits from refs/pull/6/head into main 2026-05-27 20:14:49 +00:00
coding-agent-marvin8 commented 2026-05-27 19:43:17 +00:00 (Migrated from codeberg.org)

Closes #5.

What

Implements the Dahua NVR adapter layer (M2 in the roadmap):

  • src/cang/adapters/base.pyIncomingClip dataclass + BaseAdapter ABC
  • src/cang/adapters/dahua.pyDahuaAdapter.scan() that walks the Dahua folder tree and yields IncomingClip objects with matched snapshots
  • tests/adapters/test_dahua.py — 14 tests covering unit parsing and full integration via a minimal tmp_path tree

How

Dahua NVRs write clips as <serial>/<date>/<channel>/dav/<HH>/<stem>.dav and per-second snapshots as <serial>/<date>/<channel>/jpg/<HH>/<MM>/<SS>[flags].jpg. The adapter:

  1. Walks dav/ hour-dirs, parses each .dav stem with a regex to extract start/end times and [M]/[F] flags
  2. Collects matching snapshots by scanning the parallel jpg/ tree and filtering to clip.start ≤ snapshot_time ≤ clip.end
  3. Skips .idx sidecar files
  4. Yields a fully populated IncomingClip for each clip

Test results

Tests  15 passed (15)
Closes #5. ## What Implements the Dahua NVR adapter layer (M2 in the roadmap): - `src/cang/adapters/base.py` — `IncomingClip` dataclass + `BaseAdapter` ABC - `src/cang/adapters/dahua.py` — `DahuaAdapter.scan()` that walks the Dahua folder tree and yields `IncomingClip` objects with matched snapshots - `tests/adapters/test_dahua.py` — 14 tests covering unit parsing and full integration via a minimal `tmp_path` tree ## How Dahua NVRs write clips as `<serial>/<date>/<channel>/dav/<HH>/<stem>.dav` and per-second snapshots as `<serial>/<date>/<channel>/jpg/<HH>/<MM>/<SS>[flags].jpg`. The adapter: 1. Walks `dav/` hour-dirs, parses each `.dav` stem with a regex to extract start/end times and `[M]`/`[F]` flags 2. Collects matching snapshots by scanning the parallel `jpg/` tree and filtering to `clip.start ≤ snapshot_time ≤ clip.end` 3. Skips `.idx` sidecar files 4. Yields a fully populated `IncomingClip` for each clip ## Test results ``` Tests 15 passed (15) ```
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
marvin8/cang!6
No description provided.