From 9bbaf41d5403da9f2f4654d14d20cea06a5a3d15 Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Tue, 24 Jan 2023 21:38:58 +0300 Subject: [PATCH] Second fix for Chinese buggy cameras --- pkg/h264/rtp.go | 8 +++----- www/video-rtc.js | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/pkg/h264/rtp.go b/pkg/h264/rtp.go index 08e61a78..6044caae 100644 --- a/pkg/h264/rtp.go +++ b/pkg/h264/rtp.go @@ -75,11 +75,8 @@ func RTPDepay(track *streamer.Track) streamer.WrapperFunc { // https://github.com/AlexxIT/WebRTC/issues/391 // https://github.com/AlexxIT/WebRTC/issues/392 for i := 0; i < len(payload); { - switch NALUType(payload[i:]) { - case NALUTypeSPS, NALUTypePPS, NALUTypeIFrame, NALUTypePFrame: - default: - payload = payload[:i] - continue + if i+4 >= len(payload) { + break } size := bytes.Index(payload[i+4:], []byte{0, 0, 0, 1}) @@ -89,6 +86,7 @@ func RTPDepay(track *streamer.Track) streamer.WrapperFunc { } size = len(payload) - (i + 4) } + binary.BigEndian.PutUint32(payload[i:], uint32(size)) i += size + 4 diff --git a/www/video-rtc.js b/www/video-rtc.js index 0bb9e471..e04d5b66 100644 --- a/www/video-rtc.js +++ b/www/video-rtc.js @@ -395,11 +395,11 @@ export class VideoRTC extends HTMLElement { bufLen = 0; sb.appendBuffer(data); } else if (sb.buffered && sb.buffered.length) { - const end = sb.buffered.end(sb.buffered.length - 1) - 5; + const end = sb.buffered.end(sb.buffered.length - 1) - 15; const start = sb.buffered.start(0); if (end > start) { sb.remove(start, end); - ms.setLiveSeekableRange(end, end + 5); + ms.setLiveSeekableRange(end, end + 15); } // console.debug("VideoRTC.buffered", start, end); }