Add doorbell cam video proxy
This commit is contained in:
parent
7f77b0e863
commit
0b93fba3c9
3 changed files with 64 additions and 0 deletions
|
|
@ -4,4 +4,6 @@ custom-utils.validatePortAttrset {
|
|||
asterisk-rtp = { udp.range = [ 10000 10200 ]; };
|
||||
unifi.tcp = 8443;
|
||||
doorbell-audiosocket.tcp = 9092;
|
||||
doorbell-webrtc.tcp = 8889;
|
||||
doorbell-webrtc-ice.udp = 8189;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,5 +19,13 @@ in
|
|||
uuid = "4960ab41-dbef-4773-a25e-90536d97345e";
|
||||
};
|
||||
callerId = "Sprechanlage";
|
||||
cam = {
|
||||
enable = true;
|
||||
bindAddress = "192.168.0.1";
|
||||
webrtcPort = ports.doorbell-webrtc.tcp;
|
||||
webrtcIceUdpPort = ports.doorbell-webrtc-ice.udp;
|
||||
};
|
||||
};
|
||||
networking.firewall.interfaces.lechner.allowedTCPPorts = [ ports.doorbell-webrtc.tcp ];
|
||||
networking.firewall.interfaces.lechner.allowedUDPPorts = [ ports.doorbell-webrtc-ice.udp ];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,45 @@
|
|||
|
||||
let
|
||||
cfg = config.services.myintercom-doorbell;
|
||||
mediamtxConfig = pkgs.writeTextFile {
|
||||
name = "myintercom-doorbell-cam-proxy-config";
|
||||
text = lib.generators.toJSON { } {
|
||||
paths.sprechanlage.source = "rtsp://${cfg.username}:__PASSWORD__@${cfg.host}/axis-media/media.amp?videocodec=h264&resolution=1280x720&fps=8";
|
||||
protocols = [ "udp" ];
|
||||
hls = false;
|
||||
rtmp = false;
|
||||
rtsp = false;
|
||||
srt = false;
|
||||
|
||||
webrtc = true;
|
||||
webrtcAddress = "${cfg.cam.bindAddress}:${toString cfg.cam.webrtcPort}";
|
||||
|
||||
webrtcICEHostNAT1To1IPs = [ cfg.cam.bindAddress ];
|
||||
webrtcICEUDPMuxAddress = ":${toString cfg.cam.webrtcIceUdpPort}";
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options.services.myintercom-doorbell = with lib; with lib.types; {
|
||||
enable = mkEnableOption "Enable myintercom service";
|
||||
cam = {
|
||||
enable = mkEnableOption "Enable cam proxy service";
|
||||
bindAddress = mkOption {
|
||||
type = types.str;
|
||||
description = "The Address the service binds to.";
|
||||
example = "10.0.0.1";
|
||||
};
|
||||
webrtcPort = mkOption {
|
||||
type = types.port;
|
||||
description = "Port the WebRTC service binds to.";
|
||||
default = 8889;
|
||||
};
|
||||
webrtcIceUdpPort = mkOption {
|
||||
type = types.port;
|
||||
description = "Port (udp) the WebRTC ICE service binds to.";
|
||||
default = 8189;
|
||||
};
|
||||
};
|
||||
host = mkOption {
|
||||
type = types.str;
|
||||
description = "The Hostname of myintercom.";
|
||||
|
|
@ -68,6 +103,7 @@ in
|
|||
serviceConfig = {
|
||||
Type = "simple";
|
||||
User = "asterisk";
|
||||
# @TODO: Use unstable only until 23.11 is released
|
||||
ExecStart = "${pkgs.myintercom-doorbell}/bin/myintercom-doorbell-poll";
|
||||
};
|
||||
};
|
||||
|
|
@ -95,5 +131,23 @@ in
|
|||
ExecStart = "${pkgs.myintercom-doorbell}/bin/myintercom-doorbell-audiosocket";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.myintercom-doorbell-cam-proxy = {
|
||||
enable = cfg.cam.enable;
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
description = "Proxies the videostream of myintercom doorbell.";
|
||||
script = ''
|
||||
sed "s:__PASSWORD__:$(cat "$PASSWORD_FILE"):" "${mediamtxConfig}" | ${pkgs.master.mediamtx}/bin/mediamtx /dev/stdin
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
DynamicUser = true;
|
||||
LoadCredential = "password:${cfg.passwordFile}";
|
||||
Environment = [
|
||||
"PASSWORD_FILE=%d/password"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue