diff --git a/pkg/rtsp/base_in_session.go b/pkg/rtsp/base_in_session.go index 07a923f..47d1439 100644 --- a/pkg/rtsp/base_in_session.go +++ b/pkg/rtsp/base_in_session.go @@ -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 diff --git a/pkg/rtsp/server_sub_session.go b/pkg/rtsp/server_sub_session.go index 3b72ffe..3958cac 100644 --- a/pkg/rtsp/server_sub_session.go +++ b/pkg/rtsp/server_sub_session.go @@ -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