/// <summary>
            /// Populate the camera result settings.
            /// </summary>
            /// <param name="prepareHandle">A pointer to the camera prepare handle.</param>
            /// <returns>
            /// MLResult.Result will be <c>MLResult.Code.Ok</c> if completed successfully.
            /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to internal error.
            /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if an invalid parameter was provided.
            /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if a required permission is missing.
            /// </returns>
            internal MLResult.Code PopulateSettings(ulong prepareHandle)
            {
                MLResult.Code resultCode = MLResult.Code.Ok;

                MLCamera.MetadataColorCorrectionMode colorCorrectionMode = 0;
                resultCode = MLCameraNativeBindings.MLCameraMetadataGetColorCorrectionModeResultMetadata(prepareHandle, ref colorCorrectionMode);
                if (!MLResult.IsOK(resultCode))
                {
                    MLPluginLog.ErrorFormat("MLCamera.ResultSettings.PopulateSettings failed to get color correction mode for prepare handle {0}. Reason: {1}", prepareHandle, resultCode);
                    return(resultCode);
                }

                this.ColorCorrectionMode = colorCorrectionMode;

                MLCameraNativeBindings.MLCameraMetadataRationalNative[] colorCorrectionTransform = new MLCameraNativeBindings.MLCameraMetadataRationalNative[9];
                resultCode = MLCameraNativeBindings.MLCameraMetadataGetColorCorrectionTransformResultMetadata(prepareHandle, colorCorrectionTransform);
                if (!MLResult.IsOK(resultCode))
                {
                    MLPluginLog.ErrorFormat("MLCamera.ResultSettings.PopulateSettings failed to get color correction transform matrix for prepare handle {0}. Reason: {1}", prepareHandle, resultCode);
                    return(resultCode);
                }

                this.ColorCorrectionTransform = new MLCamera.ColorCorrectionTransform(
                    colorCorrectionTransform[0].ToFloat(),
                    colorCorrectionTransform[1].ToFloat(),
                    colorCorrectionTransform[2].ToFloat(),
                    colorCorrectionTransform[3].ToFloat(),
                    colorCorrectionTransform[4].ToFloat(),
                    colorCorrectionTransform[5].ToFloat(),
                    colorCorrectionTransform[6].ToFloat(),
                    colorCorrectionTransform[7].ToFloat(),
                    colorCorrectionTransform[8].ToFloat());

                MLCamera.MetadataColorCorrectionAberrationMode colorCorrectionAberrationMode = 0;
                resultCode = MLCameraNativeBindings.MLCameraMetadataGetColorCorrectionAberrationModeResultMetadata(prepareHandle, ref colorCorrectionAberrationMode);
                if (!MLResult.IsOK(resultCode))
                {
                    MLPluginLog.ErrorFormat("MLCamera.ResultSettings.PopulateSettings failed to get color correction aberration mode for prepare handle {0}. Reason: {1}", prepareHandle, resultCode);
                    return(resultCode);
                }

                this.ColorCorrectionAberrationMode = colorCorrectionAberrationMode;

                float[] colorCorrectionGains = new float[4];
                resultCode = MLCameraNativeBindings.MLCameraMetadataGetColorCorrectionGainsResultMetadata(prepareHandle, colorCorrectionGains);
                if (!MLResult.IsOK(resultCode))
                {
                    MLPluginLog.ErrorFormat("MLCamera.ResultSettings.PopulateSettings failed to get color correction gains for prepare handle {0}. Reason: {1}", prepareHandle, resultCode);
                    return(resultCode);
                }

                // The order of this, red, greenEven, greenOdd, blue, was taken from the android developer site for the color corrections gain vector
                // https://developer.android.com/reference/android/hardware/camera2/params/RggbChannelVector
                this.ColorCorrectionGains = new MLCamera.ColorCorrectionGains(colorCorrectionGains[0], colorCorrectionGains[1], colorCorrectionGains[2], colorCorrectionGains[3]);

                MLCamera.MetadataControlAEAntibandingMode controlAEAntiBandingMode = 0;
                resultCode = MLCameraNativeBindings.MLCameraMetadataGetControlAEAntibandingModeResultMetadata(prepareHandle, ref controlAEAntiBandingMode);
                if (!MLResult.IsOK(resultCode))
                {
                    MLPluginLog.ErrorFormat("MLCamera.ResultSettings.PopulateSettings failed to get control AE antibanding mode for prepare handle {0}. Reason: {1}", prepareHandle, resultCode);
                    return(resultCode);
                }

                this.ControlAEAntibandingMode = controlAEAntiBandingMode;

                int controlAEExposureCompensation = 0;

                resultCode = MLCameraNativeBindings.MLCameraMetadataGetControlAEExposureCompensationResultMetadata(prepareHandle, ref controlAEExposureCompensation);
                if (!MLResult.IsOK(resultCode))
                {
                    MLPluginLog.ErrorFormat("MLCamera.ResultSettings.PopulateSettings failed to get control AE exposure compensation for prepare handle {0}. Reason: {1}", prepareHandle, resultCode);
                    return(resultCode);
                }

                this.AEExposureCompensation = controlAEExposureCompensation;

                MLCamera.MetadataControlAELock controlAELock = 0;
                resultCode = MLCameraNativeBindings.MLCameraMetadataGetControlAELockResultMetadata(prepareHandle, ref controlAELock);
                if (!MLResult.IsOK(resultCode))
                {
                    MLPluginLog.ErrorFormat("MLCamera.ResultSettings.PopulateSettings failed to get control AE lock for prepare handle {0}. Reason: {1}", prepareHandle, resultCode);
                    return(resultCode);
                }

                this.ControlAELock = controlAELock;

                MLCamera.MetadataControlAEMode controlAEMode = 0;
                resultCode = MLCameraNativeBindings.MLCameraMetadataGetControlAEModeResultMetadata(prepareHandle, ref controlAEMode);
                if (!MLResult.IsOK(resultCode))
                {
                    MLPluginLog.ErrorFormat("MLCamera.ResultSettings.PopulateSettings failed to get control ae mode for prepare handle {0}. Reason: {1}", prepareHandle, resultCode);
                    return(resultCode);
                }

                this.ControlAEMode = controlAEMode;

                int[] controlAETargetFPSRangeArray = new int[2];
                resultCode = MLCameraNativeBindings.MLCameraMetadataGetControlAETargetFPSRangeResultMetadata(prepareHandle, controlAETargetFPSRangeArray);
                if (!MLResult.IsOK(resultCode))
                {
                    MLPluginLog.ErrorFormat("MLCamera.ResultSettings.PopulateSettings failed to get control AE target fps for prepare handle {0}. Reason: {1}", prepareHandle, resultCode);
                    return(resultCode);
                }

                this.ControlAETargetFPSRange = new MLCamera.ControlAETargetFPSRange(controlAETargetFPSRangeArray[0], controlAETargetFPSRangeArray[1]);

                MLCamera.MetadataControlAEState controlAEState = 0;
                resultCode = MLCameraNativeBindings.MLCameraMetadataGetControlAEStateResultMetadata(prepareHandle, ref controlAEState);
                if (!MLResult.IsOK(resultCode))
                {
                    MLPluginLog.ErrorFormat("MLCamera.ResultSettings.PopulateSettings failed to get control AE state for prepare handle {0}. Reason: {1}", prepareHandle, resultCode);
                    return(resultCode);
                }

                this.ControlAEState = controlAEState;

                MLCamera.MetadataControlAWBLock controlAWBLock = 0;
                resultCode = MLCameraNativeBindings.MLCameraMetadataGetControlAWBLockResultMetadata(prepareHandle, ref controlAWBLock);
                if (!MLResult.IsOK(resultCode))
                {
                    MLPluginLog.ErrorFormat("MLCamera.ResultSettings.PopulateSettings failed to get control AWB lock for prepare handle {0}. Reason: {1}", prepareHandle, resultCode);
                    return(resultCode);
                }

                this.ControlAWBLock = controlAWBLock;

                MLCamera.MetadataControlAWBState controlAWBState = 0;
                resultCode = MLCameraNativeBindings.MLCameraMetadataGetControlAWBStateResultMetadata(prepareHandle, ref controlAWBState);
                if (!MLResult.IsOK(resultCode))
                {
                    MLPluginLog.ErrorFormat("MLCamera.ResultSettings.PopulateSettings failed to get control AWB state for prepare handle {0}. Reason: {1}", prepareHandle, resultCode);
                    return(resultCode);
                }

                this.ControlAWBState = controlAWBState;

                long sensorExposureTime = 0;

                resultCode = MLCameraNativeBindings.MLCameraMetadataGetSensorExposureTimeResultMetadata(prepareHandle, ref sensorExposureTime);
                if (!MLResult.IsOK(resultCode))
                {
                    MLPluginLog.ErrorFormat("MLCamera.ResultSettings.PopulateSettings failed to get sensor exposure time for prepare handle {0}. Reason: {1}", prepareHandle, resultCode);
                    return(resultCode);
                }

                this.SensorExposureTime = sensorExposureTime;

                int sensorySensitivity = 0;

                resultCode = MLCameraNativeBindings.MLCameraMetadataGetSensorSensitivityResultMetadata(prepareHandle, ref sensorySensitivity);
                if (!MLResult.IsOK(resultCode))
                {
                    MLPluginLog.ErrorFormat("MLCamera.ResultSettings.PopulateSettings failed to get sensor sensitivity for prepare handle {0}. Reason: {1}", prepareHandle, resultCode);
                    return(resultCode);
                }

                this.SensorSensitivity = sensorySensitivity;

                long sensorTimestamp = 0;

                resultCode = MLCameraNativeBindings.MLCameraMetadataGetSensorTimestampResultMetadata(prepareHandle, ref sensorTimestamp);
                if (!MLResult.IsOK(resultCode))
                {
                    MLPluginLog.ErrorFormat("MLCamera.ResultSettings.PopulateSettings failed to get sensor time stamp for prepare handle {0}. Reason: {1}", prepareHandle, resultCode);
                    return(resultCode);
                }

                this.SensorTimestamp = sensorTimestamp;

                int[] scalerCropRegionArray = new int[4];
                resultCode = MLCameraNativeBindings.MLCameraMetadataGetScalerCropRegionResultMetadata(prepareHandle, scalerCropRegionArray);
                if (!MLResult.IsOK(resultCode))
                {
                    MLPluginLog.ErrorFormat("MLCamera.ResultSettings.PopulateSettings failed to get scaler crop region for prepare handle {0}. Reason: {1}", prepareHandle, resultCode);
                    return(resultCode);
                }

                this.ScalerCropRegion = new MLCamera.ScalerCropRegion(scalerCropRegionArray[0], scalerCropRegionArray[1], scalerCropRegionArray[2], scalerCropRegionArray[3]);

                long sensorFrameDuration = 0;

                resultCode = MLCameraNativeBindings.MLCameraMetadataGetSensorFrameDurationResultMetadata(prepareHandle, ref sensorFrameDuration);
                if (!MLResult.IsOK(resultCode))
                {
                    MLPluginLog.ErrorFormat("MLCamera.ResultSettings.PopulateSettings failed to get sensor frame duration for prepare handle {0}. Reason: {1}", prepareHandle, resultCode);
                    return(resultCode);
                }

                this.SensorFrameDuration = sensorFrameDuration;

                return(resultCode);
            }