Skip to content

Commit 50697f7

Browse files
matteiusclaude
andcommitted
refactor: rename onvif_motion_recording to cross_stream_motion_trigger + drop /api/motion/test (#374)
The onvif_motion_recording module has been reduced to a single function (process_motion_event) whose only job is to fan a motion event out to streams linked via motion_trigger_source -- the actual "motion recording" machinery (per-camera config, buffers, retention) was deleted in 878d3f3 along with the corresponding UI section. The filename no longer matches what the module does; cross-stream motion trigger propagation is what remained, so rename accordingly. - git-mv onvif_motion_recording.{c,h} to cross_stream_motion_trigger.{c,h} - Update header guard LIGHTNVR_ONVIF_MOTION_RECORDING_H -> LIGHTNVR_CROSS_STREAM_MOTION_TRIGGER_H - Refresh the file-level doc comment in both files to describe what the module actually does now, with a one-line note on the rename for grep archaeology - Update the six #include sites: main.c, onvif_detection.c, detection_integration.c, db_motion_config.h, the test file, and the deleted api_handlers_motion.c Also delete the /api/motion/test/<stream> endpoint. It's unreachable from the current UI (the Trigger Test Motion button was removed along with the Motion Recording section) and nothing else calls it -- the whole api_handlers_motion.{c,h} pair existed solely for this one route. Removed files + the route registration + the include in libuv_api_handlers.c. No behavior change for running installations. The cross-stream motion trigger tests continue to pass (5/5). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 51e68cf commit 50697f7

10 files changed

Lines changed: 33 additions & 105 deletions

include/database/db_motion_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <stdint.h>
55
#include <stdbool.h>
6-
#include "video/onvif_motion_recording.h"
6+
#include "video/cross_stream_motion_trigger.h"
77

88
/**
99
* Motion Recording Configuration Database Module

include/video/onvif_motion_recording.h renamed to include/video/cross_stream_motion_trigger.h

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef LIGHTNVR_ONVIF_MOTION_RECORDING_H
2-
#define LIGHTNVR_ONVIF_MOTION_RECORDING_H
1+
#ifndef LIGHTNVR_CROSS_STREAM_MOTION_TRIGGER_H
2+
#define LIGHTNVR_CROSS_STREAM_MOTION_TRIGGER_H
33

44
#include <stdint.h>
55
#include <stdbool.h>
@@ -10,13 +10,18 @@
1010
#include "video/packet_buffer.h"
1111

1212
/**
13-
* ONVIF Motion Detection Recording Module
14-
*
15-
* This module implements automated recording triggered by ONVIF motion detection events.
16-
* It provides:
17-
* - Event-based recording triggered by ONVIF motion events
18-
* - Configurable pre/post-event buffer recording
19-
* - Integration with existing LightNVR detection framework
13+
* Cross-Stream Motion Trigger Module
14+
*
15+
* Fans an incoming motion event out to any streams linked via the
16+
* `motion_trigger_source` configuration, so a silent PTZ lens can start
17+
* recording when its paired wide-angle lens fires a motion event, and
18+
* vice-versa for dual-lens devices that share a single ONVIF endpoint.
19+
*
20+
* This used to be onvif_motion_recording.{c,h}; the bulk of that module
21+
* (per-camera motion recording configuration with its own buffers and
22+
* retention) was removed along with the separate "Motion Recording (ONVIF)"
23+
* UI section. What remained was just the cross-stream propagation hook,
24+
* hence the rename.
2025
*/
2126

2227
// Maximum number of motion events in queue
@@ -43,5 +48,5 @@ typedef struct {
4348
*/
4449
int process_motion_event(const char *stream_name, bool motion_detected, time_t timestamp, bool is_propagated);
4550

46-
#endif /* LIGHTNVR_ONVIF_MOTION_RECORDING_H */
51+
#endif /* LIGHTNVR_CROSS_STREAM_MOTION_TRIGGER_H */
4752

include/web/api_handlers_motion.h

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/core/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#include "video/timestamp_manager.h"
4545
#include "video/onvif_discovery.h"
4646
#include "video/ffmpeg_leak_detector.h"
47-
#include "video/onvif_motion_recording.h"
47+
#include "video/cross_stream_motion_trigger.h"
4848
#include "telemetry/stream_metrics.h"
4949
#include "telemetry/player_telemetry.h"
5050

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/**
2-
* ONVIF Motion Detection Recording Implementation
3-
*
4-
* This module implements automated recording triggered by ONVIF motion detection events.
2+
* Cross-Stream Motion Trigger Implementation
3+
*
4+
* Propagates a motion event from one stream to any linked streams via the
5+
* `motion_trigger_source` configuration. See cross_stream_motion_trigger.h
6+
* for the module-level rationale.
57
*/
68

79
#include <stdio.h>
@@ -13,7 +15,7 @@
1315
#include <sys/stat.h>
1416
#include <errno.h>
1517

16-
#include "video/onvif_motion_recording.h"
18+
#include "video/cross_stream_motion_trigger.h"
1719
#include "video/streams.h"
1820
#include "video/stream_manager.h"
1921
#include "video/unified_detection_thread.h"

src/video/detection_integration.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "video/sod_integration.h"
2424
#include "video/api_detection.h"
2525
#include "video/onvif_detection.h"
26-
#include "video/onvif_motion_recording.h"
26+
#include "video/cross_stream_motion_trigger.h"
2727
#include "utils/memory.h"
2828

2929
// Include our new modules

src/video/onvif_detection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "video/onvif_detection.h"
2020
#include "video/onvif_soap.h"
2121
#include "video/detection_result.h"
22-
#include "video/onvif_motion_recording.h"
22+
#include "video/cross_stream_motion_trigger.h"
2323
#include "video/zone_filter.h"
2424
#include "database/db_detections.h"
2525
#include "ezxml.h"

src/web/api_handlers_motion.c

Lines changed: 0 additions & 57 deletions
This file was deleted.

src/web/libuv_api_handlers.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "web/api_handlers_settings.h"
1818
#include "web/api_handlers_system.h"
1919
#include "web/api_handlers_zones.h"
20-
#include "web/api_handlers_motion.h"
2120
#include "web/api_handlers_ptz.h"
2221
#include "web/api_handlers_detection.h"
2322
#include "web/api_handlers_recordings_playback.h"
@@ -134,9 +133,6 @@ int register_all_libuv_handlers(http_server_handle_t server) {
134133
http_server_register_handler(server, "/api/detection/results/#", "GET", handle_get_detection_results);
135134
http_server_register_handler(server, "/api/detection/models", "GET", handle_get_detection_models);
136135

137-
// Motion Recording API
138-
http_server_register_handler(server, "/api/motion/test/#", "POST", handle_test_motion_event);
139-
140136
// Storage Management API
141137
http_server_register_handler(server, "/api/storage/health", "GET", handle_get_storage_health);
142138
http_server_register_handler(server, "/api/storage/cleanup", "POST", handle_post_storage_cleanup);

tests/unit/test_cross_stream_motion_trigger.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
* @file test_cross_stream_motion_trigger.c
33
* @brief Layer 3 Unity tests for cross-stream motion trigger feature
44
*
5-
* Tests the process_motion_event() cross-stream propagation logic added in
6-
* src/video/onvif_motion_recording.c. The feature allows a "silent" stream
7-
* (e.g. PTZ lens) to have its recording triggered by motion events from a
8-
* different "source" stream (e.g. fixed wide-angle lens with ONVIF support).
5+
* Tests the process_motion_event() cross-stream propagation logic in
6+
* src/video/cross_stream_motion_trigger.c. The feature allows a "silent"
7+
* stream (e.g. PTZ lens) to have its recording triggered by motion events
8+
* from a different "source" stream (e.g. fixed wide-angle lens with ONVIF
9+
* support).
910
*
10-
* Layer 3: requires lightnvr_lib + FFmpeg (for onvif_motion_recording.c which
11-
* includes libavformat/avformat.h).
11+
* Layer 3: requires lightnvr_lib + FFmpeg (the module header pulls in
12+
* libavformat/avformat.h transitively).
1213
*/
1314

1415
#define _POSIX_C_SOURCE 200809L
@@ -23,7 +24,7 @@
2324
#include "unity.h"
2425
#include "database/db_core.h"
2526
#include "database/db_streams.h"
26-
#include "video/onvif_motion_recording.h"
27+
#include "video/cross_stream_motion_trigger.h"
2728
#include "core/config.h"
2829
#include "core/logger.h"
2930
#include "utils/strings.h"

0 commit comments

Comments
 (0)