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

Index

Functions

func DecryptSample(sample []byte, info *SampleEncryptionInfo, block cipher.Block)

DecryptSample decrypts a single sample in-place. info can be nil if the sample is not encrypted.

Types

type Box

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

Functions

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

Methods

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

type BoxHeader

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

Methods

func (h *BoxHeader) Parse(data []byte) error
func (h *BoxHeader) Put(buffer []byte)

Put writes the header to the given byte slice.

type EncBox

type EncBox struct {
	Header      BoxHeader
	EntryHeader []byte
	Children    []EncChild
}

Methods

func (b *EncBox) Encode() []byte
func (b *EncBox) Parse(data []byte) error
func (b *EncBox) Unprotect() error

type EncChild

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

type EncChild struct {
	Sinf *SinfBox
	Raw  []byte
}

type FrmaBox

--- FRMA ---

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

Methods

func (b *FrmaBox) Parse(data []byte) error

type MdatBox

--- MDAT ---

type MdatBox struct {
	Header  BoxHeader
	Payload []byte
}

Methods

func (b *MdatBox) Parse(data []byte) 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
}

Methods

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

type MdiaBox

type MdiaBox struct {
	Header   BoxHeader
	Children []MdiaChild
}

Methods

func (b *MdiaBox) Encode() []byte
func (b *MdiaBox) Mdhd() (*MdhdBox, bool)
func (b *MdiaBox) MdhdRaw() ([]byte, bool)
func (b *MdiaBox) Minf() (*MinfBox, bool)
func (b *MdiaBox) Parse(data []byte) error

type MdiaChild

--- MDIA ---

type MdiaChild struct {
	Mdhd *MdhdBox
	Minf *MinfBox
	Raw  []byte
}

type MinfBox

type MinfBox struct {
	Header   BoxHeader
	Children []MinfChild
}

Methods

func (b *MinfBox) Encode() []byte
func (b *MinfBox) Parse(data []byte) error
func (b *MinfBox) Stbl() (*StblBox, bool)

type MinfChild

--- MINF ---

type MinfChild struct {
	Stbl *StblBox
	Raw  []byte
}

type MoofBox

type MoofBox struct {
	Header   BoxHeader
	Children []MoofChild
}

Methods

func (b *MoofBox) Parse(data []byte) error
func (b *MoofBox) Traf() (*TrafBox, bool)

type MoofChild

--- MOOF ---

type MoofChild struct {
	Traf *TrafBox
	Pssh *PsshBox
	Raw  []byte
}

type MoovBox

type MoovBox struct {
	Header   BoxHeader
	Children []MoovChild
}

Functions

func FindMoov(boxes []Box) (*MoovBox, bool)

--- Finders ---

Methods

func (b *MoovBox) Encode() []byte
func (b *MoovBox) FindPssh(systemID []byte) (*PsshBox, bool)
func (b *MoovBox) Mvhd() (*MvhdBox, bool)
func (b *MoovBox) Parse(data []byte) error
func (b *MoovBox) RemoveMvex()
func (b *MoovBox) RemovePssh()
func (b *MoovBox) Trak() (*TrakBox, bool)

type MoovChild

--- MOOV ---

type MoovChild struct {
	Mvhd *MvhdBox
	Trak *TrakBox
	Pssh *PsshBox
	Raw  []byte
}

type MvhdBox

--- MVHD ---

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

Methods

func (b *MvhdBox) Encode() []byte
func (b *MvhdBox) Parse(data []byte) error
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
}

Methods

func (b *PsshBox) Parse(data []byte) error

type RemuxSample

RemuxSample represents the minimal sample information needed for remuxing.

type RemuxSample struct {
	Size     uint32
	Duration uint32
	IsSync   bool
}

type Remuxer

type Remuxer struct {
	Writer io.WriteSeeker
	Moov   *MoovBox

	OnSample func(sample []byte, encInfo *SampleEncryptionInfo)
	// 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 SampleEncryptionInfo

type SampleEncryptionInfo struct {
	IV         []byte
	Subsamples []SubsampleInfo
}

type SampleInfo

--- TRUN ---

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

type SencBox

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

Methods

func (b *SencBox) Parse(data []byte) error

type SidxBox

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

Functions

func FindSidx(boxes []Box) (*SidxBox, bool)

Methods

func (b *SidxBox) Parse(data []byte) error

type SidxReference

--- SIDX ---

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

type SinfBox

type SinfBox struct {
	Header   BoxHeader
	Children []SinfChild
}

Methods

func (b *SinfBox) Frma() *FrmaBox
func (b *SinfBox) Parse(data []byte) error

type SinfChild

--- SINF ---

type SinfChild struct {
	Frma *FrmaBox
	Raw  []byte
}

type StblBox

type StblBox struct {
	Header   BoxHeader
	Children []StblChild
}

Methods

func (b *StblBox) Encode() []byte
func (b *StblBox) Parse(data []byte) error
func (b *StblBox) Stsd() (*StsdBox, bool)

type StblChild

--- STBL ---

type StblChild struct {
	Stsd *StsdBox
	Raw  []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

type StsdBox struct {
	Header       BoxHeader
	HeaderFields [8]byte // Ver(1)+Flags(3)+EntryCount(4)
	Children     []StsdChild
}

Methods

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

type StsdChild

--- STSD ---

type StsdChild struct {
	Enc *EncBox
	Raw []byte
}

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 SubsampleInfo

--- SENC ---

type SubsampleInfo struct {
	BytesOfClearData     uint16
	BytesOfProtectedData uint32
}

type TfhdBox

--- TFHD ---

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

Methods

func (b *TfhdBox) Parse(data []byte) error

type TrafBox

type TrafBox struct {
	Header   BoxHeader
	Children []TrafChild
}

Methods

func (b *TrafBox) Parse(data []byte) error
func (b *TrafBox) Senc() (*SencBox, bool)
func (b *TrafBox) Tfhd() *TfhdBox
func (b *TrafBox) Trun() *TrunBox

type TrafChild

--- TRAF ---

type TrafChild struct {
	Tfhd *TfhdBox
	Trun *TrunBox
	Senc *SencBox
	Raw  []byte
}

type TrakBox

type TrakBox struct {
	Header   BoxHeader
	Children []TrakChild
}

Methods

func (b *TrakBox) Encode() []byte
func (b *TrakBox) Mdia() (*MdiaBox, bool)
func (b *TrakBox) Parse(data []byte) error
func (b *TrakBox) RemoveEdts()

type TrakChild

--- TRAK ---

type TrakChild struct {
	Mdia *MdiaBox
	Raw  []byte
}

type TrunBox

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

Methods

func (b *TrunBox) Parse(data []byte) error