Skip to content

Commit 86ecb1f

Browse files
authored
feat: DecodeBytes function, refactor tests (#87)
* feat: add DecodeBytes function * test: unify tests for DecodeBase64 and DecodeHex, add for DecodeBytes
1 parent 98535eb commit 86ecb1f

File tree

2 files changed

+757
-606
lines changed

2 files changed

+757
-606
lines changed

pkg/scte35/scte35.go

+9
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ func DecodeHex(s string) (*SpliceInfoSection, error) {
8585
return sis, err
8686
}
8787

88+
// DecodeBytes is a convenience function for decoding a byte array into a
89+
// SpliceInfoSection. If an error occurs, the returned SpliceInfoSection will
90+
// contain the results of decoding up until the error condition was encountered.
91+
func DecodeBytes(b []byte) (*SpliceInfoSection, error) {
92+
sis := &SpliceInfoSection{}
93+
err := sis.Decode(b)
94+
return sis, err
95+
}
96+
8897
// DurationToTicks converts a duration to 90kHz ticks.
8998
func DurationToTicks(d time.Duration) uint64 {
9099
return uint64(math.Round(float64(d.Nanoseconds()) * TicksPerNanosecond))

0 commit comments

Comments
 (0)