From 4dc893e9fb609a97dd437527e8809b199954620c Mon Sep 17 00:00:00 2001 From: langhuihui <178529795@qq.com> Date: Fri, 27 Sep 2024 10:05:32 +0800 Subject: [PATCH] fix: use engine's aac format --- publisher.go | 1 + subscriber.go | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/publisher.go b/publisher.go index 9f59026..f441877 100644 --- a/publisher.go +++ b/publisher.go @@ -72,6 +72,7 @@ func (p *RTSPPublisher) SetTracks() error { conf = f.StreamMuxConfig.Programs[0].Layers[0].AudioSpecificConfig } at := p.CreateAudioTrack(codec.CodecID_AAC, byte(f.PayloadType()), uint32(conf.SampleRate)).(*AAC) + at.AACFormat = f at.AACDecoder.LATM = f.LATM at.AACDecoder.IndexDeltaLength = f.IndexDeltaLength at.AACDecoder.IndexLength = f.IndexLength diff --git a/subscriber.go b/subscriber.go index d6f4a62..6a2e4f5 100644 --- a/subscriber.go +++ b/subscriber.go @@ -69,9 +69,9 @@ func (s *RTSPSubscriber) OnEvent(event any) { } switch v.CodecID { case codec.CodecID_AAC: - s.audioTrack = &description.Media{ - Type: description.MediaTypeAudio, - Formats: []format.Format{&format.MPEG4Audio{ + f := v.AACFormat + if f == nil { + f = &format.MPEG4Audio{ PayloadTyp: v.PayloadType, Config: &mpeg4audio.Config{ Type: mpeg4audio.ObjectTypeAACLC, @@ -81,7 +81,11 @@ func (s *RTSPSubscriber) OnEvent(event any) { SizeLength: v.AACDecoder.SizeLength, IndexLength: v.AACDecoder.IndexLength, IndexDeltaLength: v.AACDecoder.IndexDeltaLength, - }}, + } + } + s.audioTrack = &description.Media{ + Type: description.MediaTypeAudio, + Formats: []format.Format{f}, } case codec.CodecID_PCMA: s.audioTrack = &description.Media{