mirror of
https://github.com/Monibuca/plugin-rtsp.git
synced 2025-09-26 19:51:14 +08:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4dc893e9fb | ||
![]() |
c943c2a0ec | ||
![]() |
eafbf28a02 |
20
publisher.go
20
publisher.go
@@ -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...))
|
||||
}
|
||||
|
@@ -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{
|
||||
|
Reference in New Issue
Block a user