How getstream/stream-video-swift works
Project Type & Purpose
• This is an open-source iOS SDK (StreamVideo) for building video/audio calling and live streaming features.
• It provides:
• A low-level client (core library) handling signaling, WebSockets, REST, WebRTC, CallKit integration.
• Two UI layers: a SwiftUI SDK and a UIKit SDK (wrapping the SwiftUI components).
• One or more demo/sample apps (DemoApp, DemoAppUIKit, SwiftUIDemoApp).
High-Level File Structure Overview
• Top-level folders:
• Sources/StreamVideo – the core low-level client
• Sources/StreamVideoSwiftUI – the SwiftUI UI library
• Sources/StreamVideoUIKit – the UIKit wrapper
• DemoApp & DemoAppUIKit – sample applications integrating the SDK
• DocumentationTests – code snippets and guides
• ScreenSharing – iOS broadcast extension sample
• Tests & StreamVideoTests/StreamVideoSwiftUITests/StreamVideoUIKitTests – unit and UI tests
• CI/CD & tooling: .github workflows, Fastlane, Scripts, lint/config files
Main Components
a. Client Application Layer
• DemoApp (SwiftUI)
• DemoAppUIKit (UIKit)
• Optional SwiftUIDemoApp sample
b. UI SDK Layer
• StreamVideoSwiftUI
• StreamVideoUIKit (calls SwiftUI under the hood)
c. Core Library Layer (StreamVideo)
• HTTPClient (REST API calls to Stream backend)
• WebSocket Client (signaling)
• WebRTC Stack (media capture, encoding/decoding, SFU adapter, filters)
• CallKit Adapter (iOS native call integration)
• CallState & CallStateMachine (state management)
• Controllers (CallController, CallsController)
• DependencyInjection (InjectedValues)
• Models & OpenAPI generated code
• Utils (logging, queues, policies, proximity, audio session)
d. External Services
• Stream Video REST API & OpenAPI server
• Signaling & SFU servers (via WebSocket)
• STUN/TURN servers (media relay)
• Push notifications (optional)
Relationships & Data Flows
• App → UI SDK: App instantiates CallViewModel / CallViewController and applies UI modifiers or pushes controllers.
• UI SDK → Core: UI components invoke core APIs on StreamVideo object (e.g., create call, mute, send reaction).
• Core → HTTPClient: Core uses HTTPClient to fetch tokens or query call metadata.
• Core → WebSocket Client: Core subscribes to real-time call events over WebSocket.
• Core → WebRTC Stack: Core orchestrates media capture, encoding, SFU signaling, and rendering.
• Core → CallKit: Core integrates with iOS CallKit for system call screens.
• Core → External Services:
• REST API endpoints (connect, join call, list participants).
• WebSocket/SFU for signaling.
• STUN/TURN for NAT traversal.
• Optional: ScreenSharing extension → Core (via broadcast buffers).
Architectural Patterns & Principles
• Layered architecture: UI → SDK → Core → External services
• MVVM in SwiftUI: CallViewModel driving SwiftUI views
• Factory & Protocol-based injection: ViewFactory, DI with InjectedValues
• State machines: CallStateMachine & WebRTCCoordinator state machines
• Adapter patterns: CallKitAdapter, WebSocketAdapter, SFUAdapter
• OpenAPI code generation for REST models & clients