-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecoder_probe_test.go
More file actions
69 lines (62 loc) · 2.06 KB
/
Copy pathdecoder_probe_test.go
File metadata and controls
69 lines (62 loc) · 2.06 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
//go:build amd64 || arm64
package ffmpeg
import (
"testing"
"time"
)
func TestBuildDecoderAVOptions_TypedOverridesRaw(t *testing.T) {
opts := &DecoderOptions{
AVOptions: map[string]string{
"probesize": "1",
"analyzeduration": "2",
"max_probe_packets": "3",
},
ProbeSizeBytes: 10,
AnalyzeDuration: 1500 * time.Microsecond,
MaxProbePackets: 20,
FormatWhitelist: []string{"mov", "mp4"},
CodecWhitelist: []string{"h264", "aac"},
}
m := buildDecoderAVOptions(opts)
if got := m["probesize"]; got != "10" {
t.Fatalf("probesize: expected 10, got %q", got)
}
if got := m["analyzeduration"]; got != "1500" {
t.Fatalf("analyzeduration: expected 1500, got %q", got)
}
if got := m["max_probe_packets"]; got != "20" {
t.Fatalf("max_probe_packets: expected 20, got %q", got)
}
if got := m["format_whitelist"]; got != "mov,mp4" {
t.Fatalf("format_whitelist: expected mov,mp4, got %q", got)
}
if got := m["codec_whitelist"]; got != "h264,aac" {
t.Fatalf("codec_whitelist: expected h264,aac, got %q", got)
}
}
func TestCloneDecoderOptionsDeepCopiesMutableFields(t *testing.T) {
original := &DecoderOptions{
AVOptions: map[string]string{"safe": "1"},
FormatWhitelist: []string{"mov"},
CodecWhitelist: []string{"h264"},
FormatBlacklist: []string{"mpegts"},
Streams: []MediaType{MediaTypeVideo},
TryMultipleFormats: true,
Hardware: &HWDecoderConfig{
Mode: HardwareAccelerationRequired,
DeviceType: HWDeviceTypeVAAPI,
},
}
clone := cloneDecoderOptions(original)
clone.AVOptions["safe"] = "0"
clone.FormatWhitelist[0] = "matroska"
clone.CodecWhitelist[0] = "aac"
clone.FormatBlacklist[0] = "avi"
clone.Streams[0] = MediaTypeAudio
clone.Hardware.DeviceType = HWDeviceTypeCUDA
if original.AVOptions["safe"] != "1" || original.FormatWhitelist[0] != "mov" ||
original.CodecWhitelist[0] != "h264" || original.FormatBlacklist[0] != "mpegts" ||
original.Streams[0] != MediaTypeVideo || original.Hardware.DeviceType != HWDeviceTypeVAAPI {
t.Fatalf("clone mutated caller options: %#v", original)
}
}