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
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
}

View File

@@ -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: