namespace MagicLeap.Android.NDK.Camera { using System; using System.Diagnostics; using static CameraConstants; internal enum CameraStatus { /// /// Camera operation has succeeded. /// Ok = 0, /// /// Camera operation has failed due to an unspecified cause. /// UnknownError = kErrorBase, /// /// Camera operation has failed due to an invalid parameter being passed to the method. /// InvalidParameter = kErrorBase - 1, /// /// Camera operation has failed because the camera device has been closed, /// possibly because a higher-priority client has taken ownership of the camera device. /// CameraDisconnected = kErrorBase - 2, /// /// Camera operation has failed due to insufficient memory. /// NotEnoughMemory = kErrorBase - 3, /// /// Camera operation has failed due to the requested metadata tag cannot be found /// in input {@link ACameraMetadata} or {@link ACaptureRequest}. /// MetadataNotFound = kErrorBase - 4, /// /// Camera operation has failed and the camera device has encountered a fatal error /// and needs to be re-opened before it can be used again. /// FatalDeviceError = kErrorBase - 5, /// /// Camera operation has failed and the camera service has encountered a fatal error. ///

The Android device may need to be shut down and restarted to restore camera function, or there may be a persistent hardware problem.

///

An attempt at recovery may be possible by closing the /// ACameraDevice and the ACameraManager, and trying to acquire all resources again from scratch.

///
FatalServiceError = kErrorBase - 6, /// /// The {@link ACameraCaptureSession} has been closed and cannnot perform any operation other than {@link ACameraCaptureSession_close}. /// SessionClosed = kErrorBase - 7, /// /// Camera operation has failed due to an invalid internal operation. Usually this is due to a low-level problem that may resolve itself on retry /// InvalidOperation = kErrorBase - 8, /// /// Camera device does not support the stream configuration provided by application in {@link ACameraDevice_createCaptureSession} or {@link ACameraDevice_isSessionConfigurationSupported}. /// StreamConfigurationFailure = kErrorBase - 9, /// /// Camera device is being used by another higher priority camera API client. /// CameraInUse = kErrorBase - 10, /// /// The system-wide limit for number of open cameras or camera resources has been reached, and more camera devices cannot be opened until previous instances are closed. /// MaximumCamerasInUse = kErrorBase - 11, /// /// The camera is disabled due to a device policy, and cannot be opened. /// CameraDisabled = kErrorBase - 12, /// /// The application does not have permission to open camera. /// PermissionDenied = kErrorBase - 13, /// /// The operation is not supported by the camera device. /// UnsupportedOperation = kErrorBase - 14, } internal static class CameraStatusExtensions { [Conditional("DEVELOPMENT_BUILD")] public static void CheckReturnValueAndThrow(this CameraStatus actual, CameraStatus expected = CameraStatus.Ok) { if (expected != actual) throw new Exception($"Unexpected result from native call. Expected: '{expected}', Actual: '{actual}'"); } } }