-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbranch_compose_fixtures_test.go
More file actions
85 lines (73 loc) · 1.99 KB
/
Copy pathbranch_compose_fixtures_test.go
File metadata and controls
85 lines (73 loc) · 1.99 KB
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
package goav
import (
"context"
"github.com/thesyncim/goav/av"
"github.com/thesyncim/goav/filter"
)
// videoVP8TranscodeTestStream is a shared VP8 video stream fixture for
// branch-composition and graph tests.
func videoVP8TranscodeTestStream() av.Stream {
return av.Stream{
ID: "video",
Type: av.MediaVideo,
TimeBase: av.TimeBase{Num: 1, Den: 90000},
Codec: av.CodecParameters{
ID: av.CodecVP8,
Type: av.MediaVideo,
ClockRate: 90000,
Width: 640,
Height: 360,
PixelFormat: av.PixelFormatYUV420P,
},
}
}
// transcodeTestFilterFactory / transcodeTestFilter are a shared pass-through
// audio resample filter fixture used by branch-composition and graph tests.
type transcodeTestFilterFactory struct {
filter *transcodeTestFilter
config filter.Config
}
func (f *transcodeTestFilterFactory) NewFilter(_ context.Context, config filter.Config) (filter.FrameFilter, error) {
f.config = config
if f.filter == nil {
f.filter = &transcodeTestFilter{}
}
return f.filter, nil
}
type transcodeTestFilter struct {
frames int
flushes int
closed bool
}
func (f *transcodeTestFilter) Descriptor() filter.Descriptor {
return filter.Descriptor{Name: filter.FactoryResample, Input: av.MediaAudio, Output: av.MediaAudio}
}
func (f *transcodeTestFilter) Open(context.Context, filter.Config) error {
return nil
}
func (f *transcodeTestFilter) FilterInto(_ context.Context, frame *av.Frame, out *filter.Result) error {
if frame == nil {
return nil
}
if len(out.Frames) == cap(out.Frames) {
return filter.ErrResultFull
}
index := len(out.Frames)
out.Frames = out.Frames[:index+1]
outFrame := &out.Frames[index]
outFrame.Reset()
*outFrame = *frame
f.frames++
return nil
}
func (f *transcodeTestFilter) FlushInto(context.Context, *filter.Result) error {
f.flushes++
return nil
}
func (f *transcodeTestFilter) HandleEvent(context.Context, *av.Event) error {
return nil
}
func (f *transcodeTestFilter) Close() error {
f.closed = true
return nil
}