From 7453fc44ea75d2bc2348dd7bff14cb95f8d09e79 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Tue, 10 May 2022 09:47:13 -0700 Subject: [PATCH] amcrest/onvif: fix 2 way audio codec matching to ignore case. add support for multichannel audio. --- plugins/amcrest/package-lock.json | 4 ++-- plugins/amcrest/package.json | 2 +- plugins/onvif/package-lock.json | 4 ++-- plugins/onvif/package.json | 2 +- plugins/onvif/src/onvif-intercom.ts | 10 +++++----- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/plugins/amcrest/package-lock.json b/plugins/amcrest/package-lock.json index 24fb7aadf..ebf0ca713 100644 --- a/plugins/amcrest/package-lock.json +++ b/plugins/amcrest/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/amcrest", - "version": "0.0.97", + "version": "0.0.98", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/amcrest", - "version": "0.0.97", + "version": "0.0.98", "license": "Apache", "dependencies": { "@koush/axios-digest-auth": "^0.8.5", diff --git a/plugins/amcrest/package.json b/plugins/amcrest/package.json index cd4196f3a..eeb99e48e 100644 --- a/plugins/amcrest/package.json +++ b/plugins/amcrest/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/amcrest", - "version": "0.0.97", + "version": "0.0.98", "description": "Amcrest Plugin for Scrypted", "author": "Scrypted", "license": "Apache", diff --git a/plugins/onvif/package-lock.json b/plugins/onvif/package-lock.json index f6eacb82e..7b7a5fd07 100644 --- a/plugins/onvif/package-lock.json +++ b/plugins/onvif/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/onvif", - "version": "0.0.84", + "version": "0.0.85", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/onvif", - "version": "0.0.84", + "version": "0.0.85", "license": "Apache", "dependencies": { "@koush/axios-digest-auth": "^0.8.5", diff --git a/plugins/onvif/package.json b/plugins/onvif/package.json index 0ba0d1447..6f19651d4 100644 --- a/plugins/onvif/package.json +++ b/plugins/onvif/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/onvif", - "version": "0.0.84", + "version": "0.0.85", "description": "ONVIF Camera Plugin for Scrypted", "author": "Scrypted", "license": "Apache", diff --git a/plugins/onvif/src/onvif-intercom.ts b/plugins/onvif/src/onvif-intercom.ts index c0da1b082..c63b9f424 100644 --- a/plugins/onvif/src/onvif-intercom.ts +++ b/plugins/onvif/src/onvif-intercom.ts @@ -46,16 +46,18 @@ interface CodecMatch { payloadType: string; sdpName: string; sampleRate: string; + channels: string; } const codecRegex = /a=rtpmap:(\d+) (.*?)\/(\d+)/g function* parseCodecs(audioSection: string): Generator { for (const match of audioSection.matchAll(codecRegex)) { - const [_, payloadType, sdpName, sampleRate] = match; + const [_, payloadType, sdpName, sampleRate, _skip, channels] = match; yield { payloadType, sdpName, sampleRate, + channels, } } } @@ -113,7 +115,7 @@ export class OnvifIntercom implements Intercom { let match: CodecMatch; let codec: SupportedCodec; for (const supported of availableCodecs) { - codec = supportedCodecs.find(check => check.sdpName === supported.sdpName); + codec = supportedCodecs.find(check => check.sdpName?.toLowerCase() === supported.sdpName.toLowerCase()); if (codec) { match = supported; break; @@ -129,9 +131,7 @@ export class OnvifIntercom implements Intercom { '-vn', '-acodec', codec.ffmpegCodec, '-ar', match.sampleRate, - // ought to fix this, i think there's a slash that follows the sample rate to indicate number of - // channels, but no way of testing at the moment. - '-ac', '1', + '-ac', match.channels || '1', "-payload_type", match.payloadType, "-ssrc", parseInt(transportDict.ssrc, 16).toString(), '-f', 'rtp',