Java Code Examples for android.view.TextureView#SurfaceTextureListener

The following examples show how to use android.view.TextureView#SurfaceTextureListener . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Camera2Manager.java    From sandriosCamera with MIT License 5 votes vote down vote up
@Override
public void openCamera(String cameraId, final CameraOpenListener<String, TextureView.SurfaceTextureListener> cameraOpenListener) {
    this.currentCameraId = cameraId;
    this.cameraOpenListener = cameraOpenListener;
    backgroundHandler.post(new Runnable() {
        @Override
        public void run() {
            if (context == null || configurationProvider == null) {
                if (cameraOpenListener != null) {
                    uiHandler.post(new Runnable() {
                        @Override
                        public void run() {
                            cameraOpenListener.onCameraOpenError();
                        }
                    });
                }
                return;
            }
            prepareCameraOutputs();
            try {
                manager.openCamera(currentCameraId, stateCallback, backgroundHandler);
            } catch (Exception e) {
                if (cameraOpenListener != null) {
                    uiHandler.post(new Runnable() {
                        @Override
                        public void run() {
                            cameraOpenListener.onCameraOpenError();
                        }
                    });
                }
            }
        }
    });
}
 
Example 2
Source File: TestUtils.java    From openwebrtc-android-sdk with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void waitForNUpdates(final TextureView textureView, int count) {
    TextureView.SurfaceTextureListener previousListener = textureView.getSurfaceTextureListener();
    final TextureViewAsserter textureViewAsserter = new TextureViewAsserter(previousListener);
    textureView.setSurfaceTextureListener(textureViewAsserter);
    TestUtils.synchronous().latchCount(count).timeout(15).run(new TestUtils.SynchronousBlock() {
        @Override
        public void run(final CountDownLatch latch) {
            textureViewAsserter.waitForUpdates(latch);
        }
    });
    textureView.setSurfaceTextureListener(previousListener);
}
 
Example 3
Source File: CameraView.java    From LiveMultimedia with Apache License 2.0 5 votes vote down vote up
public void setupSurfaceTexureListener() {
    if (mSurfaceTextureListener != null)
        return;
    mSurfaceTextureListener = new TextureView.SurfaceTextureListener() {
        @Override
        public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture,
                                              int width, int height) {
            Log.d(TAG, "onSurfaceTextureAvailable() about to open the camera with width,height "
                    + String.valueOf(width) + "," + String.valueOf(height));
            mCamera.openCamera(width, height);
        }

        @Override
        public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture,
                                                int width, int height) {
            Log.d(TAG, "onSurfaceTextureSizeChanged() width width,height "
                    + String.valueOf(width) + "," + String.valueOf(height));
            mCamera.configureTransform(width, height);
        }

        @Override
        public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
            Log.d(TAG, "onSurfaceTextureDestroyed() ");
            return true;
        }

        @Override
        public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
            Log.d(TAG, "onSurfaceTextureUpdated() ");
        }

    };
}
 
Example 4
Source File: TextureViewHelper.java    From Camera2 with Apache License 2.0 4 votes vote down vote up
public void setSurfaceTextureListener(TextureView.SurfaceTextureListener listener)
{
    mSurfaceTextureListener = listener;
}
 
Example 5
Source File: ExoFFmpegPlayer.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
public InnerSurfaceTextureListener(TextureView.SurfaceTextureListener surfaceTextureListener){
    this.surfaceTextureListener = surfaceTextureListener;
}
 
Example 6
Source File: Camera2Lifecycle.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Override
public void onCameraOpened(String openedCameraId, Size previewSize, TextureView.SurfaceTextureListener surfaceTextureListener) {
    mCameraView.updateUiForMediaAction(CameraConfig.MEDIA_ACTION_UNSPECIFIED);
    mCameraView.updateCameraPreview(previewSize, new AutoFitTextureView(mContext, surfaceTextureListener));
    mCameraView.updateCameraSwitcher(mCamera2Manager.getNumberOfCameras());
}
 
Example 7
Source File: Camera2Controller.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Override
public void onCameraOpened(String openedCameraId, Size previewSize, TextureView.SurfaceTextureListener surfaceTextureListener) {
    cameraView.updateUiForMediaAction(Configuration.MEDIA_ACTION_UNSPECIFIED);
    cameraView.updateCameraPreview(previewSize, new AutoFitTextureView(context, surfaceTextureListener));
    cameraView.updateCameraSwitcher(camera2Manager.getNumberOfCameras());
}
 
Example 8
Source File: AutoFitTextureView.java    From phoenix with Apache License 2.0 4 votes vote down vote up
public AutoFitTextureView(Context context, TextureView.SurfaceTextureListener surfaceTextureListener) {
    super(context, null);
    setSurfaceTextureListener(surfaceTextureListener);
}
 
Example 9
Source File: Camera2Controller.java    From sandriosCamera with MIT License 4 votes vote down vote up
@Override
public void onCameraOpened(String openedCameraId, Size previewSize, TextureView.SurfaceTextureListener surfaceTextureListener) {
    cameraView.updateUiForMediaAction(CameraConfiguration.MEDIA_ACTION_BOTH);
    cameraView.updateCameraPreview(previewSize, new AutoFitTextureView(cameraView.getActivity(), surfaceTextureListener));
    cameraView.updateCameraSwitcher(camera2Manager.getNumberOfCameras());
}
 
Example 10
Source File: AutoFitTextureView.java    From sandriosCamera with MIT License 4 votes vote down vote up
public AutoFitTextureView(Context context, TextureView.SurfaceTextureListener surfaceTextureListener) {
    super(context, null);
    setSurfaceTextureListener(surfaceTextureListener);
}
 
Example 11
Source File: TestUtils.java    From openwebrtc-android-sdk with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public TextureViewAsserter(final TextureView.SurfaceTextureListener surfaceTextureListener) {
    mListener = surfaceTextureListener;
}
 
Example 12
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void surfaceTextureListener(TextureView.SurfaceTextureListener arg) {
  return BaseDSL.attr("surfaceTextureListener", arg);
}
 
Example 13
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void surfaceTextureListener(TextureView.SurfaceTextureListener arg) {
  return BaseDSL.attr("surfaceTextureListener", arg);
}