func main() { src := gst.ElementFactoryMake("videotestsrc", "VideoSrc") checkElem(src, "videotestsrc") //vsink := "autovideosink" vsink := "xvimagesink" sink := gst.ElementFactoryMake(vsink, "VideoSink") checkElem(sink, vsink) pl := gst.NewPipeline("MyPipeline") pl.Add(src, sink) filter := gst.NewCapsSimple( "video/x-raw,format=yuv", glib.Params{ "width": int32(192), "height": int32(108), "framerate": &gst.Fraction{25, 1}, }, ) fmt.Println(filter) //src.LinkFiltered(sink, filter) src.Link(sink) pl.SetState(gst.STATE_PLAYING) glib.NewMainLoop(nil).Run() }
func init() { P.Element = gst.ElementFactoryMake("playbin", "player") if P.Element == nil { log.Fatal("ElementFactoryMake failed") } P.SetURI(StreamURL) state, prev, x := P.GetState(500) log.Println(state, prev, x) }
func makeElement(element, name string) *gst.Element { if err != nil { return nil } e := gst.ElementFactoryMake(element, name) if e == nil { err = fmt.Errorf("could not create element '%s' of type '%s'", name, element) } return e }
func main() { src := gst.ElementFactoryMake("videotestsrc", "VideoSrc") sink := gst.ElementFactoryMake("autovideosink", "VideoSink") pl := gst.NewPipeline("MyPipeline") pl.Add(src, sink) filter := gst.NewCapsSimple( "video/x-raw-yuv", glib.Params{ "width": 192, "height": 108, "framerate": &gst.Fraction{25, 1}, }, ) fmt.Println(filter) src.LinkFiltered(sink, filter) pl.SetState(gst.STATE_PLAYING) glib.NewMainLoop(nil).Run() }
func newPlayer() (*Player, error) { pipe := gst.ElementFactoryMake("playbin", "mp3_pipe") if pipe == nil { return nil, errors.New("gstreamer error") } return &Player{ mainloop: glib.NewMainLoop(nil), pipe: pipe, }, nil }
func main() { src := gst.ElementFactoryMake("videotestsrc", "Test source") src.SetProperty("do-timestamp", true) src.SetProperty("pattern", 18) // ball //enc := gst.ElementFactoryMake("vp8enc", "VP8 encoder") enc := gst.ElementFactoryMake("x264enc", "H.264 encoder") //mux := gst.ElementFactoryMake("webmmux", "WebM muxer") mux := gst.ElementFactoryMake("matroskamux", "matroskamux muxer") mux.SetProperty("streamable", true) demux := gst.ElementFactoryMake("matroskademux", "Matroska demuxer") //dec := gst.ElementFactoryMake("vp8dec", "VP8 dcoder") dec := gst.ElementFactoryMake("ffdec_h264", "H.264 dcoder") sink := gst.ElementFactoryMake("autovideosink", "Video display element") pl := gst.NewPipeline("MyPipeline") pl.Add(src, enc, mux, demux, dec, sink) src.Link(enc, mux, demux) demux.ConnectNoi("pad-added", cbPadAdded, dec.GetStaticPad("sink")) dec.Link(sink) pl.SetState(gst.STATE_PLAYING) glib.NewMainLoop(nil).Run() }
func NewPlayer() *Player { p := new(Player) p.window = gtk.NewWindow(gtk.WINDOW_TOPLEVEL) p.window.SetTitle("Player") p.window.ConnectNoi("destroy", gtk.MainQuit, nil) vbox := gtk.NewVBox(false, 0) p.window.Add(vbox.AsWidget()) hbox := gtk.NewHBox(false, 0) vbox.PackStart(hbox.AsWidget(), false, false, 0) fcb := gtk.NewFileChooserButton( "Choose media file", gtk.FILE_CHOOSER_ACTION_OPEN, ) fcb.Connect("selection-changed", (*Player).onFileSelected, p) hbox.Add(fcb.AsWidget()) button := gtk.NewButtonFromStock("gtk-media-play") button.Connect("clicked", (*Player).onPlayClicked, p) hbox.PackStart(button.AsWidget(), false, false, 0) button = gtk.NewButtonFromStock("gtk-media-pause") button.Connect("clicked", (*Player).onPauseClicked, p) hbox.PackStart(button.AsWidget(), false, false, 0) button = gtk.NewButtonFromStock("gtk-media-stop") button.Connect("clicked", (*Player).onStopClicked, p) hbox.PackStart(button.AsWidget(), false, false, 0) p.movie_area = gtk.NewDrawingArea() p.movie_area.Connect("realize", (*Player).onVideoWidgetRealize, p) p.movie_area.SetDoubleBuffered(false) p.movie_area.SetSizeRequest(640, 360) vbox.Add(p.movie_area.AsWidget()) p.window.ShowAll() p.window.Realize() p.pipe = gst.ElementFactoryMake("playbin2", "autoplay") p.bus = p.pipe.GetBus() p.bus.AddSignalWatch() p.bus.Connect("message", (*Player).onMessage, p) p.bus.EnableSyncMessageEmission() p.bus.Connect("sync-message::element", (*Player).onSyncMessage, p) return p }
func NewWebM(width, height, fps int) *WebM { wm := new(WebM) wm.conns = make(map[int]net.Conn) src := gst.ElementFactoryMake("videotestsrc", "Test source") src.SetProperty("do-timestamp", true) src.SetProperty("pattern", 18) // ball enc := gst.ElementFactoryMake("vp8enc", "VP8 encoder") mux := gst.ElementFactoryMake("webmmux", "WebM muxer") mux.SetProperty("streamable", true) wm.sink = gst.ElementFactoryMake("multifdsink", "Multifd sink") wm.sink.SetProperty("sync", true) wm.sink.SetProperty("recover-policy", 3) // keyframe wm.sink.SetProperty("sync-method", 2) // latest-keyframe wm.pl = gst.NewPipeline("WebM generator") wm.pl.Add(src, enc, mux, wm.sink) filter := gst.NewCapsSimple( "video/x-raw,format=yuv", glib.Params{ "width": int32(width), "height": int32(height), "framerate": &gst.Fraction{fps, 1}, }, ) src.LinkFiltered(enc, filter) enc.Link(mux, wm.sink) wm.sink.ConnectNoi("client-fd-removed", (*WebM).cbClientFdRemoved, wm) return wm }
func newGstreamer() *gstreamer { return &gstreamer{ mainloop: glib.NewMainLoop(nil), pipe: gst.ElementFactoryMake("playbin", "mp3_pipe"), } }
// Initiliazes the GST Player to read the stream. func initPlayer() (player *gst.Element) { player = gst.ElementFactoryMake("playbin", "player") player.SetProperty("uri", fipStreamURL) return }