Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: GetBtrt method for StsdBox #365

Merged
merged 1 commit into from
Jul 23, 2024
Merged
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
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
}
Loading