From c943c2a0ec79f0905219dc75b60fef90a05e9ee4 Mon Sep 17 00:00:00 2001 From: langhuihui <178529795@qq.com> Date: Thu, 26 Sep 2024 20:34:00 +0800 Subject: [PATCH] feat: add LATM support --- publisher.go | 9 +++++---- subscriber.go | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/publisher.go b/publisher.go index efaab32..9f59026 100644 --- a/publisher.go +++ b/publisher.go @@ -68,13 +68,14 @@ func (p *RTSPPublisher) SetTracks() error { at := p.AudioTrack if at == nil { conf := f.Config - if f.LATM { + if f.LATM && f.StreamMuxConfig != nil && len(f.StreamMuxConfig.Programs) > 0 && len(f.StreamMuxConfig.Programs[0].Layers) > 0 { conf = f.StreamMuxConfig.Programs[0].Layers[0].AudioSpecificConfig } at := p.CreateAudioTrack(codec.CodecID_AAC, byte(f.PayloadType()), uint32(conf.SampleRate)).(*AAC) - at.IndexDeltaLength = f.IndexDeltaLength - at.IndexLength = f.IndexLength - at.SizeLength = f.SizeLength + at.AACDecoder.LATM = f.LATM + at.AACDecoder.IndexDeltaLength = f.IndexDeltaLength + at.AACDecoder.IndexLength = f.IndexLength + at.AACDecoder.SizeLength = f.SizeLength if conf.Type == mpeg4audio.ObjectTypeAACLC { at.Mode = 1 } diff --git a/subscriber.go b/subscriber.go index 86dd62f..d6f4a62 100644 --- a/subscriber.go +++ b/subscriber.go @@ -78,9 +78,9 @@ func (s *RTSPSubscriber) OnEvent(event any) { SampleRate: int(v.SampleRate), ChannelCount: int(v.Channels), }, - SizeLength: v.SizeLength, - IndexLength: v.IndexLength, - IndexDeltaLength: v.IndexDeltaLength, + SizeLength: v.AACDecoder.SizeLength, + IndexLength: v.AACDecoder.IndexLength, + IndexDeltaLength: v.AACDecoder.IndexDeltaLength, }}, } case codec.CodecID_PCMA: