Skip to content

Commit

Permalink
[AVFoundation] Simplify code behind + api definition for AVCaptureCon…
Browse files Browse the repository at this point in the history
…nection. (#14199)

* Remove the code behind for AVCaptureConnection.SupportsVideoMinFrameDuration
  and AVCaptureConnection.SupportsVideoMaxFrameDuration. The codebehind looks like
  a workaround for Apple renaming the selector, but from history it looks like that
  happened before the earliest version of iOS we support today, so this can be expressed
  in an api definition now without any code behind.
* Add these fields to macOS, where they're not even deprecated (like they are on
  other platforms).
* Remove conditional code in api definition, and distribute [No*] attributes as
  required.
* Remove the AVCaptureConnection.AudioChannels property from .NET, it doesn't do
  anything useful.
  • Loading branch information
rolfbjarne authored Feb 21, 2022
1 parent 08f38b3 commit 66dcb94
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 63 deletions.
45 changes: 2 additions & 43 deletions src/AVFoundation/AVCaptureConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,55 +35,14 @@
using System.Runtime.Versioning;

namespace AVFoundation {
public partial class AVCaptureConnection {

#if NET
[SupportedOSPlatform ("maccatalyst14.0")]
[UnsupportedOSPlatform ("ios7.0")]
#if IOS
[Obsolete ("Starting with ios7.0.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
[UnsupportedOSPlatform ("tvos")]
#else
[Deprecated (PlatformName.iOS, 7, 0)]
#endif
public bool SupportsVideoMinFrameDuration {
get {
if (RespondsToSelector (new Selector ("isVideoMinFrameDurationSupported")))
return _SupportsVideoMinFrameDuration;
return false;
}
}

#if NET
[SupportedOSPlatform ("maccatalyst14.0")]
[UnsupportedOSPlatform ("ios7.0")]
#if IOS
[Obsolete ("Starting with ios7.0.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
[UnsupportedOSPlatform ("tvos")]
#else
[Deprecated (PlatformName.iOS, 7, 0)]
#endif
public bool SupportsVideoMaxFrameDuration {
get {
#if !MONOMAC
if (RespondsToSelector (new Selector ("isVideoMaxFrameDurationSupported")))
return _SupportsVideoMaxFrameDuration;
#endif
return false;
}
}

#if !NET
public partial class AVCaptureConnection {
[Obsolete ("Use AvailableAudioChannels property instead.")]
#else
[Obsolete ("Use AvailableAudioChannels property instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
public virtual AVCaptureAudioChannel AudioChannels {
get { throw new NotSupportedException ("Use AvailableAudioChannels property instead."); }
}
}
#endif
}

#endif // !TVOS
32 changes: 22 additions & 10 deletions src/avfoundation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9060,62 +9060,74 @@ interface AVCaptureConnection {
[Export ("isVideoOrientationSupported")]
bool SupportsVideoOrientation { get; }

[Export ("supportsVideoMinFrameDuration"), Internal]
bool _SupportsVideoMinFrameDuration { [Bind ("isVideoMinFrameDurationSupported")] get; }
[Deprecated (PlatformName.iOS, 7, 0 /* Only deprecated on iOS */)]
[Deprecated (PlatformName.MacCatalyst, 14, 0)]
[Export ("supportsVideoMinFrameDuration")]
bool SupportsVideoMinFrameDuration { [Bind ("isVideoMinFrameDurationSupported")] get; }

[Deprecated (PlatformName.iOS, 7, 0 /* Only deprecated on iOS */)]
[Deprecated (PlatformName.MacCatalyst, 14, 0)]
[Export ("videoMinFrameDuration")]
CMTime VideoMinFrameDuration { get; set; }
#if !MONOMAC
[Export ("supportsVideoMaxFrameDuration"), Internal]
bool _SupportsVideoMaxFrameDuration { [Bind ("isVideoMaxFrameDurationSupported")] get; }

[Deprecated (PlatformName.iOS, 7, 0 /* Only deprecated on iOS */)]
[Deprecated (PlatformName.MacCatalyst, 14, 0)]
[Export ("supportsVideoMaxFrameDuration")]
bool SupportsVideoMaxFrameDuration { [Bind ("isVideoMaxFrameDurationSupported")] get; }

[Export ("videoMaxFrameDuration")]
[Deprecated (PlatformName.iOS, 7, 0 /* Only deprecated on iOS */)]
[Deprecated (PlatformName.MacCatalyst, 14, 0)]
CMTime VideoMaxFrameDuration { get; set; }

[NoMac]
[Export ("videoMaxScaleAndCropFactor")]
nfloat VideoMaxScaleAndCropFactor { get; }

[NoMac]
[Export ("videoScaleAndCropFactor")]
nfloat VideoScaleAndCropFactor { get; set; }
#endif

[NullAllowed]
[Export ("videoPreviewLayer")]
AVCaptureVideoPreviewLayer VideoPreviewLayer { get; }

[Export ("automaticallyAdjustsVideoMirroring")]
bool AutomaticallyAdjustsVideoMirroring { get; set; }
#if !MONOMAC

[NoMac]
[Export ("supportsVideoStabilization")]
bool SupportsVideoStabilization { [Bind ("isVideoStabilizationSupported")] get; }

[NoMac]
[Export ("videoStabilizationEnabled")]
[Deprecated (PlatformName.iOS, 8, 0, message: "Use 'ActiveVideoStabilizationMode' instead.")]
bool VideoStabilizationEnabled { [Bind ("isVideoStabilizationEnabled")] get; }

[NoMac]
[Deprecated (PlatformName.iOS, 8, 0, message: "Use 'PreferredVideoStabilizationMode' instead.")]
[Export ("enablesVideoStabilizationWhenAvailable")]
bool EnablesVideoStabilizationWhenAvailable { get; set; }

[NoMac]
[iOS (8,0)]
[Export ("preferredVideoStabilizationMode")]
AVCaptureVideoStabilizationMode PreferredVideoStabilizationMode { get; set; }

[NoMac]
[iOS (8,0)]
[Export ("activeVideoStabilizationMode")]
AVCaptureVideoStabilizationMode ActiveVideoStabilizationMode { get; }
#endif

[Unavailable (PlatformName.MacCatalyst)]
[NoiOS]
[Export ("supportsVideoFieldMode")]
bool SupportsVideoFieldMode { [Bind ("isVideoFieldModeSupported")] get; }

#if MONOMAC
[NoiOS]
[Unavailable (PlatformName.MacCatalyst)]
[Export ("videoFieldMode")]
AVVideoFieldMode VideoFieldMode { get; set; }
#endif

[iOS (11, 0), NoMac, TV (11, 0), NoWatch]
[Export ("cameraIntrinsicMatrixDeliverySupported")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
!missing-field! AVMediaCharacteristicEasyToRead not bound
!missing-field! AVVideoDecompressionPropertiesKey not bound

# Deprecated so won't bind it
!missing-selector! AVCaptureConnection::isVideoMaxFrameDurationSupported not bound
!missing-selector! AVCaptureConnection::setVideoMaxFrameDuration: not bound
!missing-selector! AVCaptureConnection::videoMaxFrameDuration not bound

## unsorted
!unknown-native-enum! AVCaptureAutoFocusRangeRestriction bound
!unknown-native-enum! AVCaptureLensStabilizationStatus bound
Expand Down
5 changes: 0 additions & 5 deletions tests/xtro-sharpie/macOS-AVFoundation.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
!missing-field! AVMediaCharacteristicEasyToRead not bound
!missing-field! AVVideoDecompressionPropertiesKey not bound

# Deprecated so won't bind it
!missing-selector! AVCaptureConnection::isVideoMaxFrameDurationSupported not bound
!missing-selector! AVCaptureConnection::setVideoMaxFrameDuration: not bound
!missing-selector! AVCaptureConnection::videoMaxFrameDuration not bound

## unsorted
!unknown-native-enum! AVCaptureAutoFocusRangeRestriction bound
!unknown-native-enum! AVCaptureLensStabilizationStatus bound
Expand Down

5 comments on commit 66dcb94

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff
View dotnet API diff
View dotnet legacy API diff
View dotnet iOS-MacCatalayst API diff

API Current PR diff

ℹ️ API Diff (from PR only) (please review changes)

View API diff
View dotnet API diff
View dotnet legacy API diff
View dotnet iOS-MacCatalayst API diff

Generator diff

ℹ️ Generator Diff (please review changes)

Packages generated

View packages

Test results

1 tests failed, 234 tests passed.

Failed tests

  • [NUnit] Mono Mac OS X BCL tests group 2/Mac Full/Debug: Failed (Test run failed.
    Tests run: 11943 Passed: 10499 Inconclusive: 0 Failed: 3 Ignored: 354)

Pipeline on Agent XAMBOT-1030.BigSur
[AVFoundation] Simplify code behind + api definition for AVCaptureConnection. (#14199)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Tests failed catastrophically on VSTS: device tests iOS (no summary found). 🔥

Result file D:\a\1\s\Reports\TestSummary-iOS64\TestSummary.md not found.

Pipeline on Agent
[AVFoundation] Simplify code behind + api definition for AVCaptureConnection. (#14199)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Tests failed catastrophically on VSTS: device tests tvOS (no summary found). 🔥

Result file D:\a\1\s\Reports\TestSummary-tvos\TestSummary.md not found.

Pipeline on Agent
[AVFoundation] Simplify code behind + api definition for AVCaptureConnection. (#14199)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Tests failed on macOS Mac Catalina (10.15) ❌

Tests failed on Mac Catalina (10.15).

Failed tests are:

  • monotouch-test

Pipeline on Agent
[AVFoundation] Simplify code behind + api definition for AVCaptureConnection. (#14199)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Tests failed on macOS M1 - Mac Big Sur (11.5) ❌

Tests failed on M1 - Mac Big Sur (11.5).

Failed tests are:

  • monotouch-test

Pipeline on Agent
[AVFoundation] Simplify code behind + api definition for AVCaptureConnection. (#14199)

Please sign in to comment.