do not start pipeline when error.

This commit is contained in:
Miroslav Šedivý 2021-02-05 12:41:02 +01:00
parent 58ea3665b0
commit 2b72f43c9e
5 changed files with 29 additions and 8 deletions

View File

@ -32,9 +32,14 @@ func (manager *BroacastManagerCtx) shutdown() {
}
func (manager *BroacastManagerCtx) Start(url string) error {
err := manager.createPipeline()
if err != nil {
return err
}
manager.url = url
manager.enabled = true
return manager.createPipeline()
return nil
}
func (manager *BroacastManagerCtx) Stop() {

View File

@ -111,8 +111,17 @@ func (manager *CaptureManagerCtx) StartStream() {
manager.logger.Info().Msgf("starting stream pipelines")
manager.Video().Start()
manager.Audio().Start()
var err error
err = manager.Video().Start()
if err != nil {
manager.logger.Panic().Err(err).Msg("unable to start video pipeline")
}
err = manager.Audio().Start()
if err != nil {
manager.logger.Panic().Err(err).Msg("unable to start audio pipeline")
}
manager.streaming = true
}

View File

@ -147,9 +147,11 @@ func (manager *ScreencastManagerCtx) createPipeline() error {
return err
}
manager.pipeline.Start()
manager.logger.Info().Msgf("starting pipeline")
manager.logger.Info().
Str("src", manager.pipeline.Src).
Msgf("starting pipeline")
manager.pipeline.Start()
manager.sample = manager.pipeline.Sample
manager.emitUpdate <-true
return nil

View File

@ -75,9 +75,14 @@ func (manager *StreamManagerCtx) OnSample(listener func(sample types.Sample)) {
})
}
func (manager *StreamManagerCtx) Start() {
func (manager *StreamManagerCtx) Start() error {
err := manager.createPipeline()
if err != nil {
return err
}
manager.enabled = true
manager.createPipeline()
return nil
}
func (manager *StreamManagerCtx) Stop() {

View File

@ -25,7 +25,7 @@ type StreamManager interface {
Codec() codec.RTPCodec
OnSample(listener func(sample Sample))
Start()
Start() error
Stop()
Enabled() bool
}