-
Notifications
You must be signed in to change notification settings - Fork 515
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[VideoToolbox] Added support for Xcode 14 b1-3 (#15845)
Co-authored-by: Alex Soto <[email protected]> Co-authored-by: Rolf Bjarne Kvinge <[email protected]> Co-authored-by: Manuel de la Pena <[email protected]>
- Loading branch information
1 parent
216018c
commit bac36c5
Showing
19 changed files
with
550 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// VTPixelRotationProperties.cs: Strongly Typed dictionary for VTPixelRotationPropertyKeys | ||
// | ||
// Authors: Israel Soto ([email protected]) | ||
// | ||
// 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 ()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// | ||
// VTPixelRotationSession.cs: VideoTools Pixel Rotation Session class | ||
// | ||
// Authors: | ||
// Israel Soto ([email protected]) | ||
// | ||
// 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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// | ||
// VTPixelTransferSession.cs: VideoTools Pixel Transfer Session class | ||
// | ||
// Authors: | ||
// Israel Soto ([email protected]) | ||
// | ||
// 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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// VTProfessionalVideoWorkflow.cs: VideoTools Professional Video Workflow | ||
// | ||
// Authors: | ||
// Israel Soto ([email protected]) | ||
// | ||
// 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__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.