mirror of
https://github.com/Monibuca/plugin-rtsp.git
synced 2025-09-26 19:51:14 +08:00
增加强制指定拉流协议的配置
This commit is contained in:
@@ -3,7 +3,6 @@ package rtsp
|
||||
import (
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/pkg/aac"
|
||||
"go.uber.org/zap"
|
||||
. "m7s.live/engine/v4"
|
||||
"m7s.live/engine/v4/codec"
|
||||
"m7s.live/engine/v4/track"
|
||||
@@ -20,34 +19,36 @@ func (s *RTSPSubscriber) OnEvent(event any) {
|
||||
switch v.CodecID {
|
||||
case codec.CodecID_H264:
|
||||
extra := v.DecoderConfiguration.Raw
|
||||
if vtrack, err := gortsplib.NewTrackH264(v.DecoderConfiguration.PayloadType, extra[0], extra[1], nil); err == nil {
|
||||
s.videoTrackId = len(s.tracks)
|
||||
s.tracks = append(s.tracks, vtrack)
|
||||
vtrack := &gortsplib.TrackH264{
|
||||
PayloadType: v.DecoderConfiguration.PayloadType, SPS: extra[0], PPS: extra[1],
|
||||
}
|
||||
s.videoTrackId = len(s.tracks)
|
||||
s.tracks = append(s.tracks, vtrack)
|
||||
case codec.CodecID_H265:
|
||||
if vtrack, err := NewH265Track(v.DecoderConfiguration.PayloadType, v.DecoderConfiguration.Raw); err == nil {
|
||||
s.videoTrackId = len(s.tracks)
|
||||
s.tracks = append(s.tracks, vtrack)
|
||||
vtrack := &gortsplib.TrackH265{
|
||||
PayloadType: v.DecoderConfiguration.PayloadType, VPS: v.DecoderConfiguration.Raw[0], SPS: v.DecoderConfiguration.Raw[1], PPS: v.DecoderConfiguration.Raw[2],
|
||||
}
|
||||
s.videoTrackId = len(s.tracks)
|
||||
s.tracks = append(s.tracks, vtrack)
|
||||
}
|
||||
s.AddTrack(v)
|
||||
case *track.Audio:
|
||||
switch v.CodecID {
|
||||
case codec.CodecID_AAC:
|
||||
var mpegConf aac.MPEG4AudioConfig
|
||||
mpegConf.Decode(v.DecoderConfiguration.Raw)
|
||||
if atrack, err := gortsplib.NewTrackAAC(v.DecoderConfiguration.PayloadType, int(mpegConf.Type), mpegConf.SampleRate, mpegConf.ChannelCount, mpegConf.AOTSpecificConfig, 13, 3, 3); err == nil {
|
||||
s.audioTrackId = len(s.tracks)
|
||||
s.tracks = append(s.tracks, atrack)
|
||||
} else {
|
||||
v.Stream.Error("error creating AAC track", zap.Error(err))
|
||||
mpegConf.Unmarshal(v.DecoderConfiguration.Raw)
|
||||
atrack := &gortsplib.TrackAAC{
|
||||
PayloadType: v.DecoderConfiguration.PayloadType, Config: &mpegConf, SizeLength: 13, IndexLength: 3, IndexDeltaLength: 3,
|
||||
}
|
||||
s.audioTrackId = len(s.tracks)
|
||||
s.tracks = append(s.tracks, atrack)
|
||||
case codec.CodecID_PCMA:
|
||||
s.audioTrackId = len(s.tracks)
|
||||
s.tracks = append(s.tracks, gortsplib.NewTrackPCMA())
|
||||
|
||||
s.tracks = append(s.tracks, &gortsplib.TrackPCMA{})
|
||||
case codec.CodecID_PCMU:
|
||||
s.audioTrackId = len(s.tracks)
|
||||
s.tracks = append(s.tracks, gortsplib.NewTrackPCMU())
|
||||
s.tracks = append(s.tracks, &gortsplib.TrackPCMU{})
|
||||
}
|
||||
s.AddTrack(v)
|
||||
case ISubscriber:
|
||||
|
Reference in New Issue
Block a user