Sample CodemacOSReviewed 2026-07-21View on Apple Developer

Processing Apple Immersive Video with foveation

At a glance

Item Summary
Purpose Reduce a video’s data rate while maintaining high acuity in the center of the imagery by applying foveation to immersive video content.
App architecture A Metal, Swift sample with the source-visible chain FoveateAIVFoveationEngineImmersiveMediaSupport APIs.
Main patterns No named application pattern supported by the extracted structure
Project style 9 scanned source file(s) across Metal, Swift, organized around ranked entry, type, and file boundaries.
Execution model Source-visible boundaries: async declaration or closure; none alone proves a background thread.
State/event model No structured observation or publisher-scheduling marker indexed.
Key frameworks/packages AVFoundation, Foundation, VideoToolbox, ArgumentParser, ImmersiveMediaSupport; these are source dependencies, not architecture labels.

Project structure

Source bundle/
├── ImmersiveMediaSupport-Foveation/
│   ├── ImmersiveMediaSupport-Foveation/
│   │   ├── FoveateAIV.swift
│   │   ├── AIMEProcessor.swift
│   │   ├── FoveationEngine.swift
│   │   ├── MetalProcessor.swift
│   │   ├── VideoProcessor.swift
│   │   ├── UVSample.metal
│   │   ├── Types/
│   │   │   ├── FoveationConfig.swift
│   │   │   └── RuntimeError.swift
│   │   └── AVVideoCodecTypeExtension.swift
│   └── ImmersiveMediaSupport-Foveation.xcodeproj/
│       ├── .xcodesamplecode.plist
│       └── project.pbxproj
└── Configuration/
    └── SampleCode.xcconfig

Structure observations

  • Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
  • Primary languages: Metal, Swift.
  • The verified tree contains 3 project/configuration file(s) and 9 source declaration(s).

Overall architecture

Reference code

ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/FoveateAIV.swift:12 — architecture anchor

@main
struct FoveateAIV: AsyncParsableCommand {
    static let configuration = CommandConfiguration(
        abstract: """
        Apply variable rasterization rate (VRR) style foveation to Apple Immersive Video (AIV) file
        and Apple Immersive Media Embedded (AIME) metadata file.
        """,
        discussion: """
        This tool processes AIV file (`.mov` file) and AIME metadata file (`.aime` file)
        by applying VRR style foveation that reduces visual quality in peripheral areas
        while maintaining high quality in the center of focus.
        """
    )
    // ...
}

Interpretation

The arrows summarize the source-visible entry, role-named types or folders, and framework direction; when nodes come from structural folders, the sequence is a high-level interpretation rather than proof that every adjacent node calls the next. Ownership is claimed only where the next section cites a stored property or assignment. The diagram is intentionally limited to the dominant path into Immersive Media Support.

Ownership and state

Ownership evidence

ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/FoveateAIV.swift:14 — stored dependency or nearest verified ownership anchor

@main
struct FoveateAIV: AsyncParsableCommand {
    // ...
}
Owner Object or state Relationship Mutation authority
FoveateAIV CommandConfiguration (configuration) creates and retains Initialized by the owner; the binding is immutable
FoveateAIV String (inputVideoFile) owns value state App/module collaborators
FoveateAIV String (inputAIMEFile) owns value state App/module collaborators
FoveateAIV String (outputDirectory) owns value state App/module collaborators

Composition arrows indicate a source-visible construction expression or locally owned value state; aggregation means the owner stores or receives a dependency without proving exclusive lifetime ownership.

Concurrency, scheduling, and thread safety

Evidence limit: actor isolation, async/await, or Task creation does not by itself prove background-thread execution; Sendable conformance alone does not prove thread-safe mutation.

Concern Source mechanism Verified placement or handoff Evidence
Suspension boundary async declaration or closure The source declares or crosses an asynchronous boundary; it does not by itself establish background execution. ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/AIMEProcessor.swift:24

@MainActor/MainActor.run, DispatchQueue.main, and RunLoop.main are reported as distinct isolation, queue, and event-loop mechanisms. A plain Task is kept separate from Task.detached; neither is labeled as a background thread.

Reference code

ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/AIMEProcessor.swift:24 — representative execution boundary

    init(
        // ...
    ) async throws {
        // ...
    }

State propagation, frameworks, and dependencies

Evidence limit: an import proves a source-level compilation dependency at the cited line; it does not prove runtime use, architectural adoption, or whether a Swift package is a direct application dependency.

Category Mechanism or module Verified role Evidence
Source import AVFoundation The cited file imports this module; runtime use and architectural role are not inferred. ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/AVVideoCodecTypeExtension.swift:8
Source import Foundation The cited file imports this module; runtime use and architectural role are not inferred. ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/AIMEProcessor.swift:8
Source import VideoToolbox The cited file imports this module; runtime use and architectural role are not inferred. ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/MetalProcessor.swift:8
Source import ArgumentParser The cited file imports this module; runtime use and architectural role are not inferred. ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/FoveateAIV.swift:10
Source import ImmersiveMediaSupport The cited file imports this module; runtime use and architectural role are not inferred. ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/AIMEProcessor.swift:9
Source import metal_stdlib The cited file imports this module; runtime use and architectural role are not inferred. ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/UVSample.metal:8

