Skip to content

Commit

Permalink
update gohlslib; remove dts from MPEG-4 audio and opus callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Aug 5, 2023
1 parent c78e68c commit 275eaf6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ type ClientOnTracksFunc func([]*Track) error
type ClientOnDataH26xFunc func(pts time.Duration, dts time.Duration, au [][]byte)

// ClientOnDataMPEG4AudioFunc is the prototype of the function passed to OnDataMPEG4Audio().
type ClientOnDataMPEG4AudioFunc func(pts time.Duration, dts time.Duration, aus [][]byte)
type ClientOnDataMPEG4AudioFunc func(pts time.Duration, aus [][]byte)

// ClientOnDataOpusFunc is the prototype of the function passed to OnDataOpus().
type ClientOnDataOpusFunc func(pts time.Duration, dts time.Duration, packets [][]byte)
type ClientOnDataOpusFunc func(pts time.Duration, packets [][]byte)

func clientAbsoluteURL(base *url.URL, relative string) (*url.URL, error) {
u, err := url.Parse(relative)
Expand Down
8 changes: 4 additions & 4 deletions client_processor_fmp4.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,24 +213,24 @@ func (p *clientProcessorFMP4) initializeTrackProcs(ctx context.Context, track *f
}

case *codecs.MPEG4Audio:
var onDataCasted ClientOnDataMPEG4AudioFunc = func(pts time.Duration, dts time.Duration, aus [][]byte) {}
var onDataCasted ClientOnDataMPEG4AudioFunc = func(pts time.Duration, aus [][]byte) {}
if onData != nil {
onDataCasted = onData.(ClientOnDataMPEG4AudioFunc)
}

postProcess = func(pts time.Duration, dts time.Duration, payload []byte) error {
onDataCasted(pts, dts, [][]byte{payload})
onDataCasted(pts, [][]byte{payload})
return nil
}

case *codecs.Opus:
var onDataCasted ClientOnDataOpusFunc = func(pts time.Duration, dts time.Duration, packets [][]byte) {}
var onDataCasted ClientOnDataOpusFunc = func(pts time.Duration, packets [][]byte) {}
if onData != nil {
onDataCasted = onData.(ClientOnDataOpusFunc)
}

postProcess = func(pts time.Duration, dts time.Duration, payload []byte) error {
onDataCasted(pts, dts, [][]byte{payload})
onDataCasted(pts, [][]byte{payload})
return nil
}
}
Expand Down
8 changes: 4 additions & 4 deletions client_processor_mpegts.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,16 @@ func (p *clientProcessorMPEGTS) processSegment(ctx context.Context, byts []byte)
})

case *codecs.MPEG4Audio:
var onDataCasted ClientOnDataMPEG4AudioFunc = func(pts time.Duration, dts time.Duration, aus [][]byte) {}
var onDataCasted ClientOnDataMPEG4AudioFunc = func(pts time.Duration, aus [][]byte) {}
if onData != nil {
onDataCasted = onData.(ClientOnDataMPEG4AudioFunc)
}

p.reader.OnDataMPEG4Audio(mpegtsTrack, func(pts int64, dts int64, aus [][]byte) error {
p.reader.OnDataMPEG4Audio(mpegtsTrack, func(pts int64, aus [][]byte) error {
return prePreProcess(
pts, dts,
pts, pts,
func(pts time.Duration, dts time.Duration) {
onDataCasted(pts, dts, aus)
onDataCasted(pts, aus)
})
})
}
Expand Down
4 changes: 2 additions & 2 deletions examples/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ func main() {
})

case *codecs.MPEG4Audio:
c.OnDataMPEG4Audio(track, func(pts time.Duration, dts time.Duration, aus [][]byte) {
c.OnDataMPEG4Audio(track, func(pts time.Duration, aus [][]byte) {
log.Printf("received data from track %T, pts = %v", ttrack, pts)
})

case *codecs.Opus:
c.OnDataOpus(track, func(pts time.Duration, dts time.Duration, packets [][]byte) {
c.OnDataOpus(track, func(pts time.Duration, packets [][]byte) {
log.Printf("received data from track %T, pts = %v", ttrack, pts)
})
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/abema/go-mp4 v0.11.0
github.com/aler9/writerseeker v0.0.0-20220601075008-6f0e685b9c82
github.com/asticode/go-astits v1.12.0
github.com/bluenviron/mediacommon v0.7.1-0.20230730144331-10b74a4f6eda
github.com/bluenviron/mediacommon v0.7.1-0.20230805112107-7818184886e4
github.com/gin-gonic/gin v1.9.1
github.com/stretchr/testify v1.8.4
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ github.com/asticode/go-astikit v0.30.0 h1:DkBkRQRIxYcknlaU7W7ksNfn4gMFsB0tqMJflx
github.com/asticode/go-astikit v0.30.0/go.mod h1:h4ly7idim1tNhaVkdVBeXQZEE3L0xblP7fCWbgwipF0=
github.com/asticode/go-astits v1.12.0 h1:BiefTgVEyPgEB8nT6J+Sys/uxE4H/a04SW/aedpOpPc=
github.com/asticode/go-astits v1.12.0/go.mod h1:QSHmknZ51pf6KJdHKZHJTLlMegIrhega3LPWz3ND/iI=
github.com/bluenviron/mediacommon v0.7.1-0.20230730144331-10b74a4f6eda h1:+ungCWRNDjsy/CVL1l/UjAj4vYL4+NIJQoJJWbR3Xw8=
github.com/bluenviron/mediacommon v0.7.1-0.20230730144331-10b74a4f6eda/go.mod h1:tfk0qGPhqnOxVCrElu8ct3LKQn6Cj4Tpu3zbbJBTKj4=
github.com/bluenviron/mediacommon v0.7.1-0.20230805112107-7818184886e4 h1:Z220cIxQZ+i2WNV/oFliBdqFFZTfFYcNSAcLwAXQxBs=
github.com/bluenviron/mediacommon v0.7.1-0.20230805112107-7818184886e4/go.mod h1:8Y0rvMJDUCgqDegYrUxG1rbumB6DV0TZ98Rw9mowIrA=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s=
github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
Expand Down

0 comments on commit 275eaf6

Please sign in to comment.