]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Add 添加debug模式,fmp4下m4s池的报告
authorqydysky <qydysky@foxmail.com>
Thu, 10 Aug 2023 13:38:51 +0000 (21:38 +0800)
committerqydysky <qydysky@foxmail.com>
Thu, 10 Aug 2023 13:38:51 +0000 (21:38 +0800)
README.md
Reply/stream.go

index 0422f96da8d5e0fcdc811af0c7b61b3259697dc6..5af53d1145d79b6978c5f5f406b23fb28971a6eb 100644 (file)
--- a/README.md
+++ b/README.md
@@ -238,7 +238,10 @@ config_K_v.json
 }
 ```
 
-另外,当配置文件中的`debug模式`为`true`时,标准包[net/http/pprof](https://pkg.go.dev/net/http/pprof)将在`/debug/pprof/`路径可用,从而可以使用`go tool pprof`工具进行性能调试。
+另外,当配置文件中的`debug模式`为`true`时
+
+- 标准包[net/http/pprof](https://pkg.go.dev/net/http/pprof)将在`/debug/pprof/`路径可用,从而可以使用`go tool pprof`工具进行性能调试。
+- 当录制fmp4时,每1分钟打印m4s池状态
 
 
 #### 自定义config_K_v.json
index 228402d7a7706fbdbe4da19939a6622aa1470a9c..56d8c79f50b63c43905a373c3846b11f1129eb63 100644 (file)
@@ -862,8 +862,23 @@ func (t *M4SStream) saveStreamFlv() (e error) {
 
 func (t *M4SStream) saveStreamM4s() (e error) {
        // 同时下载数限制
-       var download_limit = &funcCtrl.BlockFuncN{
-               Max: 3,
+       var download_limit = &funcCtrl.BlockFuncN{Max: 3}
+
+       if v, ok := t.common.K_v.LoadV(`debug模式`).(bool); ok && v {
+               ctx, can := context.WithCancel(context.Background())
+               defer can()
+               go func() {
+                       ticker := time.NewTicker(time.Minute)
+                       defer ticker.Stop()
+                       for {
+                               select {
+                               case <-ctx.Done():
+                                       return
+                               case <-ticker.C:
+                               }
+                               t.log.L(`T: `, fmt.Sprintf("m4sPoolState pooled(%d), nopooled(%d), inuse(%d), nouse(%d), sum(%d)", t.m4s_pool.PoolState()...))
+                       }
+               }()
        }
 
        //
@@ -1462,7 +1477,7 @@ func (t *M4SStream) PusherToHttp(conn net.Conn, w http.ResponseWriter, r *http.R
                        done := time.AfterFunc(time.Second, func() {
                                cancelRec()
                                if conn != nil {
-                                       println(conn.Close())
+                                       conn.Close()
                                }
                        }).Stop
                        defer done()