Index of every page on this site: llms.txt
All skills
Run it yourself

Software Mansion's moq-kit — native Swift (iOS) and Kotlin (Android) SDKs for Media over QUIC (moq-lite) live streaming: sub-second-latency playback, camera/microphone/screen publishing, and realtime data tracks over a MoQ relay. MUST USE before writing, reviewing, or debugging ANY code that imports MoQKit (Swift) or com.swmansion.moqkit (Kotlin); for React Native apps use the react-native-moq skill instead. Trigger on: 'moq-kit', 'MoQKit', 'Media over QUIC', 'moq-lite', 'MoQ relay', 'moq-ffi', 'BroadcastSubscription', 'DataTrackEmitter', 'CameraCapture', 'MicrophoneCapture', 'MultiCameraCapture', 'ScreenCapture', 'TrackSubscription', 'AudioDataStream', 'MoQReplayKitBroadcastSampleHandler', or a Session/Player/Publisher/Catalog from moq-kit.

Use this Skill: https://skilld.dev/gh/software-mansion-labs/skills/moq-kit

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesplayback-ios.md

≈1.2k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Playback — iOS (Swift)

Session

let session = Session(url: relayURL)            // actor — all calls await
Task { for await state in session.state { … } } // .idle → .connecting → .connected; .error / .closed
try await session.connect()
// later: await session.close()                 // idempotent; session is dead afterwards
  • connect() is one-shot: reconnecting means a new Session (throws SessionError.alreadyConnected/alreadyClosed on reuse). Guard stale async completions across reconnects with a connection token (compare a UUID captured before each await).
  • Transport failures surface as state (.error(SessionError)), not as exceptions from playback calls.

Broadcast discovery

let subscription = try await session.subscribe(prefix: "live") // "" = all; throws .alreadySubscribed per duplicate prefix
for await broadcast in subscription.broadcasts { … }     // keep subscription alive; cancel() frees the prefix

Requires a connected session; one active subscription per exact prefix. Hold the Task driving the for await loop — cancelling it stops discovery.

Catalog track selection

for await catalog in broadcast.catalogs() {
    let video = catalog.playableVideoTracks
        .max { ($0.config.coded?.height ?? 0) < ($1.config.coded?.height ?? 0) }?.name
    let audio = catalog.playableAudioTracks.first?.name
}

Catalog semantics (updates replace, stream end = offline, playable lists) are in SKILL.md. Video-track playability on iOS is based on codec families the renderer recognizes; actual decode support is still decided by AVFoundation at runtime.

Player

// @MainActor — construct and drive on the main actor
let player = try Player(catalog: catalog, videoTrackName: video, audioTrackName: audio,
                        targetBuffering: .milliseconds(100), volume: 1.0)
try await player.play()
  • At least one of videoTrackName/audioTrackName is required; unknown names throw at init.
  • Controls: pause() (resumes from live on next play()), stopAll(reason:) (terminal), switchTrack(to:) (video rendition; seamless when both are active), switchAudioTrack(to:), updateTargetLatency(_:) (live), setVolume / audioVolume (clamped 0–1).
  • Audio plays via AVAudioEngine through the system output. The SDK never configures AVAudioSession (its docs claim none is needed) — set a .playback-capable category yourself or the mute switch can silence playback.

Rendering video

player.videoLayer is an AVSampleBufferDisplayLayer; add it to a layer hierarchy and size it yourself. Nothing renders until it's in the tree and play() has run.

final class VideoContainerView: UIView {
    private var displayLayer: AVSampleBufferDisplayLayer?
    func setDisplayLayer(_ layer: AVSampleBufferDisplayLayer?) {
        guard layer !== displayLayer else { return }
        displayLayer?.removeFromSuperlayer()
        displayLayer = layer
        if let layer { self.layer.addSublayer(layer) }
        setNeedsLayout()
    }
    override func layoutSubviews() { super.layoutSubviews(); displayLayer?.frame = bounds }
}

struct VideoLayerView: UIViewRepresentable {
    let videoLayer: AVSampleBufferDisplayLayer?
    func makeUIView(context: Context) -> VideoContainerView { VideoContainerView() }
    func updateUIView(_ view: VideoContainerView, context: Context) { view.setDisplayLayer(videoLayer) }
    static func dismantleUIView(_ view: VideoContainerView, coordinator: ()) { view.setDisplayLayer(nil) }
}

Moving playback to another screen (e.g. fullscreen) reuses the same layer — force the representable to re-add it (the demo bumps an .id(generation)).

Events, stats, diagnostics

Channel semantics are in SKILL.md; the iOS wiring:

let events = player.subscribeEvents { event in … }   // BEFORE play(); RETAIN the subscription
let stats  = player.subscribeStats { stats in … }    // first push deferred until real data
Task { for await event in player.diagnostics() { … } } // bounded (256) per call, non-replayed

Both subscribeEvents and subscribeStats return a PlayerEventSubscription that cancels itself on deinit — store it or events silently stop. Listeners are @MainActor. A synchronous player.stats snapshot property also exists.

Lifecycle checklist

  1. Create Session → observe state → connect().
  2. subscribe(prefix) → per broadcast, observe catalogs(); catalog stream ending = broadcast offline.
  3. On the main actor: create Player → subscribe events → attach videoLayer → play().
  4. Teardown in order: cancel observation tasks → await player.stopAll() → cancel the broadcast subscription → await session.close().

Keep strong references throughout: Session, BroadcastSubscription, Player, and every PlayerEventSubscription; the Task handles driving for await loops are the lifetime of those streams.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning26d3 checks · Risk SAFE
  • Gen Agent Trust Hub3mo

    The moq-kit skill is a developer resource providing documentation and code samples for Software Mansion's Media over QUIC (MoQ) SDKs for iOS and Android. No security risks or malicious behaviors were identified; the skill strictly provides legitimate integration guidance for mobile developers.

  • Socket26d

    No alerts

  • Snyk3mo

    Risk: MEDIUM · 1 issue

Signed by skilld at 43cde80. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated 3 months ago

README badge

README badge for software-mansion-labs/skills/moq-kit