Skip to content

Commit 776ae2b

Browse files
authored
add end to end test (#2)
* debugging * test * more debugging * something works * update * broken * lib * add end to end test
1 parent 714b464 commit 776ae2b

21 files changed

Lines changed: 320 additions & 494 deletions

File tree

cmd/wtf/main.go

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"github.com/tinyzimmer/go-glib/glib"
8+
"github.com/tinyzimmer/go-gst/gst"
9+
"github.com/tinyzimmer/go-gst/gst/app"
10+
)
11+
12+
func MonitorPipeline(mainLoop *glib.MainLoop, pipeline *gst.Pipeline) func(msg *gst.Message) bool {
13+
return func(msg *gst.Message) bool {
14+
switch msg.Type() {
15+
case gst.MessageEOS:
16+
pipeline.BlockSetState(gst.StateNull)
17+
mainLoop.Quit()
18+
case gst.MessageError:
19+
err := msg.ParseError()
20+
fmt.Println("ERROR:", err.Error())
21+
if debug := err.DebugString(); debug != "" {
22+
fmt.Println("DEBUG:", debug)
23+
}
24+
mainLoop.Quit()
25+
default:
26+
fmt.Println(msg)
27+
}
28+
return true
29+
}
30+
}
31+
32+
func input() (*gst.Pipeline, *app.Sink) {
33+
r, err := gst.NewPipelineFromString("videotestsrc ! vp8enc ! rtpvp8pay ! appsink name=sink")
34+
if err != nil {
35+
panic(err)
36+
}
37+
38+
sink, err := r.GetElementByName("sink")
39+
if err != nil {
40+
panic(err)
41+
}
42+
43+
return r, app.SinkFromElement(sink)
44+
}
45+
46+
func output() (*gst.Pipeline, *app.Source) {
47+
w, err := gst.NewPipelineFromString("appsrc name=source format=time ! rtpvp8depay ! vp8dec ! autovideosink")
48+
if err != nil {
49+
panic(err)
50+
}
51+
52+
src, err := w.GetElementByName("source")
53+
if err != nil {
54+
panic(err)
55+
}
56+
57+
return w, app.SrcFromElement(src)
58+
}
59+
60+
func main() {
61+
gst.Init(&os.Args)
62+
63+
mainLoop := glib.NewMainLoop(glib.MainContextDefault(), false)
64+
65+
r, sink := input()
66+
w, src := output()
67+
68+
r.GetPipelineBus().AddWatch(MonitorPipeline(mainLoop, r))
69+
w.GetPipelineBus().AddWatch(MonitorPipeline(mainLoop, w))
70+
71+
sink.SetCallbacks(&app.SinkCallbacks{
72+
NewSampleFunc: func(sink *app.Sink) gst.FlowReturn {
73+
sample := sink.PullSample()
74+
if sample == nil {
75+
return gst.FlowEOS
76+
}
77+
return src.PushSample(sample)
78+
},
79+
})
80+
81+
r.SetState(gst.StatePlaying)
82+
w.SetState(gst.StatePlaying)
83+
84+
mainLoop.Run()
85+
}

examples/transcode-file/README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,4 @@ transcode-file is a simple application that shows how to transcode an ivf file o
88
go run main.go -addr localhost:50051 -i input.ivf -o output.ivf
99
```
1010

11-
You should see an `output.ivf` file produced. The output file does not contain the last ~1s
12-
of video. This is a known issue due to the transcoder expecting live video sources, not
13-
sources that terminate.
14-
15-
If you intend to transcode mostly non-live video sources, it would be easier to use ffmpeg :)
11+
You should see an `output.ivf` file produced.

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ require (
1212
require (
1313
github.com/golang/protobuf v1.5.2 // indirect
1414
github.com/google/go-cmp v0.5.7 // indirect
15+
github.com/mattn/go-pointer v0.0.1 // indirect
1516
github.com/pkg/errors v0.9.1 // indirect
17+
github.com/tinyzimmer/go-glib v0.0.24 // indirect
18+
github.com/tinyzimmer/go-gst v0.2.32 // indirect
1619
go.uber.org/atomic v1.9.0 // indirect
1720
go.uber.org/multierr v1.7.0 // indirect
1821
golang.org/x/text v0.3.7 // indirect

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
6464
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
6565
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
6666
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
67+
github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0=
68+
github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc=
6769
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
6870
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
6971
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
@@ -130,6 +132,10 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
130132
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
131133
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
132134
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
135+
github.com/tinyzimmer/go-glib v0.0.24 h1:ktZZC22/9t88kGRgNEFV/SESgIWhGHE+q7Z7Qj++luw=
136+
github.com/tinyzimmer/go-glib v0.0.24/go.mod h1:ltV0gO6xNFzZhsIRbFXv8RTq9NGoNT2dmAER4YmZfaM=
137+
github.com/tinyzimmer/go-gst v0.2.32 h1:bwJ1VfLyoeQPxuE7LgCTwwvMXFufnFoSws7QhaCfsY8=
138+
github.com/tinyzimmer/go-gst v0.2.32/go.mod h1:V4h+HPS3mVGSwUJ7IBi3WAkJWITZasebERyqk3TEXUM=
133139
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
134140
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
135141
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=

internal/gst/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

internal/gst/bin.go

Lines changed: 0 additions & 61 deletions
This file was deleted.

internal/gst/caps.go

Lines changed: 0 additions & 22 deletions
This file was deleted.

internal/gst/element.go

Lines changed: 0 additions & 141 deletions
This file was deleted.

internal/gst/gst.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)