v0.20.0 -> version.go

pull/49/head v0.20.0
q191201771 4 years ago
parent 3df6ee4027
commit a25b5e4ad0

@ -1,3 +1,12 @@
#### v0.20.0 (2021-03-21)
- [feat] 新增app/demo/calcrtmpdelay可用于测量rtmp服务器的转发延时拉流支持rtmp/httpflv
- [feat] app/demo/pushrtmp 做压测时,修改为完全并行的模式
- [fix] 修复32位arm环境使用rtsp崩溃
- [refactor] 统一各Session接口
- [refactor] 使用新的unique id生成器提高性能
- [doc] 新增文档 ffplay播放rtsp花屏 https://pengrl.com/lal/#/RTSPFFPlayBlur
#### v0.19.1 (2021-02-01)
- [fix] 获取group中播放者数量时锁没有释放导致后续无法转发数据

@ -0,0 +1,115 @@
// Copyright 2021, Chef. All rights reserved.
// https://github.com/q191201771/lal
//
// Use of this source code is governed by a MIT-style license
// that can be found in the License file.
//
// Author: Chef (191201771@qq.com)
package main
import (
"flag"
"fmt"
"os"
"strconv"
"strings"
"sync"
"time"
"github.com/q191201771/lal/pkg/base"
"github.com/q191201771/lal/pkg/rtmp"
"github.com/q191201771/naza/pkg/nazalog"
)
func main() {
_ = nazalog.Init(func(option *nazalog.Option) {
option.AssertBehavior = nazalog.AssertFatal
})
defer nazalog.Sync()
urlTmpl, num := parseFlag()
urls := collect(urlTmpl, num)
var mu sync.Mutex
var succCosts []int64
var failCosts []int64
var wg sync.WaitGroup
wg.Add(len(urls))
go func() {
for {
mu.Lock()
succ := len(succCosts)
fail := len(failCosts)
mu.Unlock()
_, _ = fmt.Fprintf(os.Stderr, "task(num): total=%d, succ=%d, fail=%d\n", len(urls), succ, fail)
time.Sleep(1 * time.Second)
}
}()
totalB := time.Now()
for _, url := range urls {
go func(u string) {
pullSession := rtmp.NewPullSession()
b := time.Now()
err := pullSession.Pull(u, func(msg base.RTMPMsg) {
})
mu.Lock()
if err == nil {
succCosts = append(succCosts, time.Now().Sub(b).Milliseconds())
} else {
failCosts = append(failCosts, time.Now().Sub(b).Milliseconds())
}
mu.Unlock()
wg.Done()
}(url)
}
wg.Wait()
totalCost := time.Now().Sub(totalB).Milliseconds()
min, max, avg := analyse(succCosts)
_, _ = fmt.Fprintf(os.Stderr, "task(num): total=%d, succ=%d, fail=%d\n", len(urls), len(succCosts), len(failCosts))
_, _ = fmt.Fprintf(os.Stderr, " cost(ms): total=%d, avg=%d, min=%d, max=%d\n", totalCost, avg, min, max)
}
func analyse(costs []int64) (min, max, avg int64) {
min = 2147483647
max = 0
sum := int64(0)
for _, cost := range costs {
if cost < min {
min = cost
}
if cost > max {
max = cost
}
sum += cost
}
if len(costs) > 0 {
avg = sum / int64(len(costs))
}
return
}
func collect(urlTmpl string, num int) (urls []string) {
for i := 0; i < num; i++ {
url := strings.Replace(urlTmpl, "{i}", strconv.Itoa(i), -1)
urls = append(urls, url)
}
return
}
func parseFlag() (urlTmpl string, num int) {
i := flag.String("i", "", "specify pull rtmp pull")
n := flag.Int("n", 0, "specify num of pull connection")
flag.Parse()
if *i == "" || *n == 0 {
flag.Usage()
_, _ = fmt.Fprintf(os.Stderr, `Example:
%s -i rtmp://127.0.0.1:1935/live/test -n 1000
%s -i rtmp://127.0.0.1:1935/live/test_{i} -n 1000
`, os.Args[0], os.Args[0])
base.OSExitAndWaitPressIfWindows(1)
}
return *i, *n
}

@ -16,7 +16,7 @@ import "strings"
// 并且将这些信息打入可执行文件、日志、各协议中的标准版本字段中
// 版本,该变量由外部脚本修改维护
const LALVersion = "v0.19.1"
const LALVersion = "v0.20.0"
var (
LALLibraryName = "lal"

Loading…
Cancel
Save