import "41.neocities.org/sofia"
Decrypt decrypts a segment's mdat boxes in-place using the provided key. It self-determines if decryption is needed by checking for 'senc' boxes within the segment. This function has a side effect: it modifies the Payload of the MdatBox structs within the segmentBoxes slice.
type Box struct {
Moov *MoovBox
Moof *MoofBox
Mdat *MdatBox
Sidx *SidxBox
Pssh *PsshBox
Raw []byte
}
type FrmaBox struct {
Header BoxHeader
RawData []byte // Stores the original box data for a perfect round trip
DataFormat [4]byte
}
FrmaBox represents the 'frma' box (Original Format Box).
Encode returns the raw byte data to ensure a perfect round trip.
Parse parses the 'frma' box from a byte slice.
type MdhdBox struct {
Header BoxHeader
RawData []byte
Version byte
Timescale uint32
Duration uint64
}
MdhdBox represents the 'mdhd' box (Media Header Box).
Encode returns the raw byte data to ensure a perfect round trip.
Parse parses the 'mdhd' box from a byte slice.
Mdhd finds the MdhdBox child and returns it, along with a boolean indicating if it was found.
Minf finds the MinfBox child and returns it, along with a boolean indicating if it was found.
Stbl finds the StblBox child and returns it, along with a boolean indicating if it was found.
Missing is an error type used when a required child box is not found.
AllMoof finds all MoofBoxes in a slice of generic boxes.
Traf returns the first traf box found and a boolean indicating if it was found.
FindMoov finds the first MoovBox in a slice of generic boxes.
FindPssh finds the first PsshBox child with a matching SystemID.
type PsshBox struct {
Header BoxHeader
Version byte
Flags [3]byte
SystemID [16]byte
KIDs [][16]byte
Data []byte
}
type SampleEncryptionInfo struct {
IV []byte
Subsamples []SubsampleInfo
}
SampleEncryptionInfo contains the IV and subsample data for one sample.
type SampleInfo struct {
Size uint32
Duration uint32
Flags uint32
CompositionTimeOffset int32 // Can be signed
}
SampleInfo holds details about a single sample in a track run.
Tenc finds the TencBox child and returns it, along with a boolean indicating if it was found.
type SencBox struct {
Header BoxHeader
RawData []byte
Flags uint32
Samples []SampleEncryptionInfo
}
SencBox represents the 'senc' box (Sample Encryption Box).
Encode returns the raw byte data to ensure a perfect round trip.
Parse parses the 'senc' box from a byte slice.
type SidxBox struct {
Header BoxHeader
RawData []byte
Version byte
Flags uint32
ReferenceID uint32
Timescale uint32
EarliestPresentationTime uint64
FirstOffset uint64
References []SidxReference
}
SidxBox represents the 'sidx' box (Segment Index Box).
FindSidx finds the first SidxBox in a slice of generic boxes.
Encode returns the raw byte data to ensure a perfect round trip.
Parse parses the 'sidx' box from a byte slice.
type SidxReference struct {
ReferenceType bool // 1 bit
ReferencedSize uint32 // 31 bits
SubsegmentDuration uint32
StartsWithSAP bool // 1 bit
SAPType uint8 // 3 bits
SAPDeltaTime uint32 // 28 bits
}
SidxReference holds the data for a single entry in the sidx list.
Frma finds and returns the first FrmaBox child.
Schi finds the SchiBox child and returns it, along with a boolean indicating if it was found.
Stsd finds the StsdBox child and returns it, along with a boolean indicating if it was found.
Sinf finds the first protected sample entry and returns its SinfBox, its header, and a boolean indicating if it was found.
SubsampleInfo defines the size of clear and protected data blocks.
type TencBox struct {
Header BoxHeader
RawData []byte // Stores the original box data for a perfect round trip
DefaultKID [16]byte
}
TencBox represents the 'tenc' box (Track Encryption Box).
Encode returns the raw byte data to ensure a perfect round trip.
Parse parses the 'tenc' box from a byte slice.
type TfhdBox struct {
Header BoxHeader
RawData []byte
Flags uint32
TrackID uint32
BaseDataOffset uint64
SampleDescriptionIndex uint32
DefaultSampleDuration uint32
DefaultSampleSize uint32
DefaultSampleFlags uint32
}
TfhdBox now includes all possible fields from the header.
Parse is now a full parser that respects all flags.
Totals calculates the total byte size and duration of all samples in a traf.
Mdia finds the MdiaBox child and returns it, along with a boolean indicating if it was found.
type TrunBox struct {
Header BoxHeader
RawData []byte // Stores the original box data for a perfect round trip
Flags uint32
Samples []SampleInfo
}
TrunBox represents the 'trun' box (Track Run Box).
Encode returns the raw byte data to ensure a perfect round trip.
Parse parses the 'trun' box from a byte slice.
edts.go enca.go encv.go frma.go mdat.go mdhd.go mdia.go minf.go moof.go moov.go pssh.go schi.go senc.go sidx.go sinf.go sofia.go stbl.go stsd.go tenc.go tfhd.go traf.go trak.go trun.go
| Path | Synopsis |
|---|---|
| internal/2024/os-test | |
| internal/2024/write-at |
git clone
https://github.com/3052/sofia.git git@github.com:3052/sofia.git