From eb8ff3bd6e7354dfa03abab1e8d7aeea75fc1d81 Mon Sep 17 00:00:00 2001 From: mask-pp Date: Fri, 18 Sep 2020 09:39:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BB=A3=E7=A0=81=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/user.go | 3 +-- rtsp/rtsp-client.go | 2 +- rtsp/rtsp-session.go | 11 ++++------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/models/user.go b/models/user.go index d8bccb05..0ae76955 100644 --- a/models/user.go +++ b/models/user.go @@ -15,6 +15,5 @@ type User struct { } func (user *User) BeforeCreate(scope *gorm.Scope) error { - scope.SetColumn("ID", utils.ShortID()) - return nil + return scope.SetColumn("ID", utils.ShortID()) } diff --git a/rtsp/rtsp-client.go b/rtsp/rtsp-client.go index c822bef6..57a23076 100644 --- a/rtsp/rtsp-client.go +++ b/rtsp/rtsp-client.go @@ -372,7 +372,7 @@ func (client *RTSPClient) startStream() { case 0x24: // rtp header := make([]byte, 4) header[0] = b - _, err := io.ReadFull(client.connRW, header[1:]) + _, err = io.ReadFull(client.connRW, header[1:]) if err != nil { if !client.Stoped { diff --git a/rtsp/rtsp-session.go b/rtsp/rtsp-session.go index 6225fe38..179422d4 100644 --- a/rtsp/rtsp-session.go +++ b/rtsp/rtsp-session.go @@ -698,16 +698,13 @@ func (session *Session) handleRequest(req *Request) { func (session *Session) SendRTP(pack *RTPPack) (err error) { if pack == nil { - err = fmt.Errorf("player send rtp got nil pack") - return + return fmt.Errorf("player send rtp got nil pack") } if session.TransType == TRANS_TYPE_UDP { if session.UDPClient == nil { - err = fmt.Errorf("player use udp transport but udp client not found") - return + return fmt.Errorf("player use udp transport but udp client not found") } - err = session.UDPClient.SendRTP(pack) - return + return session.UDPClient.SendRTP(pack) } switch pack.Type { case RTP_TYPE_AUDIO: @@ -763,7 +760,7 @@ func (session *Session) SendRTP(pack *RTPPack) (err error) { session.connWLock.Unlock() session.OutBytes += pack.Buffer.Len() + 4 default: - err = fmt.Errorf("session tcp send rtp got unkown pack type[%v]", pack.Type) + return fmt.Errorf("session tcp send rtp got unkown pack type[%v]", pack.Type) } return }