mirror of https://github.com/EasyDarwin/EasyDarwin
commit
7db2df2bc2
8
main.go
8
main.go
|
@ -136,6 +136,9 @@ func (p *program) Start(s service.Service) (err error) {
|
||||||
}
|
}
|
||||||
for i := len(streams) - 1; i > -1; i-- {
|
for i := len(streams) - 1; i > -1; i-- {
|
||||||
v := streams[i]
|
v := streams[i]
|
||||||
|
if rtsp.GetServer().GetPusher(v.CustomPath) != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
agent := fmt.Sprintf("EasyDarwinGo/%s", routers.BuildVersion)
|
agent := fmt.Sprintf("EasyDarwinGo/%s", routers.BuildVersion)
|
||||||
if routers.BuildDateTime != "" {
|
if routers.BuildDateTime != "" {
|
||||||
agent = fmt.Sprintf("%s(%s)", agent, 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
|
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)
|
err = client.Start(time.Duration(v.IdleTimeout) * time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Pull stream err :%v", err)
|
log.Printf("Pull stream err :%v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
pusher := rtsp.NewClientPusher(client)
|
||||||
rtsp.GetServer().AddPusher(pusher)
|
rtsp.GetServer().AddPusher(pusher)
|
||||||
//streams = streams[0:i]
|
//streams = streams[0:i]
|
||||||
//streams = append(streams[:i], streams[i+1:]...)
|
//streams = append(streams[:i], streams[i+1:]...)
|
||||||
|
|
|
@ -354,12 +354,8 @@ func (pusher *Pusher) RemovePlayer(player *Player) *Pusher {
|
||||||
|
|
||||||
func (pusher *Pusher) ClearPlayer() {
|
func (pusher *Pusher) ClearPlayer() {
|
||||||
// copy a new map to avoid deadlock
|
// copy a new map to avoid deadlock
|
||||||
players := make(map[string]*Player)
|
|
||||||
pusher.playersLock.Lock()
|
pusher.playersLock.Lock()
|
||||||
for k, v := range pusher.players {
|
players := pusher.players
|
||||||
//v.Stop()
|
|
||||||
players[k] = v
|
|
||||||
}
|
|
||||||
pusher.players = make(map[string]*Player)
|
pusher.players = make(map[string]*Player)
|
||||||
pusher.playersLock.Unlock()
|
pusher.playersLock.Unlock()
|
||||||
go func() { // do not block
|
go func() { // do not block
|
||||||
|
|
|
@ -48,8 +48,8 @@ type RTSPClient struct {
|
||||||
OptionIntervalMillis int64
|
OptionIntervalMillis int64
|
||||||
SDPRaw string
|
SDPRaw string
|
||||||
|
|
||||||
debugLogEnable bool
|
debugLogEnable bool
|
||||||
lastRtpSN uint16
|
lastRtpSN uint16
|
||||||
|
|
||||||
Agent string
|
Agent string
|
||||||
authLine string
|
authLine string
|
||||||
|
@ -418,17 +418,13 @@ func (client *RTSPClient) startStream() {
|
||||||
client.logger.Printf("unknow rtp pack type, channel:%v", channel)
|
client.logger.Printf("unknow rtp pack type, channel:%v", channel)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if pack == nil {
|
|
||||||
client.logger.Printf("session tcp got nil rtp pack")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if client.debugLogEnable {
|
if client.debugLogEnable {
|
||||||
rtp := ParseRTP(pack.Buffer.Bytes())
|
rtp := ParseRTP(pack.Buffer.Bytes())
|
||||||
if rtp != nil {
|
if rtp != nil {
|
||||||
rtpSN := uint16(rtp.SequenceNumber)
|
rtpSN := uint16(rtp.SequenceNumber)
|
||||||
if client.lastRtpSN != 0 && client.lastRtpSN + 1 != rtpSN {
|
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.logger.Printf("%s, %d packets lost, current SN=%d, last SN=%d\n", client.String(), rtpSN-client.lastRtpSN, rtpSN, client.lastRtpSN)
|
||||||
}
|
}
|
||||||
client.lastRtpSN = rtpSN
|
client.lastRtpSN = rtpSN
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,11 +249,7 @@ func (session *Session) Start() {
|
||||||
Buffer: rtpBuf,
|
Buffer: rtpBuf,
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
logger.Printf("unknow rtp pack type, %v", pack.Type)
|
logger.Printf("unknow rtp pack type, %v", channel)
|
||||||
continue
|
|
||||||
}
|
|
||||||
if pack == nil {
|
|
||||||
logger.Printf("session tcp got nil rtp pack")
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
session.InBytes += rtpLen + 4
|
session.InBytes += rtpLen + 4
|
||||||
|
|
Loading…
Reference in New Issue