receive(on:) describes downstream delivery scheduling, while subscribe(on:) describes upstream subscription/request/cancel scheduling. An import Combine alone establishes neither behavior nor a Store, reducer, Redux, or other application architecture.

Class and protocol design

ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/AIMEProcessor.swift:12 — representative type boundary

final class AIMEProcessor {
    // ...
    private let foveationConfig: FoveationConfig
    // ...
}
Type Responsibility Depends on or conforms to
AIMEProcessor Owns a feature processing stage Concrete collaborators/imported frameworks
FoveationEngine Owns processing or simulation work Concrete collaborators/imported frameworks
MetalProcessor Owns a feature processing stage Concrete collaborators/imported frameworks
VideoProcessor Owns a feature processing stage Concrete collaborators/imported frameworks
FoveateAIV Represents a feature value or composable behavior AsyncParsableCommand
VertexIn Represents a feature value or composable behavior Concrete collaborators/imported frameworks
VertexOut Represents a feature value or composable behavior Concrete collaborators/imported frameworks
FoveationConfig Carries feature or framework configuration Concrete collaborators/imported frameworks
RuntimeError Represents feature failure conditions Error, CustomStringConvertible

No local protocol conformance is claimed as protocol-oriented design; external framework conformances are listed only as dependencies.

Access control

Symbol Access Verified effect Likely rationale
foveationConfig (ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/AIMEProcessor.swift:14) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.
inputAIMEURL (ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/AIMEProcessor.swift:16) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.
outputAIMEURL (ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/AIMEProcessor.swift:17) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.
venueDescriptor (ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/AIMEProcessor.swift:18) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.

Reference code

ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/AIMEProcessor.swift:14 — representative boundary

final class AIMEProcessor {
    // ...
    private let foveationConfig: FoveationConfig
    // ...
}

Swift declarations without a modifier are internal; explicit private, fileprivate, private(set), public, or open entries above are interpreted by language semantics. Objective-C/C samples instead rely on header and implementation boundaries, which are not equivalent to Swift lexical privacy.

Logic ownership and placement

Logic Owning type or file Placement rationale
Owns processing or simulation work FoveationEngine The source’s Engine suffix makes this role explicit.
Owns a feature processing stage AIMEProcessor, MetalProcessor, VideoProcessor The source’s Processor suffix makes this role explicit.

Design patterns

Pattern Source evidence Purpose or tradeoff
No named application pattern ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/FoveateAIV.swift:12 The verified source directly composes concrete framework types; this document avoids forcing a pattern name.

Main application flow

Reference code

ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/FoveateAIV.swift:92run()

@main
struct FoveateAIV: AsyncParsableCommand {
    // ...
        let aimeProcessor = try await AIMEProcessor(
            inputAIMEURL: inputAIMEURL,
            outputAIMEURL: outputAIMEURL,
            foveationConfig: foveationConfig
        )
    // ...
}

Naming conventions

  • Types: Engine: FoveationEngine; Processor: AIMEProcessor, MetalProcessor, VideoProcessor.
  • Protocols: no local protocol declaration in the scanned source.
  • Methods: run, validateParameters, validateInputs, validateOutputs, process, foveateMesh, generateMesh, createBuffers.
  • Files: ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/FoveateAIV.swift, ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/AIMEProcessor.swift, ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/FoveationEngine.swift, ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/MetalProcessor.swift, ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/VideoProcessor.swift, ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/Types/FoveationConfig.swift.

Architecture takeaways

  • FoveateAIV is the main source-visible entry or composition anchor for this sample.
  • Framework work reaches AVFoundation, VideoToolbox, ArgumentParser, ImmersiveMediaSupport through a deliberately small high-level chain; the detailed API graph remains inside the cited implementation files.
  • Stored-property evidence identifies lifecycle collaboration; it does not by itself prove exclusive object ownership.
  • Access-control conclusions separate verified language visibility from the likely design rationale.
  • The source does not justify labeling the design protocol-oriented.

Source map

Source file Relevant symbols
ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/FoveateAIV.swift Cited implementation, ArgumentParser, FoveateAIV
ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/AIMEProcessor.swift AIMEProcessor, Cited implementation, async declaration or closure, Foundation, ImmersiveMediaSupport
ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/AVVideoCodecTypeExtension.swift AVFoundation, Feature implementation
ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/MetalProcessor.swift VideoToolbox, MetalProcessor
ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/UVSample.metal metal_stdlib, VertexIn, VertexOut
ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/FoveationEngine.swift FoveationEngine
ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/VideoProcessor.swift VideoProcessor
ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/Types/FoveationConfig.swift FoveationConfig
ImmersiveMediaSupport-Foveation/ImmersiveMediaSupport-Foveation/Types/RuntimeError.swift RuntimeError