liiir1985 7f62dcda9f | ||
---|---|---|
.. | ||
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 containsCarEvsGLSurfaceView
andCarEvsBufferRenderer
classes.libcarevsglrenderer_jni
: This is a JNI libraryCarEvsBufferRenderer
uses to render the contents ofCarEvsBufferDescriptor
with 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-lib
andlibcarevsglrenderer_jni
libraries by adding below lines toAndroid.bp
.
static_libs: ["car-evs-helper-lib"],
jni_libs: ["libcarevsglrenderer_jni"],
- Implement
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) {
...
}
...
}
- Create
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);
...
}
- 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;
}
}
}