update gortsplib

This commit is contained in:
aler9 2022-03-24 12:59:22 +01:00
parent 4049a01d29
commit a6986e9fa4
8 changed files with 38 additions and 16 deletions

2
go.mod
View File

@ -4,7 +4,7 @@ go 1.17
require (
code.cloudfoundry.org/bytefmt v0.0.0-20211005130812-5bb3c17173e5
github.com/aler9/gortsplib v0.0.0-20220318155519-ba99421e74da
github.com/aler9/gortsplib v0.0.0-20220324114420-7f6383aa3cc4
github.com/asticode/go-astits v1.10.0
github.com/fsnotify/fsnotify v1.4.9
github.com/gin-gonic/gin v1.7.2

4
go.sum
View File

@ -4,8 +4,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafo
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/aler9/gortsplib v0.0.0-20220318155519-ba99421e74da h1:M+8aDrliK8rIpAGC9mekQJNmVZfSibJ6TARtcPHaCpE=
github.com/aler9/gortsplib v0.0.0-20220318155519-ba99421e74da/go.mod h1:4HE78w95Rqw1B2T90CHwtA4xBPPCRZ7/G8ds8ZdWcFk=
github.com/aler9/gortsplib v0.0.0-20220324114420-7f6383aa3cc4 h1:5WaJOApfEcrysFPHDBCN1XGc2JPYtEPjPC/G1LkTok8=
github.com/aler9/gortsplib v0.0.0-20220324114420-7f6383aa3cc4/go.mod h1:4HE78w95Rqw1B2T90CHwtA4xBPPCRZ7/G8ds8ZdWcFk=
github.com/aler9/rtmp v0.0.0-20210403095203-3be4a5535927 h1:95mXJ5fUCYpBRdSOnLAQAdJHHKxxxJrVCiaqDi965YQ=
github.com/aler9/rtmp v0.0.0-20210403095203-3be4a5535927/go.mod h1:vzuE21rowz+lT1NGsWbreIvYulgBpCGnQyeTyFblUHc=
github.com/asticode/go-astikit v0.20.0 h1:+7N+J4E4lWx2QOkRdOf6DafWJMv6O4RRfgClwQokrH8=

View File

@ -296,7 +296,8 @@ func (m *hlsMuxer) runInner(innerCtx context.Context, innerReady chan struct{})
videoTrack = tt
videoTrackID = i
h264Decoder = rtph264.NewDecoder()
h264Decoder = &rtph264.Decoder{}
h264Decoder.Init()
case *gortsplib.TrackAAC:
if audioTrack != nil {
@ -305,7 +306,8 @@ func (m *hlsMuxer) runInner(innerCtx context.Context, innerReady chan struct{})
audioTrack = tt
audioTrackID = i
aacDecoder = rtpaac.NewDecoder(track.ClockRate())
aacDecoder = &rtpaac.Decoder{SampleRate: track.ClockRate()}
aacDecoder.Init()
}
}

View File

@ -108,13 +108,18 @@ func (s *hlsSource) runInner() bool {
if videoTrack != nil {
videoTrackID = len(tracks)
videoEnc = rtph264.NewEncoder(96, nil, nil, nil)
videoEnc = &rtph264.Encoder{PayloadType: 96}
videoEnc.Init()
tracks = append(tracks, videoTrack)
}
if audioTrack != nil {
audioTrackID = len(tracks)
audioEnc = rtpaac.NewEncoder(97, audioTrack.ClockRate(), nil, nil, nil)
audioEnc = &rtpaac.Encoder{
PayloadType: 97,
SampleRate: audioTrack.ClockRate(),
}
audioEnc.Init()
tracks = append(tracks, audioTrack)
}

View File

@ -274,7 +274,8 @@ func (c *rtmpConn) runRead(ctx context.Context) error {
videoTrack = tt
videoTrackID = i
h264Decoder = rtph264.NewDecoder()
h264Decoder = &rtph264.Decoder{}
h264Decoder.Init()
case *gortsplib.TrackAAC:
if audioTrack != nil {
@ -283,7 +284,8 @@ func (c *rtmpConn) runRead(ctx context.Context) error {
audioTrack = tt
audioTrackID = i
aacDecoder = rtpaac.NewDecoder(track.ClockRate())
aacDecoder = &rtpaac.Decoder{SampleRate: track.ClockRate()}
aacDecoder.Init()
}
}
@ -447,14 +449,19 @@ func (c *rtmpConn) runPublish(ctx context.Context) error {
var h264Encoder *rtph264.Encoder
if videoTrack != nil {
h264Encoder = rtph264.NewEncoder(96, nil, nil, nil)
h264Encoder = &rtph264.Encoder{PayloadType: 96}
h264Encoder.Init()
videoTrackID = len(tracks)
tracks = append(tracks, videoTrack)
}
var aacEncoder *rtpaac.Encoder
if audioTrack != nil {
aacEncoder = rtpaac.NewEncoder(96, audioTrack.ClockRate(), nil, nil, nil)
aacEncoder = &rtpaac.Encoder{
PayloadType: 97,
SampleRate: audioTrack.ClockRate(),
}
aacEncoder.Init()
audioTrackID = len(tracks)
tracks = append(tracks, audioTrack)
}

View File

@ -136,14 +136,19 @@ func (s *rtmpSource) runInner() bool {
var h264Encoder *rtph264.Encoder
if videoTrack != nil {
h264Encoder = rtph264.NewEncoder(96, nil, nil, nil)
h264Encoder = &rtph264.Encoder{PayloadType: 96}
h264Encoder.Init()
videoTrackID = len(tracks)
tracks = append(tracks, videoTrack)
}
var aacEncoder *rtpaac.Encoder
if audioTrack != nil {
aacEncoder = rtpaac.NewEncoder(96, audioTrack.ClockRate(), nil, nil, nil)
aacEncoder = &rtpaac.Encoder{
PayloadType: 97,
SampleRate: audioTrack.ClockRate(),
}
aacEncoder.Init()
audioTrackID = len(tracks)
tracks = append(tracks, audioTrack)
}

View File

@ -258,7 +258,8 @@ func (s *rtspSource) handleMissingH264Params(c *gortsplib.Client, tracks gortspl
var streamMutex sync.RWMutex
var stream *stream
decoder := rtph264.NewDecoder()
decoder := &rtph264.Decoder{}
decoder.Init()
var sps []byte
var pps []byte
paramsReceived := make(chan struct{})

View File

@ -238,7 +238,8 @@ func TestRTSPSourceMissingH264Params(t *testing.T) {
go func() {
time.Sleep(500 * time.Millisecond)
enc := rtph264.NewEncoder(96, nil, nil, nil)
enc := &rtph264.Encoder{PayloadType: 96}
enc.Init()
pkts, err := enc.Encode([][]byte{{5}}, 0) // IDR
require.NoError(t, err)
@ -285,7 +286,8 @@ func TestRTSPSourceMissingH264Params(t *testing.T) {
defer p.close()
received := make(chan struct{})
decoder := rtph264.NewDecoder()
decoder := &rtph264.Decoder{}
decoder.Init()
c := gortsplib.Client{
OnPacketRTP: func(trackID int, pkt *rtp.Packet) {