-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathcaps_test.go
More file actions
35 lines (33 loc) · 803 Bytes
/
caps_test.go
File metadata and controls
35 lines (33 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
}
}
}