mirror of
https://github.com/notedit/gst.git
synced 2025-09-26 20:21:12 +08:00
Add gstCaps.GetStructure
This commit is contained in:
9
caps.go
9
caps.go
@@ -43,3 +43,12 @@ func (c *Caps) String() (str string) {
|
||||
str = C.GoString((*C.char)(unsafe.Pointer(CStr)))
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Caps) GetStructure(index int) (structure *Structure) {
|
||||
Cstructure := C.gst_caps_get_structure(c.caps, C.uint(index))
|
||||
structure = &Structure{
|
||||
C: Cstructure,
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
35
caps_test.go
Normal file
35
caps_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package gst
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestCaps_GetStructure(t *testing.T) {
|
||||
pipeline, err := ParseLaunch("videotestsrc name=src ! video/x-raw,width=640,height=480 ! fakesink")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
src := pipeline.GetByName("src")
|
||||
if src == nil {
|
||||
t.Fatal("element 'src' not found")
|
||||
}
|
||||
pipeline.SetState(StatePlaying)
|
||||
bus := pipeline.GetBus()
|
||||
for {
|
||||
msg := bus.Pull(MessageStateChanged)
|
||||
_, newState, _ := msg.ParseStateChanged()
|
||||
if newState == StatePlaying {
|
||||
structure := src.GetStaticPad("src").GetCurrentCaps().GetStructure(0)
|
||||
width, err := structure.GetInt("width")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
height, err := structure.GetInt("height")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if width != 640 || height != 480 {
|
||||
t.Fatal(err)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user