This directory contains two modules that are used by other apps to process CarEvsBufferDescriptor and render its contents to the display with EGL.
car-evs-helper-lib:
This library contains CarEvsGLSurfaceView
and CarEvsBufferRenderer
classes.libcarevsglrenderer_jni
: This is a JNI library CarEvsBufferRenderer
uses to render the contents of CarEvsBufferDescriptor
with EGL.Please follow below instructions to delegate a CarEvsBufferDescriptor
rendering to this library. A reference implementation is also available at packages/services/Car/tests/CarEvsCameraPreviewApp
.
car-evs-helper-lib
and libcarevsglrenderer_jni
libraries by adding below lines to Android.bp
.static_libs: ["car-evs-helper-lib"], jni_libs: ["libcarevsglrenderer_jni"],
CarEvsGLSurfaceView.Callback
interface. For example,/** * This method is called by the renderer to fetch a new frame to draw. */ @Override public CarEvsBufferDescriptor getNewFrame() { synchronized(mLock) { // Return a buffer to render. return mBufferToRender; } } /** * This method is called by the renderer when it is done with a passed * CarEvsBufferDescriptor object. */ @Override public void returnBuffer(CarEvsBufferDescriptor buffer) { // Return a buffer to CarEvsService. try { mEvsManager.returnFrameBuffer(buffer); } catch (Exception e) { ... } ... }
CarEvsGLSurfaceView
with the application context, CarEvsGLSurfaceView.Callback
object, and, optionally, a desired in-plane rotation angle.private CarEvsGLSurfaceView mView; @Override protected void onCreate(Bundle savedInstanceState) { ... mView = CarEvsGLSurfaceView(getAppliation(), this, /* angleInDegree= */ 0); ... }
private final CarEvsManager.CarEvsStreamCallback mStreamHandler = new CarEvsManager.CarEvsStreamCallback() { ... @Override public void onNewFrame(CarEvsBufferDescriptor buffer) { synchronized(mLock) { mBufferToRender = buffer; } } }