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{