Merge pull request #203 from mask-pp/fix_bug

调整顺序避免不必要的rtspclient创建开销
pull/206/head
milkyway river 4 years ago committed by GitHub
commit 7db2df2bc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -136,6 +136,9 @@ func (p *program) Start(s service.Service) (err error) {
}
for i := len(streams) - 1; i > -1; i-- {
v := streams[i]
if rtsp.GetServer().GetPusher(v.CustomPath) != nil {
continue
}
agent := fmt.Sprintf("EasyDarwinGo/%s", routers.BuildVersion)
if routers.BuildDateTime != "" {
agent = fmt.Sprintf("%s(%s)", agent, routers.BuildDateTime)
@ -146,15 +149,12 @@ func (p *program) Start(s service.Service) (err error) {
}
client.CustomPath = v.CustomPath
pusher := rtsp.NewClientPusher(client)
if rtsp.GetServer().GetPusher(pusher.Path()) != nil {
continue
}
err = client.Start(time.Duration(v.IdleTimeout) * time.Second)
if err != nil {
log.Printf("Pull stream err :%v", err)
continue
}
pusher := rtsp.NewClientPusher(client)
rtsp.GetServer().AddPusher(pusher)
//streams = streams[0:i]
//streams = append(streams[:i], streams[i+1:]...)

@ -354,12 +354,8 @@ func (pusher *Pusher) RemovePlayer(player *Player) *Pusher {
func (pusher *Pusher) ClearPlayer() {
// copy a new map to avoid deadlock
players := make(map[string]*Player)
pusher.playersLock.Lock()
for k, v := range pusher.players {
//v.Stop()
players[k] = v
}
players := pusher.players
pusher.players = make(map[string]*Player)
pusher.playersLock.Unlock()
go func() { // do not block

@ -48,8 +48,8 @@ type RTSPClient struct {
OptionIntervalMillis int64
SDPRaw string
debugLogEnable bool
lastRtpSN uint16
debugLogEnable bool
lastRtpSN uint16
Agent string
authLine string
@ -418,17 +418,13 @@ func (client *RTSPClient) startStream() {
client.logger.Printf("unknow rtp pack type, channel:%v", channel)
continue
}
if pack == nil {
client.logger.Printf("session tcp got nil rtp pack")
continue
}
if client.debugLogEnable {
rtp := ParseRTP(pack.Buffer.Bytes())
if rtp != nil {
rtpSN := uint16(rtp.SequenceNumber)
if client.lastRtpSN != 0 && client.lastRtpSN + 1 != rtpSN {
client.logger.Printf("%s, %d packets lost, current SN=%d, last SN=%d\n", client.String(), rtpSN - client.lastRtpSN, rtpSN, client.lastRtpSN)
if client.lastRtpSN != 0 && client.lastRtpSN+1 != rtpSN {
client.logger.Printf("%s, %d packets lost, current SN=%d, last SN=%d\n", client.String(), rtpSN-client.lastRtpSN, rtpSN, client.lastRtpSN)
}
client.lastRtpSN = rtpSN
}

@ -249,11 +249,7 @@ func (session *Session) Start() {
Buffer: rtpBuf,
}
default:
logger.Printf("unknow rtp pack type, %v", pack.Type)
continue
}
if pack == nil {
logger.Printf("session tcp got nil rtp pack")
logger.Printf("unknow rtp pack type, %v", channel)
continue
}
session.InBytes += rtpLen + 4

Loading…
Cancel
Save