From e7d23da2aaf8ff8b9bcda96c303b25a1a51acbdf Mon Sep 17 00:00:00 2001 From: pedroSG94 Date: Tue, 26 Nov 2024 02:09:52 +0100 Subject: [PATCH] fix possible h265 npe --- .../com/pedro/encoder/video/VideoEncoder.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/encoder/src/main/java/com/pedro/encoder/video/VideoEncoder.java b/encoder/src/main/java/com/pedro/encoder/video/VideoEncoder.java index 2c33d94bb..3768bca7b 100644 --- a/encoder/src/main/java/com/pedro/encoder/video/VideoEncoder.java +++ b/encoder/src/main/java/com/pedro/encoder/video/VideoEncoder.java @@ -311,7 +311,7 @@ public void setForceFps(int fps) { } @Override - public void inputYUVData(Frame frame) { + public void inputYUVData(@NonNull Frame frame) { if (running && !queue.offer(frame)) { Log.i(TAG, "frame discarded"); } @@ -326,15 +326,17 @@ private boolean sendSPSandPPS(MediaFormat mediaFormat) { getVideoData.onVideoInfo(bufferInfo, null, null); return true; } - return false; //H265 } else if (type.equals(CodecUtil.H265_MIME)) { - List byteBufferList = extractVpsSpsPpsFromH265(mediaFormat.getByteBuffer("csd-0")); - oldSps = byteBufferList.get(1); - oldPps = byteBufferList.get(2); - oldVps = byteBufferList.get(0); - getVideoData.onVideoInfo(oldSps, oldPps, oldVps); - return true; + ByteBuffer bufferInfo = mediaFormat.getByteBuffer("csd-0"); + if (bufferInfo != null) { + List byteBufferList = extractVpsSpsPpsFromH265(bufferInfo); + oldSps = byteBufferList.get(1); + oldPps = byteBufferList.get(2); + oldVps = byteBufferList.get(0); + getVideoData.onVideoInfo(oldSps, oldPps, oldVps); + return true; + } //H264 } else { oldSps = mediaFormat.getByteBuffer("csd-0"); @@ -343,6 +345,7 @@ private boolean sendSPSandPPS(MediaFormat mediaFormat) { getVideoData.onVideoInfo(oldSps, oldPps, oldVps); return true; } + return false; } /**