fix record file not showing when query.

修改了录像文件查询时不显示的bug
pull/132/head
macbookpro 2018-12-17 12:23:41 +08:00
parent 5f1d0ab96d
commit 19e06f9e44
2 changed files with 11 additions and 11 deletions

View File

@ -140,7 +140,7 @@ func (h *APIHandler) RecordFiles(c *gin.Context) {
return nil return nil
} }
if !strings.HasSuffix(info.Name(), ".m3u8") { if !strings.HasSuffix(info.Name(), ".m3u8") {
return filepath.SkipDir return nil
} }
cmd := exec.Command(ffprobe, "-i", path) cmd := exec.Command(ffprobe, "-i", path)
cmdOutput := &bytes.Buffer{} cmdOutput := &bytes.Buffer{}

View File

@ -19,7 +19,6 @@ type RTPInfo struct {
Timestamp int Timestamp int
SSRC int SSRC int
Payload []byte Payload []byte
NaluType uint8
} }
func ParseRTP(rtpBytes []byte) *RTPInfo { func ParseRTP(rtpBytes []byte) *RTPInfo {
@ -62,19 +61,20 @@ func ParseRTP(rtpBytes []byte) *RTPInfo {
if end-offset < 1 { if end-offset < 1 {
return nil return nil
} }
payloadHeader := rtpBytes[offset] //https://tools.ietf.org/html/rfc6184#section-5.2
info.NaluType = uint8(payloadHeader & 0x1F)
return info return info
} }
func (rtp *RTPInfo) IsKeyframeStart() bool { func (rtp *RTPInfo) IsKeyframeStart() bool {
var realNALU uint8 var realNALU uint8
payloadHeader := rtp.Payload[0] //https://tools.ietf.org/html/rfc6184#section-5.2
NaluType := uint8(payloadHeader & 0x1F)
switch { switch {
case rtp.NaluType <= 23: case NaluType <= 23:
realNALU = rtp.Payload[0] realNALU = rtp.Payload[0]
//log.Printf("Single NAL:%d", rtp.NaluType) //log.Printf("Single NAL:%d", rtp.NaluType)
case rtp.NaluType == 28 || rtp.NaluType == 29: case NaluType == 28 || NaluType == 29:
realNALU = rtp.Payload[1] realNALU = rtp.Payload[1]
if realNALU&0x80 != 0 { if realNALU&0x80 != 0 {
//log.Printf("FU NAL Begin :%d", rtp.NaluType) //log.Printf("FU NAL Begin :%d", rtp.NaluType)
@ -128,11 +128,11 @@ func (rtp *RTPInfo) IsKeyframeStartH265() bool {
} else { // Single NALU } else { // Single NALU
/* /*
+---------------+---------------+ +---------------+---------------+
|0|1|2|3|4|5|6|7|0|1|2|3|4|5|6|7| |0|1|2|3|4|5|6|7|0|1|2|3|4|5|6|7|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|F| Type | LayerId | TID | |F| Type | LayerId | TID |
+-------------+-----------------+ +-------------+-----------------+
*/ */
frameType = firstByte & 0x7e frameType = firstByte & 0x7e
} }