Browse Source

rtsp source: improve support for AAC tracks with custom parameters

pull/923/head
aler9 4 years ago
parent
commit
6b86607092
  1. 2
      go.mod
  2. 4
      go.sum
  3. 7
      internal/core/hls_muxer.go
  4. 7
      internal/core/hls_source.go
  5. 14
      internal/core/rtmp_conn.go
  6. 7
      internal/core/rtmp_source.go

2
go.mod

@ -4,7 +4,7 @@ go 1.17 @@ -4,7 +4,7 @@ go 1.17
require (
code.cloudfoundry.org/bytefmt v0.0.0-20211005130812-5bb3c17173e5
github.com/aler9/gortsplib v0.0.0-20220415110824-9070fde20525
github.com/aler9/gortsplib v0.0.0-20220415145506-efe7b064c35c
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

@ -4,8 +4,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafo @@ -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-20220415110824-9070fde20525 h1:terPTGeZkg+etazcPrC4edVxurH5IE5Bl9kTavwaLeQ=
github.com/aler9/gortsplib v0.0.0-20220415110824-9070fde20525/go.mod h1:Mezkz7Jb5zrIWP6MxJ2uBgt5xwywZkcdmuQZ2QrFYsM=
github.com/aler9/gortsplib v0.0.0-20220415145506-efe7b064c35c h1:DWdbgHN8t9Op2ItBrlmS3tn6oszIYtMHD7PkGb4hzE0=
github.com/aler9/gortsplib v0.0.0-20220415145506-efe7b064c35c/go.mod h1:Mezkz7Jb5zrIWP6MxJ2uBgt5xwywZkcdmuQZ2QrFYsM=
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=

7
internal/core/hls_muxer.go

@ -296,7 +296,12 @@ func (m *hlsMuxer) runInner(innerCtx context.Context, innerReady chan struct{}) @@ -296,7 +296,12 @@ func (m *hlsMuxer) runInner(innerCtx context.Context, innerReady chan struct{})
audioTrack = tt
audioTrackID = i
aacDecoder = &rtpaac.Decoder{SampleRate: track.ClockRate()}
aacDecoder = &rtpaac.Decoder{
SampleRate: tt.ClockRate(),
SizeLength: tt.SizeLength(),
IndexLength: tt.IndexLength(),
IndexDeltaLength: tt.IndexDeltaLength(),
}
aacDecoder.Init()
}
}

7
internal/core/hls_source.go

@ -115,8 +115,11 @@ func (s *hlsSource) runInner() bool { @@ -115,8 +115,11 @@ func (s *hlsSource) runInner() bool {
if audioTrack != nil {
audioTrackID = len(tracks)
audioEnc = &rtpaac.Encoder{
PayloadType: 97,
SampleRate: audioTrack.ClockRate(),
PayloadType: 97,
SampleRate: audioTrack.ClockRate(),
SizeLength: 13,
IndexLength: 3,
IndexDeltaLength: 3,
}
audioEnc.Init()
tracks = append(tracks, audioTrack)

14
internal/core/rtmp_conn.go

@ -276,7 +276,12 @@ func (c *rtmpConn) runRead(ctx context.Context) error { @@ -276,7 +276,12 @@ func (c *rtmpConn) runRead(ctx context.Context) error {
audioTrack = tt
audioTrackID = i
aacDecoder = &rtpaac.Decoder{SampleRate: track.ClockRate()}
aacDecoder = &rtpaac.Decoder{
SampleRate: tt.ClockRate(),
SizeLength: tt.SizeLength(),
IndexLength: tt.IndexLength(),
IndexDeltaLength: tt.IndexDeltaLength(),
}
aacDecoder.Init()
}
}
@ -456,8 +461,11 @@ func (c *rtmpConn) runPublish(ctx context.Context) error { @@ -456,8 +461,11 @@ func (c *rtmpConn) runPublish(ctx context.Context) error {
var aacEncoder *rtpaac.Encoder
if audioTrack != nil {
aacEncoder = &rtpaac.Encoder{
PayloadType: 97,
SampleRate: audioTrack.ClockRate(),
PayloadType: 97,
SampleRate: audioTrack.ClockRate(),
SizeLength: 13,
IndexLength: 3,
IndexDeltaLength: 3,
}
aacEncoder.Init()
audioTrackID = len(tracks)

7
internal/core/rtmp_source.go

@ -144,8 +144,11 @@ func (s *rtmpSource) runInner() bool { @@ -144,8 +144,11 @@ func (s *rtmpSource) runInner() bool {
var aacEncoder *rtpaac.Encoder
if audioTrack != nil {
aacEncoder = &rtpaac.Encoder{
PayloadType: 97,
SampleRate: audioTrack.ClockRate(),
PayloadType: 97,
SampleRate: audioTrack.ClockRate(),
SizeLength: 13,
IndexLength: 3,
IndexDeltaLength: 3,
}
aacEncoder.Init()
audioTrackID = len(tracks)

Loading…
Cancel
Save