throw new NotSupportedException("Camera feature is not supported.");
}
- CameraErrorFactory.ThrowIfError(Native.Create(device, out _handle),
- "Failed to create camera instance");
+ Native.Create(device, out _handle).ThrowIfFailed("Failed to create camera instance");
Capabilities = new CameraCapabilities(this);
Settings = new CameraSettings(this);
throw new ArgumentException("The display has already been assigned to another.");
}
- CameraErrorFactory.ThrowIfError(SetDisplay(value), "Failed to set the camera display");
+ SetDisplay(value).ThrowIfFailed("Failed to set the camera display");
ReplaceDisplay(value);
}
ValidateNotDisposed();
CameraState val = CameraState.None;
- CameraErrorFactory.ThrowIfError(Native.GetState(_handle, out val),
- "Failed to get camera state");
+
+ Native.GetState(_handle, out val).ThrowIfFailed("Failed to get camera state");
return val;
}
{
ValidateNotDisposed();
- CameraErrorFactory.ThrowIfError(Native.GetDisplayReuseHint(_handle, out bool val),
- "Failed to get camera display reuse hint");
+ Native.GetDisplayReuseHint(_handle, out bool val).ThrowIfFailed("Failed to get camera display reuse hint");
return val;
}
{
ValidateState(CameraState.Preview);
- CameraErrorFactory.ThrowIfError(Native.SetDisplayReuseHint(_handle, value),
- "Failed to set display reuse hint.");
+ Native.SetDisplayReuseHint(_handle, value).ThrowIfFailed("Failed to set display reuse hint.");
}
}
{
ValidateNotDisposed();
- CameraErrorFactory.ThrowIfError(Native.GetFacingDirection(_handle, out var val),
- "Failed to get camera direction");
+ Native.GetFacingDirection(_handle, out var val).ThrowIfFailed("Failed to get camera direction");
return val;
}
{
ValidateNotDisposed();
- CameraErrorFactory.ThrowIfError(Native.GetDeviceCount(_handle, out int val),
- "Failed to get camera device count");
+ Native.GetDeviceCount(_handle, out int val).ThrowIfFailed("Failed to get camera device count");
return val;
}
ValidateState(CameraState.Created);
ValidationUtil.ValidateEnum(typeof(CameraDevice), device, nameof(device));
- CameraErrorFactory.ThrowIfError(Native.ChangeDevice(_handle, device),
- "Failed to change the camera device");
+ Native.ChangeDevice(_handle, device).ThrowIfFailed("Failed to change the camera device");
}
/// <summary>
{
ValidationUtil.ValidateEnum(typeof(CameraDevice), device, nameof(device));
- CameraErrorFactory.ThrowIfError(Native.GetDeviceState(device, out var val),
- "Failed to get the camera device state.");
+ Native.GetDeviceState(device, out var val).ThrowIfFailed("Failed to get the camera device state.");
return val;
}
{
ValidationUtil.ValidateEnum(typeof(CameraDevice), device, nameof(device));
- CameraErrorFactory.ThrowIfError(Native.GetFlashState(device, out var val),
- "Failed to get camera flash state");
+ Native.GetFlashState(device, out var val).ThrowIfFailed("Failed to get camera flash state");
return val;
}
{
ValidateState(CameraState.Created, CameraState.Captured);
- CameraErrorFactory.ThrowIfError(Native.StartPreview(_handle),
- "Failed to start the camera preview.");
+ Native.StartPreview(_handle).ThrowIfFailed("Failed to start the camera preview.");
// Update by StateChangedCallback can be delayed for dozens of milliseconds.
SetState(CameraState.Preview);
{
ValidateState(CameraState.Preview);
- CameraErrorFactory.ThrowIfError(Native.StopPreview(_handle),
- "Failed to stop the camera preview.");
+ Native.StopPreview(_handle).ThrowIfFailed("Failed to stop the camera preview.");
SetState(CameraState.Created);
}
{
ValidateState(CameraState.Preview);
- CameraErrorFactory.ThrowIfError(Native.StartCapture(_handle, _capturingCallback, _captureCompletedCallback, IntPtr.Zero),
- "Failed to start the camera capture.");
+ Native.StartCapture(_handle, _capturingCallback, _captureCompletedCallback, IntPtr.Zero).
+ ThrowIfFailed("Failed to start the camera capture.");
SetState(CameraState.Capturing);
}
{
cancellationToken.Register(() =>
{
- CameraErrorFactory.ThrowIfError(Native.StopContinuousCapture(_handle),
- "Failed to cancel the continuous capture");
+ Native.StopContinuousCapture(_handle).ThrowIfFailed("Failed to cancel the continuous capture");
SetState(CameraState.Captured);
});
}
- CameraErrorFactory.ThrowIfError(Native.StartContinuousCapture(_handle, count, interval,
- _capturingCallback, _captureCompletedCallback, IntPtr.Zero), "Failed to start the continuous capture.");
+ Native.StartContinuousCapture(_handle, count, interval, _capturingCallback, _captureCompletedCallback, IntPtr.Zero).
+ ThrowIfFailed("Failed to start the continuous capture.");
SetState(CameraState.Capturing);
}
{
ValidateState(CameraState.Preview, CameraState.Captured);
- CameraErrorFactory.ThrowIfError(Native.StartFocusing(_handle, continuous),
- "Failed to cancel the camera focus.");
+ Native.StartFocusing(_handle, continuous).ThrowIfFailed("Failed to cancel the camera focus.");
}
/// <summary>
{
ValidateState(CameraState.Preview, CameraState.Captured);
- CameraErrorFactory.ThrowIfError(Native.CancelFocusing(_handle),
- "Failed to cancel the camera focus.");
+ Native.CancelFocusing(_handle).ThrowIfFailed("Failed to cancel the camera focus.");
}
/// <summary>
FaceDetected?.Invoke(this, new FaceDetectedEventArgs(result));
};
- CameraErrorFactory.ThrowIfError(Native.StartFaceDetection(_handle, _faceDetectedCallback, IntPtr.Zero),
- "Failed to start face detection");
+
+ Native.StartFaceDetection(_handle, _faceDetectedCallback, IntPtr.Zero).
+ ThrowIfFailed("Failed to start face detection");
}
/// <summary>
throw new InvalidOperationException("The face detection is not started.");
}
- CameraErrorFactory.ThrowIfError(Native.StopFaceDetection(_handle),
- "Failed to stop the face detection.");
+ Native.StopFaceDetection(_handle).ThrowIfFailed("Failed to stop the face detection.");
_faceDetectedCallback = null;
}
{
InterruptStarted?.Invoke(this, new CameraInterruptStartedEventArgs(policy, state));
};
- CameraErrorFactory.ThrowIfError(Native.SetInterruptStartedCallback(_handle, _interruptStartedCallback, IntPtr.Zero),
- "Failed to set interrupt callback");
+
+ Native.SetInterruptStartedCallback(_handle, _interruptStartedCallback, IntPtr.Zero).
+ ThrowIfFailed("Failed to set interrupt callback");
}
private void RegisterInterruptedCallback()
{
Interrupted?.Invoke(this, new CameraInterruptedEventArgs(policy, previous, current));
};
- CameraErrorFactory.ThrowIfError(Native.SetInterruptedCallback(_handle, _interruptedCallback, IntPtr.Zero),
- "Failed to set interrupt callback");
+
+ Native.SetInterruptedCallback(_handle, _interruptedCallback, IntPtr.Zero).
+ ThrowIfFailed("Failed to set interrupt callback");
}
private void RegisterErrorCallback()
{
ErrorOccurred?.Invoke(this, new CameraErrorOccurredEventArgs(error, current));
};
- CameraErrorFactory.ThrowIfError(Native.SetErrorCallback(_handle, _errorCallback, IntPtr.Zero),
- "Setting error callback failed");
+
+ Native.SetErrorCallback(_handle, _errorCallback, IntPtr.Zero).ThrowIfFailed("Setting error callback failed");
}
private void RegisterStateChangedCallback()
Log.Info(CameraLog.Tag, "Camera state changed " + previous.ToString() + " -> " + current.ToString());
StateChanged?.Invoke(this, new CameraStateChangedEventArgs(previous, current, byPolicy));
};
- CameraErrorFactory.ThrowIfError(Native.SetStateChangedCallback(_handle, _stateChangedCallback, IntPtr.Zero),
- "Setting state changed callback failed");
+
+ Native.SetStateChangedCallback(_handle, _stateChangedCallback, IntPtr.Zero).
+ ThrowIfFailed("Setting state changed callback failed");
}
private static void RegisterDeviceStateChangedCallback()
_deviceStateChanged?.Invoke(null, new CameraDeviceStateChangedEventArgs(device, state));
};
- CameraErrorFactory.ThrowIfError(Native.SetDeviceStateChangedCallback(_deviceStateChangedCallback, IntPtr.Zero, out _deviceStateCallbackId),
- "Failed to set device state changed callback");
+ Native.SetDeviceStateChangedCallback(_deviceStateChangedCallback, IntPtr.Zero, out _deviceStateCallbackId).
+ ThrowIfFailed("Failed to set device state changed callback");
Log.Info(CameraLog.Tag, "add callbackId " + _deviceStateCallbackId.ToString());
}
private static void UnregisterDeviceStateChangedCallback()
{
- CameraErrorFactory.ThrowIfError(Native.UnsetDeviceStateChangedCallback(_deviceStateCallbackId),
- "Unsetting device state changed callback failed");
+ Native.UnsetDeviceStateChangedCallback(_deviceStateCallbackId).
+ ThrowIfFailed("Unsetting device state changed callback failed");
+
_deviceStateChangedCallback = null;
_deviceStateCallbackId = 0;
}
{
FocusStateChanged?.Invoke(this, new CameraFocusStateChangedEventArgs(state));
};
- CameraErrorFactory.ThrowIfError(Native.SetFocusStateChangedCallback(_handle, _focusStateChangedCallback, IntPtr.Zero),
- "Setting focus changed callback failed");
+
+ Native.SetFocusStateChangedCallback(_handle, _focusStateChangedCallback, IntPtr.Zero).
+ ThrowIfFailed("Setting focus changed callback failed");
}
private void RegisterHdrCaptureProgress()
{
_hdrCaptureProgress?.Invoke(this, new HdrCaptureProgressEventArgs(percent));
};
- CameraErrorFactory.ThrowIfError(Native.SetHdrCaptureProgressCallback(_handle, _hdrCaptureProgressCallback, IntPtr.Zero),
- "Setting Hdr capture progress callback failed");
+
+ Native.SetHdrCaptureProgressCallback(_handle, _hdrCaptureProgressCallback, IntPtr.Zero).
+ ThrowIfFailed("Setting Hdr capture progress callback failed");
}
private void UnregisterHdrCaptureProgress()
{
- CameraErrorFactory.ThrowIfError(Native.UnsetHdrCaptureProgressCallback(_handle),
- "Unsetting hdr capture progress is failed");
+ Native.UnsetHdrCaptureProgressCallback(_handle).
+ ThrowIfFailed("Unsetting hdr capture progress is failed");
+
_hdrCaptureProgressCallback = null;
}
{
_preview?.Invoke(this, new PreviewEventArgs(new PreviewFrame(frame)));
};
- CameraErrorFactory.ThrowIfError(Native.SetPreviewCallback(_handle, _previewCallback, IntPtr.Zero),
- "Setting preview callback failed");
+
+ Native.SetPreviewCallback(_handle, _previewCallback, IntPtr.Zero).
+ ThrowIfFailed("Setting preview callback failed");
}
private void UnregisterPreviewCallback()
{
- CameraErrorFactory.ThrowIfError(Native.UnsetPreviewCallback(_handle),
- "Unsetting preview callback failed");
+ Native.UnsetPreviewCallback(_handle).ThrowIfFailed("Unsetting preview callback failed");
+
_previewCallback = null;
}
packet.Dispose();
};
- CameraErrorFactory.ThrowIfError(Native.SetMediaPacketPreviewCallback(_handle, _mediaPacketPreviewCallback, IntPtr.Zero),
- "Setting media packet preview callback failed");
+
+ Native.SetMediaPacketPreviewCallback(_handle, _mediaPacketPreviewCallback, IntPtr.Zero).
+ ThrowIfFailed("Setting media packet preview callback failed");
}
private void UnregisterMediaPacketPreviewCallback()
{
- CameraErrorFactory.ThrowIfError(Native.UnsetMediaPacketPreviewCallback(_handle),
- "Unsetting media packet preview callback failed");
+ Native.UnsetMediaPacketPreviewCallback(_handle).
+ ThrowIfFailed("Unsetting media packet preview callback failed");
+
_mediaPacketPreviewCallback = null;
}
#endregion Callback registrations
private bool CheckRangeValid(GetRangeDelegate func)
{
- CameraErrorFactory.ThrowIfError(func(_camera.GetHandle(), out int min, out int max),
- "Failed to check feature is suported or not.");
+ func(_camera.GetHandle(), out int min, out int max).
+ ThrowIfFailed("Failed to check feature is suported or not.");
return min < max;
}
previewResolutions.Add(new Size(width, height));
return true;
};
- CameraErrorFactory.ThrowIfError(NativeCapabilities.SupportedPreviewResolutions(_camera.GetHandle(), callback, IntPtr.Zero),
- "Failed to get the supported preview resolutions");
+
+ NativeCapabilities.SupportedPreviewResolutions(_camera.GetHandle(), callback, IntPtr.Zero).
+ ThrowIfFailed("Failed to get the supported preview resolutions");
return previewResolutions.AsReadOnly();
}
cameraResolutions.Add(new Size(width, height));
return true;
};
- CameraErrorFactory.ThrowIfError(NativeCapabilities.SupportedCaptureResolutions(_camera.GetHandle(), callback, IntPtr.Zero),
- "Failed to get the supported capture resolutions");
+
+ NativeCapabilities.SupportedCaptureResolutions(_camera.GetHandle(), callback, IntPtr.Zero).
+ ThrowIfFailed("Failed to get the supported capture resolutions");
return cameraResolutions.AsReadOnly();
}
captureFormats.Add(format);
return true;
};
- CameraErrorFactory.ThrowIfError(NativeCapabilities.SupportedCapturePixelFormats(_camera.GetHandle(), callback, IntPtr.Zero),
- "Failed to get the supported capture formats.");
+
+ NativeCapabilities.SupportedCapturePixelFormats(_camera.GetHandle(), callback, IntPtr.Zero).
+ ThrowIfFailed("Failed to get the supported capture formats.");
return captureFormats.AsReadOnly();
}
previewFormats.Add(format);
return true;
};
- CameraErrorFactory.ThrowIfError(NativeCapabilities.SupportedPreviewPixelFormats(_camera.GetHandle(), callback, IntPtr.Zero),
- "Failed to get the supported preview formats.");
+
+ NativeCapabilities.SupportedPreviewPixelFormats(_camera.GetHandle(), callback, IntPtr.Zero).
+ ThrowIfFailed("Failed to get the supported preview formats.");
return previewFormats.AsReadOnly();
}
previewFps.Add(fps);
return true;
};
- CameraErrorFactory.ThrowIfError(NativeCapabilities.SupportedPreviewFps(_camera.GetHandle(), callback, IntPtr.Zero),
- "Failed to get the supported camera fps");
+
+ NativeCapabilities.SupportedPreviewFps(_camera.GetHandle(), callback, IntPtr.Zero).
+ ThrowIfFailed("Failed to get the supported camera fps");
return previewFps.AsReadOnly();
}
fpsByResolution.Add(fps);
return true;
};
- CameraErrorFactory.ThrowIfError(NativeCapabilities.SupportedPreviewFpsByResolution(_camera.GetHandle(),
- width, height, callback, IntPtr.Zero), "Failed to get the supported fps by resolutions.");
+
+ NativeCapabilities.SupportedPreviewFpsByResolution(_camera.GetHandle(), width, height, callback, IntPtr.Zero).
+ ThrowIfFailed("Failed to get the supported fps by resolutions.");
return fpsByResolution.AsReadOnly();
}
autoFocusModes.Add(mode);
return true;
};
- CameraErrorFactory.ThrowIfError(NativeCapabilities.SupportedAutoFocusModes(_camera.GetHandle(), callback, IntPtr.Zero),
- "Failed to get the supported Auto focus modes.");
+
+ NativeCapabilities.SupportedAutoFocusModes(_camera.GetHandle(), callback, IntPtr.Zero).
+ ThrowIfFailed("Failed to get the supported Auto focus modes.");
return autoFocusModes.AsReadOnly();
}
exposureModes.Add(mode);
return true;
};
- CameraErrorFactory.ThrowIfError(NativeCapabilities.SupportedExposureModes(_camera.GetHandle(), callback, IntPtr.Zero),
- "Failed to get the supported Exposure modes.");
+
+ NativeCapabilities.SupportedExposureModes(_camera.GetHandle(), callback, IntPtr.Zero).
+ ThrowIfFailed("Failed to get the supported Exposure modes.");
return exposureModes.AsReadOnly();
}
isoLevels.Add(iso);
return true;
};
- CameraErrorFactory.ThrowIfError(NativeCapabilities.SupportedIso(_camera.GetHandle(), callback, IntPtr.Zero),
- "Failed to get the supported Iso levels.");
+
+ NativeCapabilities.SupportedIso(_camera.GetHandle(), callback, IntPtr.Zero).
+ ThrowIfFailed("Failed to get the supported Iso levels.");
return isoLevels.AsReadOnly();
}
theaterModes.Add(theaterMode);
return true;
};
- CameraErrorFactory.ThrowIfError(NativeCapabilities.SupportedTheaterModes(_camera.GetHandle(), callback, IntPtr.Zero),
- "Failed to get the supported theater modes.");
+
+ NativeCapabilities.SupportedTheaterModes(_camera.GetHandle(), callback, IntPtr.Zero).
+ ThrowIfFailed("Failed to get the supported theater modes.");
return theaterModes.AsReadOnly();
}
whitebalances.Add(whiteBalance);
return true;
};
- CameraErrorFactory.ThrowIfError(NativeCapabilities.SupportedWhitebalance(_camera.GetHandle(), callback, IntPtr.Zero),
- "Failed to get the supported white balance.");
+
+ NativeCapabilities.SupportedWhitebalance(_camera.GetHandle(), callback, IntPtr.Zero).
+ ThrowIfFailed("Failed to get the supported white balance.");
return whitebalances.AsReadOnly();
}
flashModes.Add(flashMode);
return true;
};
- CameraErrorFactory.ThrowIfError(NativeCapabilities.SupportedFlashModes(_camera.GetHandle(), callback, IntPtr.Zero),
- "Failed to get the supported flash modes.");
+
+ NativeCapabilities.SupportedFlashModes(_camera.GetHandle(), callback, IntPtr.Zero).
+ ThrowIfFailed("Failed to get the supported flash modes.");
return flashModes.AsReadOnly();
}
sceneModes.Add(sceneMode);
return true;
};
- CameraErrorFactory.ThrowIfError(NativeCapabilities.SupportedSceneModes(_camera.GetHandle(), callback, IntPtr.Zero),
- "Failed to get the supported scene modes.");
+
+ NativeCapabilities.SupportedSceneModes(_camera.GetHandle(), callback, IntPtr.Zero).
+ ThrowIfFailed("Failed to get the supported scene modes.");
return sceneModes.AsReadOnly();
}
effectModes.Add(effect);
return true;
};
- CameraErrorFactory.ThrowIfError(NativeCapabilities.SupportedEffects(_camera.GetHandle(), callback, IntPtr.Zero),
- "Failed to get the supported camera effects.");
+
+ NativeCapabilities.SupportedEffects(_camera.GetHandle(), callback, IntPtr.Zero).
+ ThrowIfFailed("Failed to get the supported camera effects.");
return effectModes.AsReadOnly();
}
streamRotations.Add(streamRotation);
return true;
};
- CameraErrorFactory.ThrowIfError(NativeCapabilities.SupportedStreamRotations(_camera.GetHandle(), callback, IntPtr.Zero),
- "Failed to get the supported camera rotations.");
+
+ NativeCapabilities.SupportedStreamRotations(_camera.GetHandle(), callback, IntPtr.Zero).
+ ThrowIfFailed("Failed to get the supported camera rotations.");
return streamRotations.AsReadOnly();
}
streamFlips.Add(streamFlip);
return true;
};
- CameraErrorFactory.ThrowIfError(NativeCapabilities.SupportedStreamFlips(_camera.GetHandle(), callback, IntPtr.Zero),
- "Failed to get the supported camera flips.");
+
+ NativeCapabilities.SupportedStreamFlips(_camera.GetHandle(), callback, IntPtr.Zero).
+ ThrowIfFailed("Failed to get the supported camera flips.");
return streamFlips.AsReadOnly();
}
ptzTypes.Add(ptzType);
return true;
};
- CameraErrorFactory.ThrowIfError(NativeCapabilities.SupportedPtzTypes(_camera.GetHandle(), callback, IntPtr.Zero),
- "Failed to get the supported Ptz types.");
+
+ NativeCapabilities.SupportedPtzTypes(_camera.GetHandle(), callback, IntPtr.Zero).
+ ThrowIfFailed("Failed to get the supported Ptz types.");
return ptzTypes.AsReadOnly();
}
private delegate CameraError GetRangeDelegate(IntPtr handle, out int min, out int max);
private Range? GetRange(GetRangeDelegate func)
{
- CameraErrorFactory.ThrowIfError(func(_camera.GetHandle(), out int min, out int max),
- "Failed to initialize the camera settings");
+ func(_camera.GetHandle(), out int min, out int max).
+ ThrowIfFailed("Failed to initialize the camera settings");
if (min > max)
{
/// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
public void SetAutoFocusArea(int x, int y)
{
- CameraErrorFactory.ThrowIfError(Native.SetAutoFocusArea(_camera.GetHandle(), x, y),
- "Failed to set the autofocus area.");
+ Native.SetAutoFocusArea(_camera.GetHandle(), x, y).
+ ThrowIfFailed("Failed to set the autofocus area.");
}
/// <summary>
/// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
public void SetAutoFocusArea(Point pos)
{
- CameraErrorFactory.ThrowIfError(Native.SetAutoFocusArea(_camera.GetHandle(), pos.X, pos.Y),
- "Failed to set the autofocus area.");
+ Native.SetAutoFocusArea(_camera.GetHandle(), pos.X, pos.Y).
+ ThrowIfFailed("Failed to set the autofocus area.");
}
/// <summary>
/// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
public void ClearFocusArea()
{
- CameraErrorFactory.ThrowIfError(Native.ClearAutoFocusArea(_camera.GetHandle()),
- "Failed to clear the autofocus area.");
+ Native.ClearAutoFocusArea(_camera.GetHandle()).
+ ThrowIfFailed("Failed to clear the autofocus area.");
}
/// <summary>
{
CameraAutoFocusMode val = CameraAutoFocusMode.None;
- CameraErrorFactory.ThrowIfError(Native.GetAutoFocusMode(_camera.GetHandle(), out val),
- "Failed to get camera autofocus mode");
+ Native.GetAutoFocusMode(_camera.GetHandle(), out val).
+ ThrowIfFailed("Failed to get camera autofocus mode");
return val;
}
{
ValidationUtil.ValidateEnum(typeof(CameraAutoFocusMode), value, nameof(value));
- CameraErrorFactory.ThrowIfError(Native.SetAutoFocusMode(_camera.GetHandle(), value),
- "Failed to set camera autofocus mode.");
+ Native.SetAutoFocusMode(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera autofocus mode.");
}
}
#endregion Auto Focus
{
get
{
- CameraErrorFactory.ThrowIfError(Native.GetContrast(_camera.GetHandle(), out int val),
- "Failed to get camera contrast value");
+ Native.GetContrast(_camera.GetHandle(), out int val).
+ ThrowIfFailed("Failed to get camera contrast value");
return val;
}
set
{
- CameraErrorFactory.ThrowIfError(Native.SetContrast(_camera.GetHandle(), value),
- "Failed to set camera contrast value.");
+ Native.SetContrast(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera contrast value.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(Native.IsEnabledAutoContrast(_camera.GetHandle(), out bool val),
- "Failed to get camera auto contrast");
+ Native.IsEnabledAutoContrast(_camera.GetHandle(), out bool val).
+ ThrowIfFailed("Failed to get camera auto contrast");
return val;
}
set
{
- CameraErrorFactory.ThrowIfError(Native.EnableAutoContrast(_camera.GetHandle(), value),
- "Failed to set camera enable auto contrast.");
+ Native.EnableAutoContrast(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera enable auto contrast.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(Native.GetHue(_camera.GetHandle(), out int val),
- "Failed to get camera hue value");
+ Native.GetHue(_camera.GetHandle(), out int val).
+ ThrowIfFailed("Failed to get camera hue value");
return val;
}
set
{
- CameraErrorFactory.ThrowIfError(Native.SetHue(_camera.GetHandle(), value),
- "Failed to set camera hue value.");
+ Native.SetHue(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera hue value.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(Native.GetBrightness(_camera.GetHandle(), out int val),
- "Failed to get camera brightness value");
+ Native.GetBrightness(_camera.GetHandle(), out int val).
+ ThrowIfFailed("Failed to get camera brightness value");
return val;
}
set
{
- CameraErrorFactory.ThrowIfError(Native.SetBrightness(_camera.GetHandle(), value),
- "Failed to set camera brightness value.");
+ Native.SetBrightness(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera brightness value.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(Native.GetExposure(_camera.GetHandle(), out int val),
- "Failed to get camera exposure value");
+ Native.GetExposure(_camera.GetHandle(), out int val).
+ ThrowIfFailed("Failed to get camera exposure value");
return val;
}
set
{
- CameraErrorFactory.ThrowIfError(Native.SetExposure(_camera.GetHandle(), value),
- "Failed to set camera exposure value.");
+ Native.SetExposure(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera exposure value.");
}
}
{
CameraExposureMode val = CameraExposureMode.Off;
- CameraErrorFactory.ThrowIfError(Native.GetExposureMode(_camera.GetHandle(), out val),
- "Failed to get camera exposure mode");
+ Native.GetExposureMode(_camera.GetHandle(), out val).
+ ThrowIfFailed("Failed to get camera exposure mode");
return val;
}
{
ValidationUtil.ValidateEnum(typeof(CameraExposureMode), value, nameof(value));
- CameraErrorFactory.ThrowIfError(Native.SetExposureMode(_camera.GetHandle(), value),
- "Failed to set camera exposure mode.");
+ Native.SetExposureMode(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera exposure mode.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(Native.GetZoom(_camera.GetHandle(), out int val),
- "Failed to get zoom level");
+ Native.GetZoom(_camera.GetHandle(), out int val).
+ ThrowIfFailed("Failed to get zoom level");
return val;
}
set
{
- CameraErrorFactory.ThrowIfError(Native.SetZoom(_camera.GetHandle(), value),
- "Failed to set zoom level.");
+ Native.SetZoom(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set zoom level.");
}
}
{
CameraWhiteBalance val = CameraWhiteBalance.None;
- CameraErrorFactory.ThrowIfError(Native.GetWhiteBalance(_camera.GetHandle(), out val),
- "Failed to get camera whitebalance");
+ Native.GetWhiteBalance(_camera.GetHandle(), out val).
+ ThrowIfFailed("Failed to get camera whitebalance");
return val;
}
{
ValidationUtil.ValidateEnum(typeof(CameraWhiteBalance), value, nameof(value));
- CameraErrorFactory.ThrowIfError(Native.SetWhitebalance(_camera.GetHandle(), value),
- "Failed to set camera whitebalance.");
+ Native.SetWhitebalance(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera whitebalance.");
}
}
{
CameraIsoLevel val = CameraIsoLevel.Auto;
- CameraErrorFactory.ThrowIfError(Native.GetIso(_camera.GetHandle(), out val),
- "Failed to get camera Iso level");
+ Native.GetIso(_camera.GetHandle(), out val).
+ ThrowIfFailed("Failed to get camera Iso level");
return val;
}
{
ValidationUtil.ValidateEnum(typeof(CameraIsoLevel), value, nameof(value));
- CameraErrorFactory.ThrowIfError(Native.SetIso(_camera.GetHandle(), value),
- "Failed to set camera Iso level.");
+ Native.SetIso(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera Iso level.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(Native.GetImageQuality(_camera.GetHandle(), out int val),
- "Failed to get image quality");
+ Native.GetImageQuality(_camera.GetHandle(), out int val).
+ ThrowIfFailed("Failed to get image quality");
return val;
}
throw new ArgumentException("Valid value is from 1(lowest quality) to 100(highest quality)");
}
- CameraErrorFactory.ThrowIfError(Native.SetImageQuality(_camera.GetHandle(), value),
- "Failed to set image quality.");
+ Native.SetImageQuality(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set image quality.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(Native.GetPreviewFps(_camera.GetHandle(), out var val),
- "Failed to get camera preview fps");
+ Native.GetPreviewFps(_camera.GetHandle(), out var val).
+ ThrowIfFailed("Failed to get camera preview fps");
return val;
}
{
ValidationUtil.ValidateEnum(typeof(CameraFps), value, nameof(value));
- CameraErrorFactory.ThrowIfError(Native.SetPreviewFps(_camera.GetHandle(), value),
- "Failed to set preview fps.");
+ Native.SetPreviewFps(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set preview fps.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(GetPreviewResolution(_camera.GetHandle(), out int width, out int height),
- "Failed to get camera preview resolution");
+ GetPreviewResolution(_camera.GetHandle(), out int width, out int height).
+ ThrowIfFailed("Failed to get camera preview resolution");
return new Size(width, height);
}
set
{
- CameraErrorFactory.ThrowIfError(SetPreviewResolution(_camera.GetHandle(), value.Width, value.Height),
- "Failed to set preview resolution.");
+ SetPreviewResolution(_camera.GetHandle(), value.Width, value.Height).
+ ThrowIfFailed("Failed to set preview resolution.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(GetRecommendedPreviewResolution(_camera.GetHandle(), out int width, out int height),
- "Failed to get recommended preview resolution");
+ GetRecommendedPreviewResolution(_camera.GetHandle(), out int width, out int height).
+ ThrowIfFailed("Failed to get recommended preview resolution");
return new Size(width, height);
}
{
get
{
- CameraErrorFactory.ThrowIfError(GetPreviewPixelFormat(_camera.GetHandle(), out var val),
- "Failed to get preview format");
+ GetPreviewPixelFormat(_camera.GetHandle(), out var val).
+ ThrowIfFailed("Failed to get preview format");
return val;
}
{
ValidationUtil.ValidateEnum(typeof(CameraPixelFormat), value, nameof(value));
- CameraErrorFactory.ThrowIfError(SetPreviewPixelFormat(_camera.GetHandle(), value),
- "Failed to set preview format.");
+ SetPreviewPixelFormat(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set preview format.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(GetCaptureResolution(_camera.GetHandle(), out int width, out int height),
- "Failed to get camera capture resolution");
+ GetCaptureResolution(_camera.GetHandle(), out int width, out int height).
+ ThrowIfFailed("Failed to get camera capture resolution");
return new Size(width, height);
}
{
Size res = value;
- CameraErrorFactory.ThrowIfError(SetCaptureResolution(_camera.GetHandle(), res.Width, res.Height),
- "Failed to set capture resolution.");
+ SetCaptureResolution(_camera.GetHandle(), res.Width, res.Height).
+ ThrowIfFailed("Failed to set capture resolution.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(GetCaptureFormat(_camera.GetHandle(), out var val),
- "Failed to get camera capture formats");
+ GetCaptureFormat(_camera.GetHandle(), out var val).
+ ThrowIfFailed("Failed to get camera capture formats");
return val;
}
{
ValidationUtil.ValidateEnum(typeof(CameraPixelFormat), value, nameof(value));
- CameraErrorFactory.ThrowIfError(SetCaptureFormat(_camera.GetHandle(), value),
- "Failed to set capture format.");
+ SetCaptureFormat(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set capture format.");
}
}
#endregion Resolution, Format, Fps of preview, capture
{
get
{
- CameraErrorFactory.ThrowIfError(Native.GetBitrate(_camera.GetHandle(), out int val),
- "Failed to get preview bitrate");
+ Native.GetBitrate(_camera.GetHandle(), out int val).
+ ThrowIfFailed("Failed to get preview bitrate");
return val;
}
set
{
- CameraErrorFactory.ThrowIfError(Native.SetBitrate(_camera.GetHandle(), value),
- "Failed to set encoded preview bitrate.");
+ Native.SetBitrate(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set encoded preview bitrate.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(Native.GetGopInterval(_camera.GetHandle(), out int val),
- "Failed to get preview gop interval");
+ Native.GetGopInterval(_camera.GetHandle(), out int val).
+ ThrowIfFailed("Failed to get preview gop interval");
return val;
}
set
{
- CameraErrorFactory.ThrowIfError(Native.SetGopInterval(_camera.GetHandle(), value),
- "Failed to set encoded preview gop intervals.");
+ Native.SetGopInterval(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set encoded preview gop intervals.");
}
}
#endregion Encoded preview
{
get
{
- CameraErrorFactory.ThrowIfError(Native.GetTheaterMode(_camera.GetHandle(), out var val),
- "Failed to get camera theater mode");
+ Native.GetTheaterMode(_camera.GetHandle(), out var val).
+ ThrowIfFailed("Failed to get camera theater mode");
return val;
}
{
ValidationUtil.ValidateEnum(typeof(CameraTheaterMode), value, nameof(value));
- CameraErrorFactory.ThrowIfError(Native.SetTheaterMode(_camera.GetHandle(), value),
- "Failed to set camera theater mode.");
+ Native.SetTheaterMode(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera theater mode.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(Native.GetEffect(_camera.GetHandle(), out var val),
- "Failed to get camera effect");
+ Native.GetEffect(_camera.GetHandle(), out var val).
+ ThrowIfFailed("Failed to get camera effect");
return val;
}
{
ValidationUtil.ValidateEnum(typeof(CameraEffectMode), value, nameof(value));
- CameraErrorFactory.ThrowIfError(Native.SetEffect(_camera.GetHandle(), value),
- "Failed to set camera effect.");
+ Native.SetEffect(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera effect.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(Native.GetSceneMode(_camera.GetHandle(), out var val),
- "Failed to get camera scene mode");
+ Native.GetSceneMode(_camera.GetHandle(), out var val).
+ ThrowIfFailed("Failed to get camera scene mode");
return val;
}
{
ValidationUtil.ValidateEnum(typeof(CameraSceneMode), value, nameof(value));
- CameraErrorFactory.ThrowIfError(Native.SetSceneMode(_camera.GetHandle(), value),
- "Failed to set camera scene mode.");
+ Native.SetSceneMode(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera scene mode.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(Native.GetFlashMode(_camera.GetHandle(), out var val),
- "Failed to get camera flash mode");
+ Native.GetFlashMode(_camera.GetHandle(), out var val).
+ ThrowIfFailed("Failed to get camera flash mode");
return val;
}
{
ValidationUtil.ValidateEnum(typeof(CameraFlashMode), value, nameof(value));
- CameraErrorFactory.ThrowIfError(Native.SetFlashMode(_camera.GetHandle(), value),
- "Failed to set camera flash mode.");
+ Native.SetFlashMode(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera flash mode.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(Native.GetLensOrientation(_camera.GetHandle(), out var val),
- "Failed to get camera lens orientation");
+ Native.GetLensOrientation(_camera.GetHandle(), out var val).
+ ThrowIfFailed("Failed to get camera lens orientation");
return val;
}
{
get
{
- CameraErrorFactory.ThrowIfError(Native.GetStreamRotation(_camera.GetHandle(), out var val),
- "Failed to get camera stream rotation");
+ Native.GetStreamRotation(_camera.GetHandle(), out var val).
+ ThrowIfFailed("Failed to get camera stream rotation");
return val;
}
{
ValidationUtil.ValidateEnum(typeof(Rotation), value, nameof(value));
- CameraErrorFactory.ThrowIfError(Native.SetStreamRotation(_camera.GetHandle(), value),
- "Failed to set camera stream rotation.");
+ Native.SetStreamRotation(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera stream rotation.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(Native.GetFlip(_camera.GetHandle(), out var val),
- "Failed to get camera stream flip");
+ Native.GetFlip(_camera.GetHandle(), out var val).
+ ThrowIfFailed("Failed to get camera stream flip");
return val;
}
{
ValidationUtil.ValidateFlagsEnum(value, Flips.Horizontal | Flips.Vertical, nameof(Flips));
- CameraErrorFactory.ThrowIfError(Native.SetFlip(_camera.GetHandle(), value),
- "Failed to set camera flip.");
+ Native.SetFlip(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera flip.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(Native.GetHdrMode(_camera.GetHandle(), out var val),
- "Failed to get camera hdr mode");
+ Native.GetHdrMode(_camera.GetHandle(), out var val).
+ ThrowIfFailed("Failed to get camera hdr mode");
return val;
}
{
ValidationUtil.ValidateEnum(typeof(CameraHdrMode), value, nameof(value));
- CameraErrorFactory.ThrowIfError(Native.SetHdrMode(_camera.GetHandle(), value),
- "Failed to set camera hdr mode.");
+ Native.SetHdrMode(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera hdr mode.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(Native.IsEnabledAntiShake(_camera.GetHandle(), out bool val),
- "Failed to get camera anti shake value");
+ Native.IsEnabledAntiShake(_camera.GetHandle(), out bool val).
+ ThrowIfFailed("Failed to get camera anti shake value");
return val;
}
set
{
- CameraErrorFactory.ThrowIfError(Native.EnableAntiShake(_camera.GetHandle(), value),
- "Failed to set camera anti shake value.");
+ Native.EnableAntiShake(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera anti shake value.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(Native.IsEnabledVideoStabilization(_camera.GetHandle(), out bool val),
- "Failed to get camera video stabilization");
+ Native.IsEnabledVideoStabilization(_camera.GetHandle(), out bool val).
+ ThrowIfFailed("Failed to get camera video stabilization");
return val;
}
set
{
- CameraErrorFactory.ThrowIfError(Native.EnableVideoStabilization(_camera.GetHandle(), value),
- "Failed to set camera video stabilization.");
+ Native.EnableVideoStabilization(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera video stabilization.");
}
}
/// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
public void DisableShutterSound(bool shutterSound)
{
- CameraErrorFactory.ThrowIfError(Native.DisableShutterSound(_camera.GetHandle(), shutterSound),
- "Failed to set disable shutter sound.");
+ Native.DisableShutterSound(_camera.GetHandle(), shutterSound).
+ ThrowIfFailed("Failed to set disable shutter sound.");
}
#region PTZ(Pan Tilt Zoom), Pan, Tilt
{
ValidationUtil.ValidateEnum(typeof(CameraPtzType), value, nameof(value));
- CameraErrorFactory.ThrowIfError(Native.SetPtzType(_camera.GetHandle(), value),
- "Failed to set camera ptz type.");
+ Native.SetPtzType(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera ptz type.");
}
}
{
ValidationUtil.ValidateEnum(typeof(CameraPtzMoveType), type, nameof(type));
- CameraErrorFactory.ThrowIfError(Native.SetPan(_camera.GetHandle(), type, panStep),
- "Failed to set the camera pan type.");
+ Native.SetPan(_camera.GetHandle(), type, panStep).
+ ThrowIfFailed("Failed to set the camera pan type.");
}
/// <summary>
/// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
public int GetPan()
{
- CameraErrorFactory.ThrowIfError(Native.GetPan(_camera.GetHandle(), out int val),
- "Failed to get the camera pan step.");
+ Native.GetPan(_camera.GetHandle(), out int val).
+ ThrowIfFailed("Failed to get the camera pan step.");
return val;
}
public void SetTilt(CameraPtzMoveType type, int tiltStep)
{
ValidationUtil.ValidateEnum(typeof(CameraPtzMoveType), type, nameof(type));
- CameraErrorFactory.ThrowIfError(Native.SetTilt(_camera.GetHandle(), type, tiltStep),
- "Failed to set the camera tilt type\t.");
+
+ Native.SetTilt(_camera.GetHandle(), type, tiltStep).
+ ThrowIfFailed("Failed to set the camera tilt type\t.");
}
/// <summary>
/// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
public int GetTilt()
{
- CameraErrorFactory.ThrowIfError(Native.GetTilt(_camera.GetHandle(), out int val),
- "Failed to set the camera current position.");
+ Native.GetTilt(_camera.GetHandle(), out int val).
+ ThrowIfFailed("Failed to set the camera current position.");
return val;
}
{
get
{
- CameraErrorFactory.ThrowIfError(Native.IsEnabledTag(_camera.GetHandle(), out bool val),
- "Failed to get camera enable tag");
+ Native.IsEnabledTag(_camera.GetHandle(), out bool val).
+ ThrowIfFailed("Failed to get camera enable tag");
return val;
}
set
{
- CameraErrorFactory.ThrowIfError(Native.EnableTag(_camera.GetHandle(), value),
- "Failed to set camera enable tag.");
+ Native.EnableTag(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera enable tag.");
}
}
IntPtr val = IntPtr.Zero;
try
{
- CameraErrorFactory.ThrowIfError(Native.GetImageDescription(_camera.GetHandle(), out val),
- "Failed to get image description");
+ Native.GetImageDescription(_camera.GetHandle(), out val).
+ ThrowIfFailed("Failed to get image description");
return Marshal.PtrToStringAnsi(val);
}
set
{
- CameraErrorFactory.ThrowIfError(Native.SetImageDescription(_camera.GetHandle(), value),
- "Failed to set image description.");
+ Native.SetImageDescription(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set image description.");
}
}
try
{
- CameraErrorFactory.ThrowIfError(Native.GetTagSoftware(_camera.GetHandle(), out val),
- "Failed to get tag software");
+ Native.GetTagSoftware(_camera.GetHandle(), out val).
+ ThrowIfFailed("Failed to get tag software");
return Marshal.PtrToStringAnsi(val);
}
set
{
- CameraErrorFactory.ThrowIfError(Native.SetTagSoftware(_camera.GetHandle(), value),
- "Failed to set tag software.");
+ Native.SetTagSoftware(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set tag software.");
}
}
{
get
{
- CameraErrorFactory.ThrowIfError(Native.GetGeotag(_camera.GetHandle(),
- out double latitude, out double longitude, out double altitude), "Failed to get tag");
+ Native.GetGeotag(_camera.GetHandle(), out double latitude, out double longitude, out double altitude).
+ ThrowIfFailed("Failed to get tag");
return new Location(latitude, longitude, altitude);
}
set
{
- CameraErrorFactory.ThrowIfError(Native.SetGeotag(_camera.GetHandle(),
- value.Latitude, value.Longitude, value.Altitude), "Failed to set geo tag.");
+ Native.SetGeotag(_camera.GetHandle(), value.Latitude, value.Longitude, value.Altitude).
+ ThrowIfFailed("Failed to set geo tag.");
}
}
/// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
public void RemoveGeoTag()
{
- CameraErrorFactory.ThrowIfError(Native.RemoveGeotag(_camera.GetHandle()),
- "Failed to remove the geotag\t.");
+ Native.RemoveGeotag(_camera.GetHandle()).
+ ThrowIfFailed("Failed to remove the geotag.");
}
/// <summary>
{
get
{
- CameraErrorFactory.ThrowIfError(Native.GetTagOrientation(_camera.GetHandle(), out var val),
- "Failed to get camera tag orientation");
+ Native.GetTagOrientation(_camera.GetHandle(), out var val).
+ ThrowIfFailed("Failed to get camera tag orientation");
return val;
}
{
ValidationUtil.ValidateEnum(typeof(CameraTagOrientation), value, nameof(value));
- CameraErrorFactory.ThrowIfError(Native.SetTagOrientation(_camera.GetHandle(), value),
- "Failed to set camera tag orientation.");
+ Native.SetTagOrientation(_camera.GetHandle(), value).
+ ThrowIfFailed("Failed to set camera tag orientation.");
}
}
#endregion EXIF tag