forked from Eyevinn/mp4ff
-
Notifications
You must be signed in to change notification settings - Fork 1
/
free.go
46 lines (39 loc) · 912 Bytes
/
free.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
package mp4
import (
"io"
"io/ioutil"
)
// FreeBox - Free Space Box (free or skip)
type FreeBox struct {
Name string
notDecoded []byte
}
// DecodeFree - box-specific decode
func DecodeFree(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error) {
data, err := ioutil.ReadAll(r)
if err != nil {
return nil, err
}
return &FreeBox{Name: hdr.name, notDecoded: data}, nil
}
// Type - box type
func (b *FreeBox) Type() string {
return b.Name
}
// Size - calculated size of box
func (b *FreeBox) Size() uint64 {
return uint64(boxHeaderSize + len(b.notDecoded))
}
// Encode - write box to w
func (b *FreeBox) Encode(w io.Writer) error {
err := EncodeHeader(b, w)
if err != nil {
return err
}
_, err = w.Write(b.notDecoded)
return err
}
func (b *FreeBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error {
bd := newInfoDumper(w, indent, b, -1, 0)
return bd.err
}