use of android.hardware.Camera.CameraInfo in project android_frameworks_base by crdroidandroid.
the class CameraDeviceUserShim method connectBinderShim.
public static CameraDeviceUserShim connectBinderShim(ICameraDeviceCallbacks callbacks, int cameraId) {
if (DEBUG) {
Log.d(TAG, "Opening shim Camera device");
}
/*
* Put the camera open on a separate thread with its own looper; otherwise
* if the main thread is used then the callbacks might never get delivered
* (e.g. in CTS which run its own default looper only after tests)
*/
CameraLooper init = new CameraLooper(cameraId);
CameraCallbackThread threadCallbacks = new CameraCallbackThread(callbacks);
// TODO: Make this async instead of blocking
int initErrors = init.waitForOpen(OPEN_CAMERA_TIMEOUT_MS);
Camera legacyCamera = init.getCamera();
// Check errors old HAL initialization
LegacyExceptionUtils.throwOnServiceError(initErrors);
// Disable shutter sounds (this will work unconditionally) for api2 clients
legacyCamera.disableShutterSound();
CameraInfo info = new CameraInfo();
Camera.getCameraInfo(cameraId, info);
Camera.Parameters legacyParameters = null;
try {
legacyParameters = legacyCamera.getParameters();
} catch (RuntimeException e) {
throw new ServiceSpecificException(ICameraService.ERROR_INVALID_OPERATION, "Unable to get initial parameters: " + e.getMessage());
}
CameraCharacteristics characteristics = LegacyMetadataMapper.createCharacteristics(legacyParameters, info);
LegacyCameraDevice device = new LegacyCameraDevice(cameraId, legacyCamera, characteristics, threadCallbacks);
return new CameraDeviceUserShim(cameraId, device, characteristics, init, threadCallbacks);
}
use of android.hardware.Camera.CameraInfo in project android_frameworks_base by crdroidandroid.
the class CamcorderProfile method get.
/**
* Returns the camcorder profile for the first back-facing camera on the
* device at the given quality level. If the device has no back-facing
* camera, this returns null.
* @param quality the target quality level for the camcorder profile
* @see #get(int, int)
*/
public static CamcorderProfile get(int quality) {
int numberOfCameras = Camera.getNumberOfCameras();
CameraInfo cameraInfo = new CameraInfo();
for (int i = 0; i < numberOfCameras; i++) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
return get(i, quality);
}
}
return null;
}
use of android.hardware.Camera.CameraInfo in project android_frameworks_base by crdroidandroid.
the class CameraStreamer method getDefaultFacing.
/**
* Returns the camera facing that is chosen when DONT_CARE is specified.
* Returns 0 if neither a front nor back camera could be found.
*/
public static int getDefaultFacing() {
int camCount = Camera.getNumberOfCameras();
if (camCount == 0) {
return 0;
} else {
CameraInfo cameraInfo = new CameraInfo();
Camera.getCameraInfo(0, cameraInfo);
return (cameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT) ? FACING_FRONT : FACING_BACK;
}
}
use of android.hardware.Camera.CameraInfo in project TextureViewDemo by dalinaum.
the class CameraSurfaceTextureListener method getBackCamera.
private Pair<CameraInfo, Integer> getBackCamera() {
CameraInfo cameraInfo = new CameraInfo();
final int numberOfCameras = Camera.getNumberOfCameras();
for (int i = 0; i < numberOfCameras; ++i) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
return new Pair<Camera.CameraInfo, Integer>(cameraInfo, Integer.valueOf(i));
}
}
return null;
}
use of android.hardware.Camera.CameraInfo in project platform_frameworks_base by android.
the class CameraStreamer method getDefaultFacing.
/**
* Returns the camera facing that is chosen when DONT_CARE is specified.
* Returns 0 if neither a front nor back camera could be found.
*/
public static int getDefaultFacing() {
int camCount = Camera.getNumberOfCameras();
if (camCount == 0) {
return 0;
} else {
CameraInfo cameraInfo = new CameraInfo();
Camera.getCameraInfo(0, cameraInfo);
return (cameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT) ? FACING_FRONT : FACING_BACK;
}
}
Aggregations