Search in sources :

Example 41 with SurfaceTexture

use of android.graphics.SurfaceTexture in project platform_frameworks_base by android.

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

use of android.graphics.SurfaceTexture in project platform_frameworks_base by android.

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;
    }
    long 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 43 with SurfaceTexture

use of android.graphics.SurfaceTexture in project ExoPlayer by google.

the class SimpleExoPlayer method setVideoTextureView.

/**
   * Sets the {@link TextureView} onto which video will be rendered. The player will track the
   * lifecycle of the surface automatically.
   *
   * @param textureView The texture view.
   */
public void setVideoTextureView(TextureView textureView) {
    removeSurfaceCallbacks();
    this.textureView = textureView;
    if (textureView == null) {
        setVideoSurfaceInternal(null, true);
    } else {
        if (textureView.getSurfaceTextureListener() != null) {
            Log.w(TAG, "Replacing existing SurfaceTextureListener.");
        }
        SurfaceTexture surfaceTexture = textureView.getSurfaceTexture();
        setVideoSurfaceInternal(surfaceTexture == null ? null : new Surface(surfaceTexture), true);
        textureView.setSurfaceTextureListener(componentListener);
    }
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture) Surface(android.view.Surface)

Example 44 with SurfaceTexture

use of android.graphics.SurfaceTexture in project platform_frameworks_base by android.

the class RequestThreadManager method createDummySurface.

/**
     * Fake preview for jpeg captures when there is no active preview
     */
private void createDummySurface() {
    if (mDummyTexture == null || mDummySurface == null) {
        mDummyTexture = new SurfaceTexture(/*ignored*/
        0);
        // TODO: use smallest default sizes
        mDummyTexture.setDefaultBufferSize(640, 480);
        mDummySurface = new Surface(mDummyTexture);
    }
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture) Surface(android.view.Surface)

Example 45 with SurfaceTexture

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

the class CameraSource method open.

@Override
public void open(FilterContext context) {
    if (mLogVerbose)
        Log.v(TAG, "Opening");
    // Open camera
    mCamera = Camera.open(mCameraId);
    // Set parameters
    getCameraParameters();
    mCamera.setParameters(mCameraParameters);
    // Create frame formats
    createFormats();
    // Bind it to our camera frame
    mCameraFrame = (GLFrame) context.getFrameManager().newBoundFrame(mOutputFormat, GLFrame.EXTERNAL_TEXTURE, 0);
    mSurfaceTexture = new SurfaceTexture(mCameraFrame.getTextureId());
    try {
        mCamera.setPreviewTexture(mSurfaceTexture);
    } catch (IOException e) {
        throw new RuntimeException("Could not bind camera surface texture: " + e.getMessage() + "!");
    }
    // Connect SurfaceTexture to callback
    mSurfaceTexture.setOnFrameAvailableListener(onCameraFrameAvailableListener);
    // Start the preview
    mNewFrameAvailable = false;
    mCamera.startPreview();
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture) IOException(java.io.IOException)

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