Skip to content

Unknown camera handling #1741

@alexsafe

Description

@alexsafe

Hi,

I think this may be a bug. If I get into a situation where the camera is not available this Exception happens:

java.lang.IllegalArgumentException: getCameraCharacteristics:857: Unable to retrieve camera characteristics for unknown device 163: No such file or directory (-2) at android.hardware.camera2.CameraManager.throwAsPublicException(CameraManager.java:1630) at android.hardware.camera2.CameraManager.getCameraCharacteristics(CameraManager.java:676) at android.hardware.camera2.CameraManager.getCameraCharacteristics(CameraManager.java:617) at com.pedro.encoder.input.video.Camera2ApiManager.getCameraCharacteristics(Camera2ApiManager.kt:265) at com.pedro.encoder.input.video.Camera2ApiManager.enableVideoStabilization(Camera2ApiManager.kt:307) at com.gpxstream2.app.pages.stream.implementations.CameraSource.start(CameraSource.kt:47)

I call it from this block

override fun start(surfaceTexture: SurfaceTexture) { this.surfaceTexture = surfaceTexture if (!isRunning()) { camera.closeCamera(false) try { camera.enableVideoStabilization() camera.enableOpticalVideoStabilization() camera.disableAutoExposure() camera.exposure = 1 surfaceTexture.setDefaultBufferSize(width, height) camera.prepareCamera(surfaceTexture, width, height, fps) camera.openLastCamera() } catch (e: CameraAccessException) { log.e("CameraAccessException: ${e.message}") e.printStackTrace() switchCamera(Cameras.BACK_CAMERA.id) } } }

To me it seems that the Exception thrown by

val cameraCharacteristics: CameraCharacteristics? get() { try { return cameraManager.getCameraCharacteristics(cameraId) } catch (e: Exception) { Log.e(TAG, "Error", e) return null } }

does not get transmitted.

For reproduction, probably setting the camera to 163 before a start() is triggered (if you don;t have an HDMI cam/port connected) should do the trick.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions