增加对publisher的非空判断

This commit is contained in:
dexter
2021-08-04 15:27:55 +08:00
parent 1ecb45d904
commit 8cf3e0c0fc
2 changed files with 20 additions and 12 deletions

View File

@@ -314,11 +314,15 @@ func (client *RTSP) startStream() {
switch channel {
case client.aRTPChannel:
client.RtpAudio.Push(content)
if client.RtpAudio != nil {
client.RtpAudio.Push(content)
}
case client.aRTPControlChannel:
case client.vRTPChannel:
client.RtpVideo.Push(content)
if client.RtpVideo != nil {
client.RtpVideo.Push(content)
}
case client.vRTPControlChannel:
default:

View File

@@ -125,22 +125,26 @@ func (session *RTSP) AcceptPush() {
switch channel {
case session.aRTPChannel:
// pack.Type = RTP_TYPE_AUDIO
elapsed := time.Since(timer)
if elapsed >= 30*time.Second {
Println("Recv an audio RTP package")
timer = time.Now()
if session.RtpAudio != nil {
elapsed := time.Since(timer)
if elapsed >= 30*time.Second {
Println("Recv an audio RTP package")
timer = time.Now()
}
session.RtpAudio.Push(rtpBytes)
}
session.RtpAudio.Push(rtpBytes)
case session.aRTPControlChannel:
// pack.Type = RTP_TYPE_AUDIOCONTROL
case session.vRTPChannel:
// pack.Type = RTP_TYPE_VIDEO
elapsed := time.Since(timer)
if elapsed >= 30*time.Second {
Println("Recv an video RTP package")
timer = time.Now()
if session.RtpVideo != nil {
elapsed := time.Since(timer)
if elapsed >= 30*time.Second {
Println("Recv an video RTP package")
timer = time.Now()
}
session.RtpVideo.Push(rtpBytes)
}
session.RtpVideo.Push(rtpBytes)
case session.vRTPControlChannel:
// pack.Type = RTP_TYPE_VIDEOCONTROL
default: