Browse Source

Merge pull request #212 from mask-pp/fix_bug

错误处理与代码规范
pull/282/head
Babosa 1 year ago committed by GitHub
parent
commit
7799fa846e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      models/user.go
  2. 2
      rtsp/rtsp-client.go
  3. 11
      rtsp/rtsp-session.go

3
models/user.go

@ -15,6 +15,5 @@ type User struct {
} }
func (user *User) BeforeCreate(scope *gorm.Scope) error { func (user *User) BeforeCreate(scope *gorm.Scope) error {
scope.SetColumn("ID", utils.ShortID()) return scope.SetColumn("ID", utils.ShortID())
return nil
} }

2
rtsp/rtsp-client.go

@ -372,7 +372,7 @@ func (client *RTSPClient) startStream() {
case 0x24: // rtp case 0x24: // rtp
header := make([]byte, 4) header := make([]byte, 4)
header[0] = b header[0] = b
_, err := io.ReadFull(client.connRW, header[1:]) _, err = io.ReadFull(client.connRW, header[1:])
if err != nil { if err != nil {
if !client.Stoped { if !client.Stoped {

11
rtsp/rtsp-session.go

@ -698,16 +698,13 @@ func (session *Session) handleRequest(req *Request) {
func (session *Session) SendRTP(pack *RTPPack) (err error) { func (session *Session) SendRTP(pack *RTPPack) (err error) {
if pack == nil { if pack == nil {
err = fmt.Errorf("player send rtp got nil pack") return fmt.Errorf("player send rtp got nil pack")
return
} }
if session.TransType == TRANS_TYPE_UDP { if session.TransType == TRANS_TYPE_UDP {
if session.UDPClient == nil { if session.UDPClient == nil {
err = fmt.Errorf("player use udp transport but udp client not found") return fmt.Errorf("player use udp transport but udp client not found")
return
} }
err = session.UDPClient.SendRTP(pack) return session.UDPClient.SendRTP(pack)
return
} }
switch pack.Type { switch pack.Type {
case RTP_TYPE_AUDIO: case RTP_TYPE_AUDIO:
@ -763,7 +760,7 @@ func (session *Session) SendRTP(pack *RTPPack) (err error) {
session.connWLock.Unlock() session.connWLock.Unlock()
session.OutBytes += pack.Buffer.Len() + 4 session.OutBytes += pack.Buffer.Len() + 4
default: 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 return
} }

Loading…
Cancel
Save