Skip to content

Commit 82e7122

Browse files
committed
Updated documentation, recording settings on the WebUI
1 parent 0033189 commit 82e7122

File tree

4 files changed

+45
-7
lines changed

4 files changed

+45
-7
lines changed

res/index.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
apiRead('mp4');
162162
apiRead('mjpeg');
163163
apiRead('night');
164+
apiRead('record');
164165
apiRead('time');
165166

166167
duplicateRows('osd', 10);
@@ -208,6 +209,35 @@ <h2 class="unl">Live</h2>
208209
</div>
209210
<div class="c cont">
210211
<h2 class="unl">Media</h2>
212+
<div class="row">
213+
<div class="12 col box">
214+
<fieldset>
215+
<legend>Recordings</legend>
216+
<table class="w-100">
217+
<tr>
218+
<td><label for="record_enable">Enabled</label></td>
219+
<td><select id="record_enable">
220+
<option value="false">OFF</option>
221+
<option value="true">ON</option>
222+
</select></td>
223+
</tr>
224+
<tr>
225+
<td><label for="record_path">Path</label></td>
226+
<td><input type="text" id="record_path"></td>
227+
</tr>
228+
<tr>
229+
<td><label for="record_filename">Filename</label></td>
230+
<td><input type="text" id="record_filename"></td>
231+
</tr>
232+
<tr>
233+
<td><label for="record_segment_size">Segment size&nbsp;(bytes)</label></td>
234+
<td><input type="number" id="record_segment_size"></td>
235+
</tr>
236+
</table>
237+
<a href="javascript:apiApply('record')" class="btn right">Apply</a>
238+
</fieldset>
239+
</div>
240+
</div>
211241
<div class="row">
212242
<div class="6 col box">
213243
<fieldset>

src/record.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
static FILE *recordFile;
44
static struct Mp4State recordState;
55
static int recordSize;
6+
time_t recordStartTime = 0;
67
char recordOn = 0, recordPath[256];
78

89
static void record_check_segment_size(int upcoming) {
@@ -22,6 +23,7 @@ void record_start(void) {
2223

2324
recordSize = 0;
2425
recordState.header_sent = false;
26+
recordStartTime = time(NULL);
2527

2628
if (EMPTY(app_config.record_path)) {
2729
HAL_DANGER("record", "Destination path is not set!\n");
@@ -37,8 +39,7 @@ void record_start(void) {
3739
recordPath[sizeof(recordPath) - 1] = '\0';
3840
} else {
3941
char tempName[160];
40-
time_t now = time(NULL);
41-
struct tm *tm_info = localtime(&now);
42+
struct tm *tm_info = localtime(&recordStartTime);
4243
sprintf(tempName, "recording_%s.mp4", timefmt);
4344
strftime(recordPath, sizeof(recordPath), tempName, tm_info);
4445
}
@@ -63,6 +64,7 @@ void record_stop(void) {
6364
recordFile = NULL;
6465

6566
recordOn = 0;
67+
recordStartTime = 0;
6668
}
6769

6870
void send_mp4_to_record(hal_vidstream *stream, char isH265) {

src/server.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,14 +1295,19 @@ void respond_request(http_request_t *req) {
12951295
record_stop();
12961296
}
12971297
}
1298+
struct tm *start = localtime(&recordStartTime);
1299+
char start_time[64];
1300+
strftime(start_time, sizeof(start_time), "%Y-%m-%dT%H:%M:%SZ", start);
1301+
12981302
respLen = sprintf(response,
12991303
"HTTP/1.1 200 OK\r\n"
13001304
"Content-Type: application/json;charset=UTF-8\r\n"
13011305
"Connection: close\r\n"
13021306
"\r\n"
1303-
"{\"recording\":%s,\"path\":\"%s\",\"filename\":\"%s\",\"segment_size\":%d}",
1304-
recordOn ? "true" : "false", app_config.record_path,
1305-
app_config.record_filename, app_config.record_segment_size);
1307+
"{\"recording\":%s,\"start_time\":\"%s\",\"path\":\"%s\","
1308+
"\"filename\":\"%s\",\"segment_size\":%d}",
1309+
recordOn ? "true" : "false", recordStartTime,
1310+
app_config.record_path, app_config.record_filename, app_config.record_segment_size);
13061311
send_and_close(req->clntFd, response, respLen);
13071312
return;
13081313
}
@@ -1349,11 +1354,11 @@ void respond_request(http_request_t *req) {
13491354
short result = strtol(value, &remain, 10);
13501355
if (remain == value) continue;
13511356
t.tv_sec = result;
1352-
clock_settime(0, &t);
1357+
clock_settime(CLOCK_REALTIME, &t);
13531358
}
13541359
}
13551360
}
1356-
clock_gettime(0, &t);
1361+
clock_gettime(CLOCK_REALTIME, &t);
13571362
int respLen = sprintf(response,
13581363
"HTTP/1.1 200 OK\r\n"
13591364
"Content-Type: application/json;charset=UTF-8\r\n"

src/server.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "watchdog.h"
2828

2929
extern char graceful, keepRunning, recordOn;
30+
extern time_t recordStartTime;
3031

3132
int start_server();
3233
int stop_server();

0 commit comments

Comments
 (0)