mp4/TrackBox.go

48 lines
1.9 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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
// TrackBox track box struct
//
// 8.3.1 Track Box
// Box Type: trak
// Container: Movie Box (moov)
// Mandatory: Yes
// Quantity: One or more
//
// This is a container box for a single track of a presentation. A presentation consists of one or more tracks.
// Each track is independent of the other tracks in the presentation and carries its own temporal and
// spatial information. Each track will contain its associated Media Box.
//
// Tracks are used for two purposes: (a) to contain media data (media tracks) and (b) to contain
// packetization information for streaming protocols (hint tracks).
//
// There shall be at least one media track within an ISO file, and all the media tracks that contributed to
// the hint tracks shall remain in the file, even if the media data within them is not referenced by the hint
// tracks; after deleting all hint tracks, the entire unhinted presentation shall remain.
type TrackBox struct {
*Box
ChildBoxes []interface{}
}
// ParseTrackBox creates a new track box struct based on bytes
func ParseTrackBox(filePosition uint64, headerSize uint32, content []byte) (*TrackBox, error) {
box := &TrackBox{Box: &Box{filePosition, headerSize}}
// parse child boxes
var err error
box.ChildBoxes, err = box.parseChildBoxes(filePosition, content)
return box, err
}