{
lock (_deviceStateChangedEventLock)
{
- int callbackId = 0;
-
_deviceStateChangedCallback = (CameraDevice device, CameraDeviceState state, IntPtr userData) =>
{
_deviceStateChanged?.Invoke(null, new CameraDeviceStateChangedEventArgs(device, state));
};
- CameraErrorFactory.ThrowIfError(Native.SetDeviceStateChangedCallback(_deviceStateChangedCallback, IntPtr.Zero, out callbackId),
+ CameraErrorFactory.ThrowIfError(Native.SetDeviceStateChangedCallback(_deviceStateChangedCallback, IntPtr.Zero, out int callbackId),
"Failed to set interrupt callback");
// Keep current callbackId and EventHandler pair to remove EventHandler later.
{
_deviceStateChanged -= value;
- int callbackId = 0;
- _callbackIdInfo.TryGetValue(value, out callbackId);
+ _callbackIdInfo.TryGetValue(value, out int callbackId);
Log.Info(CameraLog.Tag, "remove callbackId " + callbackId.ToString());
CameraErrorFactory.ThrowIfError(Native.UnsetDeviceStateChangedCallback(callbackId),
{
ValidateNotDisposed();
- bool val = false;
-
- CameraErrorFactory.ThrowIfError(Native.GetDisplayReuseHint(_handle, out val),
+ CameraErrorFactory.ThrowIfError(Native.GetDisplayReuseHint(_handle, out bool val),
"Failed to get camera display reuse hint");
return val;
{
ValidateNotDisposed();
- CameraFacingDirection val = 0;
-
- CameraErrorFactory.ThrowIfError(Native.GetFacingDirection(_handle, out val),
+ CameraErrorFactory.ThrowIfError(Native.GetFacingDirection(_handle, out var val),
"Failed to get camera direction");
return val;
{
ValidateNotDisposed();
- int val = 0;
-
- CameraErrorFactory.ThrowIfError(Native.GetDeviceCount(_handle, out val),
+ CameraErrorFactory.ThrowIfError(Native.GetDeviceCount(_handle, out int val),
"Failed to get camera device count");
return val;
ValidateState(CameraState.Created);
ValidationUtil.ValidateEnum(typeof(CameraDevice), device, nameof(device));
- CameraErrorFactory.ThrowIfError(Native.ChangeDevice(_handle, (int)device),
+ CameraErrorFactory.ThrowIfError(Native.ChangeDevice(_handle, device),
"Failed to change the camera device");
}
/// <exception cref="NotSupportedException">In case of this feature is not supported.</exception>
public CameraDeviceState GetDeviceState(CameraDevice device)
{
- int val = 0;
ValidationUtil.ValidateEnum(typeof(CameraDevice), device, nameof(device));
- CameraErrorFactory.ThrowIfError(Native.GetDeviceState(device, out val),
+ CameraErrorFactory.ThrowIfError(Native.GetDeviceState(device, out var val),
"Failed to get the camera device state.");
- return (CameraDeviceState)val;
+ return val;
}
/// <summary>
/// <exception cref="NotSupportedException">In case of this feature is not supported.</exception>
public static CameraFlashState GetFlashState(CameraDevice device)
{
- CameraFlashState val = CameraFlashState.NotUsed;
ValidationUtil.ValidateEnum(typeof(CameraDevice), device, nameof(device));
- CameraErrorFactory.ThrowIfError(Native.GetFlashState(device, out val),
+ CameraErrorFactory.ThrowIfError(Native.GetFlashState(device, out var val),
"Failed to get camera flash state");
return val;
private delegate CameraError GetRangeDelegate(IntPtr handle, out int min, out int max);
private Range? GetRange(GetRangeDelegate func)
{
- int min = 0;
- int max = 0;
-
- CameraErrorFactory.ThrowIfError(func(_camera.GetHandle(), out min, out max),
+ CameraErrorFactory.ThrowIfError(func(_camera.GetHandle(), out int min, out int max),
"Failed to initialize the camera settings");
if (min > max)
{
get
{
- int val = 0;
-
- CameraErrorFactory.ThrowIfError(Native.GetContrast(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.GetContrast(_camera.GetHandle(), out int val),
"Failed to get camera contrast value");
return val;
{
get
{
- bool val = false;
-
- CameraErrorFactory.ThrowIfError(Native.IsEnabledAutoContrast(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.IsEnabledAutoContrast(_camera.GetHandle(), out bool val),
"Failed to get camera auto contrast");
return val;
{
get
{
- int val = 0;
-
- CameraErrorFactory.ThrowIfError(Native.GetBrightness(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.GetBrightness(_camera.GetHandle(), out int val),
"Failed to get camera brightness value");
return val;
{
get
{
- int val = 0;
-
- CameraErrorFactory.ThrowIfError(Native.GetExposure(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.GetExposure(_camera.GetHandle(), out int val),
"Failed to get camera exposure value");
return val;
{
get
{
- int val = 0;
-
- CameraErrorFactory.ThrowIfError(Native.GetZoom(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.GetZoom(_camera.GetHandle(), out int val),
"Failed to get zoom level");
return val;
set
{
- CameraErrorFactory.ThrowIfError(Native.SetZoom(_camera.GetHandle(), (int)value),
+ CameraErrorFactory.ThrowIfError(Native.SetZoom(_camera.GetHandle(), value),
"Failed to set zoom level.");
}
}
{
get
{
- int val = 0;
-
- CameraErrorFactory.ThrowIfError(Native.GetImageQuality(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.GetImageQuality(_camera.GetHandle(), out int val),
"Failed to get image quality");
return val;
{
get
{
- CameraFps val = CameraFps.Auto;
-
- CameraErrorFactory.ThrowIfError(Native.GetPreviewFps(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.GetPreviewFps(_camera.GetHandle(), out var val),
"Failed to get camera preview fps");
return val;
{
get
{
- int width = 0;
- int height = 0;
-
- CameraErrorFactory.ThrowIfError(GetPreviewResolution(_camera.GetHandle(), out width, out height),
+ CameraErrorFactory.ThrowIfError(GetPreviewResolution(_camera.GetHandle(), out int width, out int height),
"Failed to get camera preview resolution");
return new Size(width, height);
{
get
{
- int width = 0;
- int height = 0;
-
- CameraErrorFactory.ThrowIfError(GetRecommendedPreviewResolution(_camera.GetHandle(), out width, out height),
+ CameraErrorFactory.ThrowIfError(GetRecommendedPreviewResolution(_camera.GetHandle(), out int width, out int height),
"Failed to get recommended preview resolution");
return new Size(width, height);
{
get
{
- CameraPixelFormat val = 0;
-
- CameraErrorFactory.ThrowIfError(GetPreviewPixelFormat(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(GetPreviewPixelFormat(_camera.GetHandle(), out var val),
"Failed to get preview format");
return val;
{
get
{
- int width = 0;
- int height = 0;
-
- CameraErrorFactory.ThrowIfError(GetCaptureResolution(_camera.GetHandle(), out width, out height),
+ CameraErrorFactory.ThrowIfError(GetCaptureResolution(_camera.GetHandle(), out int width, out int height),
"Failed to get camera capture resolution");
return new Size(width, height);
{
get
{
- CameraPixelFormat val = CameraPixelFormat.Invalid;
-
- CameraErrorFactory.ThrowIfError(GetCaptureFormat(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(GetCaptureFormat(_camera.GetHandle(), out var val),
"Failed to get camera capture formats");
return val;
{
get
{
- int val = 0;
-
- CameraErrorFactory.ThrowIfError(Native.GetBitrate(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.GetBitrate(_camera.GetHandle(), out int val),
"Failed to get preview bitrate");
return val;
set
{
- CameraErrorFactory.ThrowIfError(Native.SetBitrate(_camera.GetHandle(), (int)value),
+ CameraErrorFactory.ThrowIfError(Native.SetBitrate(_camera.GetHandle(), value),
"Failed to set encoded preview bitrate.");
}
}
{
get
{
- int val = 0;
-
- CameraErrorFactory.ThrowIfError(Native.GetGopInterval(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.GetGopInterval(_camera.GetHandle(), out int val),
"Failed to get preview gop interval");
return val;
set
{
- CameraErrorFactory.ThrowIfError(Native.SetGopInterval(_camera.GetHandle(), (int)value),
+ CameraErrorFactory.ThrowIfError(Native.SetGopInterval(_camera.GetHandle(), value),
"Failed to set encoded preview gop intervals.");
}
}
{
get
{
- CameraTheaterMode val = CameraTheaterMode.Disable;
-
- CameraErrorFactory.ThrowIfError(Native.GetTheaterMode(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.GetTheaterMode(_camera.GetHandle(), out var val),
"Failed to get camera theater mode");
return val;
{
get
{
- CameraEffectMode val = CameraEffectMode.None;
-
- CameraErrorFactory.ThrowIfError(Native.GetEffect(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.GetEffect(_camera.GetHandle(), out var val),
"Failed to get camera effect");
return val;
{
get
{
- CameraSceneMode val = CameraSceneMode.Normal;
-
- CameraErrorFactory.ThrowIfError(Native.GetSceneMode(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.GetSceneMode(_camera.GetHandle(), out var val),
"Failed to get camera scene mode");
return val;
{
get
{
- CameraFlashMode val = CameraFlashMode.Off;
-
- CameraErrorFactory.ThrowIfError(Native.GetFlashMode(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.GetFlashMode(_camera.GetHandle(), out var val),
"Failed to get camera flash mode");
return val;
{
get
{
- int val = 0;
-
- CameraErrorFactory.ThrowIfError(Native.GetLensOrientation(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.GetLensOrientation(_camera.GetHandle(), out var val),
"Failed to get camera lens orientation");
return val;
{
get
{
- CameraRotation val = CameraRotation.None;
-
- CameraErrorFactory.ThrowIfError(Native.GetStreamRotation(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.GetStreamRotation(_camera.GetHandle(), out var val),
"Failed to get camera stream rotation");
return val;
{
get
{
- CameraFlip val = CameraFlip.None;
-
- CameraErrorFactory.ThrowIfError(Native.GetFlip(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.GetFlip(_camera.GetHandle(), out var val),
"Failed to get camera stream flip");
return val;
{
get
{
- CameraHdrMode val = 0;
-
- CameraErrorFactory.ThrowIfError(Native.GetHdrMode(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.GetHdrMode(_camera.GetHandle(), out var val),
"Failed to get camera hdr mode");
return val;
{
get
{
- bool val = false;
-
- CameraErrorFactory.ThrowIfError(Native.IsEnabledAntiShake(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.IsEnabledAntiShake(_camera.GetHandle(), out bool val),
"Failed to get camera anti shake value");
return val;
{
get
{
- bool val = false;
-
- CameraErrorFactory.ThrowIfError(Native.IsEnabledVideoStabilization(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.IsEnabledVideoStabilization(_camera.GetHandle(), out bool val),
"Failed to get camera video stabilization");
return val;
set
{
ValidationUtil.ValidateEnum(typeof(CameraPtzType), value);
- CameraErrorFactory.ThrowIfError(Native.SetPtzType(_camera.GetHandle(), (int)value),
+
+ CameraErrorFactory.ThrowIfError(Native.SetPtzType(_camera.GetHandle(), value),
"Failed to set camera ptz type.");
}
}
/// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
public int GetPan()
{
- int val = 0;
-
- CameraErrorFactory.ThrowIfError(Native.GetPan(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.GetPan(_camera.GetHandle(), out int val),
"Failed to get the camera pan step.");
return val;
/// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
public int GetTilt()
{
- int val = 0;
-
- CameraErrorFactory.ThrowIfError(Native.GetTilt(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.GetTilt(_camera.GetHandle(), out int val),
"Failed to set the camera current position.");
return val;
{
get
{
- bool val = false;
-
- CameraErrorFactory.ThrowIfError(Native.IsEnabledTag(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.IsEnabledTag(_camera.GetHandle(), out bool val),
"Failed to get camera enable tag");
return val;
{
get
{
- double latitude = 0.0;
- double longitude = 0.0;
- double altitude = 0.0;
-
- CameraErrorFactory.ThrowIfError(Native.GetGeotag(_camera.GetHandle(), out latitude, out longitude, out altitude),
- "Failed to get tag");
+ CameraErrorFactory.ThrowIfError(Native.GetGeotag(_camera.GetHandle(),
+ out double latitude, out double longitude, out double altitude), "Failed to get tag");
return new Location(latitude, longitude, altitude);
}
{
get
{
- CameraTagOrientation val = 0;
-
- CameraErrorFactory.ThrowIfError(Native.GetTagOrientation(_camera.GetHandle(), out val),
+ CameraErrorFactory.ThrowIfError(Native.GetTagOrientation(_camera.GetHandle(), out var val),
"Failed to get camera tag orientation");
return val;