From 8dd079ba23f7788f88f7a8198947f7a660115da6 Mon Sep 17 00:00:00 2001 From: Emiliana <38952746+emilianavt@users.noreply.github.com> Date: Tue, 29 Sep 2020 17:14:55 +0200 Subject: [PATCH] Added default settings pretty capability to directshow cameras. --- Examples/OpenSeeWebcamInfo.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Examples/OpenSeeWebcamInfo.cs b/Examples/OpenSeeWebcamInfo.cs index 3e849cb..ecdf366 100644 --- a/Examples/OpenSeeWebcamInfo.cs +++ b/Examples/OpenSeeWebcamInfo.cs @@ -108,6 +108,8 @@ public class OpenSeeWebcam { splitCaps.Sort((a, b) => CompareCaps(a.Item1, b.Item1)); prettyCaps = new List(); + if (type == OpenSeeWebcamType.DirectShow) + prettyCaps.Add("Default settings"); foreach (var cap in splitCaps) { prettyCaps.Add(GetPrettyCapability(cap.Item1)); } @@ -116,15 +118,28 @@ public class OpenSeeWebcam { } public OpenSeeWebcamCapability GetCapabilityByPrettyIndex(int index) { - if (splitCaps == null || index >= splitCaps.Count) + int dshowOffset = 0; + if (type == OpenSeeWebcamType.DirectShow) { + if (index == 0) { + OpenSeeWebcamCapability cap = new OpenSeeWebcamCapability(); + cap.id = -1; + cap.format = OpenSeeWebcamFormat.Any; + return cap; + } + dshowOffset = 1; + } + + if (splitCaps == null || index >= splitCaps.Count + dshowOffset || index < 0) throw new InvalidOperationException("Invalid capability index."); - return caps[splitCaps[index].Item2]; + + return caps[splitCaps[index - dshowOffset].Item2]; } } [DefaultExecutionOrder(-50)] public class OpenSeeWebcamInfo : MonoBehaviour { #region DllImport + // DirectShow [DllImport("dshowcapture_x64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "create_capture")] private static extern System.IntPtr create_capture_x64(); @@ -149,7 +164,7 @@ public class OpenSeeWebcamInfo : MonoBehaviour { [DllImport("dshowcapture_x86", CallingConvention = CallingConvention.Cdecl, EntryPoint = "destroy_capture")] private static extern void destroy_capture_x86(System.IntPtr cap); - /* Blackmagic */ + // Blackmagic [DllImport("libminibmcapture64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "get_json_length")] private static extern int bm_get_json_length_x64();