forked from Eyevinn/mp4ff
-
Notifications
You must be signed in to change notification settings - Fork 1
/
minf.go
74 lines (63 loc) · 1.47 KB
/
minf.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
package mp4
import "io"
// MinfBox - Media Information Box (minf - mandatory)
//
// Contained in : Media Box (mdia)
//
type MinfBox struct {
Vmhd *VmhdBox
Smhd *SmhdBox
Stbl *StblBox
Dinf *DinfBox
Hdlr *HdlrBox
Children []Box
}
// NewMinfBox - Generate a new empty minf box
func NewMinfBox() *MinfBox {
return &MinfBox{}
}
// AddChild - Add a child box
func (m *MinfBox) AddChild(box Box) {
switch box.Type() {
case "vmhd":
m.Vmhd = box.(*VmhdBox)
case "smhd":
m.Smhd = box.(*SmhdBox)
case "dinf":
m.Dinf = box.(*DinfBox)
case "stbl":
m.Stbl = box.(*StblBox)
}
m.Children = append(m.Children, box)
}
// DecodeMinf - box-specific decode
func DecodeMinf(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error) {
l, err := DecodeContainerChildren(hdr, startPos+8, startPos+hdr.size, r)
if err != nil {
return nil, err
}
m := NewMinfBox()
for _, b := range l {
m.AddChild(b)
}
return m, nil
}
// Type - box type
func (m *MinfBox) Type() string {
return "minf"
}
// Size - calculated size of box
func (m *MinfBox) Size() uint64 {
return containerSize(m.Children)
}
// GetChildren - list of child boxes
func (m *MinfBox) GetChildren() []Box {
return m.Children
}
// Encode - write minf container to w
func (m *MinfBox) Encode(w io.Writer) error {
return EncodeContainer(m, w)
}
func (m *MinfBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error {
return ContainerInfo(m, w, specificBoxLevels, indent, indentStep)
}