summaryrefslogtreecommitdiff
path: root/player
diff options
context:
space:
mode:
Diffstat (limited to 'player')
-rw-r--r--player/player.go83
1 files changed, 49 insertions, 34 deletions
diff --git a/player/player.go b/player/player.go
index 13b1304..facf291 100644
--- a/player/player.go
+++ b/player/player.go
@@ -26,6 +26,7 @@ package player
import (
"fmt"
+ "github.com/gotk3/gotk3/glib"
"github.com/spreadspace/go-gstreamer"
"io/ioutil"
"log"
@@ -203,6 +204,54 @@ func (p *Player) dispatchRequests() {
}
}
+func (p *Player) createPipeline() (err error) {
+ if p.pipe, err = gst.PipelineNew("rhlibrary"); err != nil {
+ return
+ }
+
+ var conv1, conv2, sink *gst.Element
+ if p.src, err = gst.ElementFactoryMake("uridecodebin", "source"); err != nil {
+ return
+ }
+ if conv1, err = gst.ElementFactoryMake("audioconvert", "conv1"); err != nil {
+ return
+ }
+ if p.volume, err = gst.ElementFactoryMake("volume", "meter"); err != nil {
+ return
+ }
+ if conv2, err = gst.ElementFactoryMake("audioconvert", "conv2"); err != nil {
+ return
+ }
+ if sink, err = gst.ElementFactoryMake("autoaudiosink", "sink"); err != nil {
+ return
+ }
+
+ p.pipe.Add(p.src)
+ p.pipe.Add(conv1)
+ p.pipe.Add(p.volume)
+ p.pipe.Add(conv2)
+ p.pipe.Add(sink)
+
+ sinkpad, err := conv1.GetStaticPad("sink")
+ if err != nil {
+ return fmt.Errorf("player error getting sink pad from conv1: %s", err)
+ }
+ p.src.Connect("pad-added", func(_ *glib.Object, srcpad *gst.Pad) {
+ if ret := srcpad.Link(sinkpad); ret != gst.PAD_LINK_OK {
+ p.stdlog.Println("player error linking src with conv1 (code: %v)", ret)
+ }
+ p.dbglog.Println("player succesfully linked src with conv1")
+ })
+ conv1.Link(p.volume)
+ p.volume.Link(conv2)
+ conv2.Link(sink)
+
+ if p.bus, err = p.pipe.GetBus(); err != nil {
+ return
+ }
+ return
+}
+
// *********************************************************
// Public Interface
@@ -276,40 +325,6 @@ func (p *Player) GetInterface() *PlayerChan {
return ch
}
-func (p *Player) createPipeline() (err error) {
- if p.pipe, err = gst.PipelineNew("rhlibrary"); err != nil {
- return
- }
-
- // var conv1, conv2, sink *gst.Element
- if p.src, err = gst.ElementFactoryMake("playbin", "source"); err != nil {
- return
- }
- // if conv1, err = gst.ElementFactoryMake("audioconvert", "conv1"); err != nil {
- // return
- // }
- // if p.volume, err = gst.ElementFactoryMake("volume", "meter"); err != nil {
- // return
- // }
- // if conv2, err = gst.ElementFactoryMake("audioconvert", "conv2"); err != nil {
- // return
- // }
- // if sink, err = gst.ElementFactoryMake("autoaudiosink", "sink"); err != nil {
- // return
- // }
-
- p.pipe.Add(p.src)
- // p.pipe.Add(conv1)
- // p.pipe.Add(p.volume)
- // p.pipe.Add(conv2)
- // p.pipe.Add(sink)
-
- if p.bus, err = p.pipe.GetBus(); err != nil {
- return
- }
- return
-}
-
func NewPlayer(basepath string, stdlog *log.Logger, dbglog *log.Logger) (p *Player, err error) {
p = &Player{}
p.basepath = path.Clean(basepath)