[videotoolbox] Update for dotnet attributes (#11342)

and ajust xtro for unavbailable Catalyst API
This commit is contained in:
Sebastien Pouliot 2021-04-27 08:43:59 -04:00 коммит произвёл GitHub
Родитель b88c3bb031
Коммит cd4e5b543e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
10 изменённых файлов: 151 добавлений и 3 удалений

Просмотреть файл

@ -7,6 +7,7 @@
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Collections.Generic;
using CoreFoundation;
@ -284,7 +285,9 @@ namespace VideoToolbox {
}
}
#if !NET
[Mac (10,9)]
#endif
public VTH264EntropyMode H264EntropyMode {
get {
var key = GetNSStringValue (VTCompressionPropertyKey.H264EntropyMode);
@ -490,9 +493,15 @@ namespace VideoToolbox {
}
}
#if NET
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.15")]
#else
[Introduced (PlatformName.MacOSX, 10,15)]
[Introduced (PlatformName.iOS, 13,0)]
[Introduced (PlatformName.TvOS, 13,0)]
#endif
public VTAlphaChannelMode AlphaChannelMode {
get => VTAlphaChannelModeExtensions.GetValue (GetNSStringValue (VTCompressionPropertyKey.AlphaChannelMode));
set => SetStringValue (VTCompressionPropertyKey.AlphaChannelMode, value.GetConstant ());

Просмотреть файл

@ -204,11 +204,15 @@ namespace VideoToolbox {
return null;
}
#if !NET
[Mac (10,9)]
#endif
[DllImport (Constants.VideoToolboxLibrary)]
extern static VTStatus VTCompressionSessionPrepareToEncodeFrames (IntPtr handle);
#if !NET
[Mac (10,9)]
#endif
public VTStatus PrepareToEncodeFrames ()
{
if (Handle == IntPtr.Zero)
@ -306,11 +310,15 @@ namespace VideoToolbox {
return VTCompressionSessionCompleteFrames (Handle, completeUntilPresentationTimeStamp);
}
#if !NET
[Mac (10,10)]
#endif
[DllImport (Constants.VideoToolboxLibrary)]
extern static VTStatus VTCompressionSessionBeginPass (IntPtr session, VTCompressionSessionOptionFlags flags, IntPtr reserved);
#if !NET
[Mac (10,10)]
#endif
public VTStatus BeginPass (VTCompressionSessionOptionFlags flags)
{
if (Handle == IntPtr.Zero)
@ -318,15 +326,21 @@ namespace VideoToolbox {
return VTCompressionSessionBeginPass (Handle, flags, IntPtr.Zero);
}
#if !NET
[Mac (10,10)]
#endif
[DllImport (Constants.VideoToolboxLibrary)]
extern static VTStatus VTCompressionSessionEndPass (IntPtr session, out byte furtherPassesRequestedOut, IntPtr reserved);
#if !NET
[Mac (10,10)]
#endif
[DllImport (Constants.VideoToolboxLibrary)]
extern static VTStatus VTCompressionSessionEndPass (IntPtr session, IntPtr ptrByte, IntPtr reserved);
#if !NET
[Mac (10,10)]
#endif
public VTStatus EndPass (out bool furtherPassesRequested)
{
if (Handle == IntPtr.Zero)
@ -347,14 +361,18 @@ namespace VideoToolbox {
return VTCompressionSessionEndPass (Handle, IntPtr.Zero, IntPtr.Zero);
}
#if !NET
[Mac (10,10)]
#endif
[DllImport (Constants.VideoToolboxLibrary)]
extern static VTStatus VTCompressionSessionGetTimeRangesForNextPass (
/* VTCompressionSessionRef */ IntPtr session,
/* CMItemCount* */ out int itemCount,
/* const CMTimeRange** */ out IntPtr target);
#if !NET
[Mac (10,10)]
#endif
public VTStatus GetTimeRangesForNextPass (out CMTimeRange [] timeRanges)
{
if (Handle == IntPtr.Zero)

Просмотреть файл

@ -9,6 +9,7 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using CoreFoundation;
using ObjCRuntime;
@ -17,7 +18,12 @@ using CoreMedia;
using CoreVideo;
namespace VideoToolbox {
#if NET
[SupportedOSPlatform ("tvos10.2")]
#else
[iOS (8,0), TV (10,2)]
#endif
public class VTDecompressionSession : VTSession {
GCHandle callbackHandle;
@ -338,12 +344,22 @@ namespace VideoToolbox {
return VTSessionSetProperties (Handle, options.Dictionary.Handle);
}
#if NET
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#else
[Mac (10,13), iOS (11,0), TV (11,0)]
#endif
[DllImport (Constants.VideoToolboxLibrary)]
[return: MarshalAs (UnmanagedType.U1)]
extern static bool VTIsHardwareDecodeSupported (CMVideoCodecType codecType);
#if NET
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#else
[Mac (10,13), iOS (11,0), TV (11,0)]
#endif
public static bool IsHardwareDecodeSupported (CMVideoCodecType codecType)
{
return VTIsHardwareDecodeSupported (codecType);

Просмотреть файл

@ -9,6 +9,7 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using CoreFoundation;
using ObjCRuntime;
@ -16,7 +17,12 @@ using Foundation;
using CoreMedia;
namespace VideoToolbox {
#if NET
[SupportedOSPlatform ("tvos10.2")]
#else
[Mac (10,10), iOS (8,0), TV (10,2)]
#endif
public class VTFrameSilo : INativeObject, IDisposable {
IntPtr handle;
GCHandle callbackHandle;

Просмотреть файл

@ -9,6 +9,7 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using CoreFoundation;
using ObjCRuntime;
@ -16,7 +17,12 @@ using Foundation;
using CoreMedia;
namespace VideoToolbox {
#if NET
[SupportedOSPlatform ("tvos10.2")]
#else
[Mac (10,10), iOS (8,0), TV (10,2)]
#endif
public class VTMultiPassStorage : INativeObject, IDisposable {
IntPtr handle;
bool closed;

Просмотреть файл

@ -84,7 +84,9 @@ namespace VideoToolbox {
}
}
#if !NET
[iOS (10,0)]
#endif
public VTColorPrimaries DestinationColorPrimaries {
get {
var key = GetNSStringValue (VTPixelTransferPropertyKeys.DestinationColorPrimaries);
@ -122,7 +124,9 @@ namespace VideoToolbox {
}
}
#if !NET
[iOS (10,0)]
#endif
public VTTransferFunction DestinationTransferFunction {
get {
var key = GetNSStringValue (VTPixelTransferPropertyKeys.DestinationTransferFunction);

Просмотреть файл

@ -8,6 +8,7 @@
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using CoreFoundation;
using ObjCRuntime;
@ -16,7 +17,12 @@ using CoreMedia;
using CoreVideo;
namespace VideoToolbox {
#if NET
[SupportedOSPlatform ("tvos10.2")]
#else
[iOS (8,0), TV (10,2)]
#endif
public class VTSession : INativeObject, IDisposable {
IntPtr handle;

Просмотреть файл

@ -9,6 +9,7 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using ObjCRuntime;
using CoreGraphics;
@ -16,7 +17,12 @@ using CoreMedia;
using CoreVideo;
namespace VideoToolbox {
#if NET
[SupportedOSPlatform ("tvos10.2")]
#else
[Mac (10,11), iOS (9,0), TV (10,2)]
#endif
public static class VTUtilities {
[DllImport (Constants.VideoToolboxLibrary)]
extern static VTStatus VTCreateCGImageFromCVPixelBuffer (
@ -48,11 +54,26 @@ namespace VideoToolbox {
}
#if MONOMAC
#if NET
[SupportedOSPlatform ("macos11.0")]
[UnsupportedOSPlatform ("ios")]
[UnsupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("maccatalyst")]
#else
[NoWatch, NoTV, NoiOS, Mac (11,0)]
#endif
[DllImport (Constants.VideoToolboxLibrary)]
static extern void VTRegisterSupplementalVideoDecoderIfAvailable (uint codecType);
#if NET
[SupportedOSPlatform ("macos11.0")]
[UnsupportedOSPlatform ("ios")]
[UnsupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("maccatalyst")]
#else
[NoWatch, NoTV, NoiOS, Mac (11,0)]
#endif
public static void RegisterSupplementalVideoDecoder (CMVideoCodecType codecType)
=> VTRegisterSupplementalVideoDecoderIfAvailable ((uint) codecType);
#endif

Просмотреть файл

@ -6,6 +6,7 @@
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using CoreFoundation;
using ObjCRuntime;
@ -13,7 +14,12 @@ using Foundation;
using CoreMedia;
namespace VideoToolbox {
#if NET
[SupportedOSPlatform ("tvos10.2")]
#else
[iOS (8,0), TV (10,2)]
#endif
public class VTVideoEncoder {
[DllImport (Constants.VideoToolboxLibrary)]
@ -42,25 +48,69 @@ namespace VideoToolbox {
public string EncoderId { get; private set; }
public string EncoderName { get; private set; }
#if NET
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.14.6")]
#else
[Mac (10,14,6), iOS (13,0), TV (13,0)]
#endif
public ulong? GpuRegistryId { get; private set; } // optional, same type as `[MTLDevice registryID]`
#if NET
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.14.6")]
#else
[Mac (10,14,6), iOS (13,0), TV (13,0)]
#endif
public NSDictionary SupportedSelectionProperties {get; private set; }
#if NET
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.14.6")]
#else
[Mac (10,14,6), iOS (13,0), TV (13,0)]
#endif
public NSNumber PerformanceRating { get; private set; }
#if NET
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.14.6")]
#else
[Mac (10,14,6), iOS (13,0), TV (13,0)]
#endif
public NSNumber QualityRating { get; private set; }
#if NET
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.14.6")]
#else
[Mac (10,14,6), iOS (13,0), TV (13,0)]
#endif
public bool? InstanceLimit { get; private set; }
#if NET
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("tvos13.0")]
[SupportedOSPlatform ("macos10.14.6")]
#else
[Mac (10,14,6), iOS (13,0), TV (13,0)]
#endif
public bool? IsHardwareAccelerated { get; private set; }
#if NET
[SupportedOSPlatform ("ios14.2")]
[SupportedOSPlatform ("tvos14.2")]
[SupportedOSPlatform ("maccatalyst14.2")]
[SupportedOSPlatform ("macos11.0")]
#else
[iOS (14,2)][TV (14,2)][Mac (11,0)]
[MacCatalyst (14,2)]
#endif
public bool SupportsFrameReordering { get; private set; }
internal VTVideoEncoder (NSDictionary dict)
@ -116,7 +166,12 @@ namespace VideoToolbox {
}
}
#if NET
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#else
[Mac (10,13), iOS (11,0), TV (11,0)]
#endif
[DllImport (Constants.VideoToolboxLibrary)]
static extern /* OSStatus */ VTStatus VTCopySupportedPropertyDictionaryForEncoder (
/* int32_t */ int width,
@ -127,7 +182,12 @@ namespace VideoToolbox {
/* CFDictionaryRef */ out IntPtr outSupportedProperties
);
#if NET
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#else
[Mac (10,13), iOS (11,0), TV (11,0)]
#endif
public static VTSupportedEncoderProperties GetSupportedEncoderProperties (int width, int height, CMVideoCodecType codecType, NSDictionary encoderSpecification = null)
{
IntPtr encoderIdPtr = IntPtr.Zero;
@ -152,7 +212,12 @@ namespace VideoToolbox {
}
}
#if NET
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#else
[Mac (10,13), iOS (11,0), TV (11,0)]
#endif
public class VTSupportedEncoderProperties {
public string EncoderId { get; set; }
public NSDictionary SupportedProperties { get; set; }

Просмотреть файл

@ -1,3 +0,0 @@
!missing-field! kVTVideoDecoderSpecification_PreferredDecoderGPURegistryID not bound
!missing-field! kVTVideoDecoderSpecification_RequiredDecoderGPURegistryID not bound
!missing-pinvoke! VTRegisterSupplementalVideoDecoderIfAvailable is not bound