Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
cf06bd4
Infinity3: HAL on the vendor MI library
HeytalePazguato Oct 29, 2026
7e37832
MP4: separate track clocks, one audio frame per sample, Opus
HeytalePazguato Oct 29, 2026
f8d65a0
RTSP: allow a second server instance, system-account login
HeytalePazguato Oct 29, 2026
87c552e
Night mode: switch on ISP exposure when there is no light sensor
HeytalePazguato Oct 29, 2026
b5e4c17
OSD: region anchors (top-left ... bottom-right) with offsets
HeytalePazguato Oct 29, 2026
497327c
Recorder: storage guard, loop recording, shared muxer
HeytalePazguato Oct 29, 2026
ce33918
Server, media and page: wire up the Infinity3 features
HeytalePazguato Oct 29, 2026
067a28c
Infinity3: run on OpenIPC's musl base
HeytalePazguato Oct 29, 2026
654739f
Zero the encoder configs before filling them
HeytalePazguato Oct 30, 2026
e6dda6d
Infinity3: night grayscale through the ISP
HeytalePazguato Oct 30, 2026
32a744e
Infinity3: rate control modes, no spinning on a restarting channel
HeytalePazguato Oct 30, 2026
b204f40
Night mode: fewer daylight probes without a light sensor
HeytalePazguato Oct 30, 2026
734597c
Recorder: timed recordings for event triggers
HeytalePazguato Oct 30, 2026
3e7af9b
Server: no debug request log, clips without links, stop ends continuous
HeytalePazguato Oct 31, 2026
b2f0112
Recorder: card back to read-only after failures, cleanup off the vide…
HeytalePazguato Oct 31, 2026
539b079
System login: thread-safe, cache follows /etc/shadow, no sleep
HeytalePazguato Oct 31, 2026
0dbe907
Night mode: probe without exposure_day, lamps back on after an interr…
HeytalePazguato Oct 31, 2026
82375da
Infinity3: JPEG quality from the config, sub-stream stops at the firs…
HeytalePazguato Oct 31, 2026
61b8ae9
Page: ?debug only shows the player state
HeytalePazguato Oct 31, 2026
faa5e56
Infinity3: apply the requested snapshot quality
HeytalePazguato Oct 31, 2026
fb865e7
Merge remote-tracking branch 'origin/master' into looc2-pr
HeytalePazguato Nov 14, 2026
cedad20
Infinity3: keep musl's mmap when building with GLIBC_COMPAT
HeytalePazguato Nov 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
376 changes: 359 additions & 17 deletions res/index.html

Large diffs are not rendered by default.

