修复h265

This commit is contained in:
dexter
2022-05-09 22:03:34 +08:00
parent 87826bb069
commit 577f012eaa
3 changed files with 16 additions and 6 deletions

View File

@@ -244,7 +244,13 @@ func (opt *Plugin) Pull(streamPath string, url string, puller IPuller, save bool
var NoPushConfigErr = errors.New("no push config")
func (opt *Plugin) Push(streamPath string, url string, pusher IPusher, save bool) (err error) {
opt.Info("push", zap.String("path", streamPath), zap.String("url", url))
zp, zu := zap.String("path", streamPath), zap.String("url", url)
opt.Info("push", zp, zu)
defer func() {
if err != nil {
opt.Error("push faild", zap.Error(err))
}
}()
conf, ok := opt.Config.(config.PushConfig)
if !ok {
return NoPushConfigErr
@@ -262,9 +268,13 @@ func (opt *Plugin) Push(streamPath string, url string, pusher IPusher, save bool
}
go func() {
defer opt.Info("stop push", zap.String("remoteURL", url))
defer opt.Info("push finished", zp, zu)
for pusher.Reconnect() {
if pusher.Push(); !pusher.IsClosed() {
opt.Info("start push", zp, zu)
if err = pusher.Push(); !pusher.IsClosed() {
if err != nil {
opt.Info("stop push", zp, zu, zap.Error(err))
}
if err = pusher.Connect(); err != nil {
return
}

View File

@@ -329,7 +329,7 @@ func (s *Subscriber) sendAudioDecConf() {
type IPusher interface {
ISubscriber
Push()
Push() error
Connect() error
init(string, string, *config.Push)
Reconnect() bool

View File

@@ -65,7 +65,7 @@ func (vt *H265) WriteSlice(slice NALUSlice) {
codec.NAL_UNIT_CODED_SLICE_CRA:
vt.Video.Media.RingBuffer.Value.IFrame = true
fallthrough
case 0, 1, 2, 3, 4, 5, 6, 7, 9, codec.NAL_UNIT_SEI:
case 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, codec.NAL_UNIT_SEI:
vt.Video.Media.WriteSlice(slice)
default:
vt.Video.Stream.Warn("h265 slice type not supported", zap.Uint("type", uint(slice.H265Type())))
@@ -177,7 +177,7 @@ func (vt *H265) Flush() {
}
out = append(out, buf)
for _, bufs := range buffers[1:] {
buf := []byte{firstByte, firstBuffer[0][1], byte(naluType) >> 1}
buf := []byte{firstByte, firstBuffer[0][1], byte(naluType)}
for _, sp := range bufs {
buf = append(buf, sp...)
}