homekit: rtp talkback logging

This commit is contained in:
Koushik Dutta
2021-10-06 20:51:24 -07:00
parent b21e74be0e
commit 0352e50aea
4 changed files with 10 additions and 7 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/homekit",
"version": "0.0.79",
"version": "0.0.80",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/homekit",
"version": "0.0.79",
"version": "0.0.80",
"dependencies": {
"hap-nodejs": "file:../HAP-NodeJS",
"lodash": "^4.17.21",

View File

@@ -40,5 +40,5 @@
"@types/qrcode": "^1.4.1",
"@types/url-parse": "^1.4.3"
},
"version": "0.0.79"
"version": "0.0.80"
}

View File

@@ -12,7 +12,7 @@ function pickPort() {
export class HomeKitRtpSink {
heartbeatTimer: NodeJS.Timeout;
constructor(public server: Server, public rtpPort: number, public ffmpegInput: FFMpegInput) {
constructor(public server: Server, public rtpPort: number, public ffmpegInput: FFMpegInput, public console: Console) {
}
// Send a regular heartbeat to FFmpeg to ensure the pipe remains open and the process alive.
@@ -32,12 +32,13 @@ export class HomeKitRtpSink {
}
destroy() {
this.console.log('rtp sink closed');
this.server?.close();
clearTimeout(this.heartbeatTimer);
}
}
export async function startRtpSink(socketType: SocketType, address: string, srtp: Buffer,sampleRate: AudioStreamingSamplerate) {
export async function startRtpSink(socketType: SocketType, address: string, srtp: Buffer, sampleRate: AudioStreamingSamplerate, console: Console) {
const sdpIpVersion = socketType === "udp6" ? "IP6 " : "IP4";
const rtpPort = pickPort();
@@ -142,5 +143,5 @@ export async function startRtpSink(socketType: SocketType, address: string, srtp
]
};
return new HomeKitRtpSink(server, rtpPort, ffmpegInput);
return new HomeKitRtpSink(server, rtpPort, ffmpegInput, console);
}

View File

@@ -178,6 +178,8 @@ addSupportedType({
if (!session)
return;
console.log('streaming session killed');
sessions.delete(sessionID);
session.cp?.kill();
session.videoReturn?.close();
@@ -513,7 +515,7 @@ addSupportedType({
const socketType = session.prepareRequest.addressVersion === 'ipv6' ? 'udp6' : 'udp4';
session.rtpSink = await startRtpSink(socketType, session.prepareRequest.targetAddress,
audioKey, (request as StartStreamRequest).audio.sample_rate);
audioKey, (request as StartStreamRequest).audio.sample_rate, console);
session.demuxer.on('rtp', (buffer: Buffer) => {
session.audioReturn.send(buffer, session.rtpSink.rtpPort);