diff --git a/src/cscore/HttpCamera.cs b/src/cscore/HttpCamera.cs index a534245a..20100791 100644 --- a/src/cscore/HttpCamera.cs +++ b/src/cscore/HttpCamera.cs @@ -8,15 +8,15 @@ public class HttpCamera : VideoCamera { private static CsSource CreateHttpCamera(string name, string url, HttpCameraKind kind) { - var source = CsNative.CreateHttpCamera(name, url, kind, out var status); - VideoException.ThrowIfFailed(status); + var source = CsNative.CreateHttpCamera(name, url, kind); + return source; } private static CsSource CreateHttpCamera(string name, ReadOnlySpan urls, HttpCameraKind kind) { - var source = CsNative.CreateHttpCamera(name, urls, kind, out var status); - VideoException.ThrowIfFailed(status); + var source = CsNative.CreateHttpCamera(name, urls, kind); + return source; } @@ -33,22 +33,22 @@ public HttpCameraKind HttpCameraKind { get { - var ret = CsNative.GetHttpCameraKind(Handle, out var status); - VideoException.ThrowIfFailed(status); + var ret = CsNative.GetHttpCameraKind(Handle); + return ret; } } public void SetUrls(ReadOnlySpan urls) { - CsNative.SetHttpCameraUrls(Handle, urls, out var status); - VideoException.ThrowIfFailed(status); + CsNative.SetHttpCameraUrls(Handle, urls); + } public string[] GetUrls() { - var ret = CsNative.GetHttpCameraUrls(Handle, out var status); - VideoException.ThrowIfFailed(status); + var ret = CsNative.GetHttpCameraUrls(Handle); + return ret; } } diff --git a/src/cscore/ImageSink.cs b/src/cscore/ImageSink.cs index 8fd6f9b3..1be03428 100644 --- a/src/cscore/ImageSink.cs +++ b/src/cscore/ImageSink.cs @@ -9,15 +9,15 @@ public abstract class ImageSink(CsSink handle) : VideoSink(handle) { set { - CsNative.SetSinkDescription(Handle, value, out var status); - VideoException.ThrowIfFailed(status); + CsNative.SetSinkDescription(Handle, value); + } } public string GetError() { - CsNative.GetSinkError(Handle, out var error, out var status); - VideoException.ThrowIfFailed(status); + CsNative.GetSinkError(Handle, out var error); + return error; } @@ -25,8 +25,8 @@ public bool Enabled { set { - CsNative.SetSinkEnabled(Handle, value, out var status); - VideoException.ThrowIfFailed(status); + CsNative.SetSinkEnabled(Handle, value); + } } } diff --git a/src/cscore/ImageSource.cs b/src/cscore/ImageSource.cs index da56175c..f444dd11 100644 --- a/src/cscore/ImageSource.cs +++ b/src/cscore/ImageSource.cs @@ -9,16 +9,16 @@ public abstract class ImageSource(CsSource handle) : VideoSource(handle) { public void NotifyError(string msg) { - CsNative.NotifySourceError(Handle, msg, out var status); - VideoException.ThrowIfFailed(status); + CsNative.NotifySourceError(Handle, msg); + } public bool Connected { set { - CsNative.SetSourceConnected(Handle, value, out var status); - VideoException.ThrowIfFailed(status); + CsNative.SetSourceConnected(Handle, value); + } } @@ -26,36 +26,36 @@ public bool Connected { set { - CsNative.SetSourceDescription(Handle, value, out var status); - VideoException.ThrowIfFailed(status); + CsNative.SetSourceDescription(Handle, value); + } } public VideoProperty CreateProperty(string name, PropertyKind kind, int minimum, int maximum, int step, int defaultValue, int value) { - var property = CsNative.CreateSourceProperty(Handle, name, kind, minimum, maximum, step, defaultValue, value, out var status); - VideoException.ThrowIfFailed(status); + var property = CsNative.CreateSourceProperty(Handle, name, kind, minimum, maximum, step, defaultValue, value); + return new VideoProperty(property); } public VideoProperty CreateIntegerProperty(string name, int minimum, int maximum, int step, int defaultValue, int value) { - var property = CsNative.CreateSourceProperty(Handle, name, PropertyKind.Integer, minimum, maximum, step, defaultValue, value, out var status); - VideoException.ThrowIfFailed(status); + var property = CsNative.CreateSourceProperty(Handle, name, PropertyKind.Integer, minimum, maximum, step, defaultValue, value); + return new VideoProperty(property); } public VideoProperty CreateBooleanProperty(string name, bool defaultValue, bool value) { - var property = CsNative.CreateSourceProperty(Handle, name, PropertyKind.Boolean, 0, 1, 1, defaultValue ? 1 : 0, value ? 1 : 0, out var status); - VideoException.ThrowIfFailed(status); + var property = CsNative.CreateSourceProperty(Handle, name, PropertyKind.Boolean, 0, 1, 1, defaultValue ? 1 : 0, value ? 1 : 0); + return new VideoProperty(property); } public VideoProperty CreateStringProperty(string name, string value) { - var property = CsNative.CreateSourceProperty(Handle, name, PropertyKind.String, 0, 0, 0, 0, 0, out var status); - VideoException.ThrowIfFailed(status); + var property = CsNative.CreateSourceProperty(Handle, name, PropertyKind.String, 0, 0, 0, 0, 0); + return new VideoProperty(property) { StringValue = value @@ -64,7 +64,6 @@ public VideoProperty CreateStringProperty(string name, string value) public void SetEnumPropertyChoices(VideoProperty property, ReadOnlySpan choices) { - CsNative.SetSourceEnumPropertyChoices(Handle, property.Handle, choices, out var status); - VideoException.ThrowIfFailed(status); + CsNative.SetSourceEnumPropertyChoices(Handle, property.Handle, choices); } } diff --git a/src/cscore/MJpegServer.cs b/src/cscore/MJpegServer.cs index 021c7444..b7681e07 100644 --- a/src/cscore/MJpegServer.cs +++ b/src/cscore/MJpegServer.cs @@ -7,8 +7,8 @@ public class MJpegServer : VideoSink { private static CsSink CreateMJpegServer(string name, string listenAddress, int port) { - var ret = CsNative.CreateMjpegServer(name, listenAddress, port, out var status); - VideoException.ThrowIfFailed(status); + var ret = CsNative.CreateMjpegServer(name, listenAddress, port); + return ret; } @@ -24,8 +24,7 @@ public string ListenAddress { get { - CsNative.GetMjpegServerListenAddress(Handle, out var address, out var status); - VideoException.ThrowIfFailed(status); + CsNative.GetMjpegServerListenAddress(Handle, out var address); return address; } } @@ -34,46 +33,35 @@ public int Port { get { - int port = CsNative.GetMjpegServerPort(Handle, out var status); - VideoException.ThrowIfFailed(status); + int port = CsNative.GetMjpegServerPort(Handle); return port; } } public void SetResolution(int width, int height) { - CsProperty prop = CsNative.GetSinkProperty(Handle, "width"u8, out var status); - VideoException.ThrowIfFailed(status); - CsNative.SetProperty(prop, width, out status); - VideoException.ThrowIfFailed(status); - - prop = CsNative.GetSinkProperty(Handle, "height"u8, out status); - VideoException.ThrowIfFailed(status); - CsNative.SetProperty(prop, height, out status); - VideoException.ThrowIfFailed(status); + CsProperty prop = CsNative.GetSinkProperty(Handle, "width"u8); + CsNative.SetProperty(prop, width); + prop = CsNative.GetSinkProperty(Handle, "height"u8); + CsNative.SetProperty(prop, height); } public void SetFPS(int fps) { - CsProperty prop = CsNative.GetSinkProperty(Handle, "fps"u8, out var status); - VideoException.ThrowIfFailed(status); - CsNative.SetProperty(prop, fps, out status); - VideoException.ThrowIfFailed(status); + CsProperty prop = CsNative.GetSinkProperty(Handle, "fps"u8); + CsNative.SetProperty(prop, fps); } public void SetCompression(int quality) { - CsProperty prop = CsNative.GetSinkProperty(Handle, "compression"u8, out var status); - VideoException.ThrowIfFailed(status); - CsNative.SetProperty(prop, quality, out status); - VideoException.ThrowIfFailed(status); + CsProperty prop = CsNative.GetSinkProperty(Handle, "compression"u8); + CsNative.SetProperty(prop, quality); } public void SetDefaultCompression(int quality) { - CsProperty prop = CsNative.GetSinkProperty(Handle, "default_compression"u8, out var status); - VideoException.ThrowIfFailed(status); - CsNative.SetProperty(prop, quality, out status); - VideoException.ThrowIfFailed(status); + CsProperty prop = CsNative.GetSinkProperty(Handle, "default_compression"u8); + CsNative.SetProperty(prop, quality); + } } diff --git a/src/cscore/Natives/CsNative.cs b/src/cscore/Natives/CsNative.cs index 39ff64f6..9128c2dc 100644 --- a/src/cscore/Natives/CsNative.cs +++ b/src/cscore/Natives/CsNative.cs @@ -89,11 +89,11 @@ public static string[] GetEnumPropertyChoices(CsProperty property, out StatusVal [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial CsSource CreateHttpCamera(WpiString name, WpiString url, HttpCameraKind kind, out StatusValue status); - [AutomateStatusCheck] [LibraryImport("cscore", EntryPoint = "CS_CreateHttpCameraMulti")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial CsSource CreateHttpCamera(WpiString name, [MarshalUsing(typeof(WpiStringMarshaller), ElementIndirectionDepth = 1)] ReadOnlySpan urls, int count, HttpCameraKind kind, out StatusValue status); + [AutomateStatusCheck] public static CsSource CreateHttpCamera(string name, ReadOnlySpan urls, HttpCameraKind kind, out StatusValue status) { return CreateHttpCamera(name, urls, urls.Length, kind, out status); @@ -337,11 +337,11 @@ public static string[] GetHttpCameraUrls(CsSource source, out StatusValue status [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial CsProperty CreateSourceProperty(CsSource source, WpiString name, PropertyKind kind, int minimum, int maximum, int step, int defaultValue, int value, out StatusValue status); - [AutomateStatusCheck] [LibraryImport("cscore", EntryPoint = "CS_SetSourceEnumPropertyChoices")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetSourceEnumPropertyChoices(CsSource source, CsProperty property, [MarshalUsing(typeof(WpiStringMarshaller), ElementIndirectionDepth = 1)] ReadOnlySpan choices, int count, out StatusValue status); + [AutomateStatusCheck] public static void SetSourceEnumPropertyChoices(CsSource source, CsProperty property, ReadOnlySpan choices, out StatusValue status) { SetSourceEnumPropertyChoices(source, property, choices, choices.Length, out status); diff --git a/src/cscore/Raw/RawSink.cs b/src/cscore/Raw/RawSink.cs index 906c113e..81620280 100644 --- a/src/cscore/Raw/RawSink.cs +++ b/src/cscore/Raw/RawSink.cs @@ -9,8 +9,8 @@ public class RawSink(string name) : ImageSink(CreateRawSink(name)) { private static CsSink CreateRawSink(string name) { - var sink = CsNative.CreateRawSink(name, out var status); - VideoException.ThrowIfFailed(status); + var sink = CsNative.CreateRawSink(name); + return sink; } @@ -21,15 +21,15 @@ public long GrabFrame(RawFrameReader frame) public long GrabFrame(RawFrameReader frame, TimeSpan timeout) { - var time = CsNative.GrabRawSinkFrame(Handle, frame, timeout.TotalSeconds, out var status); - VideoException.ThrowIfFailed(status); + var time = CsNative.GrabRawSinkFrame(Handle, frame, timeout.TotalSeconds); + return (long)time; } public long GrabFrameNoTimeout(RawFrameReader frame) { - var time = CsNative.GrabRawSinkFrame(Handle, frame, out var status); - VideoException.ThrowIfFailed(status); + var time = CsNative.GrabRawSinkFrame(Handle, frame); + return (long)time; } } diff --git a/src/cscore/Raw/RawSource.cs b/src/cscore/Raw/RawSource.cs index 0dfca9d4..2b78b977 100644 --- a/src/cscore/Raw/RawSource.cs +++ b/src/cscore/Raw/RawSource.cs @@ -8,8 +8,8 @@ public class RawSource(string name, VideoMode mode) : ImageSource(CreateRawSourc { private static CsSource CreateRawSource(string name, ref readonly VideoMode mode) { - var source = CsNative.CreateRawSource(name, mode, out var status); - VideoException.ThrowIfFailed(status); + var source = CsNative.CreateRawSource(name, mode); + return source; } @@ -24,7 +24,7 @@ private static CsSource CreateRawSource(string name, ref readonly VideoMode mode public void PutFrame(RawFrameWriter image) { - CsNative.PutRawSourceFrame(Handle, image, out var status); - VideoException.ThrowIfFailed(status); + CsNative.PutRawSourceFrame(Handle, image); + } } diff --git a/src/cscore/UsbCamera.cs b/src/cscore/UsbCamera.cs index 41072e15..2ce3b923 100644 --- a/src/cscore/UsbCamera.cs +++ b/src/cscore/UsbCamera.cs @@ -7,15 +7,15 @@ public class UsbCamera : VideoCamera { private static CsSource CreateUsbCameraDev(string name, int dev) { - var handle = CsNative.CreateUsbCamera(name, dev, out var status); - VideoException.ThrowIfFailed(status); + var handle = CsNative.CreateUsbCamera(name, dev); + return handle; } private static CsSource CreateUsbCameraPath(string name, string path) { - var handle = CsNative.CreateUsbCamera(name, path, out var status); - VideoException.ThrowIfFailed(status); + var handle = CsNative.CreateUsbCamera(name, path); + return handle; } @@ -30,7 +30,7 @@ public UsbCamera(string name, string path) : base(CreateUsbCameraPath(name, path public static UsbCameraInfo[] EnumerateUsbCameras() { var info = CsNative.EnumerateUsbCameras(out var status); - VideoException.ThrowIfFailed(status); + return info; } @@ -38,14 +38,14 @@ public string Path { get { - CsNative.GetUsbCameraPath(Handle, out var path, out var status); - VideoException.ThrowIfFailed(status); + CsNative.GetUsbCameraPath(Handle, out var path); + return path; } set { - CsNative.SetUsbCameraPath(Handle, value, out var status); - VideoException.ThrowIfFailed(status); + CsNative.SetUsbCameraPath(Handle, value); + } } @@ -53,17 +53,15 @@ public UsbCameraInfo Info { get { - var info = CsNative.GetUsbCameraInfo(Handle, out var status); - VideoException.ThrowIfFailed(status); + var info = CsNative.GetUsbCameraInfo(Handle); + return info; } } public void SetConnectVerbose(int level) { - var property = CsNative.GetSourceProperty(Handle, "connect_verbose"u8, out var status); - VideoException.ThrowIfFailed(status); - CsNative.SetProperty(property, level, out status); - VideoException.ThrowIfFailed(status); + var property = CsNative.GetSourceProperty(Handle, "connect_verbose"u8); + CsNative.SetProperty(property, level); } } diff --git a/src/cscore/VideoCamera.cs b/src/cscore/VideoCamera.cs index 3ea60c6c..5918db90 100644 --- a/src/cscore/VideoCamera.cs +++ b/src/cscore/VideoCamera.cs @@ -14,50 +14,50 @@ public int Brightness { get { - int brightness = CsNative.GetCameraBrightness(Handle, out var status); - VideoException.ThrowIfFailed(status); + int brightness = CsNative.GetCameraBrightness(Handle); + return brightness; } set { - CsNative.SetCameraBrightness(Handle, value, out var status); - VideoException.ThrowIfFailed(status); + CsNative.SetCameraBrightness(Handle, value); + } } public void SetWhiteBalanceAuto() { - CsNative.SetCameraWhiteBalanceAuto(Handle, out var status); - VideoException.ThrowIfFailed(status); + CsNative.SetCameraWhiteBalanceAuto(Handle); + } public void SetWhiteBalanceHoldCurrent() { - CsNative.SetCameraWhiteBalanceHoldCurrent(Handle, out var status); - VideoException.ThrowIfFailed(status); + CsNative.SetCameraWhiteBalanceHoldCurrent(Handle); + } public void SetWhiteBalanceManual(int value) { - CsNative.SetCameraWhiteBalanceManual(Handle, value, out var status); - VideoException.ThrowIfFailed(status); + CsNative.SetCameraWhiteBalanceManual(Handle, value); + } public void SetExposureAuto() { - CsNative.SetCameraExposureAuto(Handle, out var status); - VideoException.ThrowIfFailed(status); + CsNative.SetCameraExposureAuto(Handle); + } public void SetExposureHoldCurrent() { - CsNative.SetCameraExposureHoldCurrent(Handle, out var status); - VideoException.ThrowIfFailed(status); + CsNative.SetCameraExposureHoldCurrent(Handle); + } public void SetExposureManual(int value) { - CsNative.SetCameraExposureManual(Handle, value, out var status); - VideoException.ThrowIfFailed(status); + CsNative.SetCameraExposureManual(Handle, value); + } } diff --git a/src/cscore/VideoListener.cs b/src/cscore/VideoListener.cs index 7b3c6bd6..946c5706 100644 --- a/src/cscore/VideoListener.cs +++ b/src/cscore/VideoListener.cs @@ -78,8 +78,8 @@ public VideoListener(Action listener, EventKind eventMask, bool imme s_poller = CsNative.CreateListenerPoller(); StartThread(); } - Handle = CsNative.AddPolledListener(s_poller, eventMask, immediateNotify, out var status); - VideoException.ThrowIfFailed(status); + Handle = CsNative.AddPolledListener(s_poller, eventMask, immediateNotify); + s_listeners.Add(Handle, listener); } } @@ -92,8 +92,8 @@ public void Dispose() { s_listeners.Remove(Handle); } - CsNative.RemoveListener(Handle, out var status); - VideoException.ThrowIfFailed(status); + CsNative.RemoveListener(Handle); + } Handle = default; } diff --git a/src/cscore/VideoProperty.cs b/src/cscore/VideoProperty.cs index cb8511d1..f4716c2a 100644 --- a/src/cscore/VideoProperty.cs +++ b/src/cscore/VideoProperty.cs @@ -15,8 +15,8 @@ public string Name { get { - CsNative.GetPropertyName(Handle, out var value, out var status); - VideoException.ThrowIfFailed(status); + CsNative.GetPropertyName(Handle, out var value); + return value; } } @@ -35,14 +35,14 @@ public int Value { get { - int res = CsNative.GetProperty(Handle, out var status); - VideoException.ThrowIfFailed(status); + int res = CsNative.GetProperty(Handle); + return res; } set { - CsNative.SetProperty(Handle, value, out var status); - VideoException.ThrowIfFailed(status); + CsNative.SetProperty(Handle, value); + } } @@ -50,8 +50,8 @@ public int Min { get { - int res = CsNative.GetPropertyMin(Handle, out var status); - VideoException.ThrowIfFailed(status); + int res = CsNative.GetPropertyMin(Handle); + return res; } } @@ -60,8 +60,8 @@ public int Max { get { - int res = CsNative.GetPropertyMax(Handle, out var status); - VideoException.ThrowIfFailed(status); + int res = CsNative.GetPropertyMax(Handle); + return res; } } @@ -70,8 +70,8 @@ public int Step { get { - int res = CsNative.GetPropertyStep(Handle, out var status); - VideoException.ThrowIfFailed(status); + int res = CsNative.GetPropertyStep(Handle); + return res; } } @@ -80,8 +80,8 @@ public int Default { get { - int res = CsNative.GetPropertyDefault(Handle, out var status); - VideoException.ThrowIfFailed(status); + int res = CsNative.GetPropertyDefault(Handle); + return res; } } @@ -90,14 +90,14 @@ public string StringValue { get { - CsNative.GetStringProperty(Handle, out var res, out var status); - VideoException.ThrowIfFailed(status); + CsNative.GetStringProperty(Handle, out var res); + return res; } set { - CsNative.SetStringProperty(Handle, value, out var status); - VideoException.ThrowIfFailed(status); + CsNative.SetStringProperty(Handle, value); + } } @@ -105,16 +105,16 @@ public string[] EnumChoices { get { - string[] res = CsNative.GetEnumPropertyChoices(Handle, out var status); - VideoException.ThrowIfFailed(status); + string[] res = CsNative.GetEnumPropertyChoices(Handle); + return res; } } public int Get() { - int res = CsNative.GetProperty(Handle, out var status); - VideoException.ThrowIfFailed(status); + int res = CsNative.GetProperty(Handle); + return res; } @@ -126,8 +126,8 @@ public void Set() internal VideoProperty(CsProperty handle) { Handle = handle; - Kind = CsNative.GetPropertyKind(Handle, out var status); - VideoException.ThrowIfFailed(status); + Kind = CsNative.GetPropertyKind(Handle); + } internal VideoProperty(CsProperty handle, PropertyKind kind) diff --git a/src/cscore/VideoSink.cs b/src/cscore/VideoSink.cs index 1a15146b..bf2e48de 100644 --- a/src/cscore/VideoSink.cs +++ b/src/cscore/VideoSink.cs @@ -20,8 +20,8 @@ public SinkKind Kind { get { - var kind = CsNative.GetSinkKind(Handle, out var status); - VideoException.ThrowIfFailed(status); + var kind = CsNative.GetSinkKind(Handle); + return kind; } } @@ -30,8 +30,8 @@ public string Name { get { - CsNative.GetSinkName(Handle, out var name, out var status); - VideoException.ThrowIfFailed(status); + CsNative.GetSinkName(Handle, out var name); + return name; } } @@ -40,23 +40,23 @@ public string Description { get { - CsNative.GetSinkDescription(Handle, out var description, out var status); - VideoException.ThrowIfFailed(status); + CsNative.GetSinkDescription(Handle, out var description); + return description; } } public bool SetConfigJson(string config) { - var ret = CsNative.SetSinkConfigJson(Handle, config, out var status); - VideoException.ThrowIfFailed(status); + var ret = CsNative.SetSinkConfigJson(Handle, config); + return ret; } public string GetConfigJson() { - CsNative.GetSinkConfigJson(Handle, out var str, out var status); - VideoException.ThrowIfFailed(status); + CsNative.GetSinkConfigJson(Handle, out var str); + return str; } @@ -64,8 +64,8 @@ public VideoSource? Source { get { - var sourceHandle = CsNative.GetSinkSource(Handle, out var status); - VideoException.ThrowIfFailed(status); + var sourceHandle = CsNative.GetSinkSource(Handle); + if (sourceHandle.Handle == 0) { return null; @@ -79,22 +79,22 @@ public VideoSource? Source { sourceHandle = value.Handle; } - CsNative.SetSinkSource(Handle, sourceHandle, out var status); - VideoException.ThrowIfFailed(status); + CsNative.SetSinkSource(Handle, sourceHandle); + } } public VideoProperty GetProperty(string name) { - var property = CsNative.GetSinkProperty(Handle, name, out var status); - VideoException.ThrowIfFailed(status); + var property = CsNative.GetSinkProperty(Handle, name); + return new VideoProperty(property); } public VideoProperty[] EnumerateProperties() { - var handles = CsNative.EnumerateSinkProperties(Handle, out var status); - VideoException.ThrowIfFailed(status); + var handles = CsNative.EnumerateSinkProperties(Handle); + VideoProperty[] rv = new VideoProperty[handles.Length]; for (int i = 0; i < handles.Length; i++) { @@ -105,15 +105,15 @@ public VideoProperty[] EnumerateProperties() public VideoProperty GetSourceProperty(string name) { - var property = CsNative.GetSinkSourceProperty(Handle, name, out var status); - VideoException.ThrowIfFailed(status); + var property = CsNative.GetSinkSourceProperty(Handle, name); + return new VideoProperty(property); } public static VideoSink[] EnumerateSinks() { var handles = CsNative.EnumerateSinks(out var status); - VideoException.ThrowIfFailed(status); + VideoSink[] rv = new VideoSink[handles.Length]; for (int i = 0; i < handles.Length; i++) { @@ -126,8 +126,8 @@ public void Dispose() { if (Handle.Handle != 0) { - CsNative.ReleaseSink(Handle, out var status); - VideoException.ThrowIfFailed(status); + CsNative.ReleaseSink(Handle); + } Handle = default; } diff --git a/src/cscore/VideoSource.cs b/src/cscore/VideoSource.cs index de500c15..bee7c4a1 100644 --- a/src/cscore/VideoSource.cs +++ b/src/cscore/VideoSource.cs @@ -20,8 +20,8 @@ public SourceKind Kind { get { - var kind = CsNative.GetSourceKind(Handle, out var status); - VideoException.ThrowIfFailed(status); + var kind = CsNative.GetSourceKind(Handle); + return kind; } } @@ -30,8 +30,8 @@ public string Name { get { - CsNative.GetSourceName(Handle, out var name, out var status); - VideoException.ThrowIfFailed(status); + CsNative.GetSourceName(Handle, out var name); + return name; } } @@ -40,8 +40,8 @@ public string Description { get { - CsNative.GetSourceDescription(Handle, out var description, out var status); - VideoException.ThrowIfFailed(status); + CsNative.GetSourceDescription(Handle, out var description); + return description; } } @@ -50,8 +50,8 @@ public long LastFrameTime { get { - var frameTime = CsNative.GetSourceLastFrameTime(Handle, out var status); - VideoException.ThrowIfFailed(status); + var frameTime = CsNative.GetSourceLastFrameTime(Handle); + return (long)frameTime; } } @@ -60,8 +60,8 @@ public ConnectionStrategy ConnectionStrategy { set { - CsNative.SetSourceConnectionStrategy(Handle, value, out var status); - VideoException.ThrowIfFailed(status); + CsNative.SetSourceConnectionStrategy(Handle, value); + } } @@ -69,8 +69,8 @@ public bool IsConnected { get { - var isConnected = CsNative.IsSourceConnected(Handle, out var status); - VideoException.ThrowIfFailed(status); + var isConnected = CsNative.IsSourceConnected(Handle); + return isConnected; } } @@ -79,8 +79,8 @@ public bool IsEnabled { get { - var isEnabled = CsNative.IsSourceEnabled(Handle, out var status); - VideoException.ThrowIfFailed(status); + var isEnabled = CsNative.IsSourceEnabled(Handle); + return isEnabled; } } @@ -89,14 +89,14 @@ public VideoMode VideoMode { get { - CsNative.GetSourceVideoMode(Handle, out var mode, out var status); - VideoException.ThrowIfFailed(status); + CsNative.GetSourceVideoMode(Handle, out var mode); + return mode; } set { - CsNative.SetSourceVideoMode(Handle, value, out var status); - VideoException.ThrowIfFailed(status); + CsNative.SetSourceVideoMode(Handle, value); + } } @@ -107,36 +107,36 @@ public bool SetConfigJson(string config) public string GetConfigJson() { - CsNative.GetSourceConfigJson(Handle, out var str, out var status); - VideoException.ThrowIfFailed(status); + CsNative.GetSourceConfigJson(Handle, out var str); + return str; } public double GetActualFPS() { - var avg = CsNative.GetTelemetryAverageValue(Handle, TelemetryKind.SourceFramesReceived, out var status); - VideoException.ThrowIfFailed(status); + var avg = CsNative.GetTelemetryAverageValue(Handle, TelemetryKind.SourceFramesReceived); + return avg; } public double GetActualDataRate() { - var avg = CsNative.GetTelemetryAverageValue(Handle, TelemetryKind.SourceBytesReceived, out var status); - VideoException.ThrowIfFailed(status); + var avg = CsNative.GetTelemetryAverageValue(Handle, TelemetryKind.SourceBytesReceived); + return avg; } public VideoMode[] EnumerateVideoModes() { - var modes = CsNative.EnumerateSourceVideoModes(Handle, out var status); - VideoException.ThrowIfFailed(status); + var modes = CsNative.EnumerateSourceVideoModes(Handle); + return modes; } public VideoSink[] EnumerateSinks() { - var handles = CsNative.EnumerateSourceSinks(Handle, out var status); - VideoException.ThrowIfFailed(status); + var handles = CsNative.EnumerateSourceSinks(Handle); + VideoSink[] rv = new VideoSink[handles.Length]; for (int i = 0; i < handles.Length; i++) { @@ -147,15 +147,15 @@ public VideoSink[] EnumerateSinks() public VideoProperty GetProperty(string name) { - var property = CsNative.GetSourceProperty(Handle, name, out var status); - VideoException.ThrowIfFailed(status); + var property = CsNative.GetSourceProperty(Handle, name); + return new VideoProperty(property); } public VideoProperty[] EnumerateProperties() { - var handles = CsNative.EnumerateSourceProperties(Handle, out var status); - VideoException.ThrowIfFailed(status); + var handles = CsNative.EnumerateSourceProperties(Handle); + VideoProperty[] rv = new VideoProperty[handles.Length]; for (int i = 0; i < handles.Length; i++) { @@ -167,7 +167,7 @@ public VideoProperty[] EnumerateProperties() public static VideoSource[] EnumerateSources() { var handles = CsNative.EnumerateSources(out var status); - VideoException.ThrowIfFailed(status); + VideoSource[] rv = new VideoSource[handles.Length]; for (int i = 0; i < handles.Length; i++) { @@ -180,8 +180,8 @@ public void Dispose() { if (Handle.Handle != 0) { - CsNative.ReleaseSource(Handle, out var status); - VideoException.ThrowIfFailed(status); + CsNative.ReleaseSource(Handle); + } Handle = default; }