Skip to content

[AVFoundation] Bind Xcode 27 APIs - #25828

Merged
dalexsoto merged 4 commits into
xcode27.0from
dev/alex/xc27avfoundation
Jun 29, 2026
Merged

[AVFoundation] Bind Xcode 27 APIs#25828
dalexsoto merged 4 commits into
xcode27.0from
dev/alex/xc27avfoundation

Conversation

@dalexsoto

Copy link
Copy Markdown
Member

Bind the missing Xcode 27 (beta 2) AVFoundation APIs that were tracked in tests/xtro-sharpie/api-annotations-dotnet/*-AVFoundation.todo, plus the VideoToolbox helper required by the planned-segment writing cluster.

Bindings:

  • src/avfoundation.cs and src/AVFoundation/* - new types/members across the planned segment writing cluster, AVAudio sink/source nodes, AVAsset constituentFileURLs (macOS-only), AVCaptureMovieFileOutput / AVAssetWriter ProVideoStorage, and assorted enums/types.
  • src/VideoToolbox/VTCompressionSession.cs - resumable compression session support used by AVPlannedVideoSegmentWritingRequest.
  • src/frameworks.sources - register the new manual source file.

Tooling/tests:

  • tests/xtro-sharpie/xtro-sharpie/EnumCheck.cs - handle the new CMPersistentTrackID-backed enum underlying type (Xcode 27).
  • tests/introspection/ApiTypoTest.cs - widen the "Aime" allow-list to all platforms (AVMetadataIdentifierQuickTimeMetadataAIMEData is now all-platform).
  • tests/introspection/iOSApiSelectorTest.cs - skip the AVAssetWriter ProVideoStorage selectors on the tvOS 27 simulator only (beta 2 simulator gap; real devices still validated).
  • tests/cecil-tests/Documentation.KnownFailures.txt - regenerated.
  • tests/xtro-sharpie/api-annotations-dotnet/*-AVFoundation.todo - removed (fully bound); tvOS .ignore updated for AVAudioSessionInterruptionReasonKey.

Validation: make world clean on all 4 platforms; xtro sanity passes with all AVFoundation .todo files resolved; cecil green; introspection green on macOS, Mac Catalyst, iOS and tvOS.

Bind the missing Xcode 27 (beta 2) AVFoundation APIs that were tracked in
tests/xtro-sharpie/api-annotations-dotnet/*-AVFoundation.todo, plus the
VideoToolbox helper required by the planned-segment writing cluster.

Bindings:
* src/avfoundation.cs and src/AVFoundation/* - new types/members across the
  planned segment writing cluster, AVAudio sink/source nodes, AVAsset
  constituentFileURLs (macOS-only), AVCaptureMovieFileOutput / AVAssetWriter
  ProVideoStorage, and assorted enums/types.
* src/VideoToolbox/VTCompressionSession.cs - resumable compression session
  support used by AVPlannedVideoSegmentWritingRequest.
* src/frameworks.sources - register the new manual source file.

Tooling/tests:
* tests/xtro-sharpie/xtro-sharpie/EnumCheck.cs - handle the new
  CMPersistentTrackID-backed enum underlying type (Xcode 27).
* tests/introspection/ApiTypoTest.cs - widen the "Aime" allow-list to all
  platforms (AVMetadataIdentifierQuickTimeMetadataAIMEData is now all-platform).
* tests/introspection/iOSApiSelectorTest.cs - skip the AVAssetWriter
  ProVideoStorage selectors on the tvOS 27 simulator only (beta 2 simulator
  gap; real devices still validated).
* tests/cecil-tests/Documentation.KnownFailures.txt - regenerated.
* tests/xtro-sharpie/api-annotations-dotnet/*-AVFoundation.todo - removed
  (fully bound); tvOS .ignore updated for AVAudioSessionInterruptionReasonKey.

Validation: make world clean on all 4 platforms; xtro sanity passes with all
AVFoundation .todo files resolved; cecil green; introspection green on macOS,
Mac Catalyst, iOS and tvOS.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Binds missing AVFoundation (Xcode 27 beta 2) APIs and updates related tooling/tests so the new surface area is covered by xtro-sharpie, introspection, and cecil documentation checks.

Changes:

  • Added new AVFoundation bindings (planned segment writing cluster, audio realtime-safe nodes, ProVideoStorage-related APIs, additional enums/constants/selectors).
  • Added VideoToolbox VTCompressionSession helpers to support AVPlannedVideoSegmentWritingRequest resumable compression session creation.
  • Updated test infrastructure: xtro EnumCheck, introspection skips/typo allow-list, regenerated cecil documentation known failures, and removed resolved xtro .todo files (with a tvOS ignore exception).

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/xtro-sharpie/xtro-sharpie/EnumCheck.cs Accepts CMPersistentTrackID as a known enum underlying type to avoid xtro crashes.
tests/xtro-sharpie/api-annotations-dotnet/tvOS-AVFoundation.todo Removed resolved AVFoundation todo entries (fully bound).
tests/xtro-sharpie/api-annotations-dotnet/tvOS-AVFoundation.ignore Ignores AVAudioSessionInterruptionReasonKey on tvOS due to header/libclang mismatch.
tests/xtro-sharpie/api-annotations-dotnet/macOS-AVFoundation.todo Removed resolved AVFoundation todo entries (fully bound).
tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-AVFoundation.todo Removed resolved AVFoundation todo entries (fully bound).
tests/xtro-sharpie/api-annotations-dotnet/iOS-AVFoundation.todo Removed resolved AVFoundation todo entries (fully bound).
tests/introspection/iOSApiSelectorTest.cs Skips specific tvOS simulator-only missing selectors (ProVideoStorage on AVAssetWriter).
tests/introspection/ApiTypoTest.cs Expands “Aime” allow-list to all platforms to reflect updated AVMetadata availability.
tests/cecil-tests/Documentation.KnownFailures.txt Regenerated known-failures list for newly visible members.
src/VideoToolbox/VTCompressionSession.cs Adds internal helpers to reuse trampoline/GCHandle management when AVFoundation creates native sessions.
src/frameworks.sources Registers new manual AVFoundation source file for compilation.
src/AVFoundation/Enums.cs Adds new enums/values introduced in Xcode 27 AVFoundation.
src/AVFoundation/AVTypes.cs Adds AVPlannedVideoSegmentBoundaryGuidelines struct for segment-writing APIs.
src/AVFoundation/AVPlannedVideoSegmentWritingRequest.cs New manual binding exposing resumable compression-session creation via AVFoundation selector.
src/AVFoundation/AVAudioSourceNode.cs Adds realtime-safe factory APIs mapping to new AVFoundation initializers.
src/AVFoundation/AVAudioSinkNode.cs Adds realtime-safe factory API mapping to new AVFoundation initializer.
src/avfoundation.cs Main binding updates across AVFoundation: new types/members, new selectors, deprecations, and additional constants.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

Comment thread src/AVFoundation/Enums.cs Outdated
Comment thread src/avfoundation.cs Outdated

[Export ("initWithVideoCodecType:encoderSpecification:mediaType:segmentConfigurations:assemblyTrackID:")]
[DesignatedInitializer]
NativeHandle Constructor ([BindAs (typeof (AVVideoCodecType))] NSString videoCodecType, [NullAllowed] NSDictionary encoderSpecification, string mediaType, AVPlannedSegmentConfiguration [] segmentConfigurations, int trackId);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a strongly typed dictionary for encoderSpecification? Also I think AVMediaTypes (or maybe AVMediaType) can be used as the strongly typed enum for mediaType.

FWIW we should probably also expose a weakly typed overload of this constructor, where none of the parameters use a strongly typed parameter type.

Comment thread src/avfoundation.cs

[Export ("resumableAssetWriterInputWithMediaType:outputSettings:sourceFormatHint:returningError:")]
[return: NullAllowed]
AVAssetWriterInput GetResumableAssetWriterInput (string mediaType, [NullAllowed] NSDictionary outputSettings, [NullAllowed] CMFormatDescription sourceFormatHint, [NullAllowed] out NSError error);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same wrt mediaType, and outputSettings + weakly typed overload.

Comment thread src/avfoundation.cs

// AIME = Apple Immersive Media Embedded
[NoMacCatalyst, NoTV, NoiOS, Mac (26, 0)]
[MacCatalyst (26, 0), TV (26, 0), Mac (26, 0), iOS (26, 0)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are these 26.0 availability attributes correct?

Comment thread src/avfoundation.cs
NSString QuickTimeMetadataAimeData { get; }

[NoMacCatalyst, NoTV, NoiOS, Mac (26, 0)]
[MacCatalyst (26, 0), TV (26, 0), Mac (26, 0), iOS (26, 0)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same, 26.0 versions.

Comment thread src/AVFoundation/AVAudioSinkNode.cs
Comment thread src/AVFoundation/AVAudioSinkNode.cs
Comment thread src/AVFoundation/AVTypes.cs Outdated
@rolfbjarne

Copy link
Copy Markdown
Member

/review

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

.NET for Apple Platforms PR Reviewer completed successfully!

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review Summary

This PR binds the missing Xcode 27 (beta 2) AVFoundation APIs with good overall quality. The bindings follow established patterns and the test updates are appropriate.

Issues Found

❌ Errors (must fix):

  • AVAudioSession.Activate has incorrect platform attribute (MacCatalyst (15, 0) should be MacCatalyst (27, 0))

⚠️ Warnings (should fix):

  • AVAudioSession.Activate and Deactivate use Action<bool, NSError> instead of named delegate types, reducing API discoverability

💡 Suggestions (consider):

  • Add XML documentation to the internal VTCompressionSession helper methods
  • Error handling pattern in AVPlannedVideoSegmentWritingRequest is correct but could use a comment documenting the rationale

What's Good

✅ Platform attributes are correct throughout (except the one noted above)
✅ New types properly added to frameworks.sources
✅ EnumCheck.cs correctly updated to handle CMPersistentTrackID
✅ Test exclusions for tvOS simulator appropriately documented
✅ Nullable reference types properly used in new files
✅ Memory management in CreateResumableCompressionSession correctly handles GCHandle lifecycle
✅ Custom delegates defined for the planner callbacks
✅ ApiTypoTest updated to reflect multi-platform availability of "Aime"

Verification

  • AVFoundation .todo files removed ✅
  • New manual binding file added to sources ✅
  • Cross-framework integration (VideoToolbox helpers) implemented correctly ✅
  • Platform-specific binding (constituentFileURLs macOS-only) properly constrained ✅

Generated by .NET for Apple Platforms PR Reviewer for issue #25828 · 103.2 AIC · ⌖ 9.06 AIC · ⊞ 5.1K
Comment /review to run again

Comment thread src/avfoundation.cs
Comment thread src/avfoundation.cs
Comment thread src/avfoundation.cs
Comment thread src/VideoToolbox/VTCompressionSession.cs

IntPtr handle;
try {
handle = _CreateResumableCompressionSession (IntPtr.Zero, width, height, codecType, encoderSpecification, sourceImageBufferAttributes, IntPtr.Zero, outputCallback, outputCallbackRefCon, out error);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤖 💡 Error handling — The empty catch block that just rethrows is fine, but consider whether callbackHandle.Free() should be in a finally block to ensure cleanup even if the exception handling itself throws.

Current pattern is correct for the try-catch around the native call, but you could simplify slightly:

IntPtr handle;
try {
    handle = _CreateResumableCompressionSession (...);
} catch {
    if (callbackHandle.IsAllocated)
        callbackHandle.Free ();
    throw;
}

This is already what you have, so this is just a confirmation that the pattern is correct. The comment is to document the rationale.

Rule: Include actionable details in exceptions

- Add strongly-typed + weakly-typed overloads for the asset writing planner
  APIs (AVAssetTrackPlan/AVAssetVideoTrackPlan ctors, GetSegmentBoundary-
  Guidelines, GetResumableAssetWriterInput) using AVMediaTypes,
  AVVideoCodecType and VTVideoEncoderSpecification.
- Switch manual CreateResumableCompressionSession to strong
  VTVideoEncoderSpecification?/CVPixelBufferAttributes? to match
  VTCompressionSession.Create.
- Replace the new "To be added." xml docs in Enums.cs with meaningful text.
- Convert AVPlannedVideoSegmentBoundaryGuidelines to private fields + property
  accessors while preserving the sequential by-value marshaling layout.
- Add xml docs to the AVAudioSinkNode/AVAudioSourceNode CreateRealtimeSafe
  factories and add guarded manual tests for them.
- Keep the shipped MacCatalyst (15, 0) availability on AVAudioSession.Activate
  (raising an already-shipped intro version is a breaking change) and document
  why.
- Regenerate cecil Documentation.KnownFailures.txt.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

Fixes three CI test failures from the Xcode 27 AVFoundation bindings:

* xtro (macOS): AVAudioSessionDeactivationOptions.NotifyOthersOnDeactivation
  triggered !extra-enum-value! because the native value is API_UNAVAILABLE(macos)
  while the managed value was available on macOS. The macOS AVFAudio header
  defines the enum *type* (no typedef-level annotation; None=0 is macOS-available)
  and only marks the *value* unavailable, so the fix is a value-level [NoMac] on
  NotifyOthersOnDeactivation, keeping the type macOS-available. Marking the whole
  enum [NoMac] would have excluded the type from Microsoft.macOS.dll and produced
  a !missing-enum! instead.

* introspection (macOS + Mac Catalyst): AVAssetWriter's ProVideoStorage selectors
  (isProVideoStorageSupported, usesProVideoStorage, setUsesProVideoStorage:) are
  declared for 27.0 but not yet implemented in the 27.0 beta runtime. The binding
  correctly matches the header, so skip these selectors in introspection, mirroring
  the existing tvOS skip.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #c1c6a63] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: c1c6a639e5932329a62fbaf575899dcaebc76626 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: c1c6a639e5932329a62fbaf575899dcaebc76626 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #c1c6a63] Build passed (Build packages) ✅

Pipeline on Agent
Hash: c1c6a639e5932329a62fbaf575899dcaebc76626 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #c1c6a63] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: c1c6a639e5932329a62fbaf575899dcaebc76626 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #c1c6a63] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 196 tests passed 🎉

Tests counts

✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 6 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 17 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 18 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Sonoma (14): All 5 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ Tests on macOS Golden Gate (27): All 5 tests passed. [attempt 2] Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: c1c6a639e5932329a62fbaf575899dcaebc76626 [PR build]

@dalexsoto
dalexsoto requested a review from rolfbjarne June 29, 2026 13:14
@dalexsoto
dalexsoto merged commit f2f7cb7 into xcode27.0 Jun 29, 2026
55 checks passed
@dalexsoto
dalexsoto deleted the dev/alex/xc27avfoundation branch June 29, 2026 16:07
dalexsoto added a commit that referenced this pull request Jul 2, 2026
Merge the stashed macios-binding-creator skill work (Xcode 27
xtro/cecil/introspection accuracy from three real binding sessions)
onto the rebased branch, which had already committed two other
2026-07-01 sessions (xkit.cs consolidation + runtime-only protocol
conformance). 3-way merge against the clean common base preserves all
three sessions with no content lost either way.

Also fixes two claims in the session-3 content that went stale after
the branch's main-merge pulled in their source PRs (#25811, #25828):
- AUHeadTrackingBinauralRenderer is now a real factory-variant type;
  the illustrative plain-Constructor example is renamed to
  MySpatialAudioUnit and the real type is cited as a factory precedent.
- iOSApiSelectorTest.cs already has a Skip(Type,string) override, so
  the selector-skip guidance now says to extend it (adding a second
  override would be CS0111), citing the AVAssetWriter precedent.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants