diff --git a/plugins/homekit/package-lock.json b/plugins/homekit/package-lock.json index 1c9aa5e0a..d7d9af6e8 100644 --- a/plugins/homekit/package-lock.json +++ b/plugins/homekit/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/homekit", - "version": "0.0.209", + "version": "0.0.211", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/homekit", - "version": "0.0.209", + "version": "0.0.211", "dependencies": { "@koush/qrcode-terminal": "^0.12.0", "hap-nodejs": "file:../../external/HAP-NodeJS", diff --git a/plugins/homekit/package.json b/plugins/homekit/package.json index 3778669a9..d210f4fe9 100644 --- a/plugins/homekit/package.json +++ b/plugins/homekit/package.json @@ -39,5 +39,5 @@ "@types/node": "^14.17.9", "@types/url-parse": "^1.4.3" }, - "version": "0.0.209" + "version": "0.0.211" } diff --git a/plugins/homekit/src/main.ts b/plugins/homekit/src/main.ts index b41ec9304..3f38a5396 100644 --- a/plugins/homekit/src/main.ts +++ b/plugins/homekit/src/main.ts @@ -109,6 +109,14 @@ class HomeKit extends ScryptedDeviceBase implements MixinProvider, Settings, Hom multiple: true, combobox: true, }, + { + key: 'forceOpus', + group: 'Performance', + title: 'Force Opus Audio Codec', + description: 'Adding or resetting a camera accessory will force HomeKit to use the Opus Audio codec rather than AAC-ELD.', + type: 'boolean', + value: this.storage.getItem('forceOpus') !== 'false', + } ] } diff --git a/plugins/homekit/src/types/camera.ts b/plugins/homekit/src/types/camera.ts index cea85b7a2..9006c44cf 100644 --- a/plugins/homekit/src/types/camera.ts +++ b/plugins/homekit/src/types/camera.ts @@ -32,10 +32,13 @@ addSupportedType({ const codecs: AudioStreamingCodec[] = []; // homekit seems to prefer AAC_ELD if it is offered. // so forcing opus must be done by not offering AAC_ELD. - for (const type of [ + const enabledAudioCodecTypes = [ AudioStreamingCodecType.OPUS, - // AudioStreamingCodecType.AAC_ELD, - ]) { + ]; + if (homekitSession.storage.getItem('forceOpus') !== 'true') { + enabledAudioCodecTypes.push(AudioStreamingCodecType.AAC_ELD); + } + for (const type of enabledAudioCodecTypes) { // force 24k, because various parts of the pipeline make that assumption. // off the top of my head: // 1) opus rtp timestamp mangling assumes 24k for the interval of 480