feat: add LATM support

This commit is contained in:
langhuihui
2024-09-26 20:34:00 +08:00
parent eafbf28a02
commit c943c2a0ec
2 changed files with 8 additions and 7 deletions

View File

@@ -68,13 +68,14 @@ func (p *RTSPPublisher) SetTracks() error {
at := p.AudioTrack at := p.AudioTrack
if at == nil { if at == nil {
conf := f.Config 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 conf = f.StreamMuxConfig.Programs[0].Layers[0].AudioSpecificConfig
} }
at := p.CreateAudioTrack(codec.CodecID_AAC, byte(f.PayloadType()), uint32(conf.SampleRate)).(*AAC) at := p.CreateAudioTrack(codec.CodecID_AAC, byte(f.PayloadType()), uint32(conf.SampleRate)).(*AAC)
at.IndexDeltaLength = f.IndexDeltaLength at.AACDecoder.LATM = f.LATM
at.IndexLength = f.IndexLength at.AACDecoder.IndexDeltaLength = f.IndexDeltaLength
at.SizeLength = f.SizeLength at.AACDecoder.IndexLength = f.IndexLength
at.AACDecoder.SizeLength = f.SizeLength
if conf.Type == mpeg4audio.ObjectTypeAACLC { if conf.Type == mpeg4audio.ObjectTypeAACLC {
at.Mode = 1 at.Mode = 1
} }

View File

@@ -78,9 +78,9 @@ func (s *RTSPSubscriber) OnEvent(event any) {
SampleRate: int(v.SampleRate), SampleRate: int(v.SampleRate),
ChannelCount: int(v.Channels), ChannelCount: int(v.Channels),
}, },
SizeLength: v.SizeLength, SizeLength: v.AACDecoder.SizeLength,
IndexLength: v.IndexLength, IndexLength: v.AACDecoder.IndexLength,
IndexDeltaLength: v.IndexDeltaLength, IndexDeltaLength: v.AACDecoder.IndexDeltaLength,
}}, }},
} }
case codec.CodecID_PCMA: case codec.CodecID_PCMA: