diff --git a/src/VideoToolbox/VTDefs.cs b/src/VideoToolbox/VTDefs.cs index d35cef42dc37..b66bf7dcede1 100644 --- a/src/VideoToolbox/VTDefs.cs +++ b/src/VideoToolbox/VTDefs.cs @@ -31,7 +31,9 @@ public enum VTStatus { VideoDecoderMalfunction = -12911, VideoEncoderMalfunction = -12912, VideoDecoderNotAvailableNow = -12913, + [Obsolete ("Use PixelRotationNotSupported enum value instead.")] ImageRotationNotSupported = -12914, + PixelRotationNotSupported = -12914, VideoEncoderNotAvailableNow = -12915, FormatDescriptionChangeNotSupported = -12916, InsufficientSourceColorData = -12917, @@ -53,6 +55,12 @@ public enum VTStatus { DecoderNeedsRosetta = -17692, [Mac (11, 0)] EncoderNeedsRosetta = -17693, + [Mac (12,0), iOS (15,0), MacCatalyst (15,0), Watch (9,0), TV (15,0)] + VideoDecoderReferenceMissing = -17694, + [Mac (12,0), iOS (15,0), MacCatalyst (15,0), Watch (9,0), TV (15,0)] + VideoDecoderCallbackMessaging = -17695, + [Mac (13,0), iOS (16,0), MacCatalyst (16,0), Watch (9,0), TV (16,0)] + VideoDecoderUnknownErr = -17696, } // uint32_t -> VTErrors.h @@ -266,4 +274,17 @@ public enum HdrMetadataInsertionMode { [Field ("kVTHDRMetadataInsertionMode_Auto")] Auto, } + + [Mac (13,0), iOS (16,0), MacCatalyst (16,0), Watch (9,0), TV (16,0)] + public enum VTRotation { + [DefaultEnumValue] + [Field ("kVTRotation_0")] + Zero, + [Field ("kVTRotation_CW90")] + ClockwiseNinety, + [Field ("kVTRotation_180")] + OneHundredAndEighty, + [Field ("kVTRotation_CCW90")] + CounterclockwiseNinety, + } } diff --git a/src/VideoToolbox/VTPixelRotationProperties.cs b/src/VideoToolbox/VTPixelRotationProperties.cs new file mode 100644 index 000000000000..7e928bd5237a --- /dev/null +++ b/src/VideoToolbox/VTPixelRotationProperties.cs @@ -0,0 +1,29 @@ +// +// VTPixelRotationProperties.cs: Strongly Typed dictionary for VTPixelRotationPropertyKeys +// +// Authors: Israel Soto (issoto@microsoft.com) +// +// Copyright 2022 Microsoft Corporation. +// + +#nullable enable + +using System; +using System.Runtime.InteropServices; +using System.Collections.Generic; + +using CoreFoundation; +using ObjCRuntime; +using Foundation; +using CoreMedia; +using CoreVideo; +using AVFoundation; + +namespace VideoToolbox { + public partial class VTPixelRotationProperties : DictionaryContainer { + public VTRotation Rotation { + get => VTRotationExtensions.GetValue (GetNSStringValue (VTPixelRotationPropertyKeys.Rotation)!); + set => SetStringValue (VTPixelRotationPropertyKeys.Rotation, value.GetConstant ()); + } + } +} diff --git a/src/VideoToolbox/VTPixelRotationSession.cs b/src/VideoToolbox/VTPixelRotationSession.cs new file mode 100644 index 000000000000..4d05a3d4f7e5 --- /dev/null +++ b/src/VideoToolbox/VTPixelRotationSession.cs @@ -0,0 +1,107 @@ +// +// VTPixelRotationSession.cs: VideoTools Pixel Rotation Session class +// +// Authors: +// Israel Soto (issoto@microsoft.com) +// +// Copyright 2022 Microsoft Corporation. +// + +#nullable enable + +using System; +using System.Runtime.InteropServices; + +using CoreFoundation; +using ObjCRuntime; +using Foundation; +using CoreMedia; +using CoreVideo; + +#if !NET +using NativeHandle = System.IntPtr; +#endif + +namespace VideoToolbox { + +#if NET + [SupportedOSPlatform ("macos13.0")] + [SupportedOSPlatform ("ios16.0")] + [SupportedOSPlatform ("maccatalyst16.0")] + [SupportedOSPlatform ("watchos9.0")] + [SupportedOSPlatform ("tvos16.0")] +#else + [Mac (13,0), iOS (16,0), MacCatalyst (16,0), Watch (9,0), TV (16,0)] +#endif + public class VTPixelRotationSession : VTSession { + + [DllImport (Constants.VideoToolboxLibrary)] + extern static /* CFTypeID */ nint VTPixelRotationSessionGetTypeID (); + public static nint GetTypeID () => VTPixelRotationSessionGetTypeID (); + +#if !NET + /* invoked by marshallers */ + protected internal VTPixelRotationSession (NativeHandle handle) : base (handle) + { + } +#endif + + [Preserve (Conditional=true)] + internal VTPixelRotationSession (NativeHandle handle, bool owns) : base (handle, owns) + { + } + + [DllImport (Constants.VideoToolboxLibrary)] + extern static void VTPixelRotationSessionInvalidate (/* VTPixelRotationSessionRef */ IntPtr session); + + protected override void Dispose (bool disposing) + { + if (Handle != IntPtr.Zero) + VTPixelRotationSessionInvalidate (Handle); + + base.Dispose (disposing); + } + + [DllImport (Constants.VideoToolboxLibrary)] + unsafe extern static VTStatus VTPixelRotationSessionCreate ( + /* CFAllocatorRef */ IntPtr allocator, /* can be null */ + /* VTPixelRotationSessionRef* */ out IntPtr pixelRotationSessionOut); + + public static VTPixelRotationSession? Create () => Create (null); + + public static VTPixelRotationSession? Create (CFAllocator? allocator) + { + var result = VTPixelRotationSessionCreate (allocator.GetHandle (), out var ret); + + if (result == VTStatus.Ok && ret != IntPtr.Zero) + return new VTPixelRotationSession (ret, true); + + return null; + } + + [DllImport (Constants.VideoToolboxLibrary)] + extern static VTStatus VTPixelRotationSessionRotateImage ( + /* VTPixelRotationSessionRef */ IntPtr session, + /* CVPixelBuffer */ IntPtr sourceBuffer, + /* CVPixelBuffer */ IntPtr destinationBuffer); + + public VTStatus RotateImage (CVPixelBuffer sourceBuffer, CVPixelBuffer destinationBuffer) + { + if (sourceBuffer is null) + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (sourceBuffer)); + + if (destinationBuffer is null) + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (destinationBuffer)); + + return VTPixelRotationSessionRotateImage (GetCheckedHandle (), sourceBuffer.Handle, destinationBuffer.Handle); + } + + public VTStatus SetRotationProperties (VTPixelRotationProperties options) + { + if (options is null) + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (options)); + + return VTSessionSetProperties (Handle, options.Dictionary.Handle); + } + } +} diff --git a/src/VideoToolbox/VTPixelTransferSession.cs b/src/VideoToolbox/VTPixelTransferSession.cs new file mode 100644 index 000000000000..9e4824c79297 --- /dev/null +++ b/src/VideoToolbox/VTPixelTransferSession.cs @@ -0,0 +1,106 @@ +// +// VTPixelTransferSession.cs: VideoTools Pixel Transfer Session class +// +// Authors: +// Israel Soto (issoto@microsoft.com) +// +// Copyright 2022 Microsoft Corporation. +// + +#nullable enable + +using System; +using System.Runtime.InteropServices; + +using CoreFoundation; +using ObjCRuntime; +using Foundation; +using CoreMedia; +using CoreVideo; + +#if !NET +using NativeHandle = System.IntPtr; +#endif + +namespace VideoToolbox { + +#if NET + [SupportedOSPlatform ("macos10.9")] + [SupportedOSPlatform ("ios16.0")] + [SupportedOSPlatform ("maccatalyst16.0")] + [SupportedOSPlatform ("watchos9.0")] + [SupportedOSPlatform ("tvos16.0")] +#else + [Mac (10,9), iOS (16,0), MacCatalyst (16,0), Watch (9,0), TV (16,0)] +#endif + public class VTPixelTransferSession : VTSession { + + [DllImport (Constants.VideoToolboxLibrary)] + extern static /* CFTypeID */ nint VTPixelTransferSessionGetTypeID (); + public static nint GetTypeID () => VTPixelTransferSessionGetTypeID (); + +#if !NET + /* invoked by marshallers */ + protected internal VTPixelTransferSession (NativeHandle handle) : base (handle) + { + } +#endif + + [Preserve (Conditional=true)] + internal VTPixelTransferSession (NativeHandle handle, bool owns) : base (handle, owns) + { + } + + [DllImport (Constants.VideoToolboxLibrary)] + extern static void VTPixelTransferSessionInvalidate (/* VTPixelTransferSessionRef */ IntPtr session); + + protected override void Dispose (bool disposing) + { + if (Handle != IntPtr.Zero) + VTPixelTransferSessionInvalidate (Handle); + + base.Dispose (disposing); + } + + [DllImport (Constants.VideoToolboxLibrary)] + unsafe extern static VTStatus VTPixelTransferSessionCreate ( + /* CFAllocatorRef */ IntPtr allocator, /* can be null */ + /* VTPixelTransferSessionRef* */ out IntPtr pixelTransferSessionOut); + + public static VTPixelTransferSession? Create () => Create (null); + + public static VTPixelTransferSession? Create (CFAllocator? allocator) { + var result = VTPixelTransferSessionCreate (allocator.GetHandle (), out var ret); + + if (result == VTStatus.Ok && ret != IntPtr.Zero) + return new VTPixelTransferSession (ret, true); + + return null; + } + + [DllImport (Constants.VideoToolboxLibrary)] + extern static VTStatus VTPixelTransferSessionTransferImage ( + /* VTPixelTransferSessionRef */ IntPtr session, + /* CVPixelBuffer */ IntPtr sourceBuffer, + /* CVPixelBuffer */ IntPtr destinationBuffer); + + public VTStatus TransferImage (CVPixelBuffer sourceBuffer, CVPixelBuffer destinationBuffer) + { + if (sourceBuffer is null) + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (sourceBuffer)); + + if (destinationBuffer is null) + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (destinationBuffer)); + + return VTPixelTransferSessionTransferImage (GetCheckedHandle (), sourceBuffer.Handle, destinationBuffer.Handle); + } + + public VTStatus SetTransferProperties (VTPixelTransferProperties options) + { + if (options is null) + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (options)); + + return VTSessionSetProperties (Handle, options.Dictionary.Handle); + } + } +} diff --git a/src/VideoToolbox/VTProfessionalVideoWorkflow.cs b/src/VideoToolbox/VTProfessionalVideoWorkflow.cs new file mode 100644 index 000000000000..5d9d4c2d4a19 --- /dev/null +++ b/src/VideoToolbox/VTProfessionalVideoWorkflow.cs @@ -0,0 +1,40 @@ +// +// VTProfessionalVideoWorkflow.cs: VideoTools Professional Video Workflow +// +// Authors: +// Israel Soto (issoto@microsoft.com) +// +// Copyright 2022 Microsoft Corporation. +// + +#if __MACOS__ + +#nullable enable + +using System; +using System.Runtime.InteropServices; + +using ObjCRuntime; +using Foundation; + +namespace VideoToolbox { + +#if NET + [SupportedOSPlatform ("macos10.9")] + [UnsupportedOSPlatform ("ios")] + [UnsupportedOSPlatform ("maccatalyst")] + [UnsupportedOSPlatform ("watchos")] + [UnsupportedOSPlatform ("tvos")] +#else + [Mac (10,9), NoiOS, NoMacCatalyst, NoWatch, NoTV] +#endif + public static class VTProfessionalVideoWorkflow { + [DllImport (Constants.VideoToolboxLibrary, EntryPoint = "VTRegisterProfessionalVideoWorkflowVideoDecoders")] + public extern static void RegisterVideoDecoders (); + + [DllImport (Constants.VideoToolboxLibrary, EntryPoint = "VTRegisterProfessionalVideoWorkflowVideoEncoders")] + public extern static void RegisterVideoEncoders (); + } +} + +#endif // __MACOS__ diff --git a/src/frameworks.sources b/src/frameworks.sources index da7d58e1245a..ba4af2ac9308 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -1791,6 +1791,11 @@ VIDEOTOOLBOX_SOURCES = \ VideoToolbox/VTDecompressionSession.cs \ VideoToolbox/VTFrameSilo.cs \ VideoToolbox/VTMultiPassStorage.cs \ + VideoToolbox/VTPixelRotationProperties.cs \ + VideoToolbox/VTPixelRotationSession.cs \ + VideoToolbox/VTPixelTransferProperties.cs \ + VideoToolbox/VTPixelTransferSession.cs \ + VideoToolbox/VTProfessionalVideoWorkflow.cs \ VideoToolbox/VTPropertyOptions.cs \ VideoToolbox/VTSession.cs \ VideoToolbox/VTVideoEncoder.cs \ diff --git a/src/videotoolbox.cs b/src/videotoolbox.cs index 5baed355c1ca..b5b00b93002e 100644 --- a/src/videotoolbox.cs +++ b/src/videotoolbox.cs @@ -79,6 +79,10 @@ interface VTCompressionPropertyKey { [Field ("kVTCompressionPropertyKey_Depth")] NSString Depth { get; } + [Mac (13,0), iOS (16,0), MacCatalyst (16,0), Watch (9,0), TV (16,0)] + [Field ("kVTCompressionPropertyKey_PreserveAlphaChannel")] + NSString PreserveAlphaChannel { get; } + // Runtime restrictions [Field ("kVTCompressionPropertyKey_MaxFrameDelayCount")] @@ -115,6 +119,10 @@ interface VTCompressionPropertyKey { [Field ("kVTCompressionPropertyKey_BaseLayerFrameRate")] NSString BaseLayerFrameRate { get; } + [Mac (13,0), iOS (16,0), MacCatalyst (16,0), Watch (9,0), TV (16,0)] + [Field ("kVTCompressionPropertyKey_ReferenceBufferCount")] + NSString ReferenceBufferCount { get; } + // Hardware acceleration // Hardware acceleration is default behavior on iOS. No opt-in required. @@ -204,6 +212,14 @@ interface VTCompressionPropertyKey { [Field ("kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality")] NSString PrioritizeEncodingSpeedOverQuality { get; } + [Mac (13,0), iOS (16,0), MacCatalyst (16,0), NoWatch, TV (16,0)] + [Field ("kVTCompressionPropertyKey_ConstantBitRate")] + NSString ConstantBitRate { get; } + + [Mac (13,0), iOS (16,0), MacCatalyst (16,0), Watch (9,0), TV (16,0)] + [Field ("kVTCompressionPropertyKey_EstimatedAverageBytesPerFrame")] + NSString EstimatedAverageBytesPerFrame { get; } + [iOS (14,1)] [TV (14,2)][Mac (11,0)] [MacCatalyst (14,1)] @@ -227,6 +243,10 @@ interface VTCompressionPropertyKey { [Field ("kVTCompressionPropertyKey_MaxAllowedFrameQP")] NSString MaxAllowedFrameQP { get; } + [Mac (13,0), iOS (16,0), MacCatalyst (16,0), NoWatch, TV (16,0)] + [Field ("kVTCompressionPropertyKey_MinAllowedFrameQP")] + NSString MinAllowedFrameQP { get; } + [TV (15, 0), Mac (12, 0), iOS (15, 0), MacCatalyst (15,0)] [Field ("kVTCompressionPropertyKey_SupportsBaseFrameQP")] NSString SupportsBaseFrameQP { get; } @@ -289,6 +309,10 @@ interface VTCompressionProperties { [Export ("Depth")] CMPixelFormat Depth { get; set; } + [Mac (13,0), iOS (16,0), MacCatalyst (16,0), Watch (9,0), TV (16,0)] + [Export ("PreserveAlphaChannel")] + bool PreserveAlphaChannel { get; set; } + [Export ("MaxFrameDelayCount")] int MaxFrameDelayCount { get; set; } @@ -316,6 +340,10 @@ interface VTCompressionProperties { [Export ("BaseLayerFrameRate")] double BaseLayerFrameRate { get; set; } + [Mac (13,0), iOS (16,0), MacCatalyst (16,0), Watch (9,0), TV (16,0)] + [Export ("ReferenceBufferCount")] + long ReferenceBufferCount { get; } + [Export ("UsingHardwareAcceleratedVideoEncoder")] bool UsingHardwareAcceleratedVideoEncoder { get; } @@ -364,11 +392,48 @@ interface VTCompressionProperties { [Export ("UsingGpuRegistryId")] uint UsingGpuRegistryId { get; } + [Mac (13,0), iOS (16,0), MacCatalyst (16,0), NoWatch, TV (16,0)] + [Export ("ConstantBitRate")] + long ConstantBitRate { get; set; } + + [Mac (13,0), iOS (16,0), MacCatalyst (16,0), Watch (9,0), TV (16,0)] + [Export ("EstimatedAverageBytesPerFrame")] + long EstimatedAverageBytesPerFrame { get; } + [iOS (14,1)] [TV (14,2)][Mac (11,0)] [MacCatalyst (14,1)] [Export ("PreserveDynamicHdrMetadata")] bool PreserveDynamicHdrMetadata { get; set; } + + [TV (14,5)][Mac (11,3)][iOS (14,5)][NoWatch] + [MacCatalyst (14,5)] + [Export ("EnableLowLatencyRateControl")] + bool EnableLowLatencyRateControl { get; set; } + + [TV (15, 0), Mac (12, 0), iOS (15, 0), MacCatalyst (15,0), NoWatch] + [Export ("BaseLayerBitRateFraction")] + float BaseLayerBitRateFraction { get; set; } + + [TV (15, 0), Mac (12, 0), iOS (15, 0), MacCatalyst (15,0), NoWatch] + [Export ("EnableLtr")] + bool EnableLtr { get; set; } + + [TV (15, 0), Mac (12, 0), iOS (15, 0), MacCatalyst (15,0), NoWatch] + [Export ("MaxAllowedFrameQP")] + uint MaxAllowedFrameQP { get; set; } + + [Mac (13,0), iOS (16,0), MacCatalyst (16,0), NoWatch, TV (16,0)] + [Export ("MinAllowedFrameQP")] + uint MinAllowedFrameQP { get; } + + [TV (15, 0), Mac (12, 0), iOS (15, 0), MacCatalyst (15,0), NoWatch] + [Export ("SupportsBaseFrameQP")] + bool SupportsBaseFrameQP { get; } + + [Watch (8,5), TV (15,4), Mac (12,3), iOS (15,4), MacCatalyst (15,4)] + [Export ("OutputBitDepth")] + bool OutputBitDepth { get; set; } } [iOS (8,0), TV (10,2)] @@ -1167,4 +1232,35 @@ interface VTPixelTransferPropertyKeys { [Field ("kVTPixelTransferPropertyKey_RealTime")] NSString RealTime { get; } } + + [Mac (13,0), iOS (16,0), MacCatalyst (16,0), Watch (9,0), TV (16,0)] + [StrongDictionary ("VTPixelRotationPropertyKeys")] + interface VTPixelRotationProperties { + [Export ("FlipHorizontalOrientation")] + bool FlipHorizontalOrientation { get; set; } + + [Export ("FlipVerticalOrientation")] + bool FlipVerticalOrientation { get; set; } + } + + [Mac (13,0), iOS (16,0), MacCatalyst (16,0), Watch (9,0), TV (16,0)] + [Static] + [Advanced] + interface VTPixelRotationPropertyKeys { + + // Rotation + + [Field ("kVTPixelRotationPropertyKey_Rotation")] + NSString Rotation { get; } + + // FlipHorizontalOrientation + + [Field ("kVTPixelRotationPropertyKey_FlipHorizontalOrientation")] + NSString FlipHorizontalOrientation { get; } + + // FlipVerticalOrientation + + [Field ("kVTPixelRotationPropertyKey_FlipVerticalOrientation")] + NSString FlipVerticalOrientation { get; } + } } diff --git a/tests/introspection/ApiCMAttachmentTest.cs b/tests/introspection/ApiCMAttachmentTest.cs index 3afc153edb29..c8a1e96f0c76 100644 --- a/tests/introspection/ApiCMAttachmentTest.cs +++ b/tests/introspection/ApiCMAttachmentTest.cs @@ -428,6 +428,10 @@ protected INativeObject GetINativeInstance (Type t) case "VTCompressionSession": case "VTSession": return VTCompressionSession.Create (1024, 768, CMVideoCodecType.H264, (sourceFrame, status, flags, buffer) => { }, null, (CVPixelBufferAttributes) null); + case "VTPixelRotationSession": + return VTPixelRotationSession.Create (); + case "VTPixelTransferSession": + return VTPixelTransferSession.Create (); case "VTFrameSilo": return VTFrameSilo.Create (); case "VTMultiPassStorage": diff --git a/tests/monotouch-test/VideoToolbox/VTPixelRotationSessionTests.cs b/tests/monotouch-test/VideoToolbox/VTPixelRotationSessionTests.cs new file mode 100644 index 000000000000..d52ab1a611f5 --- /dev/null +++ b/tests/monotouch-test/VideoToolbox/VTPixelRotationSessionTests.cs @@ -0,0 +1,73 @@ +// +// Unit tests for VTPixelRotationSession +// +// Authors: +// Israel Soto +// +// +// Copyright 2022 Microsoft Corporation. +// + +#if !__WATCHOS__ + +#nullable enable + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Threading; + +using Foundation; +using VideoToolbox; +using CoreMedia; +using CoreVideo; +using AVFoundation; +using CoreFoundation; +using ObjCRuntime; +using NUnit.Framework; +using Xamarin.Utils; + +namespace MonoTouchFixtures.VideoToolbox { + + [TestFixture] + [Preserve (AllMembers = true)] + public class VTPixelRotationSessionTests + { + [OneTimeSetUp] + public void Init () => TestRuntime.AssertXcodeVersion (14, 0); + + [Test] + public void CreateTest () + { + using var session = VTPixelRotationSession.Create (); + Assert.IsNotNull (session, "Session should not be null"); + } + + [Test] + public void RotateImageTest () + { + using var session = VTPixelRotationSession.Create (); + using var sourcePixelBuffer = new CVPixelBuffer (640, 480, CVPixelFormatType.CV420YpCbCr8BiPlanarFullRange); + using var destinationPixelBuffer = new CVPixelBuffer (480, 640, CVPixelFormatType.CV420YpCbCr8BiPlanarFullRange); + + var result = session.SetProperty (VTPixelRotationPropertyKeys.Rotation, VTRotation.ClockwiseNinety.GetConstant ()); + Assert.AreEqual (result, VTStatus.Ok, "SetProperty"); + + result = session.RotateImage (sourcePixelBuffer, destinationPixelBuffer); + Assert.AreEqual (result, VTStatus.Ok, "RotateImage"); + } + + [Test] + public void SetRotationPropertiesTest () + { + using var session = VTPixelRotationSession.Create (); + var result = session.SetRotationProperties (new VTPixelRotationProperties { + Rotation = VTRotation.ClockwiseNinety + }); + + Assert.AreEqual (result, VTStatus.Ok, "SetRotationProperties"); + } + } +} + +#endif // !__WATCHOS__ diff --git a/tests/monotouch-test/VideoToolbox/VTPixelTransferSessionTests.cs b/tests/monotouch-test/VideoToolbox/VTPixelTransferSessionTests.cs new file mode 100644 index 000000000000..8813d9344bfc --- /dev/null +++ b/tests/monotouch-test/VideoToolbox/VTPixelTransferSessionTests.cs @@ -0,0 +1,69 @@ +// +// Unit tests for VTPixelTransferSession +// +// Authors: +// Israel Soto +// +// +// Copyright 2022 Microsoft Corporation. +// + +#if !__WATCHOS__ + +#nullable enable + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Threading; + +using Foundation; +using VideoToolbox; +using CoreMedia; +using CoreVideo; +using AVFoundation; +using CoreFoundation; +using ObjCRuntime; +using NUnit.Framework; +using Xamarin.Utils; + +namespace MonoTouchFixtures.VideoToolbox { + + [TestFixture] + [Preserve (AllMembers = true)] + public class VTPixelTransferSessionTests + { + [OneTimeSetUp] + public void Init () => TestRuntime.AssertXcodeVersion (14, 0); + + [Test] + public void PixelTransferSessionCreateTest () + { + using var session = VTPixelTransferSession.Create (); + Assert.IsNotNull (session, "Session should not be null"); + } + + [Test] + public void PixelTransferSessionTransferImageTest () + { + using var session = VTPixelTransferSession.Create (); + using var sourcePixelBuffer = new CVPixelBuffer (640, 480, CVPixelFormatType.CV420YpCbCr8BiPlanarFullRange); + using var destinationPixelBuffer = new CVPixelBuffer (320, 240, CVPixelFormatType.CV420YpCbCr8BiPlanarFullRange); + var result = session.TransferImage (sourcePixelBuffer, destinationPixelBuffer); + Assert.AreEqual (result, VTStatus.Ok, "TransferImage"); + } + + [Test] + public void SetTransferPropertiesTest () + { + using var session = VTPixelTransferSession.Create (); + var result = session.SetTransferProperties (new VTPixelTransferProperties { + ScalingMode = VTScalingMode.Letterbox + }); + + Assert.AreEqual (result, VTStatus.Ok, "SetTransferProperties"); + } + } +} + +#endif // !__WATCHOS__ diff --git a/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-VideoToolbox.todo b/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-VideoToolbox.todo deleted file mode 100644 index dcd7ad13cec8..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-VideoToolbox.todo +++ /dev/null @@ -1,18 +0,0 @@ -!missing-field! kVTCompressionPropertyKey_ConstantBitRate not bound -!missing-field! kVTCompressionPropertyKey_MinAllowedFrameQP not bound -!missing-field! kVTCompressionPropertyKey_ReferenceBufferCount not bound -!missing-field! kVTPixelRotationPropertyKey_FlipHorizontalOrientation not bound -!missing-field! kVTPixelRotationPropertyKey_FlipVerticalOrientation not bound -!missing-field! kVTPixelRotationPropertyKey_Rotation not bound -!missing-field! kVTRotation_0 not bound -!missing-field! kVTRotation_180 not bound -!missing-field! kVTRotation_CCW90 not bound -!missing-field! kVTRotation_CW90 not bound -!missing-pinvoke! VTPixelRotationSessionCreate is not bound -!missing-pinvoke! VTPixelRotationSessionGetTypeID is not bound -!missing-pinvoke! VTPixelRotationSessionInvalidate is not bound -!missing-pinvoke! VTPixelRotationSessionRotateImage is not bound -!missing-pinvoke! VTPixelTransferSessionCreate is not bound -!missing-pinvoke! VTPixelTransferSessionGetTypeID is not bound -!missing-pinvoke! VTPixelTransferSessionInvalidate is not bound -!missing-pinvoke! VTPixelTransferSessionTransferImage is not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/iOS-VideoToolbox.todo b/tests/xtro-sharpie/api-annotations-dotnet/iOS-VideoToolbox.todo deleted file mode 100644 index 90bce8c3310f..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/iOS-VideoToolbox.todo +++ /dev/null @@ -1,20 +0,0 @@ -!missing-field! kVTCompressionPropertyKey_ConstantBitRate not bound -!missing-field! kVTCompressionPropertyKey_MinAllowedFrameQP not bound -!missing-field! kVTCompressionPropertyKey_ReferenceBufferCount not bound -!missing-field! kVTPixelRotationPropertyKey_FlipHorizontalOrientation not bound -!missing-field! kVTPixelRotationPropertyKey_FlipVerticalOrientation not bound -!missing-field! kVTPixelRotationPropertyKey_Rotation not bound -!missing-field! kVTRotation_0 not bound -!missing-field! kVTRotation_180 not bound -!missing-field! kVTRotation_CCW90 not bound -!missing-field! kVTRotation_CW90 not bound -!missing-pinvoke! VTPixelRotationSessionCreate is not bound -!missing-pinvoke! VTPixelRotationSessionGetTypeID is not bound -!missing-pinvoke! VTPixelRotationSessionInvalidate is not bound -!missing-pinvoke! VTPixelRotationSessionRotateImage is not bound -!missing-pinvoke! VTPixelTransferSessionCreate is not bound -!missing-pinvoke! VTPixelTransferSessionGetTypeID is not bound -!missing-pinvoke! VTPixelTransferSessionInvalidate is not bound -!missing-pinvoke! VTPixelTransferSessionTransferImage is not bound -!missing-field! kVTCompressionPropertyKey_EstimatedAverageBytesPerFrame not bound -!missing-field! kVTCompressionPropertyKey_PreserveAlphaChannel not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/macOS-VideoToolbox.ignore b/tests/xtro-sharpie/api-annotations-dotnet/macOS-VideoToolbox.ignore deleted file mode 100644 index da394b7816ec..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/macOS-VideoToolbox.ignore +++ /dev/null @@ -1,6 +0,0 @@ -!missing-pinvoke! VTPixelTransferSessionCreate is not bound -!missing-pinvoke! VTPixelTransferSessionGetTypeID is not bound -!missing-pinvoke! VTPixelTransferSessionInvalidate is not bound -!missing-pinvoke! VTPixelTransferSessionTransferImage is not bound -!missing-pinvoke! VTRegisterProfessionalVideoWorkflowVideoDecoders is not bound -!missing-pinvoke! VTRegisterProfessionalVideoWorkflowVideoEncoders is not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/macOS-VideoToolbox.todo b/tests/xtro-sharpie/api-annotations-dotnet/macOS-VideoToolbox.todo deleted file mode 100644 index 5e590289bc20..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/macOS-VideoToolbox.todo +++ /dev/null @@ -1,16 +0,0 @@ -!missing-field! kVTCompressionPropertyKey_ConstantBitRate not bound -!missing-field! kVTCompressionPropertyKey_MinAllowedFrameQP not bound -!missing-field! kVTCompressionPropertyKey_ReferenceBufferCount not bound -!missing-field! kVTPixelRotationPropertyKey_FlipHorizontalOrientation not bound -!missing-field! kVTPixelRotationPropertyKey_FlipVerticalOrientation not bound -!missing-field! kVTPixelRotationPropertyKey_Rotation not bound -!missing-field! kVTRotation_0 not bound -!missing-field! kVTRotation_180 not bound -!missing-field! kVTRotation_CCW90 not bound -!missing-field! kVTRotation_CW90 not bound -!missing-pinvoke! VTPixelRotationSessionCreate is not bound -!missing-pinvoke! VTPixelRotationSessionGetTypeID is not bound -!missing-pinvoke! VTPixelRotationSessionInvalidate is not bound -!missing-pinvoke! VTPixelRotationSessionRotateImage is not bound -!missing-field! kVTCompressionPropertyKey_EstimatedAverageBytesPerFrame not bound -!missing-field! kVTCompressionPropertyKey_PreserveAlphaChannel not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/tvOS-VideoToolbox.todo b/tests/xtro-sharpie/api-annotations-dotnet/tvOS-VideoToolbox.todo deleted file mode 100644 index 90bce8c3310f..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/tvOS-VideoToolbox.todo +++ /dev/null @@ -1,20 +0,0 @@ -!missing-field! kVTCompressionPropertyKey_ConstantBitRate not bound -!missing-field! kVTCompressionPropertyKey_MinAllowedFrameQP not bound -!missing-field! kVTCompressionPropertyKey_ReferenceBufferCount not bound -!missing-field! kVTPixelRotationPropertyKey_FlipHorizontalOrientation not bound -!missing-field! kVTPixelRotationPropertyKey_FlipVerticalOrientation not bound -!missing-field! kVTPixelRotationPropertyKey_Rotation not bound -!missing-field! kVTRotation_0 not bound -!missing-field! kVTRotation_180 not bound -!missing-field! kVTRotation_CCW90 not bound -!missing-field! kVTRotation_CW90 not bound -!missing-pinvoke! VTPixelRotationSessionCreate is not bound -!missing-pinvoke! VTPixelRotationSessionGetTypeID is not bound -!missing-pinvoke! VTPixelRotationSessionInvalidate is not bound -!missing-pinvoke! VTPixelRotationSessionRotateImage is not bound -!missing-pinvoke! VTPixelTransferSessionCreate is not bound -!missing-pinvoke! VTPixelTransferSessionGetTypeID is not bound -!missing-pinvoke! VTPixelTransferSessionInvalidate is not bound -!missing-pinvoke! VTPixelTransferSessionTransferImage is not bound -!missing-field! kVTCompressionPropertyKey_EstimatedAverageBytesPerFrame not bound -!missing-field! kVTCompressionPropertyKey_PreserveAlphaChannel not bound diff --git a/tests/xtro-sharpie/iOS-VideoToolbox.todo b/tests/xtro-sharpie/iOS-VideoToolbox.todo deleted file mode 100644 index 90bce8c3310f..000000000000 --- a/tests/xtro-sharpie/iOS-VideoToolbox.todo +++ /dev/null @@ -1,20 +0,0 @@ -!missing-field! kVTCompressionPropertyKey_ConstantBitRate not bound -!missing-field! kVTCompressionPropertyKey_MinAllowedFrameQP not bound -!missing-field! kVTCompressionPropertyKey_ReferenceBufferCount not bound -!missing-field! kVTPixelRotationPropertyKey_FlipHorizontalOrientation not bound -!missing-field! kVTPixelRotationPropertyKey_FlipVerticalOrientation not bound -!missing-field! kVTPixelRotationPropertyKey_Rotation not bound -!missing-field! kVTRotation_0 not bound -!missing-field! kVTRotation_180 not bound -!missing-field! kVTRotation_CCW90 not bound -!missing-field! kVTRotation_CW90 not bound -!missing-pinvoke! VTPixelRotationSessionCreate is not bound -!missing-pinvoke! VTPixelRotationSessionGetTypeID is not bound -!missing-pinvoke! VTPixelRotationSessionInvalidate is not bound -!missing-pinvoke! VTPixelRotationSessionRotateImage is not bound -!missing-pinvoke! VTPixelTransferSessionCreate is not bound -!missing-pinvoke! VTPixelTransferSessionGetTypeID is not bound -!missing-pinvoke! VTPixelTransferSessionInvalidate is not bound -!missing-pinvoke! VTPixelTransferSessionTransferImage is not bound -!missing-field! kVTCompressionPropertyKey_EstimatedAverageBytesPerFrame not bound -!missing-field! kVTCompressionPropertyKey_PreserveAlphaChannel not bound diff --git a/tests/xtro-sharpie/macOS-VideoToolbox.ignore b/tests/xtro-sharpie/macOS-VideoToolbox.ignore deleted file mode 100644 index da394b7816ec..000000000000 --- a/tests/xtro-sharpie/macOS-VideoToolbox.ignore +++ /dev/null @@ -1,6 +0,0 @@ -!missing-pinvoke! VTPixelTransferSessionCreate is not bound -!missing-pinvoke! VTPixelTransferSessionGetTypeID is not bound -!missing-pinvoke! VTPixelTransferSessionInvalidate is not bound -!missing-pinvoke! VTPixelTransferSessionTransferImage is not bound -!missing-pinvoke! VTRegisterProfessionalVideoWorkflowVideoDecoders is not bound -!missing-pinvoke! VTRegisterProfessionalVideoWorkflowVideoEncoders is not bound diff --git a/tests/xtro-sharpie/macOS-VideoToolbox.todo b/tests/xtro-sharpie/macOS-VideoToolbox.todo deleted file mode 100644 index 5e590289bc20..000000000000 --- a/tests/xtro-sharpie/macOS-VideoToolbox.todo +++ /dev/null @@ -1,16 +0,0 @@ -!missing-field! kVTCompressionPropertyKey_ConstantBitRate not bound -!missing-field! kVTCompressionPropertyKey_MinAllowedFrameQP not bound -!missing-field! kVTCompressionPropertyKey_ReferenceBufferCount not bound -!missing-field! kVTPixelRotationPropertyKey_FlipHorizontalOrientation not bound -!missing-field! kVTPixelRotationPropertyKey_FlipVerticalOrientation not bound -!missing-field! kVTPixelRotationPropertyKey_Rotation not bound -!missing-field! kVTRotation_0 not bound -!missing-field! kVTRotation_180 not bound -!missing-field! kVTRotation_CCW90 not bound -!missing-field! kVTRotation_CW90 not bound -!missing-pinvoke! VTPixelRotationSessionCreate is not bound -!missing-pinvoke! VTPixelRotationSessionGetTypeID is not bound -!missing-pinvoke! VTPixelRotationSessionInvalidate is not bound -!missing-pinvoke! VTPixelRotationSessionRotateImage is not bound -!missing-field! kVTCompressionPropertyKey_EstimatedAverageBytesPerFrame not bound -!missing-field! kVTCompressionPropertyKey_PreserveAlphaChannel not bound diff --git a/tests/xtro-sharpie/tvOS-VideoToolbox.todo b/tests/xtro-sharpie/tvOS-VideoToolbox.todo deleted file mode 100644 index 90bce8c3310f..000000000000 --- a/tests/xtro-sharpie/tvOS-VideoToolbox.todo +++ /dev/null @@ -1,20 +0,0 @@ -!missing-field! kVTCompressionPropertyKey_ConstantBitRate not bound -!missing-field! kVTCompressionPropertyKey_MinAllowedFrameQP not bound -!missing-field! kVTCompressionPropertyKey_ReferenceBufferCount not bound -!missing-field! kVTPixelRotationPropertyKey_FlipHorizontalOrientation not bound -!missing-field! kVTPixelRotationPropertyKey_FlipVerticalOrientation not bound -!missing-field! kVTPixelRotationPropertyKey_Rotation not bound -!missing-field! kVTRotation_0 not bound -!missing-field! kVTRotation_180 not bound -!missing-field! kVTRotation_CCW90 not bound -!missing-field! kVTRotation_CW90 not bound -!missing-pinvoke! VTPixelRotationSessionCreate is not bound -!missing-pinvoke! VTPixelRotationSessionGetTypeID is not bound -!missing-pinvoke! VTPixelRotationSessionInvalidate is not bound -!missing-pinvoke! VTPixelRotationSessionRotateImage is not bound -!missing-pinvoke! VTPixelTransferSessionCreate is not bound -!missing-pinvoke! VTPixelTransferSessionGetTypeID is not bound -!missing-pinvoke! VTPixelTransferSessionInvalidate is not bound -!missing-pinvoke! VTPixelTransferSessionTransferImage is not bound -!missing-field! kVTCompressionPropertyKey_EstimatedAverageBytesPerFrame not bound -!missing-field! kVTCompressionPropertyKey_PreserveAlphaChannel not bound