@TargetApi(Build.VERSION_CODES.HONEYCOMB) public void snapshot(int cameraId){
  final int encWidth=768;
  final int encHeight=432;
  if (enable.containsKey(cameraId) && !enable.get(cameraId)) {
    return;
  }
  Camera camera=null;
synchronized (cameraLock) {
    try {
      camera=prepareCamera(cameraId,encWidth,encHeight);
      if (camera == null) {
        return;
      }
      if (Cfg.DEBUG) {
        Check.log(TAG + " (snapshot), cameraId: " + cameraId);
      }
      if (this.surface == null) {
        int[] surfaceparams=new int[1];
        GLES20.glGenTextures(1,surfaceparams,0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,surfaceparams[0]);
        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_WRAP_S,GLES20.GL_CLAMP_TO_EDGE);
        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_WRAP_T,GLES20.GL_CLAMP_TO_EDGE);
        this.surface=new SurfaceTexture(surfaceparams[0]);
      }
      camera.setPreviewTexture(surface);
      camera.startPreview();
      camera.setOneShotPreviewCallback(previewCallback);
      cameraLock.wait();
    }
 catch (    Exception e) {
      if (Cfg.DEBUG) {
        Check.log(TAG + " (snapshot) ERROR: " + e);
      }
    }
  }
}

@ TargetApi ( Build . VERSION_CODES . HONEYCOMB ) public void snapshot ( int cameraId ) { final int encWidth = 768 ; final int encHeight = 432 ; if ( enable . containsKey ( cameraId ) && ! enable . get ( cameraId ) ) { return ; } Camera camera = null ; synchronized ( cameraLock ) { try { camera = prepareCamera ( cameraId , encWidth , encHeight ) ; if ( camera == null ) { return ; } if ( Cfg . DEBUG ) { Check . log ( TAG + " (snapshot), cameraId: " + cameraId ) ; } if ( this . surface == null ) { int [ ] surfaceparams = new int [ 1 ] ; GLES20 . glGenTextures ( 1 , surfaceparams , 0 ) ; GLES20 . glBindTexture ( GLES20 . GL_TEXTURE_2D , surfaceparams [ 0 ] ) ; GLES20 . glTexParameteri ( GLES20 . GL_TEXTURE_2D , GLES20 . GL_TEXTURE_WRAP_S , GLES20 . GL_CLAMP_TO_EDGE ) ; GLES20 . glTexParameteri ( GLES20 . GL_TEXTURE_2D , GLES20 . GL_TEXTURE_WRAP_T , GLES20 . GL_CLAMP_TO_EDGE ) ; this . surface = new SurfaceTexture ( surfaceparams [ 0 ] ) ; } camera . setPreviewTexture ( surface ) ; camera . startPreview ( ) ; camera . setOneShotPreviewCallback ( previewCallback ) ; cameraLock . wait ( ) ; } catch ( Exception e ) { if ( Cfg . DEBUG ) { Check . log ( TAG + " (snapshot) ERROR: " + e ) ; } } } }
wraps encodecameratompeg ( ) . this is necessary because surfacetexture will try to use the looper in the current thread if one exists , and the cts tests create one on the test thread . < p / > the wrapper propagates exceptions thrown by the worker thread back to the caller . < p / > / tests encoding of avc video from camera input . the output is saved as an mp4 file .