56 changes: 54 additions & 2 deletions src/app_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ int app_config_save(void) {
fprintf(file, " ir_cut_pin1: %d\n", app_config.ir_cut_pin1);
fprintf(file, " ir_cut_pin2: %d\n", app_config.ir_cut_pin2);
fprintf(file, " ir_led_pin: %d\n", app_config.ir_led_pin);
if (app_config.white_led_pin != 999)
fprintf(file, " white_led_pin: %d\n", app_config.white_led_pin);
fprintf(file, " pin_switch_delay_us: %d\n", app_config.pin_switch_delay_us);
fprintf(file, " adc_device: %s\n", app_config.adc_device);
{
Expand All @@ -114,6 +116,8 @@ int app_config_save(void) {
fprintf(file, " lamp: %s\n", lamp);
}
fprintf(file, " adc_threshold: %d\n", app_config.adc_threshold);
fprintf(file, " exposure_night: %u\n", app_config.exposure_night);
fprintf(file, " exposure_day: %u\n", app_config.exposure_day);

fprintf(file, "isp:\n");
fprintf(file, " mirror: %s\n", app_config.mirror ? "true" : "false");
Expand Down Expand Up @@ -144,6 +148,7 @@ int app_config_save(void) {
fprintf(file, " filename: %s\n", app_config.record_filename);
fprintf(file, " segment_duration: %d\n", app_config.record_segment_duration);
fprintf(file, " segment_size: %d\n", app_config.record_segment_size);
fprintf(file, " reserve: %d\n", app_config.record_reserve);

fprintf(file, "stream:\n");
fprintf(file, " enable: %s\n", app_config.stream_enable ? "true" : "false");
Expand All @@ -164,6 +169,7 @@ int app_config_save(void) {
fprintf(file, "mp4:\n");
fprintf(file, " enable: %s\n", app_config.mp4_enable ? "true" : "false");
fprintf(file, " codec: %s\n", app_config.mp4_codecH265 ? "H.265" : "H.264");
fprintf(file, " audio: %s\n", app_config.mp4_audio ? "true" : "false");
fprintf(file, " mode: %d\n", app_config.mp4_mode);
fprintf(file, " width: %d\n", app_config.mp4_width);
fprintf(file, " height: %d\n", app_config.mp4_height);
Expand All @@ -172,6 +178,14 @@ int app_config_save(void) {
fprintf(file, " profile: %d\n", app_config.mp4_profile);
fprintf(file, " bitrate: %d\n", app_config.mp4_bitrate);

fprintf(file, "sub:\n");
fprintf(file, " enable: %s\n", app_config.sub_enable ? "true" : "false");
fprintf(file, " width: %d\n", app_config.sub_width);
fprintf(file, " height: %d\n", app_config.sub_height);
fprintf(file, " gop: %d\n", app_config.sub_gop);
fprintf(file, " bitrate: %d\n", app_config.sub_bitrate);
fprintf(file, " rtsp_port: %d\n", app_config.sub_rtsp_port);

fprintf(file, "osd:\n");
fprintf(file, " enable: %s\n", app_config.osd_enable ? "true" : "false");
for (char i = 0; i < MAX_OSD; i++) {
Expand All @@ -185,6 +199,7 @@ int app_config_save(void) {
fprintf(file, " reg%d_text: %s\n", i, osds[i].text);
fprintf(file, " reg%d_font: %s\n", i, osds[i].font);
fprintf(file, " reg%d_opal: %d\n", i, osds[i].opal);
fprintf(file, " reg%d_anchor: %s\n", i, osd_anchors[(unsigned char)osds[i].anchor % 9]);
fprintf(file, " reg%d_posx: %d\n", i, osds[i].posx);
fprintf(file, " reg%d_posy: %d\n", i, osds[i].posy);
fprintf(file, " reg%d_size: %.1f\n", i, osds[i].size);
Expand Down Expand Up @@ -256,8 +271,9 @@ enum ConfigError app_config_parse(void) {
app_config.record_continuous = false;
app_config.record_filename[0] = '\0';
strcpy(app_config.record_path, "/mnt/sdcard/recordings");
app_config.record_segment_duration = 0;
app_config.record_segment_duration = 300;
app_config.record_segment_size = 0;
app_config.record_reserve = 512;

app_config.stream_enable = false;
app_config.stream_udp_srcport = 0;
Expand All @@ -269,6 +285,13 @@ enum ConfigError app_config_parse(void) {
app_config.audio_gain = 0;
app_config.jpeg_enable = false;
app_config.mp4_enable = false;
app_config.mp4_audio = true;
app_config.sub_enable = false;
app_config.sub_width = 640;
app_config.sub_height = 360;
app_config.sub_gop = 30;
app_config.sub_bitrate = 512;
app_config.sub_rtsp_port = 555;

app_config.mjpeg_enable = false;
app_config.mjpeg_fps = 15;
Expand All @@ -286,11 +309,14 @@ enum ConfigError app_config_parse(void) {
app_config.ir_cut_pin1 = 999;
app_config.ir_cut_pin2 = 999;
app_config.ir_led_pin = 999;
app_config.white_led_pin = 999;
app_config.pin_switch_delay_us = 250;
app_config.check_interval_s = 10;
app_config.adc_device[0] = 0;
app_config.night_lamp = HAL_LIGHT_IR;
app_config.adc_threshold = 128;
app_config.exposure_night = 0;
app_config.exposure_day = 0;

struct IniConfig ini;
memset(&ini, 0, sizeof(struct IniConfig));
Expand Down Expand Up @@ -354,7 +380,7 @@ enum ConfigError app_config_parse(void) {

err =
parse_bool(&ini, "night_mode", "enable", &app_config.night_mode_enable);
#define PIN_MAX 95
#define PIN_MAX 127 /* Infinity3 has GPIOs up to 109 (IR-cut on 96/97) */
if (app_config.night_mode_enable) {
{
int pin;
Expand All @@ -374,6 +400,9 @@ enum ConfigError app_config_parse(void) {
parse_int(
&ini, "night_mode", "ir_led_pin", 0, PIN_MAX,
&app_config.ir_led_pin);
parse_int(
&ini, "night_mode", "white_led_pin", 0, PIN_MAX,
&app_config.white_led_pin);
parse_int(
&ini, "night_mode", "pin_switch_delay_us", 0, 1000,
&app_config.pin_switch_delay_us);
Expand Down Expand Up @@ -403,6 +432,12 @@ enum ConfigError app_config_parse(void) {
parse_int(
&ini, "night_mode", "adc_threshold", INT_MIN, INT_MAX,
&app_config.adc_threshold);
parse_int(
&ini, "night_mode", "exposure_night", 0, 100000,
&app_config.exposure_night);
parse_int(
&ini, "night_mode", "exposure_day", 0, 100000,
&app_config.exposure_day);
}

err = parse_bool(&ini, "isp", "mirror", &app_config.mirror);
Expand All @@ -415,6 +450,13 @@ enum ConfigError app_config_parse(void) {

parse_bool(&ini, "mdns", "enable", &app_config.mdns_enable);

parse_bool(&ini, "sub", "enable", &app_config.sub_enable);
parse_int(&ini, "sub", "width", 160, INT_MAX, &app_config.sub_width);
parse_int(&ini, "sub", "height", 120, INT_MAX, &app_config.sub_height);
parse_int(&ini, "sub", "gop", 1, INT_MAX, &app_config.sub_gop);
parse_int(&ini, "sub", "bitrate", 32, INT_MAX, &app_config.sub_bitrate);
parse_int(&ini, "sub", "rtsp_port", 1, USHRT_MAX, &app_config.sub_rtsp_port);

parse_bool(&ini, "osd", "enable", &app_config.osd_enable);
if (app_config.osd_enable) {
for (char i = 0; i < MAX_OSD; i++) {
Expand All @@ -430,6 +472,12 @@ enum ConfigError app_config_parse(void) {
sprintf(param, "reg%d_opal", i);
err = parse_int(&ini, "osd", param, 0, UCHAR_MAX, &val);
if (err == CONFIG_OK) osds[i].opal = (unsigned char)val;
{
char anchor[16] = {0};
sprintf(param, "reg%d_anchor", i);
if (parse_param_value(&ini, "osd", param, anchor) == CONFIG_OK)
osds[i].anchor = region_anchor_parse(anchor);
}
sprintf(param, "reg%d_posx", i);
err = parse_int(&ini, "osd", param, 0, SHRT_MAX, &val);
if (err == CONFIG_OK) osds[i].posx = (short)val;
Expand Down Expand Up @@ -467,6 +515,8 @@ enum ConfigError app_config_parse(void) {
&app_config.record_segment_duration);
parse_int(&ini, "record", "segment_size", 0, INT_MAX,
&app_config.record_segment_size);
parse_int(&ini, "record", "reserve", 0, INT_MAX,
&app_config.record_reserve);

parse_bool(&ini, "rtsp", "enable", &app_config.rtsp_enable);
parse_int(&ini, "rtsp", "port", 0, USHRT_MAX, &app_config.rtsp_port);
Expand Down Expand Up @@ -511,6 +561,8 @@ enum ConfigError app_config_parse(void) {

parse_bool(&ini, "mp4", "enable", &app_config.mp4_enable);
if (app_config.mp4_enable) {
/* MP3 from the built-in encoder is rejected by strict browser decoders */
parse_bool(&ini, "mp4", "audio", &app_config.mp4_audio);
{
const char *possible_values[] = {"H.264", "H.265", "H264", "H265", "AVC", "HEVC"};
const int count = sizeof(possible_values) / sizeof(const char *);
Expand Down
9 changes: 9 additions & 0 deletions src/app_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ struct AppConfig {
unsigned int ir_cut_pin1;
unsigned int ir_cut_pin2;
unsigned int ir_led_pin;
unsigned int white_led_pin;
unsigned int ir_sensor_pin;
unsigned int check_interval_s;
unsigned int pin_switch_delay_us;
char adc_device[128];
hal_light night_lamp;
int adc_threshold;
unsigned int exposure_night;
unsigned int exposure_day;

// [isp]
bool mirror;
Expand Down Expand Up @@ -70,6 +73,7 @@ struct AppConfig {
char record_path[128];
int record_segment_duration;
int record_segment_size;
int record_reserve;

// [stream]
bool stream_enable;
Expand All @@ -85,6 +89,11 @@ struct AppConfig {
// [mp4]
bool mp4_enable;
bool mp4_codecH265;
bool mp4_audio;

// [sub] second, smaller H.264 stream on its own RTSP port
bool sub_enable;
unsigned int sub_width, sub_height, sub_gop, sub_bitrate, sub_rtsp_port;
unsigned int mp4_mode;
unsigned int mp4_fps;
unsigned int mp4_gop;
Expand Down
14 changes: 12 additions & 2 deletions src/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,23 @@ int stat(const char *restrict path, struct stat *restrict buf)

void __assert(void) {}
void akuio_clean_invalidate_dcache(void) {}
#ifndef __GLIBC__
// GLIBC_COMPAT: linked against OpenIPC's glibc-compat shim (infinity3 on
// musl), which, with musl, has working versions of these; an empty one here
// would be found first and break the vendor libraries that call them.
#if !defined(__GLIBC__) && !defined(GLIBC_COMPAT)
void backtrace(void) {}
void backtrace_symbols(void) {}
#endif
void __ctype_b(void) {}
#ifndef __GLIBC__
#if !defined(__GLIBC__) && !defined(GLIBC_COMPAT)
void __ctype_b_loc(void) {}
void __ctype_tolower(void) {}
#endif
void _MI_PRINT_GetDebugLevel(void) {}
#ifndef GLIBC_COMPAT
void __pthread_register_cancel(void) {}
void __pthread_unregister_cancel(void) {}
#endif
#ifndef __UCLIBC__
void _stdlib_mb_cur_max(void) {}
#endif
Expand All @@ -56,9 +61,14 @@ int __fgetc_unlocked(FILE *stream) { return fgetc(stream); }
double __log_finite(double x) { return log(x); }

#if defined(__arm__) || defined(__aarch64__) || defined(__mips__)
// With GLIBC_COMPAT (infinity3 on musl) the vendor libraries' 32-bit mmap
// calls go through the shim's mm32, which calls mmap with musl's 64-bit off_t,
// so musl's own mmap has to stay in place there.
#ifndef GLIBC_COMPAT
void *mmap(void *start, size_t len, int prot, int flags, int fd, uint32_t off) {
return (void*)syscall(SYS_mmap2, start, len, prot, flags, fd, off >> 12);
}
#endif

void *__mmap64(void *start, size_t len, int prot, int flags, int fd, off_t off) {
return (void*)syscall(SYS_mmap2, start, len, prot, flags, fd, (long)(off >> 12));
Expand Down
29 changes: 25 additions & 4 deletions src/fmt/moov.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,8 @@ enum BufError write_mp4a(struct BitBuf *ptr, const struct MoovInfo *moov_info) {
err = put_u32_be(ptr, 0);
chk_err;

err = put_str4(ptr, "mp4a");
char is_opus = (unsigned char)moov_info->audio_codec == ACODEC_ID_OPUS;
err = put_str4(ptr, is_opus ? "Opus" : "mp4a");
chk_err;
err = put_skip(ptr, 6);
chk_err; // 6 reserved
Expand All @@ -771,11 +772,31 @@ enum BufError write_mp4a(struct BitBuf *ptr, const struct MoovInfo *moov_info) {
chk_err; // 2 sample size
err = put_skip(ptr, 4);
chk_err; // 4 reserved
err = put_u16_be(ptr, moov_info->audio_samplerate);
chk_err; // 2 samplerate
err = put_u16_be(ptr, is_opus ? 48000 : moov_info->audio_samplerate);
chk_err; // 2 samplerate (Opus in ISOBMFF is always signalled as 48 kHz)
err = put_skip(ptr, 2);
chk_err; // 2 reserved
err = write_esds(ptr, moov_info);
if (is_opus) {
uint32_t start_dops = ptr->offset;
err = put_u32_be(ptr, 0);
chk_err;
err = put_str4(ptr, "dOps");
chk_err;
err = put_u8(ptr, 0);
chk_err; // 1 version
err = put_u8(ptr, moov_info->audio_channels);
chk_err; // 1 output channel count
err = put_u16_be(ptr, 312);
chk_err; // 2 pre-skip (48 kHz samples)
err = put_u32_be(ptr, 48000);
chk_err; // 4 input sample rate (informational; Chrome wants it equal to the entry's rate)
err = put_u16_be(ptr, 0);
chk_err; // 2 output gain
err = put_u8(ptr, 0);
chk_err; // 1 channel mapping family
err = put_u32_be_to_offset(ptr, start_dops, ptr->offset - start_dops);
} else
err = write_esds(ptr, moov_info);
chk_err;
err = write_btrt(ptr, moov_info);
chk_err;
Expand Down
Loading