-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdecoder_helpers_test.go
More file actions
60 lines (47 loc) · 1.44 KB
/
decoder_helpers_test.go
File metadata and controls
60 lines (47 loc) · 1.44 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
package gopus
import "testing"
func mustNewTestEncoder(t *testing.T, sampleRate, channels int, application Application) *Encoder {
t.Helper()
enc, err := NewEncoder(EncoderConfig{SampleRate: sampleRate, Channels: channels, Application: application})
if err != nil {
t.Fatalf("NewEncoder error: %v", err)
}
return enc
}
func mustNewTestDecoder(t *testing.T, sampleRate, channels int) *Decoder {
t.Helper()
dec, err := NewDecoder(DefaultDecoderConfig(sampleRate, channels))
if err != nil {
t.Fatalf("NewDecoder error: %v", err)
}
return dec
}
func mustNewDefaultMultistreamEncoder(t *testing.T, sampleRate, channels int, application Application) *MultistreamEncoder {
t.Helper()
enc, err := NewMultistreamEncoderDefault(sampleRate, channels, application)
if err != nil {
t.Fatalf("NewMultistreamEncoderDefault error: %v", err)
}
return enc
}
func mustNewDefaultMultistreamDecoder(t *testing.T, sampleRate, channels int) *MultistreamDecoder {
t.Helper()
dec, err := NewMultistreamDecoderDefault(sampleRate, channels)
if err != nil {
t.Fatalf("NewMultistreamDecoderDefault error: %v", err)
}
return dec
}
func newMonoTestDecoder(t *testing.T) *Decoder {
t.Helper()
return mustNewTestDecoder(t, 48000, 1)
}
func decodeMinimalHybrid20ms(t *testing.T, dec *Decoder) int {
t.Helper()
pcm := make([]float32, 960)
n, err := dec.Decode(minimalHybridTestPacket20ms(), pcm)
if err != nil {
t.Fatalf("Decode error: %v", err)
}
return n
}