Compare commits

...

3 Commits
v4.3.5 ... v4

Author SHA1 Message Date
langhuihui
4dc893e9fb fix: use engine's aac format 2024-09-27 10:05:32 +08:00
langhuihui
c943c2a0ec feat: add LATM support 2024-09-26 20:34:00 +08:00
langhuihui
eafbf28a02 feat: support LATM 2024-09-26 14:08:06 +08:00
2 changed files with 24 additions and 14 deletions

View File

@@ -67,15 +67,21 @@ func (p *RTSPPublisher) SetTracks() error {
case *format.MPEG4Audio:
at := p.AudioTrack
if at == nil {
at := p.CreateAudioTrack(codec.CodecID_AAC, byte(f.PayloadType()), uint32(f.Config.SampleRate)).(*AAC)
at.IndexDeltaLength = f.IndexDeltaLength
at.IndexLength = f.IndexLength
at.SizeLength = f.SizeLength
if f.Config.Type == mpeg4audio.ObjectTypeAACLC {
conf := f.Config
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.AACFormat = f
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
}
at.Channels = uint8(f.Config.ChannelCount)
asc, _ := f.Config.Marshal()
at.Channels = uint8(conf.ChannelCount)
asc, _ := conf.Marshal()
// 复用AVCC写入逻辑解析出AAC的配置信息
at.WriteSequenceHead(append([]byte{0xAF, 0x00}, asc...))
}

View File

@@ -69,19 +69,23 @@ 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,
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,
}
}
s.audioTrack = &description.Media{
Type: description.MediaTypeAudio,
Formats: []format.Format{f},
}
case codec.CodecID_PCMA:
s.audioTrack = &description.Media{