forked from Eyevinn/mp4ff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschi.go
78 lines (66 loc) · 1.68 KB
/
schi.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
package mp4
import (
"io"
"github.com/edgeware/mp4ff/bits"
)
// SchiBox - Schema Information Box
type SchiBox struct {
Tenc *TencBox
Children []Box
}
// AddChild - Add a child box
func (b *SchiBox) AddChild(box Box) {
switch box.Type() {
case "tenc":
b.Tenc = box.(*TencBox)
}
b.Children = append(b.Children, box)
}
// DecodeSchi - box-specific decode
func DecodeSchi(hdr boxHeader, startPos uint64, r io.Reader) (Box, error) {
children, err := DecodeContainerChildren(hdr, startPos+8, startPos+hdr.size, r)
if err != nil {
return nil, err
}
b := &SchiBox{}
for _, child := range children {
b.AddChild(child)
}
return b, nil
}
// DecodeSchiSR - box-specific decode
func DecodeSchiSR(hdr boxHeader, startPos uint64, sr bits.SliceReader) (Box, error) {
children, err := DecodeContainerChildrenSR(hdr, startPos+8, startPos+hdr.size, sr)
if err != nil {
return nil, err
}
b := &SchiBox{}
for _, child := range children {
b.AddChild(child)
}
return b, nil
}
// Type - box type
func (b *SchiBox) Type() string {
return "schi"
}
// Size - calculated size of box
func (b *SchiBox) Size() uint64 {
return containerSize(b.Children)
}
// GetChildren - list of child boxes
func (b *SchiBox) GetChildren() []Box {
return b.Children
}
// Encode - write minf container to w
func (b *SchiBox) Encode(w io.Writer) error {
return EncodeContainer(b, w)
}
// Encode - write minf container to sw
func (b *SchiBox) EncodeSW(sw bits.SliceWriter) error {
return EncodeContainerSW(b, sw)
}
// Info - write box-specific information
func (b *SchiBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error {
return ContainerInfo(b, w, specificBoxLevels, indent, indentStep)
}