Skip to content

Commit

Permalink
Address reviews.
Browse files Browse the repository at this point in the history
  • Loading branch information
mandel-macaque committed Aug 26, 2021
1 parent aaa698a commit 1ee4425
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 27 deletions.
11 changes: 8 additions & 3 deletions src/AVFoundation/AVTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,18 @@ public enum AVCaptionUnitsType : long {
[StructLayout (LayoutKind.Sequential)]
public struct AVCaptionDimension {
public nfloat Value;
public AVCaptionUnitsType Units;
public nuint units;

public AVCaptionUnitsType Units {
get => (AVCaptionUnitsType) (long) units;
set => units = (nuint) (long) value;
}

[DllImport (Constants.AVFoundationLibrary)]
static extern AVCaptionDimension AVCaptionDimensionMake (nfloat dimension, AVCaptionUnitsType units);
static extern AVCaptionDimension AVCaptionDimensionMake (nfloat dimension, /* AVCaptionUnitsType */ nuint units);

public static AVCaptionDimension Create (nfloat dimension, AVCaptionUnitsType units)
=> AVCaptionDimensionMake (dimension, units);
=> AVCaptionDimensionMake (dimension, (nuint) (long)units);
}

#if !NET
Expand Down
12 changes: 6 additions & 6 deletions src/AVFoundation/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1349,17 +1349,17 @@ public enum AVCaptionFontStyle : long {
#endif
[Flags]
[Native]
public enum AVCaptionDecoration : ulong {
public enum AVCaptionDecoration : ulong {
None = 0x0,
Underline = 1uL << 0,
LineThrough = 1uL << 1,
Overline = 1uL << 2,
}

#if !NET
[NoWatch, NoTV, NoiOS, Mac (12,0), NoMacCatalyst]
[NoWatch, NoTV, NoiOS, Mac (12,0), NoMacCatalyst]
#else
[UnsupportedOSPlatform ("ios"), UnsupportedOSPlatform ("tvos"), UnsupportedOSPlatform ("maccatalyst"), SupportedOSPlatform ("macos12.0")]
[UnsupportedOSPlatform ("ios"), UnsupportedOSPlatform ("tvos"), UnsupportedOSPlatform ("maccatalyst"), SupportedOSPlatform ("macos12.0")]
#endif
[Native]
public enum AVCaptionTextCombine : long {
Expand All @@ -1372,9 +1372,9 @@ public enum AVCaptionTextCombine : long {
}

#if !NET
[NoWatch, NoTV, NoiOS, Mac (12,0), NoMacCatalyst]
[NoWatch, NoTV, NoiOS, Mac (12,0), NoMacCatalyst]
#else
[UnsupportedOSPlatform ("ios"), UnsupportedOSPlatform ("tvos"), UnsupportedOSPlatform ("maccatalyst"), SupportedOSPlatform ("macos12.0")]
[UnsupportedOSPlatform ("ios"), UnsupportedOSPlatform ("tvos"), UnsupportedOSPlatform ("maccatalyst"), SupportedOSPlatform ("macos12.0")]
#endif
[Native]
public enum AVCaptionTextAlignment : long {
Expand All @@ -1394,7 +1394,7 @@ public enum AVCaptionTextAlignment : long {
public enum AVCaptionRegionWritingMode : long
{
LeftToRightAndTopToBottom = 0,
TopToBottomAndRightToLeft = 2
TopToBottomAndRightToLeft = 2,
}

#if !NET
Expand Down
23 changes: 11 additions & 12 deletions src/avfoundation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3184,12 +3184,12 @@ interface AVAsset : NSCopying {
[Async]
[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Export ("loadChapterMetadataGroupsBestMatchingPreferredLanguages:completionHandler:")]
void LoadChapterMetadataGroups (string[] preferredLanguages, Action<NSArray<AVTimedMetadataGroup>, NSError> completionHandler);
void LoadChapterMetadataGroups (string[] bestMatchingPreferredLanguages, Action<NSArray<AVTimedMetadataGroup>, NSError> completionHandler);

[Async]
[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Export ("loadChapterMetadataGroupsWithTitleLocale:containingItemsWithCommonKeys:completionHandler:")]
void LoadChapterMetadataGroups (NSLocale locale, string[] commonKeys, Action<NSArray<AVTimedMetadataGroup>, NSError> completionHandler);
void LoadChapterMetadataGroups (NSLocale titleLocale, string[] commonKeys, Action<NSArray<AVTimedMetadataGroup>, NSError> completionHandler);

[Async]
[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
Expand All @@ -3204,7 +3204,7 @@ interface AVAsset : NSCopying {
[Async]
[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Export ("loadTrackWithTrackID:completionHandler:")]
void LoadTrack (int trackID, Action<AVCompositionTrack, NSError> completionHandler);
void LoadTrack (int trackId, Action<AVCompositionTrack, NSError> completionHandler);

[Async]
[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
Expand Down Expand Up @@ -3498,7 +3498,6 @@ interface AVQueuedSampleBufferRendering
[BaseType (typeof(NSObject))]
interface AVSampleBufferAudioRenderer : AVQueuedSampleBufferRendering
{

[Export ("status")]
AVQueuedSampleBufferRenderingStatus Status { get; }

Expand Down Expand Up @@ -11403,7 +11402,7 @@ enum AVPlayerWaitingReason {

[TV (15, 0), NoWatch, Mac (12, 0), iOS (15, 0), MacCatalyst (15,0)]
[Field ("AVPlayerWaitingForCoordinatedPlaybackReason")]
aitingForCoordinatedPlayback,
WaitingForCoordinatedPlayback,
}

[Watch (6,0)]
Expand Down Expand Up @@ -14905,7 +14904,7 @@ interface AVAssetVariantAudioAttributes

[Export ("renditionSpecificAttributesForMediaOption:")]
[return: NullAllowed]
AVAssetVariantAudioRenditionSpecificAttributes RenditionSpecificAttributesForMediaOption (AVMediaSelectionOption mediaSelectionOption);
AVAssetVariantAudioRenditionSpecificAttributes GetRenditionSpecificAttributesForMediaOption (AVMediaSelectionOption mediaSelectionOption);
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
Expand Down Expand Up @@ -14941,7 +14940,7 @@ interface AVAssetVariantQualifier : NSCopying
[Internal]
[Static]
[Export ("predicateForPresentationHeight:operatorType:")]
NSPredicate PredicateForPresentationHeight (nfloat height, NSPredicateOperatorType operatorType);
NSPredicate GetPredicateForPresentationHeight (nfloat height, NSPredicateOperatorType operatorType);
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
Expand Down Expand Up @@ -15215,7 +15214,7 @@ interface AVAssetReaderOutputCaptionAdaptor
[NoMacCatalyst]
[Export ("nextCaptionGroup")]
[return: NullAllowed]
AVCaptionGroup NextCaptionGroup ();
AVCaptionGroup GetNextCaptionGroup ();

[NoMacCatalyst]
[Export ("captionsNotPresentInPreviousGroupsInCaptionGroup:")]
Expand Down Expand Up @@ -15400,19 +15399,19 @@ interface AVCaptionRegion : NSCopying, NSMutableCopying, NSSecureCoding
{
[Static]
[Export ("appleITTTopRegion")]
AVCaptionRegion AppleITTTopRegion { get; }
AVCaptionRegion AppleiTTTopRegion { get; }

[Static]
[Export ("appleITTBottomRegion")]
AVCaptionRegion AppleITTBottomRegion { get; }
AVCaptionRegion AppleiTTBottomRegion { get; }

[Static]
[Export ("appleITTLeftRegion")]
AVCaptionRegion AppleITTLeftRegion { get; }
AVCaptionRegion AppleiTTLeftRegion { get; }

[Static]
[Export ("appleITTRightRegion")]
AVCaptionRegion AppleITTRightRegion { get; }
AVCaptionRegion AppleiTTRightRegion { get; }

[Static]
[Export ("subRipTextBottomRegion")]
Expand Down
32 changes: 32 additions & 0 deletions tests/monotouch-test/AVFoundation/AVCaptionDimensionTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#if __MACOS__
using System;
using Foundation;
using AVFoundation;
using NUnit.Framework;
using ObjCRuntime;

namespace MonoTouchFixtures.AVFoundation {

[TestFixture]
[Preserve (AllMembers = true)]
public class AVCaptionDimensionTest {

[SetUp]
public void SetUp ()
{
TestRuntime.AssertSystemVersion (PlatformName.MacOSX, 12,0);
}

[TestCase]
public void CreateTest ()
{
// create a new struct, test that we do have the expected values
nfloat val = 10;
var units = AVCaptionUnitsType.Cells;
var dimension = AVCaptionDimension.Create (val, units);
Assert.AreEqual (val, dimension.Value, "Value");
Assert.AreEqual (units, dimension.Units);
}
}
}
#endif
34 changes: 34 additions & 0 deletions tests/monotouch-test/AVFoundation/AVCaptionPointTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#if __MACOS__
using System;
using Foundation;
using AVFoundation;
using NUnit.Framework;
using ObjCRuntime;

namespace MonoTouchFixtures.AVFoundation {

[TestFixture]
[Preserve (AllMembers = true)]
public class AVCaptionPointTest {

[SetUp]
public void SetUp ()
{
TestRuntime.AssertSystemVersion (PlatformName.MacOSX, 12,0);
}

[TestCase]
public void CreateTest ()
{
nfloat val = 10;
var units = AVCaptionUnitsType.Cells;
var firstDimension = AVCaptionDimension.Create (val, units);
var secondDimension = AVCaptionDimension.Create (val, units);

var point = AVCaptionPoint.Create (firstDimension, secondDimension);
Assert.AreEqual (val, point.X.Value, "X");
Assert.AreEqual (val, point.Y.Value, "Y");
}
}
}
#endif
34 changes: 34 additions & 0 deletions tests/monotouch-test/AVFoundation/AVCaptionSizeTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#if __MACOS__
using System;
using Foundation;
using AVFoundation;
using NUnit.Framework;
using ObjCRuntime;

namespace MonoTouchFixtures.AVFoundation {

[TestFixture]
[Preserve (AllMembers = true)]
public class AVCaptionSizeTest {

[SetUp]
public void SetUp ()
{
TestRuntime.AssertSystemVersion (PlatformName.MacOSX, 12,0);
}

[Test]
public void CreateTest ()
{
nfloat val = 10;
var units = AVCaptionUnitsType.Cells;
var firstDimension = AVCaptionDimension.Create (val, units);
var secondDimension = AVCaptionDimension.Create (val, units);

var size = AVCaptionSize.Create (firstDimension, secondDimension);
Assert.AreEqual (val, size.Width.Value, "Width");
Assert.AreEqual (val, size.Height.Value, "Height");
}
}
}
#endif
2 changes: 0 additions & 2 deletions tests/xtro-sharpie/iOS-AVFoundation.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@

# Deprecated in iOS 6.0 but we have same C# signature as a method that was deprecated in iOS 8.0
!deprecated-attribute-wrong! AVAudioRecorderDelegate::audioRecorderEndInterruption:withFlags: has 8.0 not 6.0 on [Deprecated] attribute

# Initial result from new rule missing-release-attribute-on-return-value
2 changes: 0 additions & 2 deletions tests/xtro-sharpie/macOS-AVFoundation.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
## https://github.com/xamarin/xamarin-macios/issues/3213 should be fixed before conformance to 'AVQueuedSampleBufferRendering' is restored.
!missing-protocol-conformance! AVSampleBufferDisplayLayer should conform to AVQueuedSampleBufferRendering (defined in 'AVSampleBufferDisplayLayerQueueManagement' category)

# Initial result from new rule missing-release-attribute-on-return-value

# AVFoundation differs between IOS and macOS. Fields not availble in macOS 10.15.
!missing-field! AVMetadataIdentifierQuickTimeMetadataAutoLivePhoto not bound
!missing-field! AVMetadataIdentifierQuickTimeMetadataDetectedCatBody not bound
Expand Down
2 changes: 0 additions & 2 deletions tests/xtro-sharpie/tvOS-AVFoundation.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@
!unknown-field! AVAssetDownloadTaskMediaSelectionKey bound
!unknown-field! AVAssetDownloadTaskMinimumRequiredMediaBitrateKey bound

# Initial result from new rule missing-release-attribute-on-return-value

# not used on tvOS
!missing-enum! AVAudioSessionInterruptionReason not bound

0 comments on commit 1ee4425

Please sign in to comment.