Skip to content

Commit

Permalink
Merge pull request #365 from Eyevinn/get-btrt
Browse files Browse the repository at this point in the history
feat: GetBtrt method for StsdBox
  • Loading branch information
tobbee authored Jul 23, 2024
2 parents d8a9389 + 0e14642 commit 2e3834a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- mvhd and tkhd methods to set and get creation and modification times
- Event Message boxes evte, emib, emeb
- GetBtrt method to StsdBox
- Btrt pointer attribute in AudioSampleEnntry

## [0.45.1] - 2024-07-12

Expand Down
3 changes: 3 additions & 0 deletions mp4/audiosamplentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type AudioSampleEntryBox struct {
Esds *EsdsBox
Dac3 *Dac3Box
Dec3 *Dec3Box
Btrt *BtrtBox
Sinf *SinfBox
Children []Box
}
Expand Down Expand Up @@ -60,6 +61,8 @@ func (a *AudioSampleEntryBox) AddChild(child Box) {
a.Dac3 = child.(*Dac3Box)
case "dec3":
a.Dec3 = child.(*Dec3Box)
case "btrt":
a.Btrt = child.(*BtrtBox)
case "sinf":
a.Sinf = child.(*SinfBox)
}
Expand Down
19 changes: 19 additions & 0 deletions mp4/stsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,22 @@ func (s *StsdBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string
}
return err
}

// GetBtrt returns the first BtrtBox found in StsdBox children.
func (s *StsdBox) GetBtrt() *BtrtBox {
for _, c := range s.Children {
switch child := c.(type) {
case *VisualSampleEntryBox:
return child.Btrt
case *AudioSampleEntryBox:
return child.Btrt
case *WvttBox:
return child.Btrt
case *StppBox:
return child.Btrt
case *EvteBox:
return child.Btrt
}
}
return nil
}

0 comments on commit 2e3834a

Please sign in to comment.