Package sofia (v1.13.9) [up] [repository]

config.go

core.go

encryption.go

fragment.go

movie.go

remuxer.go

tables.go

track.go

Index

Functions

func Decrypt(data []byte, sample *SencSample, block cipher.Block)

--- Logic ---

Types

type Box

--- Box ---

type Box struct {
	Moov *MoovBox
	Moof *MoofBox
	Mdat *MdatBox
	Sidx *SidxBox
	Pssh *PsshBox
	Raw  []byte
}

Functions

func DecodeBoxes(data []byte) ([]Box, error)

Methods

func (b *Box) Encode() []byte

type BoxHeader

--- BoxHeader ---

type BoxHeader struct {
	Size uint32
	Type [4]byte
}

Functions

func DecodeBoxHeader(data []byte) (*BoxHeader, error)

Methods

func (h *BoxHeader) Put(buffer []byte)

type Co64Box

--- CO64 ---

type Co64Box struct {
	Header  *BoxHeader
	Offsets []uint64
}

Methods

func (b *Co64Box) Encode() []byte

type CttsBox

type CttsBox struct {
	Header  *BoxHeader
	Entries []CttsEntry
}

Methods

func (b *CttsBox) Encode() []byte

type CttsEntry

--- CTTS ---

type CttsEntry struct {
	SampleCount  uint32
	SampleOffset int32
}

type EncBox

--- ENC (Encrypted Sample Entry) ---

type EncBox struct {
	Header      *BoxHeader
	EntryHeader []byte
	Sinf        *SinfBox
	RawChildren [][]byte
}

Functions

func DecodeEncBox(data []byte) (*EncBox, error)

Methods

func (b *EncBox) Encode() []byte

type FrmaBox

--- FRMA ---

type FrmaBox struct {
	Header     *BoxHeader
	DataFormat [4]byte
}

Functions

func DecodeFrmaBox(data []byte) (*FrmaBox, error)

type MdatBox

--- MDAT ---

type MdatBox struct {
	Header  *BoxHeader
	Payload []byte
}

Functions

func DecodeMdatBox(data []byte) (*MdatBox, error)

type MdhdBox

--- MDHD ---

type MdhdBox struct {
	Header           *BoxHeader
	Version          byte
	Flags            [3]byte
	CreationTime     uint64
	ModificationTime uint64
	Timescale        uint32
	Duration         uint64
	Language         [2]byte
	Quality          [2]byte
}

Functions

func DecodeMdhdBox(data []byte) (*MdhdBox, error)

Methods

func (b *MdhdBox) Encode() []byte
func (b *MdhdBox) SetDuration(duration uint64)

type MdiaBox

--- MDIA ---

type MdiaBox struct {
	Header      *BoxHeader
	Mdhd        *MdhdBox
	Minf        *MinfBox
	RawChildren [][]byte
}

Functions

func DecodeMdiaBox(data []byte) (*MdiaBox, error)

Methods

func (b *MdiaBox) Encode() []byte

type MinfBox

--- MINF ---

type MinfBox struct {
	Header      *BoxHeader
	Stbl        *StblBox
	RawChildren [][]byte
}

Functions

func DecodeMinfBox(data []byte) (*MinfBox, error)

Methods

func (b *MinfBox) Encode() []byte

type MoofBox

--- MOOF ---

type MoofBox struct {
	Header      *BoxHeader
	Traf        *TrafBox
	Pssh        []*PsshBox
	RawChildren [][]byte
}

Functions

func DecodeMoofBox(data []byte) (*MoofBox, error)

type MoovBox

--- MOOV ---

type MoovBox struct {
	Header      *BoxHeader
	Mvhd        *MvhdBox
	Trak        []*TrakBox
	Pssh        []*PsshBox
	RawChildren [][]byte
}

Functions

func DecodeMoovBox(data []byte) (*MoovBox, error)
func FindMoov(boxes []Box) (*MoovBox, bool)

--- Finders ---

Methods

func (b *MoovBox) Encode() []byte
func (b *MoovBox) FindPssh(systemID []byte) (*PsshBox, bool)
func (b *MoovBox) RemoveMvex()
func (b *MoovBox) RemovePssh()

type MvhdBox

--- MVHD ---

type MvhdBox struct {
	Header           *BoxHeader
	Version          byte
	Flags            [3]byte
	CreationTime     uint64
	ModificationTime uint64
	Timescale        uint32
	Duration         uint64
	RemainingData    []byte
}

Functions

func DecodeMvhdBox(data []byte) (*MvhdBox, error)

Methods

func (b *MvhdBox) Encode() []byte
func (b *MvhdBox) SetDuration(duration uint64)

type PsshBox

--- PSSH ---

type PsshBox struct {
	Header   *BoxHeader
	Version  byte
	Flags    [3]byte
	SystemID [16]byte
	KIDs     [][16]byte
	Data     []byte
}

Functions

func DecodePsshBox(data []byte) (*PsshBox, error)

type RemuxSample

type RemuxSample struct {
	Size                  uint32
	Duration              uint32
	IsSync                bool
	CompositionTimeOffset int32
}

type Remuxer

type Remuxer struct {
	Writer io.WriteSeeker
	Moov   *MoovBox

	OnSample func(data []byte, sample *SencSample)
	// contains filtered or unexported fields
}

Methods

func (r *Remuxer) AddSegment(segmentData []byte) error
func (r *Remuxer) Finish() error
func (r *Remuxer) Initialize(initSegment []byte) error

type SchiBox

--- SCHI (Scheme Information) ---

type SchiBox struct {
	Header      *BoxHeader
	Tenc        *TencBox
	RawChildren [][]byte
}

Functions

