AVFoundation sample architecture
Source-backed, high-level architecture notes for Apple sample-code pages grouped in the AVFoundation folder.
- Catalog module label:
AVFoundation - Coverage: 28 / 28 sample pages documented
- Source policy: archive hashes and extracted-tree references are verified locally before analysis
Samples
| Sample | Platforms | High-level architecture | Documented patterns |
|---|---|---|---|
| Adding a display mask rectangle metadata track to a movie file | macOS | A two-file command-line tool: an AsyncParsableCommand validates arguments and hands one operation to MovieProcessor. |
command entry point, processing pipeline, reader-writer passthrough |
| AVCam: Building a camera app | iOS, iPadOS, Mac Catalyst | SwiftUI MVVM-style app: CameraView consumes the Camera capability, CameraModel owns UI state, and actor services own capture and library work. |
MVVM, protocol-oriented view model, actor-isolated service, output-service composition, adapter |
| AVCamBarcode: detecting barcodes and faces | iOS, iPadOS, Mac Catalyst | Storyboard-driven UIKit app centered on one CameraViewController that owns the capture graph and coordinates specialized views. |
UIKit view controller, delegate, generic selection controller, serialized capture queue |
| AVCamFilter: Applying filters to a capture stream | iOS, iPadOS, Mac Catalyst | Controller-centered UIKit capture app with pluggable renderer objects and a custom Metal preview. | UIKit view controller, strategy protocol, capture delegates, GPU processing pipeline |
| AVMultiCamPiP: Capturing from Multiple Cameras | iOS, iPadOS, Mac Catalyst | Controller-centered UIKit app that manually wires a multi-camera capture graph, delegates mixing to PiPVideoMixer, and delegates writing to MovieRecorder. |
UIKit view controller, manual capture graph, GPU compositor, recorder facade |
| Build a responsive camera app that launches quickly | iOS, iPadOS, Mac Catalyst, macOS | README-described two-phase launch built on AVCam; full implementation is absent from the archive. | phased initialization, deferred start, conditional UI composition |
| Capturing Cinematic video | iOS, iPadOS, Mac Catalyst | SwiftUI MVVM-style app: a Camera protocol feeds generic views, CameraModel owns presentation state, and CaptureService owns AVFoundation work on a serial actor executor. |
MVVM, protocol-oriented view model, actor-isolated capture service, delegate-to-async adapter |
| Capturing consistent color images | iOS, iPadOS, Mac Catalyst | SwiftUI view owns an observable DataModel; the model owns a concrete Camera, which owns the capture session, outputs, delegates, and result state. |
MVVM-style view model, async stream, capture delegates, controller-service object |
| Capturing depth using the LiDAR camera | iOS, iPadOS, Mac Catalyst | SwiftUI owns CameraManager; the manager owns a capture controller and shared captured-data object; delegate callbacks update views backed by reusable Metal coordinators. |
view model, weak delegate, protocol-oriented Metal view, generic coordinator, singleton environment |
| Capturing Spatial Audio in your iOS app | iOS, iPadOS, Mac Catalyst | SwiftUI composition with one observable capture owner and a separate playback view model. | Observable model, Delegate, Model-View-ViewModel |
| Converting projected video to Apple Projected Media Profile | macOS | Three-part command-line pipeline: argument orchestration, optional classification, and media conversion. | Command, Processing pipeline, Data transfer object |
| Converting side-by-side 3D video to multiview HEVC and spatial video | macOS | A two-file command-line app: argument policy delegates one streaming conversion to a stateful converter. | Command, Producer-consumer pipeline, Data transfer object |
| Creating a seamless multiview playback experience | iOS, iPadOS, Mac Catalyst, tvOS | SwiftUI MVVM with a menu view model, a layout-level player coordinator, and one observable state object per AVPlayer. |
Model-View-ViewModel, Observable state, Coordinated playback |
| Debugging AVFoundation audio mixes, compositions, and video compositions | iOS, iPadOS, Mac Catalyst | Storyboard UIKit controller coordinates a domain-style editor, AVPlayer, and a custom diagnostic view. |
Model-View-Controller, Builder, Delegate |
| Editing and playing HDR video | iOS, iPadOS, Mac Catalyst, macOS | Shared asset/filter/export code plus target-selected AVVideoCompositionBuilder implementations and platform UI adapters. |
Builder, Compile-time strategy, Adapter |
| Enhancing live video by leveraging TrueDepth camera data | iOS, iPadOS, Mac Catalyst | Storyboard UIKit controller owns the end-to-end capture and Core Image pipeline; a custom MTKView owns display rendering. |
Model-View-Controller, Delegate, Thread confinement |
| Integrating AirPlay for long-form video apps | iOS, iPadOS, Mac Catalyst | Compact storyboard MVC with one route-selection controller and one externally playing remote-control controller. | Model-View-Controller, Callback, Property injection |
| Processing spatial video with a custom video compositor | iOS, iPadOS, Mac Catalyst, macOS, visionOS | SwiftUI owns one observable feature model; the model builds compositions and selects exporters through explicit protocol/factory boundaries. | Observable model, Strategy, Factory, Decorator, Builder |
| Providing an integrated view of your timeline when playing HLS interstitials | iOS, iPadOS, Mac Catalyst | SwiftUI menu and player views use observable view models; PlayerState owns AVFoundation playback and timeline observation. |
MVVM, Observable state, Delegate, Shared coordinator |
| Reading multiview 3D video files | macOS | Small SwiftUI app with view-owned navigation state, a metadata view model, and a frame-decoding view model. | Model-View-ViewModel, Observable state, Explicit state machine |
| Streaming depth data from the TrueDepth camera | iOS, iPadOS, Mac Catalyst | A storyboard-backed CameraViewController owns capture, synchronization, processing, and view coordination; renderer types isolate GPU work. |
MVC, Delegate, Strategy, Synchronized processing pipeline |
| Supporting Center Stage front camera in your iOS app | iOS, iPadOS, Mac Catalyst | SwiftUI views depend on a Camera protocol; observable CameraModel mediates UI state; a custom-executor CaptureService actor owns AVFoundation. |
MVVM, Actor isolation, Protocol-oriented design, Async sequence |
| Supporting Continuity Camera in your macOS app | macOS | ContentView owns one main-actor Camera observable object that combines capture-session ownership, device selection, and UI-facing state. |
Observable model, Observer, Adapter, UI state projection |
| Supporting coordinated media playback | iOS, iPadOS, Mac Catalyst | UIKit view controllers share a singleton CoordinationManager; Combine publishes movie/session changes into list and player controllers. |
MVC, Shared coordinator, Observer, GroupActivity |
| Supporting remote interactions in tvOS | tvOS | A menu launches independent UIKit scenarios; each controller owns a scenario-specific player and translates remote input into domain enums/commands. | MVC, Command mapping, Delegate, Observer, Shared catalog |
| Using AVFoundation to play and persist HTTP live streams | iOS, iPadOS, Mac Catalyst | Storyboard UIKit MVC backed by singleton list, playback, persistence, and stream-catalog managers. | MVC, Singleton managers, Delegate, Notification observer |
| Using HEVC video with alpha | macOS | One workspace contains three independent targets: playback app, asset-writing app, and command-line export examples. | Pipeline, Framework delegate, Callback completion, Multi-target examples |
| Writing fragmented MPEG-4 files for HTTP Live Streaming | macOS | A command-line orchestrator wires track loading, a reader/writer segment producer, and two Combine consumers for files and playlist text. | Reactive pipeline, Delegate, Configuration object, Value object |
Cross-sample signals
Recurring documented patterns
| Pattern label | Sample documents |
|---|---|
| Delegate | 8 |
| MVVM | 4 |
| MVC | 4 |
| UIKit view controller | 3 |
| Observable model | 3 |
| Model-View-ViewModel | 3 |
| Observable state | 3 |
| Model-View-Controller | 3 |
| Builder | 3 |
| Observer | 3 |
| protocol-oriented view model | 2 |
| capture delegates | 2 |
| Command | 2 |
| Data transfer object | 2 |
| Adapter | 2 |
| Strategy | 2 |
| Shared coordinator | 2 |
Type-role naming evidence
Counts below are declaration-name suffixes, not inferred patterns.
| Role suffix | Distinct declarations across samples |
|---|---|
View |
73 |
Delegate |
29 |
Controller |
22 |
Coordinator |
10 |
ViewModel |
10 |
App |
9 |
Model |
8 |
Manager |
7 |
Service |
6 |
Observer |
4 |
Converter |
4 |
Renderer |
4 |
Recorder |
2 |
Builder |
2 |
Player |
2 |
Processor |
1 |
Loader |
1 |
Command |
1 |
Swift access-control evidence
These are declaration occurrences in scanned Swift source, including implicit internal declarations.
| Access level | Occurrences |
|---|---|
implicit internal |
4147 |
private |
1111 |
private(set) |
98 |
public |
25 |
fileprivate |
8 |
References
Generated from the verified local catalog and completed Markdown documents.