Search in sources :

Example 26 with SurfaceTexture

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

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

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

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)

Example 28 with SurfaceTexture

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

the class TextureView method getHardwareLayer.

HardwareLayer getHardwareLayer() {
    if (mLayer == null) {
        if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) {
            return null;
        }
        mLayer = mAttachInfo.mHardwareRenderer.createTextureLayer();
        boolean createNewSurface = (mSurface == null);
        if (createNewSurface) {
            // Create a new SurfaceTexture for the layer.
            mSurface = new SurfaceTexture(false);
            nCreateNativeWindow(mSurface);
        }
        mLayer.setSurfaceTexture(mSurface);
        mSurface.setDefaultBufferSize(getWidth(), getHeight());
        mSurface.setOnFrameAvailableListener(mUpdateListener, mAttachInfo.mHandler);
        if (mListener != null && createNewSurface) {
            mListener.onSurfaceTextureAvailable(mSurface, getWidth(), getHeight());
        }
        mLayer.setLayerPaint(mLayerPaint);
    }
    if (mUpdateSurface) {
        // Someone has requested that we use a specific SurfaceTexture, so
        // tell mLayer about it and set the SurfaceTexture to use the
        // current view size.
        mUpdateSurface = false;
        // Since we are updating the layer, force an update to ensure its
        // parameters are correct (width, height, transform, etc.)
        updateLayer();
        mMatrixChanged = true;
        mLayer.setSurfaceTexture(mSurface);
        mSurface.setDefaultBufferSize(getWidth(), getHeight());
    }
    return mLayer;
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture)

Example 29 with SurfaceTexture

use of android.graphics.SurfaceTexture in project XobotOS by xamarin.

the class HTML5VideoInline method decideDisplayMode.

@Override
public void decideDisplayMode() {
    SurfaceTexture surfaceTexture = getSurfaceTexture(getVideoLayerId());
    Surface surface = new Surface(surfaceTexture);
    mPlayer.setSurface(surface);
    surface.release();
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture) Surface(android.view.Surface)

Example 30 with SurfaceTexture

use of android.graphics.SurfaceTexture in project XobotOS by xamarin.

the class HTML5VideoInline method getSurfaceTexture.

// Inline Video specific FUNCTIONS:
@Override
public SurfaceTexture getSurfaceTexture(int videoLayerId) {
    // Create the surface texture.
    if (videoLayerId != mVideoLayerUsingSurfaceTexture || mSurfaceTexture == null) {
        if (mTextureNames == null) {
            mTextureNames = new int[1];
            GLES20.glGenTextures(1, mTextureNames, 0);
        }
        mSurfaceTexture = new SurfaceTexture(mTextureNames[0]);
    }
    mVideoLayerUsingSurfaceTexture = videoLayerId;
    return mSurfaceTexture;
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture)

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