diff --git a/CHANGELOG.md b/CHANGELOG.md
index 08bf8d98..28e1b343 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@ Current Stable Release: 3.5.0 (March 2024)
-----------------------------------------------
Release: 3.6.X (August 2024)
+- [ENH] MediaFoundation: Add VirtualCamera support (mfvirtualcamera.h)
- [ENH] General: Drop .net7 support
- [ENH] Vortice.Dxc: Handle correctly IDxcCompilerArgs bindings and improve interop
- [ENH] Vortice.WinUI interop improvements.
diff --git a/Directory.Build.props b/Directory.Build.props
index dc1888a2..490d1c4d 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -16,7 +16,7 @@
- 3.5.10
+ 3.5.11
beta
diff --git a/Directory.Packages.props b/Directory.Packages.props
index f739ce35..ce890cf6 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -10,11 +10,11 @@
-
+
-
+
diff --git a/src/Vortice.DirectX/Mappings.xml b/src/Vortice.DirectX/Mappings.xml
index b518105f..4fce28f0 100644
--- a/src/Vortice.DirectX/Mappings.xml
+++ b/src/Vortice.DirectX/Mappings.xml
@@ -32,7 +32,8 @@
-
+
+
@@ -138,6 +139,9 @@
+
+
+
@@ -288,6 +292,9 @@
AutoConvertPCM
ExpireWhenUnowned
HideWhenExpired
+ DevPropertyKey
+ DevPropertyType
+ NtStatus
@@ -437,6 +444,15 @@
-
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Vortice.DirectX/Multimedia/WaveFormatAdpcm.cs b/src/Vortice.DirectX/Multimedia/WaveFormatAdpcm.cs
index 75273bad..3de81cd2 100644
--- a/src/Vortice.DirectX/Multimedia/WaveFormatAdpcm.cs
+++ b/src/Vortice.DirectX/Multimedia/WaveFormatAdpcm.cs
@@ -131,10 +131,10 @@ internal unsafe void __MarshalFrom(ref __Native @ref)
private unsafe void __MarshalTo(ref __Native @ref)
{
- if(Coefficients1 == null)
+ if (Coefficients1 == null)
throw new ArgumentNullException(nameof(Coefficients1));
- if ( Coefficients1.Length > 7)
+ if (Coefficients1.Length > 7)
throw new InvalidOperationException("Unable to encode Adpcm format. Too may coefficients (max 7)");
extraSize = (short)(sizeof(int) + sizeof(int) * Coefficients1.Length);
@@ -149,6 +149,6 @@ private unsafe void __MarshalTo(ref __Native @ref)
pCoefs[i * 2 + 1] = Coefficients2[i];
}
}
- }
+ }
#endregion
}
diff --git a/src/Vortice.MediaFoundation/IMFVirtualCamera.cs b/src/Vortice.MediaFoundation/IMFVirtualCamera.cs
new file mode 100644
index 00000000..1dfcd75d
--- /dev/null
+++ b/src/Vortice.MediaFoundation/IMFVirtualCamera.cs
@@ -0,0 +1,49 @@
+// Copyright (c) Amer Koleci and Contributors.
+// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
+
+using SharpGen.Runtime;
+using Vortice.Mathematics;
+using Vortice.Win32;
+
+namespace Vortice.MediaFoundation;
+
+public unsafe partial class IMFVirtualCamera
+{
+ public Result AddProperty(DevPropertyKey key, DevPropertyType type, byte[] data)
+ {
+ fixed (byte* pbData = data)
+ return AddProperty(ref key, (uint)type, pbData, (uint)data.Length);
+ }
+
+ public Result AddProperty(DevPropertyKey key, DevPropertyType type, Span data)
+ {
+ fixed (byte* pbData = data)
+ return AddProperty(ref key, (uint)type, pbData, (uint)data.Length);
+ }
+
+ public Result AddProperty(DevPropertyKey key, DevPropertyType type, Span data)
+ where T : unmanaged
+ {
+ fixed (T* pbData = data)
+ return AddProperty(ref key, (uint)type, pbData, (uint)(sizeof(T) * data.Length));
+ }
+
+ public Result AddRegistryEntry(string entryName, string subkeyPath, int regType, byte[] data)
+ {
+ fixed (byte* pbData = data)
+ return AddRegistryEntry(entryName, subkeyPath, regType, pbData, (uint)data.Length);
+ }
+
+ public Result AddRegistryEntry(string entryName, string subkeyPath, int regType, Span data)
+ {
+ fixed (byte* pbData = data)
+ return AddRegistryEntry(entryName, subkeyPath, regType, pbData, (uint)data.Length);
+ }
+
+ public Result AddRegistryEntry(string entryName, string subkeyPath, int regType, Span data)
+ where T : unmanaged
+ {
+ fixed (T* pbData = data)
+ return AddRegistryEntry(entryName, subkeyPath, regType, pbData, (uint)(sizeof(T) * data.Length));
+ }
+}
diff --git a/src/Vortice.MediaFoundation/Mappings.xml b/src/Vortice.MediaFoundation/Mappings.xml
index 02e9226c..146723da 100644
--- a/src/Vortice.MediaFoundation/Mappings.xml
+++ b/src/Vortice.MediaFoundation/Mappings.xml
@@ -31,6 +31,7 @@
+
@@ -974,6 +975,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Vortice.MediaFoundation/MediaFactory.cs b/src/Vortice.MediaFoundation/MediaFactory.cs
index 760ae17e..96c04f2a 100644
--- a/src/Vortice.MediaFoundation/MediaFactory.cs
+++ b/src/Vortice.MediaFoundation/MediaFactory.cs
@@ -1,6 +1,7 @@
// Copyright (c) Amer Koleci and Contributors.
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
+using System.Runtime.InteropServices;
using SharpGen.Runtime;
using SharpGen.Runtime.Win32;
using Vortice.Multimedia;
@@ -240,4 +241,59 @@ public static Result MFSetAttributeSize(IMFAttributes attributes, Guid guidKey,
{
return MFSetAttribute2UInt32asUInt64(attributes, guidKey, width, height);
}
+
+ public static IMFVirtualCamera MFCreateVirtualCamera(
+ VirtualCameraType type,
+ VirtualCameraLifetime lifetime,
+ VirtualCameraAccess access,
+ string friendlyName,
+ string sourceId,
+ Guid[]? categories = default)
+ {
+ nint virtualCameraPtr = default;
+ Result result;
+
+ fixed (char* sourceId_ = sourceId)
+ fixed (char* friendlyName_ = friendlyName)
+ {
+ if (categories?.Length > 0)
+ {
+ fixed (Guid* categories_ = categories)
+ result = (Result)MFCreateVirtualCamera_(
+ (int)type,
+ (int)lifetime,
+ (int)access,
+ friendlyName_,
+ sourceId_,
+ categories_,
+ (uint)categories.Length,
+ &virtualCameraPtr
+ );
+ }
+ else
+ {
+ result = (Result)MFCreateVirtualCamera_(
+ (int)type,
+ (int)lifetime,
+ (int)access,
+ friendlyName_,
+ sourceId_,
+ null,
+ 0,
+ &virtualCameraPtr);
+ }
+ }
+
+ result.CheckError();
+
+ return new IMFVirtualCamera(virtualCameraPtr);
+ }
+
+ public static bool MFIsVirtualCameraTypeSupported(VirtualCameraType type)
+ {
+ RawBool supported;
+ Result result = MFIsVirtualCameraTypeSupported_(unchecked((int)type), &supported);
+ result.CheckError();
+ return supported;
+ }
}