From 700755d9fe22035ae11585580706b9804596c3ec Mon Sep 17 00:00:00 2001 From: qydysky Date: Sun, 6 Aug 2023 15:48:54 +0800 Subject: [PATCH] =?utf8?q?Add=20=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE=20?= =?utf8?q?=E7=9B=B4=E6=92=AD=E6=B5=81=E4=B8=8D=E4=BD=BF=E7=94=A8mcdn?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Reply/stream.go | 20 ++++++++++++++++++-- demo/config/config_K_v.json | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Reply/stream.go b/Reply/stream.go index 5bb6076..d196cab 100644 --- a/Reply/stream.go +++ b/Reply/stream.go @@ -211,8 +211,19 @@ func (t *M4SStream) fetchCheckStream() bool { return true }) + var nomcdn bool + if v, ok := t.common.K_v.LoadV("直播流不使用mcdn").(bool); ok && v { + nomcdn = true + } + + r := t.reqPool.Get() + defer t.reqPool.Put(r) for _, v := range t.common.Live { - r := t.reqPool.Get() + if nomcdn && strings.Contains(v.Url, ".mcdn.") { + t.common.Live = t.common.Live[1:] + continue + } + if e := r.Reqf(reqf.Rval{ Url: v.Url, Retry: 10, @@ -239,11 +250,16 @@ func (t *M4SStream) fetchCheckStream() bool { if r.Response == nil { t.log.L(`W: `, `live响应错误`) t.common.Live = t.common.Live[1:] + continue } else if r.Response.StatusCode&200 != 200 { t.log.L(`W: `, `live响应错误`, r.Response.Status) t.common.Live = t.common.Live[1:] + continue } - t.reqPool.Put(r) + + // 显示使用流服务器 + u, _ := url.Parse(v.Url) + t.log.L(`I: `, `使用流服务器`, u.Host) } return len(t.common.Live) != 0 diff --git a/demo/config/config_K_v.json b/demo/config/config_K_v.json index 963eabf..35046c7 100644 --- a/demo/config/config_K_v.json +++ b/demo/config/config_K_v.json @@ -69,6 +69,7 @@ "直播流清晰度": 10000, "直播流类型-help": "flv,fmp4,flvH,fmp4H,带H后缀的为Hevc格式编码", "直播流类型": "flv", + "直播流不使用mcdn": false, "flv断流超时s": 5, "flv断流续接": true, "fmp4切片下载超时s": 3, -- 2.39.2