Browse Source

rtsp source: fix regression (#949)

This caused a periodic disconnection when sourceOnDemand is yes
pull/956/head
aler9 4 years ago
parent
commit
23ac079646
  1. 40
      internal/core/path.go

40
internal/core/path.go

@ -439,11 +439,7 @@ func (pa *path) run() {
} }
pa.setupPlayRequestsOnHold = nil pa.setupPlayRequestsOnHold = nil
if len(pa.readers) > 0 { pa.onDemandStaticSourceScheduleClose()
pa.onDemandStaticSourceState = pathOnDemandStateReady
} else {
pa.onDemandStaticSourceScheduleClose()
}
} }
req.res <- pathSourceStaticSetReadyRes{stream: pa.stream} req.res <- pathSourceStaticSetReadyRes{stream: pa.stream}
@ -859,11 +855,7 @@ func (pa *path) handlePublisherRecord(req pathPublisherRecordReq) {
} }
pa.setupPlayRequestsOnHold = nil pa.setupPlayRequestsOnHold = nil
if len(pa.readers) > 0 { pa.onDemandPublisherScheduleClose()
pa.onDemandPublisherState = pathOnDemandStateReady
} else {
pa.onDemandPublisherScheduleClose()
}
} }
req.res <- pathPublisherRecordRes{stream: pa.stream} req.res <- pathPublisherRecordRes{stream: pa.stream}
@ -887,10 +879,14 @@ func (pa *path) handleReaderRemove(req pathReaderRemoveReq) {
close(req.res) close(req.res)
if len(pa.readers) == 0 { if len(pa.readers) == 0 {
if pa.hasOnDemandStaticSource() && pa.onDemandStaticSourceState == pathOnDemandStateReady { if pa.hasOnDemandStaticSource() {
pa.onDemandStaticSourceScheduleClose() if pa.onDemandStaticSourceState == pathOnDemandStateReady {
} else if pa.hasOnDemandPublisher() && pa.onDemandPublisherState == pathOnDemandStateReady { pa.onDemandStaticSourceScheduleClose()
pa.onDemandPublisherScheduleClose() }
} 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) { func (pa *path) handleReaderSetupPlayPost(req pathReaderSetupPlayReq) {
pa.readers[req.author] = pathReaderStatePrePlay pa.readers[req.author] = pathReaderStatePrePlay
if pa.hasOnDemandPublisher() && pa.onDemandPublisherState == pathOnDemandStateClosing { if pa.hasOnDemandStaticSource() {
pa.onDemandPublisherState = pathOnDemandStateReady if pa.onDemandStaticSourceState == pathOnDemandStateClosing {
pa.onDemandPublisherCloseTimer.Stop() pa.onDemandStaticSourceState = pathOnDemandStateReady
pa.onDemandPublisherCloseTimer = newEmptyTimer() 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{ req.res <- pathReaderSetupPlayRes{

Loading…
Cancel
Save