Android SurfaceTexture - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android SurfaceTexture class.

This code example shows how to use the following methods:
                throw new RuntimeException("failed to eglMakeCurrent");
            } 
 
            mGl = (GL10) mEglContext.getGL();
 
            mInputSurfaceTexture = new SurfaceTexture(MosaicRenderer.init());
            MosaicRenderer.reset(mWidth, mHeight, true);
        } 
 
        private void doRelease() { 
            mEgl.eglDestroySurface(mEglDisplay, mEglSurface);
            mEgl.eglDestroyContext(mEglDisplay, mEglContext);
            mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE,
                    EGL10.EGL_NO_CONTEXT);
            mEgl.eglTerminate(mEglDisplay);
            mEglSurface = null;
            mEglContext = null;
            mEglDisplay = null;
            releaseSurfaceTexture(mInputSurfaceTexture);
            mEglThread.quit();
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
            GLES20.glVertexAttribPointer(mTexCoordHandle, 2, GLES20.GL_FLOAT,
                    false, 0, mTextureVertices);
            GLES20.glVertexAttribPointer(mTriangleVerticesHandle, 2, GLES20.GL_FLOAT,
                    false, 0, mQuadVertices);
            checkGlError("initialization"); 
            mSurfaceTexture = new SurfaceTexture(mTextureName);
            mSurfaceTexture.setOnFrameAvailableListener(new OnFrameAvailableListener() {
                @Override 
                public void onFrameAvailable(SurfaceTexture surfaceTexture) {
                    mCameraFrameCount.incrementAndGet();
                } 
            }); 
        } 
 
        /* (non-Javadoc) 
         * @see android.opengl.GLSurfaceView.Renderer#onSurfaceChanged(javax.microedition.khronos.opengles.GL10, int, int) 
         */ 
        @Override 
        public void onSurfaceChanged(GL10 gl, int width, int height) {
            mViewWidth = width;
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getTransformMatrix, updateTexImage
                    break; 
            } 
        } 
 
        private void doAlignFrame() { 
            mInputSurfaceTexture.updateTexImage();
            mInputSurfaceTexture.getTransformMatrix(mTransformMatrix);
 
            MosaicRenderer.setWarping(true); 
            // Call preprocess to render it to low-res and high-res RGB textures. 
            MosaicRenderer.preprocess(mTransformMatrix);
            // Now, transfer the textures from GPU to CPU memory for processing 
            MosaicRenderer.transferGPUtoCPU(); 
            MosaicRenderer.updateMatrix(); 
            draw(); 
            mEgl.eglSwapBuffers(mEglDisplay, mEglSurface);
        } 
 
        private void doShowPreviewFrame() { 
            mInputSurfaceTexture.updateTexImage();
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:release, setOnFrameAvailableListener
        return new SurfaceTexture(textureId);
    } 
 
    @CalledByNative 
    private static void destroy(SurfaceTexture surfaceTexture) {
        surfaceTexture.setOnFrameAvailableListener(null);
        surfaceTexture.release();
    } 
 
    @CalledByNative 
    private static void setFrameAvailableCallback(SurfaceTexture surfaceTexture,
            int nativeSurfaceTextureListener) {
       surfaceTexture.setOnFrameAvailableListener(
               new SurfaceTextureListener(nativeSurfaceTextureListener));
    } 
 
    @CalledByNative 
    private static void updateTexImage(SurfaceTexture surfaceTexture) {
        surfaceTexture.updateTexImage();
    } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        return mFrameHeight;
    } 
 
    public void setPreview() throws IOException { 
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
            mCamera.setPreviewTexture( new SurfaceTexture(10) );
        else 
            mCamera.setPreviewDisplay(null);
    } 
 
    public boolean openCamera() { 
        Log.i(TAG, "openCamera");
        releaseCamera(); 
        mCamera = Camera.open();
        if(mCamera == null) {
            Log.e(TAG, "Can't open camera!");
            return false; 
        } 
 
        mCamera.setPreviewCallbackWithBuffer(new PreviewCallback() {
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
                                GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
                        GLES20.glTexParameteri(
                                GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
                                GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
 
                        FlashDevice.surfaceTexture = new SurfaceTexture(textures[0]);
                        mCamera.setPreviewTexture(FlashDevice.surfaceTexture);
                        surfaceCreated = true;
                        mCamera.startPreview();
                    } 
                    mParams = mCamera.getParameters();
                    mParams.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
                    mCamera.setParameters(mParams);
                    if (!mWakeLock.isHeld()) {  // only get the wakelock if we don't have it already
                        mWakeLock.acquire(); // we don't want to go to sleep while cam is up
                    } 
                } 
            } else { 
                // Devices with sysfs toggle and sysfs luminosity 
                if (mFlashDeviceLuminosity != null && mFlashDeviceLuminosity.length() > 0) {
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setOnFrameAvailableListener
        GLES20.glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER,
                GLES20.GL_NEAREST);
        GLES20.glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER,
                GLES20.GL_LINEAR);
 
        _mySurfaceTexture = new SurfaceTexture(_myTextureId[0]);
        _mySurfaceTexture.setOnFrameAvailableListener(this);
 
        Surface mySurface = new Surface(_mySurfaceTexture);
        _myMediaPlayer = new MediaPlayer();
        _myMediaPlayer.setSurface(mySurface);
        mySurface.release();
        // TODO: switch to async 
        //_myMediaPlayer.setOnPreparedListener(this); 
    } 
 
    // Called when MediaPlayer is ready 
    public void onPrepared(MediaPlayer player) {
        //player.start(); 
 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setOnFrameAvailableListener
	        setContentView(glSurfaceView);
	    } 
 
	    public void startCamera(int texture)
	    { 
	        surface = new SurfaceTexture(texture);
	        surface.setOnFrameAvailableListener(this);
	        renderer.setSurface(surface);
 
	        mCamera = Camera.open();
 
	        try 
	        { 
	            mCamera.setPreviewTexture(surface);
	            mCamera.startPreview();
	        } 
	        catch (IOException ioe)
	        { 
	            Log.w("MainActivity","CAM LAUNCH FAILED");
	        } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getTransformMatrix, updateTexImage
                params.setAutoExposureLock(true);
                //mCamera.setParameters(params); 
                mStartCaptureTime = 0;
            } 
 
            mSurfaceTexture.updateTexImage();
            mSurfaceTexture.getTransformMatrix(mCameraTransform);
 
            // display it here 
        } 
    } 
 
    public synchronized boolean hasNewFrame() { 
        return mNewFrameAvailable;
    } 
 
    public synchronized void endCapture() { 
        mIsOpen = false;
        if (mCamera != null) {
            mCamera.release();
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        return mFrameHeight;
    } 
 
    public void setPreview() throws IOException { 
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
            mCamera.setPreviewTexture( new SurfaceTexture(10) );
        else 
	    mCamera.setPreviewDisplay(null);
    } 
 
 
    public boolean openCamera() { 
        Log.i(TAG, "openCamera");
        releaseCamera(); 
        mCamera = Camera.open();
        if(mCamera == null) {
        	Log.e(TAG, "Can't open camera!");
        	return false; 
        } 
 
5
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android SurfaceTexture Questions & Answers:

See Code Examples for Android SurfaceTexture Methods: