Skip to content

Commit 0033189

Browse files
committed
Inclusion of a local recording module, only accessible over the API right now
1 parent 47ffe00 commit 0033189

File tree

11 files changed

+394
-13
lines changed

11 files changed

+394
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ _* At the moment, text, RGB or bitfield bitmaps and PNG overlays are handled, mo
7777
- [ ] ONVIF write support, enhanced compatiblity
7878
- [ ] Motors and PTZ control
7979
- [ ] Lens correction profiles
80-
- [ ] Local recordings with motion detection
80+
- [ ] Motion detection
8181
- [ ] Alternative audio codecs
8282

8383

divinus.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ rtsp:
3535
auth_pass: 12345
3636
port: 554
3737

38+
record:
39+
enable: false
40+
path: /mnt/sdcard/recordings
41+
#filename: "output.mp4"
42+
#segment_size: 52428800
43+
3844
stream:
3945
enable: false
4046
udp_srcport: 5600

src/app_config.c

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,6 @@ int save_app_config(void) {
7878
fprintf(file, " flip: %s\n", app_config.flip ? "true" : "false");
7979
fprintf(file, " antiflicker: %d\n", app_config.antiflicker);
8080

81-
fprintf(file, "stream:\n");
82-
fprintf(file, " enable: %s\n", app_config.stream_enable ? "true" : "false");
83-
fprintf(file, " udp_srcport: %d\n", app_config.stream_udp_srcport);
84-
if (!EMPTY(*app_config.stream_dests)) {
85-
fprintf(file, " dests: ");
86-
for (int i = 0; app_config.stream_dests[i] && *app_config.stream_dests[i]; i++) {
87-
fprintf(file, " - %s\n", app_config.stream_dests[i]);
88-
}
89-
}
90-
9181
fprintf(file, "mdns:\n");
9282
fprintf(file, " enable: %s\n", app_config.mdns_enable ? "true" : "false");
9383

@@ -104,6 +94,22 @@ int save_app_config(void) {
10494
fprintf(file, " auth_user: %s\n", app_config.rtsp_auth_user);
10595
fprintf(file, " auth_pass: %s\n", app_config.rtsp_auth_pass);
10696

97+
fprintf(file, "record:\n");
98+
fprintf(file, " enable: %s\n", app_config.record_enable ? "true" : "false");
99+
fprintf(file, " path: %s\n", app_config.record_path);
100+
fprintf(file, " filename: %s\n", app_config.record_filename);
101+
fprintf(file, " segment_size: %d\n", app_config.record_segment_size);
102+
103+
fprintf(file, "stream:\n");
104+
fprintf(file, " enable: %s\n", app_config.stream_enable ? "true" : "false");
105+
fprintf(file, " udp_srcport: %d\n", app_config.stream_udp_srcport);
106+
if (!EMPTY(*app_config.stream_dests)) {
107+
fprintf(file, " dests: ");
108+
for (int i = 0; app_config.stream_dests[i] && *app_config.stream_dests[i]; i++) {
109+
fprintf(file, " - %s\n", app_config.stream_dests[i]);
110+
}
111+
}
112+
107113
fprintf(file, "audio:\n");
108114
fprintf(file, " enable: %s\n", app_config.audio_enable ? "true" : "false");
109115
fprintf(file, " bitrate: %d\n", app_config.audio_bitrate);
@@ -198,6 +204,11 @@ enum ConfigError parse_app_config(void) {
198204
app_config.rtsp_auth_user[0] = '\0';
199205
app_config.rtsp_auth_pass[0] = '\0';
200206

207+
app_config.record_enable = false;
208+
app_config.record_filename[0] = '\0';
209+
strcpy(app_config.record_path, "/mnt/sdcard/recordings");
210+
app_config.record_segment_size = 0;
211+
201212
app_config.stream_enable = false;
202213
app_config.stream_udp_srcport = 0;
203214
*app_config.stream_dests[0] = '\0';
@@ -368,6 +379,14 @@ enum ConfigError parse_app_config(void) {
368379
&ini, "onvif", "auth_pass", app_config.onvif_auth_pass);
369380
}
370381

382+
parse_bool(&ini, "record", "enable", &app_config.record_enable);
383+
parse_param_value(
384+
&ini, "record", "path", app_config.record_path);
385+
parse_param_value(
386+
&ini, "record", "filename", app_config.record_filename);
387+
parse_int(&ini, "record", "segment_size", 0, INT_MAX,
388+
&app_config.record_segment_size);
389+
371390
parse_bool(&ini, "rtsp", "enable", &app_config.rtsp_enable);
372391
parse_int(&ini, "rtsp", "port", 0, USHRT_MAX, &app_config.rtsp_port);
373392
if (app_config.rtsp_enable) {

src/app_config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ struct AppConfig {
5959
char rtsp_auth_pass[32];
6060
int rtsp_port;
6161

62+
// [record]
63+
bool record_enable;
64+
char record_filename[128];
65+
char record_path[128];
66+
int record_segment_size;
67+
6268
// [stream]
6369
bool stream_enable;
6470
unsigned short stream_udp_srcport;

src/hal/plus/aw_common.h

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
#pragma once
2+
3+
#include <stdio.h>
4+
#include <stdlib.h>
5+
#include <string.h>
6+
7+
#include "../symbols.h"
8+
#include "../types.h"
9+
10+
typedef enum {
11+
AW_BAYER_RG,
12+
AW_BAYER_GR,
13+
AW_BAYER_GB,
14+
AW_BAYER_BG,
15+
AW_BAYER_END
16+
} aw_common_bayer;
17+
18+
typedef enum {
19+
AW_COMPR_NONE,
20+
AW_COMPR_SEG,
21+
AW_COMPR_SEG128,
22+
AW_COMPR_LINE,
23+
AW_COMPR_FRAME,
24+
AW_COMPR_END
25+
} aw_common_compr;
26+
27+
typedef enum {
28+
AW_HDR_SDR8,
29+
AW_HDR_SDR10,
30+
AW_HDR_HDR10,
31+
AW_HDR_HLG,
32+
AW_HDR_SLF,
33+
AW_HDR_XDR,
34+
AW_HDR_END
35+
} aw_common_hdr;
36+
37+
typedef enum {
38+
AW_MIRR_NONE,
39+
AW_MIRR_HORIZ,
40+
AW_MIRR_VERT,
41+
AW_MIRR_BOTH,
42+
AW_MIRR_END
43+
} aw_common_mirr;
44+
45+
typedef enum {
46+
AW_PIXFMT_RGB_1BPP,
47+
AW_PIXFMT_RGB_2BPP,
48+
AW_PIXFMT_RGB_4BPP,
49+
AW_PIXFMT_RGB_8BPP,
50+
AW_PIXFMT_RGB444,
51+
AW_PIXFMT_RGB4444,
52+
AW_PIXFMT_RGB555,
53+
AW_PIXFMT_RGB565,
54+
AW_PIXFMT_RGB1555,
55+
AW_PIXFMT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B12,
98+
AW_PIXFMT_BUF_NV21S = AW_PIXFMT_YVU420SP,
99+
AW_PIXFMT_BUF_NV21M = 0x0100,
100+
AW_PIXFMT_YUV_GREY,
101+
AW_PIXFMT_END,
102+
} aw_common_pixfmt;
103+
104+
typedef enum {
105+
AW_PREC_8BPP,
106+
AW_PREC_10BPP,
107+
AW_PREC_12BPP,
108+
AW_PREC_14BPP,
109+
AW_PREC_16BPP,
110+
AW_PREC_END
111+
} aw_common_prec;
112+
113+
typedef enum {
114+
AW_VIDFMT_LINEAR,
115+
AW_VIDFMT_TILE_64X16,
116+
AW_VIDFMT_TILE_16X8,
117+
AW_VIDFMT_LINEAR_DISCRETE,
118+
AW_VIDFMT_END
119+
} aw_common_vidfmt;
120+
121+
typedef enum {
122+
AW_WDR_NONE,
123+
AW_WDR_BUILTIN,
124+
AW_WDR_QUDRA,
125+
AW_WDR_2TO1_LINE,
126+
AW_WDR_2TO1_FRAME,
127+
AW_WDR_2TO1_FRAME_FULLRATE,
128+
AW_WDR_3TO1_LINE,
129+
AW_WDR_3TO1_FRAME,
130+
AW_WDR_3TO1_FRAME_FULLRATE,
131+
AW_WDR_4TO1_LINE,
132+
AW_WDR_4TO1_FRAME,
133+
AW_WDR_4TO1_FRAME_FULLRATE,
134+
AW_WDR_END
135+
} aw_common_wdr;
136+
137+
typedef struct {
138+
unsigned int topWidth;
139+
unsigned int bottomWidth;
140+
unsigned int leftWidth;
141+
unsigned int rightWidth;
142+
unsigned int color;
143+
} aw_common_bord;
144+
145+
typedef struct {
146+
unsigned int width;
147+
unsigned int height;
148+
} aw_common_dim;
149+
150+
typedef struct {
151+
int x;
152+
int y;
153+
} aw_common_pnt;
154+
155+
typedef struct {
156+
int x;
157+
int y;
158+
unsigned int width;
159+
unsigned int height;
160+
} aw_common_rect;

src/media.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ int save_video_stream(char index, hal_vidstream *stream) {
8888
if (app_config.mp4_enable) {
8989
pthread_mutex_lock(&mp4Mtx);
9090
send_mp4_to_client(index, stream, isH265);
91+
if (recordOn) send_mp4_to_record(stream, isH265);
9192
pthread_mutex_unlock(&mp4Mtx);
9293

9394
send_h26x_to_client(index, stream);

src/media.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "server.h"
1919
#include "stream.h"
2020

21-
extern char audioOn, udpOn;
21+
extern char audioOn, recordOn, udpOn;
2222
extern rtsp_handle rtspHandle;
2323

2424
int start_sdk(void);

0 commit comments

Comments
 (0)