Search in sources :

Example 56 with SurfaceTexture

use of android.graphics.SurfaceTexture in project android_frameworks_base by AOSPA.

the class MediaSource method open.

@Override
public void open(FilterContext context) {
    if (mLogVerbose) {
        Log.v(TAG, "Opening MediaSource");
        if (mSelectedIsUrl) {
            Log.v(TAG, "Current URL is " + mSourceUrl);
        } else {
            Log.v(TAG, "Current source is Asset!");
        }
    }
    mMediaFrame = (GLFrame) context.getFrameManager().newBoundFrame(mOutputFormat, GLFrame.EXTERNAL_TEXTURE, 0);
    mSurfaceTexture = new SurfaceTexture(mMediaFrame.getTextureId());
    if (!setupMediaPlayer(mSelectedIsUrl)) {
        throw new RuntimeException("Error setting up MediaPlayer!");
    }
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture)

Example 57 with SurfaceTexture

use of android.graphics.SurfaceTexture in project android_frameworks_base by DirtyUnicorns.

the class EGL14 method eglCreateWindowSurface.

public static EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, Object win, int[] attrib_list, int offset) {
    Surface sur = null;
    if (win instanceof SurfaceView) {
        SurfaceView surfaceView = (SurfaceView) win;
        sur = surfaceView.getHolder().getSurface();
    } else if (win instanceof SurfaceHolder) {
        SurfaceHolder holder = (SurfaceHolder) win;
        sur = holder.getSurface();
    } else if (win instanceof Surface) {
        sur = (Surface) win;
    }
    EGLSurface surface;
    if (sur != null) {
        surface = _eglCreateWindowSurface(dpy, config, sur, attrib_list, offset);
    } else if (win instanceof SurfaceTexture) {
        surface = _eglCreateWindowSurfaceTexture(dpy, config, win, attrib_list, offset);
    } else {
        throw new java.lang.UnsupportedOperationException("eglCreateWindowSurface() can only be called with an instance of " + "Surface, SurfaceView, SurfaceTexture or SurfaceHolder at the moment, " + "this will be fixed later.");
    }
    return surface;
}
Also used : SurfaceHolder(android.view.SurfaceHolder) SurfaceTexture(android.graphics.SurfaceTexture) SurfaceView(android.view.SurfaceView) Surface(android.view.Surface)

Example 58 with SurfaceTexture

use of android.graphics.SurfaceTexture in project SocialRec by Jkuras.

the class CameraSource method start.

/**
 * Opens the camera and starts sending preview frames to the underlying detector.  The preview
 * frames are not displayed.
 *
 * @throws IOException if the camera's preview texture or display could not be initialized
 */
@RequiresPermission(Manifest.permission.CAMERA)
public CameraSource start() throws IOException {
    synchronized (mCameraLock) {
        if (mCamera != null) {
            return this;
        }
        mCamera = createCamera();
        // old version of Android. fall back to use SurfaceView.
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            mDummySurfaceTexture = new SurfaceTexture(DUMMY_TEXTURE_NAME);
            mCamera.setPreviewTexture(mDummySurfaceTexture);
        } else {
            mDummySurfaceView = new SurfaceView(mContext);
            mCamera.setPreviewDisplay(mDummySurfaceView.getHolder());
        }
        mCamera.startPreview();
        mProcessingThread = new Thread(mFrameProcessor);
        mFrameProcessor.setActive(true);
        mProcessingThread.start();
    }
    return this;
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture) SurfaceView(android.view.SurfaceView) RequiresPermission(android.support.annotation.RequiresPermission)

Example 59 with SurfaceTexture

use of android.graphics.SurfaceTexture in project KISS by Neamar.

the class CameraHandler method openCamera.

private void openCamera() throws IOException {
    if (camera == null) {
        camera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK);
        if (surfaceTexture == null) {
            surfaceTexture = new SurfaceTexture(0);
            camera.setPreviewTexture(surfaceTexture);
        }
    }
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture)

Example 60 with SurfaceTexture

use of android.graphics.SurfaceTexture in project android_frameworks_base by ResurrectionRemix.

the class EGL14 method eglCreateWindowSurface.

public static EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, Object win, int[] attrib_list, int offset) {
    Surface sur = null;
    if (win instanceof SurfaceView) {
        SurfaceView surfaceView = (SurfaceView) win;
        sur = surfaceView.getHolder().getSurface();
    } else if (win instanceof SurfaceHolder) {
        SurfaceHolder holder = (SurfaceHolder) win;
        sur = holder.getSurface();
    } else if (win instanceof Surface) {
        sur = (Surface) win;
    }
    EGLSurface surface;
    if (sur != null) {
        surface = _eglCreateWindowSurface(dpy, config, sur, attrib_list, offset);
    } else if (win instanceof SurfaceTexture) {
        surface = _eglCreateWindowSurfaceTexture(dpy, config, win, attrib_list, offset);
    } else {
        throw new java.lang.UnsupportedOperationException("eglCreateWindowSurface() can only be called with an instance of " + "Surface, SurfaceView, SurfaceTexture or SurfaceHolder at the moment, " + "this will be fixed later.");
    }
    return surface;
}
Also used : SurfaceHolder(android.view.SurfaceHolder) SurfaceTexture(android.graphics.SurfaceTexture) SurfaceView(android.view.SurfaceView) Surface(android.view.Surface)

Aggregations

SurfaceTexture (android.graphics.SurfaceTexture)99 Surface (android.view.Surface)49 SurfaceView (android.view.SurfaceView)16 IOException (java.io.IOException)16 SurfaceHolder (android.view.SurfaceHolder)14 EGLSurface (android.opengl.EGLSurface)13 OutputConfiguration (android.hardware.camera2.params.OutputConfiguration)5 ServiceSpecificException (android.os.ServiceSpecificException)5 SmallTest (android.test.suitebuilder.annotation.SmallTest)5 Size (android.util.Size)5 RequiresPermission (android.support.annotation.RequiresPermission)4 TextureView (android.view.TextureView)4 PrintWriter (java.io.PrintWriter)3 StringWriter (java.io.StringWriter)3 Camera (android.hardware.Camera)2 WindowManager (android.view.WindowManager)2 FrameLayout (android.widget.FrameLayout)2 ByteBuffer (java.nio.ByteBuffer)2 CalledByNative (org.chromium.base.CalledByNative)2 Size (android.hardware.Camera.Size)1