Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions atom/ctts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package atom

import "encoding/binary"

// CttsBox - Composition offset atom Box
// Box Type: ctts
// Container: Composition offset atom Box (ctts)
// Mandatory: Yes
// Quantity: Exactly one.
type CttsBox struct {
*Box
Version byte
Flags uint32
EntryCount uint32
}

func (b *CttsBox) parse() error {
data := b.ReadBoxData()

b.Version = data[0]
b.Flags = binary.BigEndian.Uint32(data[0:4])
b.EntryCount = binary.BigEndian.Uint32(data[4:8])
return nil
}
21 changes: 21 additions & 0 deletions atom/stbl.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ type StblBox struct {
*Box
Stts *SttsBox
Stsd *StsdBox
Stss *StssBox
Ctts *CttsBox
Stsc *StscBox
Stsz *StszBox
Stco *StcoBox
}

func (b *StblBox) parse() error {
Expand All @@ -23,6 +28,22 @@ func (b *StblBox) parse() error {
case "stsd":
b.Stsd = &StsdBox{Box: box}
b.Stsd.parse()

case "stss":
b.Stss = &StssBox{Box: box}
b.Stss.parse()
case "ctts":
b.Ctts = &CttsBox{Box: box}
b.Ctts.parse()
case "stsc":
b.Stsc = &StscBox{Box: box}
b.Stsc.parse()
case "stsz":
b.Stsz = &StszBox{Box: box}
b.Stsz.parse()
case "stco":
b.Stco = &StcoBox{Box: box}
b.Stco.parse()
}
}
return nil
Expand Down
28 changes: 28 additions & 0 deletions atom/stco.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package atom

import "encoding/binary"

// StcoBox - Chunk offset atom Box
// Box Type: stco
// Container: Chunk offset atom Box (stco)
// Mandatory: Yes
// Quantity: Exactly one.
type StcoBox struct {
*Box
Version byte
Flags uint32
EntryCount uint32
ChunkOffsetTable []uint32
}

func (b *StcoBox) parse() error {
data := b.ReadBoxData()
b.Version = data[0]
b.Flags = binary.BigEndian.Uint32(data[0:4])
b.EntryCount = binary.BigEndian.Uint32(data[4:8])

for i := 0; i < int(b.EntryCount); i++ {
b.ChunkOffsetTable = append(b.ChunkOffsetTable, binary.BigEndian.Uint32(data[i*4+8:i*4+12]))
}
return nil
}
32 changes: 32 additions & 0 deletions atom/stsc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package atom

import "encoding/binary"

// StscBox - Sample-to-chunk atom Box
// Box Type: stsc
// Container: Sample-to-chunk atom Box (stsc)
// Mandatory: Yes
// Quantity: Exactly one.
type StscBox struct {
*Box
Version byte
Flags uint32
EntryCount uint32
SampletoChunkData SampletoChunk
}
type SampletoChunk struct {
Firstchunk uint32
SamplesPerChunk uint32
SampleDescriptionID uint32
}

func (b *StscBox) parse() error {
data := b.ReadBoxData()
b.Version = data[0]
b.Flags = binary.BigEndian.Uint32(data[0:4])
b.EntryCount = binary.BigEndian.Uint32(data[4:8])
b.SampletoChunkData.Firstchunk = binary.BigEndian.Uint32(data[8:12])
b.SampletoChunkData.SamplesPerChunk = binary.BigEndian.Uint32(data[12:16])
b.SampletoChunkData.SampleDescriptionID = binary.BigEndian.Uint32(data[16:20])
return nil
}
30 changes: 30 additions & 0 deletions atom/stss.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package atom

import (
"encoding/binary"
)

// StssBox - Sync sample atom Box
// Box Type: stss
// Container: Sync sample atom Box (stss)
// Mandatory: Yes
// Quantity: Exactly one.
type StssBox struct {
*Box
Version byte
Flags uint32
EntriesNumber uint32
SyncSampleTable []uint32
}

func (b *StssBox) parse() error {
data := b.ReadBoxData()
b.Version = data[0]
b.Flags = binary.BigEndian.Uint32(data[0:4])
b.EntriesNumber = binary.BigEndian.Uint32(data[4:8])
for i := 8; i < len(data); i += 4 {
b.SyncSampleTable = append(b.SyncSampleTable, uint32(binary.BigEndian.Uint32(data[i:i+4])))
}

return nil
}
31 changes: 31 additions & 0 deletions atom/stsz.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package atom

import "encoding/binary"

// StszBox - Sample size atom Box
// Box Type: sttz
// Container: Sample Size Table Box (stsz)
// Mandatory: Yes
// Quantity: Exactly one.
type StszBox struct {
*Box
Version byte
Flags uint32
SampleSize uint32
EntryCount uint32
SampleSizeTable []uint32
}

func (b *StszBox) parse() error {
data := b.ReadBoxData()
b.Version = data[0]
b.Flags = binary.BigEndian.Uint32(data[0:4])
b.SampleSize = binary.BigEndian.Uint32(data[4:8])
b.EntryCount = binary.BigEndian.Uint32(data[8:12])
if b.SampleSize == 0 {
for i := 0; i < int(b.EntryCount); i++ {
b.SampleSizeTable = append(b.SampleSizeTable, binary.BigEndian.Uint32(data[i*4+12:i*4+16]))
}
}
return nil
}