From 19e06f9e44c4854be06bfdc170acb09ac962fa8b Mon Sep 17 00:00:00 2001 From: macbookpro Date: Mon, 17 Dec 2018 12:23:41 +0800 Subject: [PATCH] =?UTF-8?q?fix=20record=20file=20not=20showing=20when=20qu?= =?UTF-8?q?ery.=20=E4=BF=AE=E6=94=B9=E4=BA=86=E5=BD=95=E5=83=8F=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=9F=A5=E8=AF=A2=E6=97=B6=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/record.go | 2 +- rtsp/rtp-parser.go | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/routers/record.go b/routers/record.go index 21b240dd..b3f8594b 100644 --- a/routers/record.go +++ b/routers/record.go @@ -140,7 +140,7 @@ func (h *APIHandler) RecordFiles(c *gin.Context) { return nil } if !strings.HasSuffix(info.Name(), ".m3u8") { - return filepath.SkipDir + return nil } cmd := exec.Command(ffprobe, "-i", path) cmdOutput := &bytes.Buffer{} diff --git a/rtsp/rtp-parser.go b/rtsp/rtp-parser.go index 9e95b966..3ce509c3 100644 --- a/rtsp/rtp-parser.go +++ b/rtsp/rtp-parser.go @@ -19,7 +19,6 @@ type RTPInfo struct { Timestamp int SSRC int Payload []byte - NaluType uint8 } func ParseRTP(rtpBytes []byte) *RTPInfo { @@ -62,19 +61,20 @@ func ParseRTP(rtpBytes []byte) *RTPInfo { if end-offset < 1 { return nil } - payloadHeader := rtpBytes[offset] //https://tools.ietf.org/html/rfc6184#section-5.2 - info.NaluType = uint8(payloadHeader & 0x1F) + return info } func (rtp *RTPInfo) IsKeyframeStart() bool { var realNALU uint8 + payloadHeader := rtp.Payload[0] //https://tools.ietf.org/html/rfc6184#section-5.2 + NaluType := uint8(payloadHeader & 0x1F) switch { - case rtp.NaluType <= 23: + case NaluType <= 23: realNALU = rtp.Payload[0] //log.Printf("Single NAL:%d", rtp.NaluType) - case rtp.NaluType == 28 || rtp.NaluType == 29: + case NaluType == 28 || NaluType == 29: realNALU = rtp.Payload[1] if realNALU&0x80 != 0 { //log.Printf("FU NAL Begin :%d", rtp.NaluType) @@ -128,11 +128,11 @@ func (rtp *RTPInfo) IsKeyframeStartH265() bool { } else { // Single NALU /* - +---------------+---------------+ - |0|1|2|3|4|5|6|7|0|1|2|3|4|5|6|7| - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - |F| Type | LayerId | TID | - +-------------+-----------------+ + +---------------+---------------+ + |0|1|2|3|4|5|6|7|0|1|2|3|4|5|6|7| + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |F| Type | LayerId | TID | + +-------------+-----------------+ */ frameType = firstByte & 0x7e }