forked from asticode/go-astiav
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilter.go
55 lines (45 loc) · 1.07 KB
/
filter.go
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package astiav
//#include <libavfilter/avfilter.h>
import "C"
import (
"unsafe"
)
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavfilter/avfilter.h#L165
type Filter struct {
c *C.AVFilter
}
func newFilterFromC(c *C.AVFilter) *Filter {
if c == nil {
return nil
}
return &Filter{c: c}
}
func FindFilterByName(n string) *Filter {
cn := C.CString(n)
defer C.free(unsafe.Pointer(cn))
return newFilterFromC(C.avfilter_get_by_name(cn))
}
func (f *Filter) Name() string {
return C.GoString(f.c.name)
}
func (f *Filter) String() string {
return f.Name()
}
func (f *Filter) NbInputs() int {
return int(f.c.nb_inputs)
}
func (f *Filter) NbOutputs() int {
return int(f.c.nb_outputs)
}
func (f *Filter) Inputs() (ps []*FilterPad) {
for idx := 0; idx < f.NbInputs(); idx++ {
ps = append(ps, newFilterPad(MediaType(C.avfilter_pad_get_type(f.c.inputs, C.int(idx)))))
}
return
}
func (f *Filter) Outputs() (ps []*FilterPad) {
for idx := 0; idx < f.NbOutputs(); idx++ {
ps = append(ps, newFilterPad(MediaType(C.avfilter_pad_get_type(f.c.outputs, C.int(idx)))))
}
return
}