When the publisher or source of a stream is offline, the server can be configured to fill gaps in the stream with a video that is played on repeat until a publisher comes back online. This allows readers to stay connected regardless of the state of the stream. The offline video and any future online stream are concatenated without decoding or re-encoding packets, using the original codec.
36 lines
748 B
Go
36 lines
748 B
Go
package stream
|
|
|
|
import (
|
|
"github.com/bluenviron/gortsplib/v5/pkg/description"
|
|
"github.com/bluenviron/gortsplib/v5/pkg/format"
|
|
)
|
|
|
|
type subStreamMedia struct {
|
|
curMedia *description.Media
|
|
streamMedia *streamMedia
|
|
useRTPPackets bool
|
|
|
|
formats map[format.Format]*subStreamFormat
|
|
}
|
|
|
|
func (ssm *subStreamMedia) initialize() error {
|
|
ssm.formats = make(map[format.Format]*subStreamFormat)
|
|
|
|
for i, curFormat := range ssm.curMedia.Formats {
|
|
forma := ssm.streamMedia.media.Formats[i]
|
|
|
|
ssf := &subStreamFormat{
|
|
curFormat: curFormat,
|
|
streamFormat: ssm.streamMedia.formats[forma],
|
|
useRTPPackets: ssm.useRTPPackets,
|
|
}
|
|
err := ssf.initialize()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
ssm.formats[curFormat] = ssf
|
|
}
|
|
|
|
return nil
|
|
}
|