[fix] rtsp,输入流只有单路音频或视频时,接收对象设置错误导致崩溃

pull/44/head
q191201771 4 years ago
parent 1a0232f779
commit 7dcd4a6b73

@ -116,10 +116,10 @@ func (s *BaseInSession) SetObserver(observer BaseInSessionObserver) {
}
func (s *BaseInSession) SetupWithConn(uri string, rtpConn, rtcpConn *nazanet.UDPConnection) error {
if strings.HasSuffix(uri, s.sdpLogicCtx.AudioAControl) {
if s.sdpLogicCtx.AudioAControl != "" && strings.HasSuffix(uri, s.sdpLogicCtx.AudioAControl) {
s.audioRTPConn = rtpConn
s.audioRTCPConn = rtcpConn
} else if strings.HasSuffix(uri, s.sdpLogicCtx.VideoAControl) {
} else if s.sdpLogicCtx.VideoAControl != "" && strings.HasSuffix(uri, s.sdpLogicCtx.VideoAControl) {
s.videoRTPConn = rtpConn
s.videoRTCPConn = rtcpConn
} else {
@ -133,12 +133,11 @@ func (s *BaseInSession) SetupWithConn(uri string, rtpConn, rtcpConn *nazanet.UDP
}
func (s *BaseInSession) SetupWithChannel(uri string, rtpChannel, rtcpChannel int) error {
if strings.HasSuffix(uri, s.sdpLogicCtx.AudioAControl) {
if s.sdpLogicCtx.AudioAControl != "" && strings.HasSuffix(uri, s.sdpLogicCtx.AudioAControl) {
s.audioRTPChannel = rtpChannel
s.audioRTCPChannel = rtcpChannel
return nil
}
if strings.HasSuffix(uri, s.sdpLogicCtx.VideoAControl) {
} else if s.sdpLogicCtx.VideoAControl != "" && strings.HasSuffix(uri, s.sdpLogicCtx.VideoAControl) {
s.videoRTPChannel = rtpChannel
s.videoRTCPChannel = rtcpChannel
return nil

@ -76,10 +76,10 @@ func (s *SubSession) InitWithSDP(rawSDP []byte, sdpLogicCtx sdp.LogicContext) {
}
func (s *SubSession) SetupWithConn(uri string, rtpConn, rtcpConn *nazanet.UDPConnection) error {
if strings.HasSuffix(uri, s.sdpLogicCtx.AudioAControl) {
if s.sdpLogicCtx.AudioAControl != "" && strings.HasSuffix(uri, s.sdpLogicCtx.AudioAControl) {
s.audioRTPConn = rtpConn
s.audioRTCPConn = rtcpConn
} else if strings.HasSuffix(uri, s.sdpLogicCtx.VideoAControl) {
} else if s.sdpLogicCtx.VideoAControl != "" && strings.HasSuffix(uri, s.sdpLogicCtx.VideoAControl) {
s.videoRTPConn = rtpConn
s.videoRTCPConn = rtcpConn
} else {
@ -95,12 +95,11 @@ func (s *SubSession) SetupWithConn(uri string, rtpConn, rtcpConn *nazanet.UDPCon
func (s *SubSession) SetupWithChannel(uri string, rtpChannel, rtcpChannel int, remoteAddr string) error {
s.stat.RemoteAddr = remoteAddr
if strings.HasSuffix(uri, s.sdpLogicCtx.AudioAControl) {
if s.sdpLogicCtx.AudioAControl != "" && strings.HasSuffix(uri, s.sdpLogicCtx.AudioAControl) {
s.audioRTPChannel = rtpChannel
s.audioRTCPChannel = rtcpChannel
return nil
}
if strings.HasSuffix(uri, s.sdpLogicCtx.VideoAControl) {
} else if s.sdpLogicCtx.VideoAControl != "" && strings.HasSuffix(uri, s.sdpLogicCtx.VideoAControl) {
s.videoRTPChannel = rtpChannel
s.videoRTCPChannel = rtcpChannel
return nil

Loading…
Cancel
Save