I call the following method to stream frames from a USB Camera to org.WebRTC
's Video Capture Observer. It works fine, except for some corrupted frames (green, or distorted grey frames) that appear every couple of seconds in the remote peer's video display. I want to verify that the nv21Buffer
or the videoFrame
are good pictures before sending them further to the observer.
public void addFrame(ByteBuffer frame) {
try {
byte[] imageArray = new byte[frame.remaining()];
frame.get(imageArray);
NV21Buffer nv21Buffer = new NV21Buffer(imageArray, 640, 480, () -> JniCommon.nativeFreeByteBuffer(frame));
VideoFrame videoFrame = new VideoFrame(nv21Buffer, 0, System.nanoTime());
// before sending the videoFrame further, I need to validate if it is a good picture / frame
capturerObs.onFrameCaptured(videoFrame);
} catch (
Exception e) {
Log.d("addFrame", e.getMessage());
}
}
Is there any built in tools / methods to verify the goodness of the frames before sending them further?