Search in sources :

Example 21 with CameraInfo

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);
}
Also used : ServiceSpecificException(android.os.ServiceSpecificException) CameraCharacteristics(android.hardware.camera2.CameraCharacteristics) Camera(android.hardware.Camera) CameraInfo(android.hardware.Camera.CameraInfo)

Example 22 with CameraInfo

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;
}
Also used : CameraInfo(android.hardware.Camera.CameraInfo)

Example 23 with CameraInfo

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;
    }
}
Also used : CameraInfo(android.hardware.Camera.CameraInfo)

Example 24 with CameraInfo

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;
}
Also used : Camera(android.hardware.Camera) CameraInfo(android.hardware.Camera.CameraInfo) Pair(android.util.Pair)

Example 25 with CameraInfo

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;
    }
}
Also used : CameraInfo(android.hardware.Camera.CameraInfo)

Aggregations

CameraInfo (android.hardware.Camera.CameraInfo)56 Camera (android.hardware.Camera)6 CameraCharacteristics (android.hardware.camera2.CameraCharacteristics)5 ServiceSpecificException (android.os.ServiceSpecificException)5 SuppressLint (android.annotation.SuppressLint)3 WindowManager (android.view.WindowManager)2 IOException (java.io.IOException)2 TargetApi (android.annotation.TargetApi)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 Face (android.hardware.Camera.Face)1 FaceDetectionListener (android.hardware.Camera.FaceDetectionListener)1 MediaRecorder (android.media.MediaRecorder)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 Pair (android.util.Pair)1 LayoutInflater (android.view.LayoutInflater)1 ViewGroup (android.view.ViewGroup)1 AppDataDirGuesser (com.google.testing.littlemock.AppDataDirGuesser)1