forked from godeep/mp4
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdinf.go
45 lines (39 loc) · 734 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
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) (Box, error) {
l, err := DecodeContainer(r)
if err != nil {
return nil, err
}
d := &DinfBox{}
for _, b := range l {
switch b.Type() {
case "dref":
d.Dref = b.(*DrefBox)
default:
return nil, ErrBadFormat
}
}
return d, nil
}
func (b *DinfBox) Type() string {
return "dinf"
}
func (b *DinfBox) Size() int {
return BoxHeaderSize + b.Dref.Size()
}
func (b *DinfBox) Encode(w io.Writer) error {
err := EncodeHeader(b, w)
if err != nil {
return err
}
return b.Dref.Encode(w)
}