|  | ||
|---|---|---|
| .. | ||
| jni | ||
| src/com/android/car/internal/evs | ||
| Android.bp | ||
| AndroidManifest.xml | ||
| README.md | ||
		
			
				
				README.md
			
		
		
			
			
		
	
	car-evs-helper-lib
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- CarEvsGLSurfaceViewand- CarEvsBufferRendererclasses.
- libcarevsglrenderer_jni: This is a JNI library- CarEvsBufferRendereruses to render the contents of- CarEvsBufferDescriptorwith EGL.
How to use
Please follow below instructions to delegate a CarEvsBufferDescriptor rendering
to this library.  A reference implementation is also available at
packages/services/Car/tests/CarEvsCameraPreviewApp.
- Make the application refer to car-evs-helper-libandlibcarevsglrenderer_jnilibraries by adding below lines toAndroid.bp.
static_libs: ["car-evs-helper-lib"],
jni_libs: ["libcarevsglrenderer_jni"],
- Implement CarEvsGLSurfaceView.Callbackinterface. 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) {
        ...
    }
    ...
}
- Create CarEvsGLSurfaceViewwith the application context,CarEvsGLSurfaceView.Callbackobject, and, optionally, a desired in-plane rotation angle.
private CarEvsGLSurfaceView mView;
@Override
protected void onCreate(Bundle savedInstanceState) {
    ...
    mView = CarEvsGLSurfaceView(getAppliation(), this, /* angleInDegree= */ 0);
    ...
}
- Start a video stream and update wheneven new frame buffer arrives. For example,
private final CarEvsManager.CarEvsStreamCallback mStreamHandler =
    new CarEvsManager.CarEvsStreamCallback() {
    ...
    @Override
    public void onNewFrame(CarEvsBufferDescriptor buffer) {
      synchronized(mLock) {
        mBufferToRender = buffer;
      }
    }
}