From 8cc8fbfd547724fe01b6ca2a99a3f70da48ab597 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Thu, 2 Feb 2023 20:06:44 -0800 Subject: [PATCH] rebroadcast: reduce inactivity timeout to 10 seconds. watch for invalid server_port values in rtsp session. --- plugins/prebuffer-mixin/src/main.ts | 2 +- plugins/prebuffer-mixin/src/rtsp-session.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/prebuffer-mixin/src/main.ts b/plugins/prebuffer-mixin/src/main.ts index f6f8957a7..65f08dc95 100644 --- a/plugins/prebuffer-mixin/src/main.ts +++ b/plugins/prebuffer-mixin/src/main.ts @@ -929,7 +929,7 @@ class PrebufferSession { } this.console.log(this.streamName, 'terminating rebroadcast due to inactivity'); session.kill(new Error('stream inactivity')); - }, 30000); + }, 10000); } async handleRebroadcasterClient(options: { diff --git a/plugins/prebuffer-mixin/src/rtsp-session.ts b/plugins/prebuffer-mixin/src/rtsp-session.ts index 25a452e41..5c8c9c6ba 100644 --- a/plugins/prebuffer-mixin/src/rtsp-session.ts +++ b/plugins/prebuffer-mixin/src/rtsp-session.ts @@ -127,9 +127,12 @@ export async function startRtspSession(console: Console, url: string, mediaStrea const transport = setupResult.headers['transport']; const match = transport.match(/.*?server_port=([0-9]+)-([0-9]+)/); const [_, rtp, rtcp] = match; - const { hostname } = new URL(rtspClient.url); - udp.send(punch, parseInt(rtp), hostname) - + const rtpPort = parseInt(rtp); + // have seen some servers return a server_port 0. should watch for bad data in any case. + if (rtpPort) { + const { hostname } = new URL(rtspClient.url); + udp.send(punch, rtpPort, hostname) + } mapping[channel] = codec; } else {