mirror of
https://github.com/Monibuca/plugin-rtsp.git
synced 2025-09-30 21:42:09 +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:
|
case *format.MPEG4Audio:
|
||||||
at := p.AudioTrack
|
at := p.AudioTrack
|
||||||
if at == nil {
|
if at == nil {
|
||||||
at := p.CreateAudioTrack(codec.CodecID_AAC, byte(f.PayloadType()), uint32(f.Config.SampleRate)).(*AAC)
|
conf := f.Config
|
||||||
at.IndexDeltaLength = f.IndexDeltaLength
|
if f.LATM && f.StreamMuxConfig != nil && len(f.StreamMuxConfig.Programs) > 0 && len(f.StreamMuxConfig.Programs[0].Layers) > 0 {
|
||||||
at.IndexLength = f.IndexLength
|
conf = f.StreamMuxConfig.Programs[0].Layers[0].AudioSpecificConfig
|
||||||
at.SizeLength = f.SizeLength
|
}
|
||||||
if f.Config.Type == mpeg4audio.ObjectTypeAACLC {
|
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.Mode = 1
|
||||||
}
|
}
|
||||||
at.Channels = uint8(f.Config.ChannelCount)
|
at.Channels = uint8(conf.ChannelCount)
|
||||||
asc, _ := f.Config.Marshal()
|
asc, _ := conf.Marshal()
|
||||||
// 复用AVCC写入逻辑,解析出AAC的配置信息
|
// 复用AVCC写入逻辑,解析出AAC的配置信息
|
||||||
at.WriteSequenceHead(append([]byte{0xAF, 0x00}, asc...))
|
at.WriteSequenceHead(append([]byte{0xAF, 0x00}, asc...))
|
||||||
}
|
}
|
||||||
|
@@ -69,19 +69,23 @@ func (s *RTSPSubscriber) OnEvent(event any) {
|
|||||||
}
|
}
|
||||||
switch v.CodecID {
|
switch v.CodecID {
|
||||||
case codec.CodecID_AAC:
|
case codec.CodecID_AAC:
|
||||||
s.audioTrack = &description.Media{
|
f := v.AACFormat
|
||||||
Type: description.MediaTypeAudio,
|
if f == nil {
|
||||||
Formats: []format.Format{&format.MPEG4Audio{
|
f = &format.MPEG4Audio{
|
||||||
PayloadTyp: v.PayloadType,
|
PayloadTyp: v.PayloadType,
|
||||||
Config: &mpeg4audio.Config{
|
Config: &mpeg4audio.Config{
|
||||||
Type: mpeg4audio.ObjectTypeAACLC,
|
Type: mpeg4audio.ObjectTypeAACLC,
|
||||||
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,
|
||||||
}},
|
}
|
||||||
|
}
|
||||||
|
s.audioTrack = &description.Media{
|
||||||
|
Type: description.MediaTypeAudio,
|
||||||
|
Formats: []format.Format{f},
|
||||||
}
|
}
|
||||||
case codec.CodecID_PCMA:
|
case codec.CodecID_PCMA:
|
||||||
s.audioTrack = &description.Media{
|
s.audioTrack = &description.Media{
|
||||||
|
Reference in New Issue
Block a user