feat: add insert sei

feat: add engine init done event
refactor: remove ring_lock
fix: retry connect to console
fix: h265 sps parse error
fix: concurrent publish

desc:
- 增加插入SEI帧的功能
- 增加engine初始化完成事件
- 删除ring_lock,DataTrack和MediaTrack共用一个ring
- 修复console无限重连导致远程服务器崩溃问题
- 修复h265 sps解析错误问题
- 修复并发发布导致的问题
This commit is contained in:
langhuihui
2023-06-15 20:04:14 +08:00
parent 1769ba1549
commit b87416b78e
24 changed files with 416 additions and 287 deletions

31
http.go
View File

@@ -2,6 +2,7 @@ package engine
import (
"encoding/json"
"io"
"net/http"
"os"
"strconv"
@@ -341,3 +342,33 @@ func (conf *GlobalConfig) API_replay_mp4(w http.ResponseWriter, r *http.Request)
go pub.ReadMP4Data(f)
}
}
func (conf *GlobalConfig) API_insertSEI(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
streamPath := q.Get("streamPath")
s := Streams.Get(streamPath)
if s == nil {
http.Error(w, NO_SUCH_STREAM, http.StatusNotFound)
return
}
t := q.Get("type")
tb, err := strconv.ParseInt(t, 10, 8)
if err != nil {
if t == "" {
tb = 5
} else {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
}
sei, err := io.ReadAll(r.Body)
if err == nil {
if s.Tracks.AddSEI(byte(tb), sei) {
w.Write([]byte("ok"))
} else {
http.Error(w, "no sei track", http.StatusBadRequest)
}
} else {
http.Error(w, err.Error(), http.StatusBadRequest)
}
}