fix: change tracks to sync.Map to void dead lock

This commit is contained in:
langhuihui
2023-05-21 14:27:57 +08:00
parent 3ee931ce61
commit e21f8f765a
9 changed files with 170 additions and 37 deletions

13
http.go
View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"net/http"
"os"
"strconv"
"strings"
"time"
@@ -233,14 +234,18 @@ func (conf *GlobalConfig) API_replay_rtpdump(w http.ResponseWriter, r *http.Requ
}
cv := q.Get("vcodec")
ca := q.Get("acodec")
cvp := q.Get("vpayload")
cap := q.Get("apayload")
var pub RTPDumpPublisher
i, _ := strconv.ParseInt(cvp, 10, 64)
pub.VPayloadType = byte(i)
i, _ = strconv.ParseInt(cap, 10, 64)
pub.APayloadType = byte(i)
switch cv {
case "h264":
pub.VCodec = codec.CodecID_H264
case "h265":
pub.VCodec = codec.CodecID_H265
default:
pub.VCodec = codec.CodecID_H264
}
switch ca {
case "aac":
@@ -249,8 +254,6 @@ func (conf *GlobalConfig) API_replay_rtpdump(w http.ResponseWriter, r *http.Requ
pub.ACodec = codec.CodecID_PCMA
case "pcmu":
pub.ACodec = codec.CodecID_PCMU
default:
pub.ACodec = codec.CodecID_AAC
}
ss := strings.Split(dumpFile, ",")
if len(ss) > 1 {
@@ -331,4 +334,4 @@ func (conf *GlobalConfig) API_replay_mp4(w http.ResponseWriter, r *http.Request)
w.Write([]byte("ok"))
go pub.ReadMP4Data(f)
}
}
}