Search in sources :

Example 6 with SurfaceTexture

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

the class SurfaceTextureSource method open.

@Override
public void open(FilterContext context) {
    if (mLogVerbose)
        Log.v(TAG, "Opening SurfaceTextureSource");
    // Create SurfaceTexture anew each time - it can use substantial memory.
    mSurfaceTexture = new SurfaceTexture(mMediaFrame.getTextureId());
    // Connect SurfaceTexture to callback
    mSurfaceTexture.setOnFrameAvailableListener(onFrameAvailableListener);
    // Connect SurfaceTexture to source
    mSourceListener.onSurfaceTextureSourceReady(mSurfaceTexture);
    mFirstFrame = true;
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture)

Example 7 with SurfaceTexture

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

the class EGLImpl method eglCreateWindowSurface.

public EGLSurface eglCreateWindowSurface(EGLDisplay display, EGLConfig config, Object native_window, int[] attrib_list) {
    Surface sur = null;
    if (native_window instanceof SurfaceView) {
        SurfaceView surfaceView = (SurfaceView) native_window;
        sur = surfaceView.getHolder().getSurface();
    } else if (native_window instanceof SurfaceHolder) {
        SurfaceHolder holder = (SurfaceHolder) native_window;
        sur = holder.getSurface();
    } else if (native_window instanceof Surface) {
        sur = (Surface) native_window;
    }
    int eglSurfaceId;
    if (sur != null) {
        eglSurfaceId = _eglCreateWindowSurface(display, config, sur, attrib_list);
    } else if (native_window instanceof SurfaceTexture) {
        eglSurfaceId = _eglCreateWindowSurfaceTexture(display, config, native_window, attrib_list);
    } else {
        throw new java.lang.UnsupportedOperationException("eglCreateWindowSurface() can only be called with an instance of " + "Surface, SurfaceView, SurfaceHolder or SurfaceTexture at the moment.");
    }
    if (eglSurfaceId == 0) {
        return EGL10.EGL_NO_SURFACE;
    }
    return new EGLSurfaceImpl(eglSurfaceId);
}
Also used : SurfaceHolder(android.view.SurfaceHolder) SurfaceTexture(android.graphics.SurfaceTexture) SurfaceView(android.view.SurfaceView) Surface(android.view.Surface)

Example 8 with SurfaceTexture

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

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 9 with SurfaceTexture

use of android.graphics.SurfaceTexture in project UltimateAndroid by cymcsg.

the class CameraPreviewInput method initWithGLContext.

@Override
protected void initWithGLContext() {
    super.initWithGLContext();
    int[] textures = new int[1];
    GLES20.glGenTextures(1, textures, 0);
    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textures[0]);
    GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
    GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 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);
    texture_in = textures[0];
    camTex = new SurfaceTexture(texture_in);
    camTex.setOnFrameAvailableListener(this);
    boolean failed = true;
    while (failed) {
        try {
            if (camera != null) {
                camera.stopPreview();
                camera.release();
                camera = null;
            }
            camera = createCamera();
            camera.setPreviewTexture(camTex);
            camera.startPreview();
            setRenderSizeToCameraSize();
            failed = false;
        } catch (Exception e) {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            Log.e("CameraInput", sw.toString());
            if (camera != null) {
                camera.release();
                camera = null;
            }
        }
    }
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture) StringWriter(java.io.StringWriter) PrintWriter(java.io.PrintWriter)

Example 10 with SurfaceTexture

use of android.graphics.SurfaceTexture in project UltimateAndroid by cymcsg.

the class VideoResourceInput method initWithGLContext.

@Override
protected void initWithGLContext() {
    ready = false;
    try {
        player = MediaPlayer.create(context, id);
    } catch (Exception e) {
        Log.e("VideoPlayer", "Failed to load video");
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        e.printStackTrace(pw);
        Log.e("VideoPlayer", sw.toString());
        player.release();
    }
    setRenderSize(player.getVideoWidth(), player.getVideoHeight());
    super.initWithGLContext();
    int[] textures = new int[1];
    GLES20.glGenTextures(1, textures, 0);
    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textures[0]);
    GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
    GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 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);
    texture_in = textures[0];
    videoTex = new SurfaceTexture(texture_in);
    videoTex.setOnFrameAvailableListener(this);
    Surface surface = new Surface(videoTex);
    player.setSurface(surface);
    ready = true;
    if (startWhenReady) {
        player.start();
    }
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture) StringWriter(java.io.StringWriter) PrintWriter(java.io.PrintWriter) Surface(android.view.Surface)

Aggregations

SurfaceTexture (android.graphics.SurfaceTexture)159 Surface (android.view.Surface)97 SurfaceView (android.view.SurfaceView)18 IOException (java.io.IOException)17 Test (org.junit.Test)16 EGLSurface (android.opengl.EGLSurface)14 SurfaceHolder (android.view.SurfaceHolder)14 Context (android.content.Context)13 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)13 FakeClock (com.google.android.exoplayer2.testutil.FakeClock)13 TextureView (android.view.TextureView)12 PlaybackOutput (com.google.android.exoplayer2.robolectric.PlaybackOutput)12 CapturingRenderersFactory (com.google.android.exoplayer2.testutil.CapturingRenderersFactory)12 Uri (android.net.Uri)9 MediaPlayer (android.media.MediaPlayer)8 OnInfoListener (android.media.MediaPlayer.OnInfoListener)8 OnPreparedListener (android.media.MediaPlayer.OnPreparedListener)8 ImageView (android.widget.ImageView)6 ApplicationProvider (androidx.test.core.app.ApplicationProvider)6 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)6