protected void doStop() { Log.d(LOGTAG, "doStop"); synchronized(this) { mUpdateST = false; mIsStarted = false; mHaveFBO = false; closeCamera(); deleteSurfaceTexture(); } CameraTextureListener listener = mView.getCameraTextureListener(); if(listener != null) listener.onCameraViewStopped(); }
private void deleteSurfaceTexture() { Log.d(LOGTAG, "deleteSurfaceTexture"); if(mSTexture != null) { mSTexture.release(); mSTexture = null; deleteTex(texCamera); } }
public void setMaxCameraPreviewSize(int maxWidth, int maxHeight) { disableView(); mMaxCameraWidth = maxWidth; mMaxCameraHeight = maxHeight; enableView(); }
protected void updateState() { Log.d(LOGTAG, "updateState"); Log.d(LOGTAG, "mEnabled="+mEnabled+", mHaveSurface="+mHaveSurface); boolean willStart = mEnabled && mHaveSurface && mView.getVisibility() == View.VISIBLE; if (willStart != mIsStarted) { if(willStart) doStart(); else doStop(); } else { Log.d(LOGTAG, "keeping State unchanged"); } Log.d(LOGTAG, "updateState end"); }
protected void setPreviewSize(int width, int height) { synchronized(this) { mHaveFBO = false; mCameraWidth = width; mCameraHeight = height; setCameraPreviewSize(width, height); // can change mCameraWidth & mCameraHeight initFBO(mCameraWidth, mCameraHeight); mHaveFBO = true; } CameraTextureListener listener = mView.getCameraTextureListener(); if(listener != null) listener.onCameraViewStarted(mCameraWidth, mCameraHeight); }
private void initSurfaceTexture() { Log.d(LOGTAG, "initSurfaceTexture"); deleteSurfaceTexture(); initTexOES(texCamera); mSTexture = new SurfaceTexture(texCamera[0]); mSTexture.setOnFrameAvailableListener(this); }
private void initFBO(int width, int height) { Log.d(LOGTAG, "initFBO("+width+"x"+height+")"); deleteFBO(); GLES20.glGenTextures(1, texDraw, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texDraw[0]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); 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); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST); GLES20.glGenTextures(1, texFBO, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texFBO[0]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); 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); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST); //int hFBO; GLES20.glGenFramebuffers(1, FBO, 0); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, FBO[0]); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, texFBO[0], 0); Log.d(LOGTAG, "initFBO error status: " + GLES20.glGetError()); int FBOstatus = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER); if (FBOstatus != GLES20.GL_FRAMEBUFFER_COMPLETE) Log.e(LOGTAG, "initFBO failed, status: " + FBOstatus); mFBOWidth = width; mFBOHeight = height; }
@Override protected void doStop() { Log.d(LOGTAG, "doStop"); super.doStop(); stopBackgroundThread(); }
@Override protected void doStart() { Log.d(LOGTAG, "doStart"); startBackgroundThread(); super.doStart(); }
protected void setPreviewSize(int width, int height) { synchronized(this) { mHaveFBO = false; mCameraWidth = width; mCameraHeight = height; setCameraPreviewSize(width, height); // can change mCameraWidth & mCameraHeight initFBO(mCameraWidth, mCameraHeight); mHaveFBO = true; } CameraTextureListener listener = mView.getCameraTextureListener(); if(listener != null) listener.onCameraViewStarted(mCameraWidth, mCameraHeight); }
protected void updateState() { Log.d(LOGTAG, "updateState"); Log.d(LOGTAG, "mEnabled="+mEnabled+", mHaveSurface="+mHaveSurface); boolean willStart = mEnabled && mHaveSurface && mView.getVisibility() == View.VISIBLE; if (willStart != mIsStarted) { if(willStart) doStart(); else doStop(); } else { Log.d(LOGTAG, "keeping State unchanged"); } Log.d(LOGTAG, "updateState end"); }
private void initSurfaceTexture() { Log.d(LOGTAG, "initSurfaceTexture"); deleteSurfaceTexture(); initTexOES(texCamera); mSTexture = new SurfaceTexture(texCamera[0]); mSTexture.setOnFrameAvailableListener(this); }
private void initFBO(int width, int height) { Log.d(LOGTAG, "initFBO("+width+"x"+height+")"); deleteFBO(); GLES20.glGenTextures(1, texDraw, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texDraw[0]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); 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); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST); GLES20.glGenTextures(1, texFBO, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texFBO[0]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); 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); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST); //int hFBO; GLES20.glGenFramebuffers(1, FBO, 0); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, FBO[0]); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, texFBO[0], 0); Log.d(LOGTAG, "initFBO error status: " + GLES20.glGetError()); int FBOstatus = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER); if (FBOstatus != GLES20.GL_FRAMEBUFFER_COMPLETE) Log.e(LOGTAG, "initFBO failed, status: " + FBOstatus); mFBOWidth = width; mFBOHeight = height; }
@Override protected void doStop() { Log.d(LOGTAG, "doStop"); super.doStop(); stopBackgroundThread(); }
@Override protected void doStart() { Log.d(LOGTAG, "doStart"); startBackgroundThread(); super.doStart(); }
public void setCameraIndex(int cameraIndex) { disableView(); mCameraIndex = cameraIndex; enableView(); }
protected void doStop() { Log.d(LOGTAG, "doStop"); synchronized(this) { mUpdateST = false; mIsStarted = false; mHaveFBO = false; closeCamera(); deleteSurfaceTexture(); } CameraTextureListener listener = mView.getCameraTextureListener(); if(listener != null) listener.onCameraViewStopped(); }
protected void setPreviewSize(int width, int height) { synchronized(this) { mHaveFBO = false; mCameraWidth = width; mCameraHeight = height; setCameraPreviewSize(width, height); // can change mCameraWidth & mCameraHeight initFBO(mCameraWidth, mCameraHeight); mHaveFBO = true; } CameraTextureListener listener = mView.getCameraTextureListener(); if(listener != null) listener.onCameraViewStarted(mCameraWidth, mCameraHeight); }