-
Notifications
You must be signed in to change notification settings - Fork 84
/
eventmessage_test.go
96 lines (89 loc) · 2.01 KB
/
eventmessage_test.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
package mp4
import (
"bytes"
"encoding/hex"
"os"
"testing"
"github.com/Eyevinn/mp4ff/bits"
)
func TestEvteDecode(t *testing.T) {
hexEvte := "0000002465767465000000000000000100000014627472740000000000001f4000001f40"
data, err := hex.DecodeString(hexEvte)
if err != nil {
t.Error(err)
}
sr := bits.NewFixedSliceReader(data)
box, err := DecodeBoxSR(0, sr)
if err != nil {
t.Error(err)
}
evte := box.(*EvteBox)
if evte.DataReferenceIndex != 1 {
t.Errorf("Wrong DataReferenceIndex %d", evte.DataReferenceIndex)
}
if evte.Btrt == nil {
t.Error("btrt is nil")
}
}
func TestEvteInclSilb(t *testing.T) {
silb := SilbBox{
Version: 0,
Flags: 0,
Schemes: []SilbEntry{
{
SchemeIdURI: "urn:mpeg:dash:event:2012",
Value: "event1",
AtLeastOneFlag: false,
},
},
}
boxDiffAfterEncodeAndDecode(t, &silb)
evte := EvteBox{
DataReferenceIndex: 1,
}
evte.AddChild(&silb)
boxDiffAfterEncodeAndDecode(t, &evte)
}
func TestEmib(t *testing.T) {
scteSchemeIdURI := "urn:scte:scte35:2013:bin"
t.Run("DecodeEmib", func(t *testing.T) {
data, err := os.ReadFile("testdata/emib.dat")
if err != nil {
t.Error(err)
}
buf := bytes.NewBuffer(data)
box, err := DecodeBox(0, buf)
if err != nil {
t.Error(err)
}
emib := box.(*EmibBox)
if emib.SchemeIdURI != scteSchemeIdURI {
t.Errorf("Wrong SchemeIdURI %s", emib.SchemeIdURI)
}
out := bytes.Buffer{}
err = emib.Encode(&out)
if err != nil {
t.Error(err)
}
if !bytes.Equal(data, out.Bytes()) {
t.Error("Encode/Decode mismatch")
}
})
t.Run("EncodeDecodeEmib", func(t *testing.T) {
emib := EmibBox{
Version: 0,
Flags: 0,
PresentationTimeDelta: -1000,
EventDuration: 2000,
Id: 1234,
SchemeIdURI: scteSchemeIdURI,
Value: "2",
MessageData: []byte{0x01, 0x02, 0x03},
}
boxDiffAfterEncodeAndDecode(t, &emib)
})
}
func TestEmeb(t *testing.T) {
emeb := EmebBox{}
boxDiffAfterEncodeAndDecode(t, &emeb)
}