Skip to content

Commit

Permalink
fix possible h265 npe
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroSG94 committed Nov 26, 2024
1 parent 63ea93d commit e7d23da
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions encoder/src/main/java/com/pedro/encoder/video/VideoEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand All @@ -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<ByteBuffer> 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<ByteBuffer> 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");
Expand All @@ -343,6 +345,7 @@ private boolean sendSPSandPPS(MediaFormat mediaFormat) {
getVideoData.onVideoInfo(oldSps, oldPps, oldVps);
return true;
}
return false;
}

/**
Expand Down

0 comments on commit e7d23da

Please sign in to comment.