From 23ac079646613da31c0d7e420400b64022f38c43 Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Fri, 20 May 2022 23:41:30 +0200 Subject: [PATCH] rtsp source: fix regression (#949) This caused a periodic disconnection when sourceOnDemand is yes --- internal/core/path.go | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/internal/core/path.go b/internal/core/path.go index 6249babf..461aa3c6 100644 --- a/internal/core/path.go +++ b/internal/core/path.go @@ -439,11 +439,7 @@ func (pa *path) run() { } pa.setupPlayRequestsOnHold = nil - if len(pa.readers) > 0 { - pa.onDemandStaticSourceState = pathOnDemandStateReady - } else { - pa.onDemandStaticSourceScheduleClose() - } + pa.onDemandStaticSourceScheduleClose() } req.res <- pathSourceStaticSetReadyRes{stream: pa.stream} @@ -859,11 +855,7 @@ func (pa *path) handlePublisherRecord(req pathPublisherRecordReq) { } pa.setupPlayRequestsOnHold = nil - if len(pa.readers) > 0 { - pa.onDemandPublisherState = pathOnDemandStateReady - } else { - pa.onDemandPublisherScheduleClose() - } + pa.onDemandPublisherScheduleClose() } req.res <- pathPublisherRecordRes{stream: pa.stream} @@ -887,10 +879,14 @@ func (pa *path) handleReaderRemove(req pathReaderRemoveReq) { close(req.res) if len(pa.readers) == 0 { - if pa.hasOnDemandStaticSource() && pa.onDemandStaticSourceState == pathOnDemandStateReady { - pa.onDemandStaticSourceScheduleClose() - } else if pa.hasOnDemandPublisher() && pa.onDemandPublisherState == pathOnDemandStateReady { - pa.onDemandPublisherScheduleClose() + if pa.hasOnDemandStaticSource() { + if pa.onDemandStaticSourceState == pathOnDemandStateReady { + pa.onDemandStaticSourceScheduleClose() + } + } else if pa.hasOnDemandPublisher() { + if pa.onDemandPublisherState == pathOnDemandStateReady { + pa.onDemandPublisherScheduleClose() + } } } } @@ -923,10 +919,18 @@ func (pa *path) handleReaderSetupPlay(req pathReaderSetupPlayReq) { func (pa *path) handleReaderSetupPlayPost(req pathReaderSetupPlayReq) { pa.readers[req.author] = pathReaderStatePrePlay - if pa.hasOnDemandPublisher() && pa.onDemandPublisherState == pathOnDemandStateClosing { - pa.onDemandPublisherState = pathOnDemandStateReady - pa.onDemandPublisherCloseTimer.Stop() - pa.onDemandPublisherCloseTimer = newEmptyTimer() + if pa.hasOnDemandStaticSource() { + if pa.onDemandStaticSourceState == pathOnDemandStateClosing { + pa.onDemandStaticSourceState = pathOnDemandStateReady + pa.onDemandStaticSourceCloseTimer.Stop() + pa.onDemandStaticSourceCloseTimer = newEmptyTimer() + } + } else if pa.hasOnDemandPublisher() { + if pa.onDemandPublisherState == pathOnDemandStateClosing { + pa.onDemandPublisherState = pathOnDemandStateReady + pa.onDemandPublisherCloseTimer.Stop() + pa.onDemandPublisherCloseTimer = newEmptyTimer() + } } req.res <- pathReaderSetupPlayRes{