forked from andrewzeneski/mp4
-
Notifications
You must be signed in to change notification settings - Fork 2
/
dinf.go
47 lines (41 loc) · 818 Bytes
/
dinf.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
package mp4
import "io"
// Data Information Box (dinf - mandatory)
//
// Contained in : Media Information Box (minf) or Meta Box (meta)
//
// Status : decoded
type DinfBox struct {
Dref *DrefBox
}
func DecodeDinf(r io.Reader, size uint64) (Box, error) {
l, err := DecodeContainer(r, size)
if err != nil {
return nil, err
}
d := &DinfBox{}
for _, b := range l {
switch b.Type() {
case "dref":
d.Dref = b.(*DrefBox)
default:
return nil, &BadFormatErr{
enclosingBox: "dinf",
unexpectedBox: b.Type(),
}
}
}
return d, nil
}
func (b *DinfBox) Type() string {
return "dinf"
}
func (b *DinfBox) Size() uint64 {
return AddHeaderSize(b.Dref.Size())
}
func (b *DinfBox) Encode(w io.Writer) error {
if err := EncodeHeader(b, w); err != nil {
return err
}
return b.Dref.Encode(w)
}