homekit: only start intercom once audio starts flowing back. this addresses issues where doorbell chimes get muted if two way mode is activated.

This commit is contained in:
Koushik Dutta
2022-05-07 13:36:31 -07:00
parent c79f4111fa
commit b38ceff3c5
3 changed files with 17 additions and 9 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/homekit",
"version": "0.0.270",
"version": "0.0.271",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/homekit",
"version": "0.0.270",
"version": "0.0.271",
"dependencies": {
"@koush/qrcode-terminal": "^0.12.0",
"check-disk-space": "^3.3.0",

View File

@@ -44,5 +44,5 @@
"@types/node": "^14.17.9",
"@types/url-parse": "^1.4.3"
},
"version": "0.0.270"
"version": "0.0.271"
}

View File

@@ -51,8 +51,6 @@ export function createCameraStreamingDelegate(device: ScryptedDevice & VideoCame
session.videoReturn?.close();
session.audioReturn?.close();
session.rtpSink?.destroy();
if (twoWayAudio)
device.stopIntercom();
}
const delegate: CameraStreamingDelegate = {
@@ -318,19 +316,29 @@ export function createCameraStreamingDelegate(device: ScryptedDevice & VideoCame
// demux the audio return socket to distinguish between rtp audio return
// packets and rtcp.
// send the audio return off to the rtp
// send the audio return off to the rtp
let startedIntercom = false;
session.audioReturn.on('message', buffer => {
const rtp = RtpPacket.deSerialize(buffer);
if (rtp.header.payloadType === session.startRequest.audio.pt) {
if (!startedIntercom) {
console.log('Received first two way audio packet, starting intercom.');
startedIntercom = true;
mediaManager.createFFmpegMediaObject(session.rtpSink.ffmpegInput)
.then(mo => {
device.startIntercom(mo);
session.audioReturn.once('close', () => {
console.log('Stopping intercom.');
device.stopIntercom();
});
});
}
session.audioReturn.send(buffer, session.rtpSink.rtpPort);
}
else {
session.rtpSink.heartbeat(session.audioReturn, buffer);
}
});
const mo = await mediaManager.createFFmpegMediaObject(session.rtpSink.ffmpegInput);
device.startIntercom(mo);
}
},
};