You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Box interfaces and some code in this directory is from the project https://github.com/jfbus/mp4. It has been vastly enhanced and the focus has changed from progessive mp4 files to segmented files.
4
+
The Box interfaces and some code in this directory is from the project https://github.com/jfbus/mp4. It has been vastly enhanced and the focus has changed from progressive mp4 files to segmented files.
5
5
6
6
## Overall structure
7
-
Most boxes have their own file named after the box, but in some cases, there may be multiple boxes that have the same content, and the code is then having a generic name like visualsampleentry.go.
7
+
Most boxes have their own file named after the box, but in some cases, there may be multiple boxes that have the same content, and the code is then having a generic name like `visualsampleentry.go`.
8
8
9
9
10
10
The Box interface is specified in `box.go`. It does not contain decode (parsing) methods which have distinct names for each box type
@@ -16,23 +16,28 @@ To implement a new box `fooo`, the following is needed.
16
16
17
17
Create a file `fooo.go` and create a struct type `FoooBox`.
18
18
19
-
Fooo should then implement the Box interface methods:
19
+
FoooBox should then implement the Box interface methods:
20
20
21
+
```go
21
22
Type()
22
23
Size()
23
24
Encode()
24
25
Info()
26
+
```
25
27
26
-
but also its own decode method `DecodeFooo`, and register that method in the `decoders` map in `box.go`. For a simple example, look at the `prft` box in `prft.go`.
28
+
but also its own decode method `DecodeFooo`, and register that method in the `decoders` map in `box.go`.
29
+
For a simple example, look at the `prft` box in `prft.go`.
27
30
28
-
A test file `fooo_test.go` should have a test using the method `boxDiffAfterEncodeAndDecode`to check that the box information is equal after
29
-
encoding and decoding.
31
+
A test file `fooo_test.go` should have a test using the method `boxDiffAfterEncodeAndDecode`to check that
32
+
the box information is equal after encoding and decoding.
30
33
31
34
Container boxes like `moof`, have a list of all their children called `Children`,
32
35
but also direct pointers to the children with appropriate names, like `Mfhd`
33
-
and `Traf`. This makes it easy to chain box paths to reach an element like a TfhdBox as
36
+
and `Traf`. This makes it easy to chain box paths to reach an element like a `TfhdBox` as
34
37
38
+
```go
35
39
file.Moof.Traf.Tfhd
40
+
```
36
41
37
42
When there may be multiple children with the same name, there may be both a
38
43
slice `Trafs` with all boxes and `Traf` that points to the first.
@@ -44,9 +49,9 @@ To handle media sample data there are two structures:
44
49
45
50
A MediaSegment can be fragmented into multiple fragments by the method
0 commit comments