func DecodeSchiBox(data []byte) (*SchiBox, error)

type SencBox

type SencBox struct {
	Header  *BoxHeader
	Flags   uint32
	Samples []SencSample
}

Functions

func DecodeSencBox(data []byte) (*SencBox, error)

type SencSample

type SencSample struct {
	IV         []byte
	Subsamples []Subsample
}

type SidxBox

type SidxBox struct {
	Header                   *BoxHeader
	Version                  byte
	Flags                    uint32
	ReferenceID              uint32
	Timescale                uint32
	EarliestPresentationTime uint64
	FirstOffset              uint64
	References               []SidxReference
}

Functions

func DecodeSidxBox(data []byte) (*SidxBox, error)
func FindSidx(boxes []Box) (*SidxBox, bool)

type SidxReference

--- SIDX ---

type SidxReference struct {
	ReferenceType      bool
	ReferencedSize     uint32
	SubsegmentDuration uint32
	StartsWithSAP      bool
	SAPType            uint8
	SAPDeltaTime       uint32
}

type SinfBox

--- SINF ---

type SinfBox struct {
	Header      *BoxHeader
	Frma        *FrmaBox
	Schi        *SchiBox
	RawChildren [][]byte
}

Functions

func DecodeSinfBox(data []byte) (*SinfBox, error)

type StblBox

--- STBL ---

type StblBox struct {
	Header      *BoxHeader
	Stsd        *StsdBox
	RawChildren [][]byte
}

Functions

func DecodeStblBox(data []byte) (*StblBox, error)

Methods

func (b *StblBox) Encode() []byte

type StcoBox

--- STCO ---

type StcoBox struct {
	Header  *BoxHeader
	Offsets []uint32
}

Methods

func (b *StcoBox) Encode() []byte

type StscBox

type StscBox struct {
	Header  *BoxHeader
	Entries []StscEntry
}

Methods

func (b *StscBox) Encode() []byte

type StscEntry

--- STSC ---

type StscEntry struct {
	FirstChunk             uint32
	SamplesPerChunk        uint32
	SampleDescriptionIndex uint32
}

type StsdBox

--- STSD ---

type StsdBox struct {
	Header       *BoxHeader
	HeaderFields [8]byte // Ver(1)+Flags(3)+EntryCount(4)
	EncChildren  []*EncBox
	RawChildren  [][]byte
}

Functions

func DecodeStsdBox(data []byte) (*StsdBox, error)

Methods

func (b *StsdBox) Encode() []byte
func (b *StsdBox) RemoveSinf() error
func (b *StsdBox) Sinf() (*SinfBox, *BoxHeader, bool)

type StssBox

--- STSS ---

type StssBox struct {
	Header  *BoxHeader
	Indices []uint32
}

Methods

func (b *StssBox) Encode() []byte

type StszBox

--- STSZ ---

type StszBox struct {
	Header      *BoxHeader
	SampleSize  uint32
	SampleCount uint32
	EntrySizes  []uint32
}

Methods

func (b *StszBox) Encode() []byte

type SttsBox

type SttsBox struct {
	Header  *BoxHeader
	Entries []SttsEntry
}

Methods

func (b *SttsBox) Encode() []byte

type SttsEntry

--- STTS ---

type SttsEntry struct {
	SampleCount    uint32
	SampleDuration uint32
}

type Subsample

--- SENC ---

type Subsample struct {
	BytesOfClearData     uint16
	BytesOfProtectedData uint32
}

type TencBox

--- TENC --- TencBox defines the Track Encryption Box ('tenc'), which contains default encryption parameters for a track. Specification: ISO/IEC 23001-7

type TencBox struct {
	Header                 *BoxHeader
	Version                byte
	Flags                  uint32
	DefaultIsProtected     byte
	DefaultPerSampleIVSize byte
	DefaultKID             [16]byte
	DefaultConstantIVSize  byte   // Present if DefaultIsProtected=1 and DefaultPerSampleIVSize=0
	DefaultConstantIV      []byte // Present if DefaultIsProtected=1 and DefaultPerSampleIVSize=0
}

Functions

func DecodeTencBox(data []byte) (*TencBox, error)

type TfhdBox

--- TFHD ---

type TfhdBox struct {
	Header                 *BoxHeader
	Flags                  uint32
	TrackID                uint32
	BaseDataOffset         uint64
	SampleDescriptionIndex uint32
	DefaultSampleDuration  uint32
	DefaultSampleSize      uint32
	DefaultSampleFlags     uint32
}

Functions

func DecodeTfhdBox(data []byte) (*TfhdBox, error)

type TrafBox

--- TRAF ---

type TrafBox struct {
	Header      *BoxHeader
	Tfhd        *TfhdBox
	Trun        []*TrunBox
	Senc        *SencBox
	Tenc        *TencBox
	RawChildren [][]byte
}

Functions

func DecodeTrafBox(data []byte) (*TrafBox, error)

type TrakBox

--- TRAK ---

type TrakBox struct {
	Header      *BoxHeader
	Mdia        *MdiaBox
	RawChildren [][]byte
}

Functions

func DecodeTrakBox(data []byte) (*TrakBox, error)

Methods

func (b *TrakBox) Encode() []byte
func (b *TrakBox) RemoveEdts()

type TrunBox

type TrunBox struct {
	Header           *BoxHeader
	Flags            uint32
	SampleCount      uint32
	DataOffset       int32
	FirstSampleFlags uint32
	Samples          []TrunSample
}

Functions

func DecodeTrunBox(data []byte) (*TrunBox, error)

type TrunSample

--- TRUN ---

type TrunSample struct {
	Size                  uint32
	Duration              uint32
	Flags                 uint32
	CompositionTimeOffset int32
}