refactor: improve pipeline state management and logging for ndi device
This commit is contained in:
parent
35a8e20244
commit
7147f3f13b
2 changed files with 77 additions and 11 deletions
|
@ -427,19 +427,34 @@ func (api *API) createPreviewPipeline(d Device) (*PreviewPipeline, error) {
|
|||
return nil, fmt.Errorf("setting audio proxy src proxysink: %w", err)
|
||||
}
|
||||
|
||||
if err := pipeline.SetState(gst.StatePlaying); err != nil {
|
||||
return nil, fmt.Errorf("setting pipeline state: %w", err)
|
||||
}
|
||||
// Construct the struct before setting state, so we have it in case of errors during state change
|
||||
// Store the outputID so we can potentially clean up the source proxy later if needed
|
||||
previewPipeline := &PreviewPipeline{
|
||||
outputID: outputID,
|
||||
pipeline: pipeline,
|
||||
webrtcbin: webRtcBin,
|
||||
}
|
||||
|
||||
// Connect signals before setting state
|
||||
log.Debug().Str("pipeline", pipeline.GetName()).Msg("Connecting signals")
|
||||
if _, err := multiQueue.Connect("pad-added", previewPipeline.onMultiqueuePadAdded); err != nil {
|
||||
// Attempt cleanup if signal connection fails
|
||||
pipeline.SetState(gst.StateNull)
|
||||
// TODO: Need to potentially remove the proxysinks from the source device pipeline using outputID
|
||||
return nil, fmt.Errorf("connecting multiqueue pad-added signal: %w", err)
|
||||
}
|
||||
|
||||
// Now set the preview pipeline to playing
|
||||
log.Info().Str("pipeline", pipeline.GetName()).Msg("Setting preview pipeline state to PLAYING")
|
||||
if err := pipeline.SetState(gst.StatePlaying); err != nil {
|
||||
// Attempt cleanup
|
||||
pipeline.SetState(gst.StateNull)
|
||||
// TODO: Need to potentially remove the proxysinks from the source device pipeline using outputID
|
||||
return nil, fmt.Errorf("setting preview pipeline state to playing: %w", err)
|
||||
}
|
||||
log.Info().Str("pipeline", pipeline.GetName()).Msg("Preview pipeline state set to PLAYING")
|
||||
|
||||
|
||||
return previewPipeline, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue