Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VideoToolbox] Added support for Xcode 14 b1-3 #15845

Merged
merged 30 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b0203d7
Revert "[BackgroundAssets] Add new framework from Xcode1 4 beta 4. (#…
dalexsoto Sep 7, 2022
d428810
[xcode14] Bump to Xcode 14 RC
dalexsoto Sep 8, 2022
66fbeef
Fix intro tests
dalexsoto Sep 8, 2022
9a6cae9
Merge remote-tracking branch 'xamarin/xcode14' into xcode14-rc-bump
dalexsoto Sep 8, 2022
c7c2ed0
Remove not needed BackgroundAssets.todo
dalexsoto Sep 9, 2022
1102c78
[devops] Work around the fact that macOS is disabled in this branch.
rolfbjarne Sep 9, 2022
031410f
[devops] More fixes for missing (as expected) Xamarin.Mac.
rolfbjarne Sep 9, 2022
994dbaa
[VideoToolbox] Added support for Xcode 14 b1-3
Aug 31, 2022
29ea7a3
[VideoToolbox] Added macOS only file
Aug 31, 2022
113ad99
[VideoToolbox] Added tests
Sep 1, 2022
2762972
[VideoToolbox] Moved the OutputBitDepth StrongDictionary prop to the …
Sep 1, 2022
f3cb3c3
[VideoToolbox] Added suggestions
Sep 1, 2022
c0e6e66
[VideoToolbox] Added suggestions
Sep 2, 2022
e70d077
[devops] Only add platforms we're building for into WorkloadRollback.…
rolfbjarne Sep 9, 2022
eba9544
Xcode 14 RC 1 requires macOS 12.5.
rolfbjarne Sep 9, 2022
7435d8a
[devops] Fix typo in bash script.
rolfbjarne Sep 12, 2022
2ef695d
[devops] Don't create legacy iOS/Mac symlinks unless legacy build is …
rolfbjarne Sep 12, 2022
77dd98c
Merge remote-tracking branch 'origin/xcode14' into xcode14-rc-bump
rolfbjarne Sep 12, 2022
e7c187d
[VideoToolbox] Removed extra SupportedOSPlatform attributes
Sep 9, 2022
00b3705
Merge branch 'xcode14' into xcode14-rc-bump
dalexsoto Sep 13, 2022
4c90a7f
Bump to stable Xcode 14
dalexsoto Sep 13, 2022
1d38f94
[devops] Fix parsing WorkloadRollback.json.
rolfbjarne Sep 13, 2022
6f8d821
[devops] Fix json syntax.
rolfbjarne Sep 13, 2022
bb9eb0a
Fix xtro.
rolfbjarne Sep 13, 2022
6df6207
[tests] Ignore tests that require platforms not included in the curre…
rolfbjarne Sep 15, 2022
a2f89bd
Merge remote-tracking branch 'origin/xcode14' into xcode14-rc-bump
rolfbjarne Sep 15, 2022
c629dd8
[xcode14] Bump to Xcode 14 (#15898)
rolfbjarne Sep 15, 2022
e7571c8
Merge branch 'xcode14' into VideoToolbox-xcode14
mandel-macaque Oct 3, 2022
663e3ec
Merge branch 'xcode14.1' into VideoToolbox-xcode14
mandel-macaque Oct 12, 2022
41c9c8e
Merge branch 'xcode14.1' into VideoToolbox-xcode14
mandel-macaque Oct 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/VideoToolbox/VTDefs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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,
}
}
29 changes: 29 additions & 0 deletions src/VideoToolbox/VTPixelRotationProperties.cs
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 ());
}
}
}
107 changes: 107 additions & 0 deletions src/VideoToolbox/VTPixelRotationSession.cs
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);
}
}
}
106 changes: 106 additions & 0 deletions src/VideoToolbox/VTPixelTransferSession.cs
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);
}
}
}
40 changes: 40 additions & 0 deletions src/VideoToolbox/VTProfessionalVideoWorkflow.cs
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__
SotoiGhost marked this conversation as resolved.
Show resolved Hide resolved

#nullable enable

using System;
using System.Runtime.InteropServices;

using ObjCRuntime;
using Foundation;

namespace VideoToolbox {

#if NET
[SupportedOSPlatform ("macos10.9")]
SotoiGhost marked this conversation as resolved.
Show resolved Hide resolved
[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__
5 changes: 5 additions & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
Loading