Search in sources :

Example 16 with SurfaceTexture

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

the class CameraDeviceBinderTest method testCreateStreamTwo.

@SmallTest
public void testCreateStreamTwo() throws Exception {
    // Create first stream
    int streamId = mCameraUser.createStream(mOutputConfiguration);
    assertEquals(0, streamId);
    try {
        mCameraUser.createStream(mOutputConfiguration);
        fail("Created same stream twice");
    } catch (ServiceSpecificException e) {
        assertEquals("Created same stream twice", ICameraService.ERROR_ALREADY_EXISTS, e.errorCode);
    }
    // Create second stream with a different surface.
    SurfaceTexture surfaceTexture = new SurfaceTexture(/* ignored */
    0);
    surfaceTexture.setDefaultBufferSize(640, 480);
    Surface surface2 = new Surface(surfaceTexture);
    OutputConfiguration output2 = new OutputConfiguration(surface2);
    int streamId2 = mCameraUser.createStream(output2);
    assertEquals(1, streamId2);
    // Clean up streams
    mCameraUser.deleteStream(streamId);
    mCameraUser.deleteStream(streamId2);
}
Also used : ServiceSpecificException(android.os.ServiceSpecificException) SurfaceTexture(android.graphics.SurfaceTexture) OutputConfiguration(android.hardware.camera2.params.OutputConfiguration) Surface(android.view.Surface) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 17 with SurfaceTexture

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

the class FingerprintLocationAnimationVideoView method onFinishInflate.

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    setSurfaceTextureListener(new SurfaceTextureListener() {

        private SurfaceTexture mTextureToDestroy = null;

        @Override
        public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) {
            setVisibility(View.INVISIBLE);
            Uri videoUri = getFingerprintLocationAnimation();
            if (mMediaPlayer != null) {
                mMediaPlayer.release();
            }
            if (mTextureToDestroy != null) {
                mTextureToDestroy.release();
                mTextureToDestroy = null;
            }
            mMediaPlayer = MediaPlayer.create(mContext, videoUri);
            mMediaPlayer.setSurface(new Surface(surfaceTexture));
            mMediaPlayer.setOnPreparedListener(new OnPreparedListener() {

                @Override
                public void onPrepared(MediaPlayer mediaPlayer) {
                    mediaPlayer.setLooping(true);
                }
            });
            mMediaPlayer.setOnInfoListener(new OnInfoListener() {

                @Override
                public boolean onInfo(MediaPlayer mediaPlayer, int what, int extra) {
                    if (what == MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START) {
                        // Keep the view hidden until video starts
                        setVisibility(View.VISIBLE);
                    }
                    return false;
                }
            });
            mAspect = (float) mMediaPlayer.getVideoHeight() / mMediaPlayer.getVideoWidth();
            requestLayout();
            startAnimation();
        }

        @Override
        public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int width, int height) {
        }

        @Override
        public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
            mTextureToDestroy = surfaceTexture;
            return false;
        }

        @Override
        public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
        }
    });
}
Also used : OnInfoListener(android.media.MediaPlayer.OnInfoListener) SurfaceTexture(android.graphics.SurfaceTexture) OnPreparedListener(android.media.MediaPlayer.OnPreparedListener) Uri(android.net.Uri) Surface(android.view.Surface) MediaPlayer(android.media.MediaPlayer)

Example 18 with SurfaceTexture

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

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

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

the class SurfaceTextureRenderer method configureSurfaces.

/**
     * Set a collection of output {@link Surface}s that can be drawn to.
     *
     * @param surfaces a {@link Collection} of surfaces.
     */
public void configureSurfaces(Collection<Pair<Surface, Size>> surfaces) {
    releaseEGLContext();
    if (surfaces == null || surfaces.size() == 0) {
        Log.w(TAG, "No output surfaces configured for GL drawing.");
        return;
    }
    for (Pair<Surface, Size> p : surfaces) {
        Surface s = p.first;
        Size surfaceSize = p.second;
        // If pixel conversions aren't handled by egl, use a pbuffer
        try {
            EGLSurfaceHolder holder = new EGLSurfaceHolder();
            holder.surface = s;
            holder.width = surfaceSize.getWidth();
            holder.height = surfaceSize.getHeight();
            if (LegacyCameraDevice.needsConversion(s)) {
                mConversionSurfaces.add(holder);
                // LegacyCameraDevice is the producer of surfaces if it's not handled by EGL,
                // so LegacyCameraDevice needs to connect to the surfaces.
                LegacyCameraDevice.connectSurface(s);
            } else {
                mSurfaces.add(holder);
            }
        } catch (LegacyExceptionUtils.BufferQueueAbandonedException e) {
            Log.w(TAG, "Surface abandoned, skipping configuration... ", e);
        }
    }
    // Set up egl display
    configureEGLContext();
    // Set up regular egl surfaces if needed
    if (mSurfaces.size() > 0) {
        configureEGLOutputSurfaces(mSurfaces);
    }
    // Set up pbuffer surface if needed
    if (mConversionSurfaces.size() > 0) {
        configureEGLPbufferSurfaces(mConversionSurfaces);
    }
    makeCurrent((mSurfaces.size() > 0) ? mSurfaces.get(0).eglSurface : mConversionSurfaces.get(0).eglSurface);
    initializeGLState();
    mSurfaceTexture = new SurfaceTexture(getTextureId());
    // Set up performance tracking if enabled
    if (SystemProperties.getBoolean(LEGACY_PERF_PROPERTY, false)) {
        setupGlTiming();
    }
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture) Size(android.util.Size) EGLSurface(android.opengl.EGLSurface) Surface(android.view.Surface)

Example 20 with SurfaceTexture

use of android.graphics.SurfaceTexture in project react-native-android-video-editor by RZulfikri.

the class ImageTextureRenderer method initializeBuffers.

private void initializeBuffers() {
    ByteBuffer buff = ByteBuffer.allocateDirect(vertices.length * 4);
    buff.order(ByteOrder.nativeOrder());
    verticesBuffer = buff.asFloatBuffer();
    verticesBuffer.put(vertices);
    verticesBuffer.position(0);
    buff = ByteBuffer.allocateDirect(textureVertices.length * 4);
    buff.order(ByteOrder.nativeOrder());
    textureBuffer = buff.asFloatBuffer();
    textureBuffer.put(textureVertices);
    textureBuffer.position(0);
    imageTexture = new SurfaceTexture(textures[0]);
    imageTexture.setOnFrameAvailableListener(this);
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture) ByteBuffer(java.nio.ByteBuffer)

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