-
Notifications
You must be signed in to change notification settings - Fork 0
/
pass_through.go
103 lines (81 loc) · 2.59 KB
/
pass_through.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package main
import "C"
import (
"encoding/json"
"errors"
"fmt"
"github.com/babitmf/bmf-gosdk/bmf"
)
type PassThroughModuleOption struct {
Value int32
}
type PassThroughModule struct {
nodeId int32
option PassThroughModuleOption
}
func (self *PassThroughModule) Process(task *bmf.Task) error {
fmt.Println("Go-PassThrough process-in")
defer fmt.Println("Go-PassThrough process-out")
iids := task.GetInputStreamIds()
oids := task.GetOutputStreamIds()
gotEof := false
for i, iid := range iids {
for pkt, err := task.PopPacketFromInputQueue(iid); err == nil; {
defer pkt.Free()
if ok := task.FillOutputPacket(oids[i], pkt); !ok {
return errors.New("Fill output queue failed")
}
if pkt.Timestamp() == bmf.EOF {
gotEof = true
}
pkt, err = task.PopPacketFromInputQueue(iid)
}
}
if gotEof {
task.SetTimestamp(bmf.DONE)
}
return nil
}
func (self *PassThroughModule) Init() error {
return nil
}
func (self *PassThroughModule) Reset() error {
return errors.New("Reset is not supported")
}
func (self *PassThroughModule) Close() error {
return nil
}
func (self *PassThroughModule) GetModuleInfo() (interface{}, error) {
info := map[string]string{
"NodeId": fmt.Sprintf("%d", self.nodeId),
}
return info, nil
}
func (self *PassThroughModule) NeedHungryCheck(istreamId int32) (bool, error) {
return true, nil
}
func (self *PassThroughModule) IsHungry(istreamId int32) (bool, error) {
return true, nil
}
func (self *PassThroughModule) IsInfinity() (bool, error) {
return true, nil
}
func NewPassThroughModule(nodeId int32, option []byte) (bmf.Module, error) {
m := &PassThroughModule{}
err := json.Unmarshal(option, &m.option)
if err != nil {
return nil, err
}
m.nodeId = nodeId
return m, nil
}
func RegisterPassThroughInfo(info bmf.ModuleInfo) {
info.SetModuleDescription("Go PassThrough description")
tag := bmf.NewModuleTag(bmf.BMF_TAG_UTILS|bmf.BMF_TAG_VIDEO_PROCESSOR)
info.SetModuleTag(tag)
}
//export ConstructorRegister
func ConstructorRegister() {
bmf.RegisterModuleConstructor("go_pass_through", NewPassThroughModule, RegisterPassThroughInfo)
}
func main() {}