-
Notifications
You must be signed in to change notification settings - Fork 511
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
[CoreVideo] Add support for Xcode 13 beta3. #12257
Changes from 1 commit
da24cab
7d79213
7b35179
915f8e6
2b32222
03026b5
dcbbdf3
ecb3a76
b1e0ec9
c33bb04
21b7238
43657fc
127806e
ba74e6f
76d8cc2
2aba632
3da2cc7
1b6f927
02ec533
a94f580
733cc93
35503c8
f091491
7cd7f9e
23e6096
43a87fc
be1614e
1da2f02
94d8143
b141a30
050f6f0
5c17e7d
e522eb4
ac7a987
d44a025
3949601
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
// | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.Versioning; | ||
using CoreFoundation; | ||
using ObjCRuntime; | ||
using Foundation; | ||
|
@@ -150,9 +151,9 @@ public NSObject GetAttachment (NSString key, out CVAttachmentMode attachmentMode | |
if (key == null) | ||
throw new ArgumentNullException ("key"); | ||
if (PlatformHelper.CheckSystemVersion (12, 0)) | ||
return Runtime.GetNSObject (CVBufferCopyAttachment (handle, key.Handle, out attachmentMode)); | ||
return Runtime.GetINativeObject<NSObject> (CVBufferCopyAttachment (handle, key.Handle, out attachmentMode), true); | ||
mandel-macaque marked this conversation as resolved.
Show resolved
Hide resolved
|
||
else | ||
return Runtime.GetNSObject (CVBufferGetAttachment (handle, key.Handle, out attachmentMode)); | ||
return Runtime.GetINativeObject<NSObject> (CVBufferGetAttachment (handle, key.Handle, out attachmentMode), false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same
mandel-macaque marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
#endif | ||
|
||
|
@@ -177,8 +178,8 @@ public NSDictionary GetAttachments (CVAttachmentMode attachmentMode) | |
#elif MONOMAC | ||
if (PlatformHelper.CheckSystemVersion (12, 0)) | ||
#endif | ||
return (NSDictionary) Runtime.GetNSObject (CVBufferCopyAttachments (handle, attachmentMode)); | ||
return (NSDictionary) Runtime.GetNSObject (CVBufferGetAttachments (handle, attachmentMode)); | ||
return Runtime.GetINativeObject<NSDictionary> (CVBufferCopyAttachments (handle, attachmentMode), true); | ||
return Runtime.GetINativeObject<NSDictionary> (CVBufferGetAttachments (handle, attachmentMode), false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
mandel-macaque marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// There is some API that needs a more strongly typed version of a NSDictionary | ||
|
@@ -232,7 +233,7 @@ public void SetAttachments (NSDictionary theAttachments, CVAttachmentMode attach | |
[SupportedOSPlatform ("macos12.0")] | ||
#endif | ||
[DllImport (Constants.CoreVideoLibrary)] | ||
[return: MarshalAs(UnmanagedType.U1)] | ||
[return: MarshalAs (UnmanagedType.U1)] | ||
static extern bool CVBufferHasAttachment (/* CVBufferRef */ IntPtr buffer, /* CFStringRef */ IntPtr key); | ||
|
||
#if !NET | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
#if __MACOS__ | ||
using System; | ||
using CoreGraphics; | ||
using Foundation; | ||
using NUnit.Framework; | ||
using Foundation; | ||
using ObjCRuntime; | ||
using CoreVideo; | ||
|
||
namespace MonoTouchFixtures.CoreVideo { | ||
|
||
[TestFixture] | ||
[Preserve (AllMembers = true)] | ||
public class CVDisplayLinkTest { | ||
int? mainDisplayId = null; | ||
|
||
[SetUp] | ||
public void SetUp () | ||
{ | ||
// we need to have access to the media display to be able to perform | ||
// the displaylink tests | ||
mainDisplayId = CGDisplay.MainDisplayID; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can remove SetUp and TearDown. |
||
} | ||
|
||
[TearDown] | ||
public void TearDown () | ||
{ | ||
mainDisplayId = null; | ||
} | ||
|
||
[Test] | ||
public void CreateFromDisplayIdValidIdTest () | ||
{ | ||
TestRuntime.AssertSystemVersion (PlatformName.MacOSX, 12, 0); | ||
Assert.DoesNotThrow (() => { | ||
using var displayLink = CVDisplayLink.CreateFromDisplayId ((uint) CGDisplay.MainDisplayID); | ||
Assert.NotNull (displayLink, "Not null"); | ||
Assert.AreEqual (CGDisplay.MainDisplayID, displayLink.GetCurrentDisplay (), "DisplayId"); | ||
}, "Throws"); | ||
} | ||
|
||
[Test] | ||
public void CreateFromDisplayWrongIdTest () | ||
{ | ||
TestRuntime.AssertSystemVersion (PlatformName.MacOSX, 12, 0); | ||
Assert.DoesNotThrow (() => { | ||
using var displayLink = CVDisplayLink.CreateFromDisplayId (UInt32.MaxValue); | ||
Assert.Null (displayLink, "null"); | ||
}, "Throws"); | ||
} | ||
|
||
[Test] | ||
public void CreateFromDisplayIdsTest () | ||
{ | ||
TestRuntime.AssertSystemVersion (PlatformName.MacOSX, 12, 0); | ||
// we might not have more than one display, therefore we will use an array | ||
// with a single one, there is nothing in the docs that say that we cannot do that | ||
Assert.DoesNotThrow (() => { | ||
using var displayLink = CVDisplayLink.CreateFromDisplayIds (new []{ (uint) CGDisplay.MainDisplayID}); | ||
Assert.Null (displayLink, "null"); | ||
}, "Throws"); | ||
} | ||
|
||
[Test] | ||
public void CreateFromOpenGLMaskTest () | ||
{ | ||
TestRuntime.AssertSystemVersion (PlatformName.MacOSX, 12, 0); | ||
var openGLMask = CGDisplay.GetOpenGLDisplayMask (CGDisplay.MainDisplayID); | ||
Assert.DoesNotThrow (() => { | ||
using var displayLink = CVDisplayLink.CreateFromOpenGLMask ((uint) openGLMask); | ||
Assert.NotNull (displayLink, "Not null"); | ||
}, "Throws"); | ||
} | ||
|
||
[Test] | ||
public void DefaultconstructorTest () => Assert.DoesNotThrow (() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: DefaultconstructorTest -> DefaultConstructorTest |
||
using var displayLink = new CVDisplayLink (); | ||
}); | ||
|
||
[Test] | ||
public void SetCurrentDisplayOpenGLTest () => Assert.DoesNotThrow (() => { | ||
using var displayLink = new CVDisplayLink (); | ||
displayLink.SetCurrentDisplay (CGDisplay.MainDisplayID); | ||
}); | ||
|
||
[Test] | ||
public void GetCurrentDisplayTest () => Assert.DoesNotThrow (() => { | ||
using var displayLink = new CVDisplayLink (); | ||
Assert.AreEqual (CGDisplay.MainDisplayID, displayLink.GetCurrentDisplay ()); | ||
}); | ||
|
||
[Test] | ||
public void GetTypeIdTest () | ||
{ | ||
TestRuntime.AssertSystemVersion (PlatformName.MacOSX, 12, 0); | ||
Assert.DoesNotThrow (() => { | ||
CVDisplayLink.GetTypeId (); | ||
}, "Throws"); | ||
} | ||
|
||
[Test] | ||
public void TryTranslateTimeValidTest () | ||
{ | ||
TestRuntime.AssertSystemVersion (PlatformName.MacOSX, 12, 0); | ||
using var displayLink = new CVDisplayLink (); | ||
displayLink.GetCurrentTime (out var timeStamp); | ||
Assert.True (displayLink.TryTranslateTime (timeStamp, out var _)); | ||
} | ||
} | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Runtime.GetNSObject<NSObject> (ptr, true)
since
GetINativeObject
logic is more complex and you already know the return type.