PID int `json:"pid"` //进程id
Version string `json:"version"` //版本
Uid int `json:"-"` //client uid
- Live []LiveQn `json:"-"` //直播流链接
+ Live []*LiveQn `json:"-"` //直播流链接
Live_qn int `json:"liveQn"` //当前直播流质量
Live_want_qn int `json:"-"` //期望直播流质量
Roomid int `json:"roomid"` //房间ID
if time.Now().Before(t.Live[i].ReUpTime) {
continue
}
- return &t.Live[i]
+ return t.Live[i]
}
return nil
}
r := t.reqPool.Get()
defer t.reqPool.Put(r)
- for i := 0; i < len(t.common.Live); i++ {
- v := &(t.common.Live[i])
+ for _, v := range t.common.Live {
if nomcdn && strings.Contains(v.Url, ".mcdn.") {
v.Disable(time.Now().Add(time.Hour * 100))
+ t.log.L(`I: `, `停用流服务器`, F.ParseHost(v.Url))
continue
}
defer t.reqPool.Put(r)
// 请求解析m3u8内容
- for k := 0; k < len(t.common.Live); k++ {
- v := &(t.common.Live[k])
-
+ for _, v := range t.common.Live {
// 跳过尚未启用的live地址
if !v.Valid() {
continue
if err := r.Reqf(rval); err != nil {
// 1min后重新启用
- t.common.Live[k].DisableAuto()
+ v.DisableAuto()
t.log.L("W: ", fmt.Sprintf("服务器 %s 发生故障 %s", F.ParseHost(v.Url), pe.ErrorFormat(err, pe.ErrSimplifyFunc)))
if t.common.ValidLive() == nil {
e = errors.New("全部流服务器发生故障")
!lastM4s.createdTime.IsZero() &&
time.Since(lastM4s.createdTime).Seconds() > fmp4ListUpdateTo {
// 1min后重新启用
- t.common.Live[k].DisableAuto()
+ v.DisableAuto()
t.log.L("W: ", fmt.Sprintf("服务器 %s 发生故障 %.2f 秒未产出切片", F.ParseHost(v.Url), time.Since(lastM4s.createdTime).Seconds()))
if t.common.ValidLive() == nil {
e = errors.New("全部切片服务器发生故障")
noe := lastNo
if (timed > 5 && nos-noe == 0) || (nos-noe > 50) {
// 1min后重新启用
- t.common.Live[k].DisableAuto()
+ v.DisableAuto()
t.log.L("W: ", fmt.Sprintf("服务器 %s 发生故障 %d 秒产出了 %d 切片", F.ParseHost(v.Url), int(timed), nos-noe))
if t.common.ValidLive() == nil {
e = errors.New("全部切片服务器发生故障")