From 65eb9ae5c1a21ce49745646182af951ea2edfab2 Mon Sep 17 00:00:00 2001 From: Martin Riedl Date: Thu, 14 Nov 2024 18:42:41 +0100 Subject: [PATCH] new data information box --- Box.go | 2 ++ DataInformationBox.go | 40 ++++++++++++++++++++++++++++++++++++++++ Parser.go | 2 ++ README.md | 2 +- 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 DataInformationBox.go diff --git a/Box.go b/Box.go index 69ea768..e701337 100644 --- a/Box.go +++ b/Box.go @@ -40,6 +40,8 @@ const ( BoxTypeHandlerReference = "hdlr" // BoxTypeMediaInformation Media Information Box BoxTypeMediaInformation = "minf" + // BoxTypeDataInformation Data Information Box + BoxTypeDataInformation = "dinf" // BoxTypeMovieFragment Movie Fragment Box BoxTypeMovieFragment = "moof" // BoxTypeMovieFragmentHeader Movie Fragment Header Box diff --git a/DataInformationBox.go b/DataInformationBox.go new file mode 100644 index 0000000..6b56ea7 --- /dev/null +++ b/DataInformationBox.go @@ -0,0 +1,40 @@ +// Copyright 2024 Martin Riedl +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package gomp4 + +// DataInformationBox data information box struct +// +// 8.7.1 Data Information Box +// +// Box Type: ‘dinf’ +// Container: Media Information Box (‘minf’) or Meta Box (‘meta’) +// Mandatory: Yes (required within ‘minf’ box) and No (optional within ‘meta’ box) +// Quantity: Exactly one +// +// The data information box contains objects that declare the location of the media information in a track. +type DataInformationBox struct { + *Box + ChildBoxes []interface{} +} + +// ParseDataInformationBox creates a new data information box struct based on bytes +func ParseDataInformationBox(filePosition uint64, headerSize uint32, content []byte) (*DataInformationBox, error) { + box := &DataInformationBox{Box: &Box{filePosition, headerSize}} + + // parse child boxes + var err error + box.ChildBoxes, err = box.parseChildBoxes(filePosition, content) + return box, err +} diff --git a/Parser.go b/Parser.go index dc3f2f5..c393672 100644 --- a/Parser.go +++ b/Parser.go @@ -124,6 +124,8 @@ func parseNextBox(reader io.Reader, filePosition uint64) (box interface{}, endPo box = ParseHandlerReferenceBox(filePosition, boxHeaderSize, boxContentBytes) case BoxTypeMediaInformation: box, err = ParseMediaInformationBox(filePosition, boxHeaderSize, boxContentBytes) + case BoxTypeDataInformation: + box, err = ParseDataInformationBox(filePosition, boxHeaderSize, boxContentBytes) case BoxTypeMovieFragment: box, err = ParseMovieFragmentBox(filePosition, boxHeaderSize, boxContentBytes) case BoxTypeMovieFragmentHeader: diff --git a/README.md b/README.md index a1b2d8b..1423d14 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Implementation progress | 8.6.4 Independent and Disposable Samples Box | sdtp | - | | 8.6.5 Edit Box | edts | - | | 8.6.6 Edit List Box | elst | - | -| 8.7.1 Data Information Box | dinf | - | +| 8.7.1 Data Information Box | dinf | 100% | | 8.7.2 Data Reference Box | dref, url, urn | - | | 8.7.3 Sample Size Boxes | stsz, stz2 | - | | 8.7.4 Sample To Chunk Box | stsc | - |