streaming

Media streaming and broadcast systems in Go
Log | Files | Refs | README | LICENSE

commit dfd42b06d7b8816d35e0b574ad54e5146d9d5ab6
parent f9d860476fbcf68d9cb28f489eafc3db682a040c
Author: Oliver Lowe <o@olowe.co>
Date:   Wed,  8 May 2024 17:29:31 +1000

internal/scte35: use plain byte slices instead of iobit

Since all that was being done was reading a uint32 from a byte slice,
we can just use Go's encoding/binary instead of relying on some 3rd
party package. This removes the entire module's dependency on iobit!

Diffstat:
Mgo.mod | 5-----
Dgo.sum | 4----
Minternal/scte35/crc_32.go | 14+++++---------
Minternal/scte35/scte35.go | 13-------------
4 files changed, 5 insertions(+), 31 deletions(-)

diff --git a/go.mod b/go.mod @@ -1,8 +1,3 @@ module github.com/untangledco/streaming go 1.19 - -require ( - github.com/bamiaux/iobit v0.0.0-20170418073505-498159a04883 - golang.org/x/text v0.14.0 -) diff --git a/go.sum b/go.sum @@ -1,4 +0,0 @@ -github.com/bamiaux/iobit v0.0.0-20170418073505-498159a04883 h1:XNtOMwxmV2PI/vuTHDZnFzGIFNUh8MK73q7+Kna7AXs= -github.com/bamiaux/iobit v0.0.0-20170418073505-498159a04883/go.mod h1:9IjZnSQGh45J46HHS45pxuMJ6WFTtSXbaX0FoHDvxh8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= diff --git a/internal/scte35/crc_32.go b/internal/scte35/crc_32.go @@ -17,9 +17,8 @@ package scte35 import ( + "encoding/binary" "errors" - - "github.com/bamiaux/iobit" ) // ErrCRC32Invalid indicates that a splice_info_sections CRC_32 is @@ -304,13 +303,10 @@ func verifyCRC32(b []byte) error { return ErrCRC32Invalid } - r := iobit.NewReader(b) - - payload := r.Bytes(len(b) - 4) - crc := r.Uint32(32) - - calculated := calculateCRC32(payload) - if calculated != crc { + // crc32 is the last 4 bytes. + payload := b[:len(b)-4] + crc := binary.BigEndian.Uint32(b[len(b)-4:]) + if calculateCRC32(payload) != crc { return ErrCRC32Invalid } diff --git a/internal/scte35/scte35.go b/internal/scte35/scte35.go @@ -22,8 +22,6 @@ import ( "errors" "math" "time" - - "github.com/bamiaux/iobit" ) const ( @@ -91,14 +89,3 @@ func TicksToDuration(ticks uint64) time.Duration { s := float64(ticks) / float64(TicksPerSecond) return time.Duration(int64(s * float64(time.Second))) } - -// readerError returns the readers error state, if any. -func readerError(r iobit.Reader) error { - if r.LeftBits() > 0 { - return ErrBufferUnderflow - } - if errors.Is(r.Error(), iobit.ErrOverflow) { - return ErrBufferOverflow - } - return nil -}