]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Add 添加配置 直播流不使用mcdn
authorqydysky <qydysky@foxmail.com>
Sun, 6 Aug 2023 07:48:54 +0000 (15:48 +0800)
committerqydysky <qydysky@foxmail.com>
Sun, 6 Aug 2023 07:48:54 +0000 (15:48 +0800)
Reply/stream.go
demo/config/config_K_v.json

index 5bb607640b9454f6117ab7e73e43c95c017bde07..d196cab9006390ffcf26e9f827db693a4d89fb6f 100644 (file)
@@ -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
index 963eabf306fc7ecf6d55c2110bb886abf6cb237e..35046c76f09e592fb0ca49317e5d2d6690decef0 100644 (file)
@@ -69,6 +69,7 @@
     "直播流清晰度": 10000,
     "直播流类型-help": "flv,fmp4,flvH,fmp4H,带H后缀的为Hevc格式编码",
     "直播流类型": "flv",
+    "直播流不使用mcdn": false,
     "flv断流超时s": 5,
     "flv断流续接": true,
     "fmp4切片下载超时s": 3,