mirror of
https://github.com/notedit/gst.git
synced 2025-09-26 20:21:12 +08:00
fix gst test
This commit is contained in:
45
gst_test.go
45
gst_test.go
@@ -3,7 +3,6 @@ package gst
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -145,46 +144,12 @@ func TestAppsink(t *testing.T) {
|
||||
time.Sleep(1000000)
|
||||
}
|
||||
|
||||
func TestDynamicPipeline(t *testing.T) {
|
||||
func TestCheckPlugins(t *testing.T) {
|
||||
|
||||
pipeline, err := PipelineNew("test-pipeline")
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
source, _ := ElementFactoryMake("uridecodebin", "source")
|
||||
convert, _ := ElementFactoryMake("audioconvert", "convert")
|
||||
sink, _ := ElementFactoryMake("autoaudiosink", "sink")
|
||||
|
||||
pipeline.Add(source)
|
||||
pipeline.Add(convert)
|
||||
pipeline.Add(sink)
|
||||
|
||||
convert.Link(sink)
|
||||
|
||||
source.SetObject("uri", "https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm")
|
||||
|
||||
source.SetPadAddedCallback(func(element *Element, pad *Pad) {
|
||||
capstr := pad.GetCurrentCaps().ToString()
|
||||
|
||||
if strings.HasPrefix(capstr, "audio") {
|
||||
sinkpad := convert.GetStaticPad("sink")
|
||||
pad.Link(sinkpad)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
pipeline.SetState(StatePlaying)
|
||||
|
||||
bus := pipeline.GetBus()
|
||||
|
||||
for {
|
||||
message := bus.Pull(MessageError | MessageEos)
|
||||
fmt.Println("message:", message.GetName())
|
||||
if message.GetType() == MessageEos {
|
||||
break
|
||||
}
|
||||
error := CheckPlugins([]string{"flv", "rtmp"})
|
||||
|
||||
if error != nil {
|
||||
t.Error("CheckPlugins", error)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user