33 lines
648 B
Go
33 lines
648 B
Go
package gstreamer
|
|
|
|
import (
|
|
"errors"
|
|
"github.com/tinyzimmer/go-glib/glib"
|
|
"github.com/tinyzimmer/go-gst/gst"
|
|
)
|
|
|
|
var gstreamer *Gstreamer
|
|
|
|
func Init() *Gstreamer {
|
|
gst.Init(nil)
|
|
glib.NewMainLoop(glib.MainContextDefault(), true)
|
|
gstreamer = &Gstreamer{}
|
|
return gstreamer
|
|
}
|
|
|
|
func (g *Gstreamer) DeletePipeline(id string) {
|
|
g.Lock()
|
|
if pipeline, err := g.GetPipeline(id); err == nil {
|
|
delete(g.Pipelines, id)
|
|
pipeline.ctxCancel()
|
|
}
|
|
g.Unlock()
|
|
}
|
|
|
|
func (g *Gstreamer) GetPipeline(id string) (*Pipeline, error) {
|
|
g.RLock()
|
|
if pipeline, ok := g.Pipelines[id]; ok {
|
|
return pipeline, nil
|
|
}
|
|
return nil, errors.New("Pipeline not found")
|
|
}
|