amcrest/onvif: fix 2 way audio codec matching to ignore case. add support for multichannel audio.

This commit is contained in:
Koushik Dutta
2022-05-10 09:47:13 -07:00
parent 6e6697c890
commit 7453fc44ea
5 changed files with 11 additions and 11 deletions

View File

@@ -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",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/amcrest",
"version": "0.0.97",
"version": "0.0.98",
"description": "Amcrest Plugin for Scrypted",
"author": "Scrypted",
"license": "Apache",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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<CodecMatch> {
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',