From ac97ab3000eaba0ba71f22f43eff5cc0ee7f2a0e Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Mon, 9 May 2022 09:48:50 -0700 Subject: [PATCH] rebroadcast: fix stream filtering --- plugins/prebuffer-mixin/package-lock.json | 4 ++-- plugins/prebuffer-mixin/package.json | 2 +- plugins/prebuffer-mixin/src/main.ts | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/prebuffer-mixin/package-lock.json b/plugins/prebuffer-mixin/package-lock.json index aa308ff3a..14cf4f243 100644 --- a/plugins/prebuffer-mixin/package-lock.json +++ b/plugins/prebuffer-mixin/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/prebuffer-mixin", - "version": "0.1.258", + "version": "0.1.259", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/prebuffer-mixin", - "version": "0.1.258", + "version": "0.1.259", "license": "Apache-2.0", "dependencies": { "@scrypted/common": "file:../../common", diff --git a/plugins/prebuffer-mixin/package.json b/plugins/prebuffer-mixin/package.json index 97a2a6745..fe4c4c56b 100644 --- a/plugins/prebuffer-mixin/package.json +++ b/plugins/prebuffer-mixin/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/prebuffer-mixin", - "version": "0.1.258", + "version": "0.1.259", "description": "Rebroadcast and Prebuffer for VideoCameras.", "author": "Scrypted", "license": "Apache-2.0", diff --git a/plugins/prebuffer-mixin/src/main.ts b/plugins/prebuffer-mixin/src/main.ts index 29b02bdfe..9ef83ad6f 100644 --- a/plugins/prebuffer-mixin/src/main.ts +++ b/plugins/prebuffer-mixin/src/main.ts @@ -1120,7 +1120,11 @@ class PrebufferSession { if (container === 'rtsp') { const parsedSdp = parseSdp(sdp); - parsedSdp.msections = parsedSdp.msections.filter(msection => msection.codec === mediaStreamOptions.video?.codec || msection.codec === mediaStreamOptions.audio?.codec); + const videoSection = parsedSdp.msections.find(msection => msection.codec && msection.codec === mediaStreamOptions.video?.codec) || parsedSdp.msections.find(msection => msection.type === 'video'); + let audioSection = parsedSdp.msections.find(msection => msection.codec && msection.codec === mediaStreamOptions.audio?.codec) || parsedSdp.msections.find(msection => msection.type === 'audio'); + if (mediaStreamOptions.audio === null) + audioSection = undefined; + parsedSdp.msections = parsedSdp.msections.filter(msection => msection === videoSection || msection === audioSection); const filterPrebufferAudio = options?.prebuffer === undefined; const videoCodec = parsedSdp.msections.find(msection => msection.type === 'video')?.codec; sdp = parsedSdp.toSdp();