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.

referencespublishing-android.md

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

Publishing — Android (Kotlin)

Go-live order

Shared ordering and publisher states are in SKILL.md. Android specifics: Publisher() doesn't throw; start()/stop() are not suspend; start() validates every track's codec first and throws UnsupportedCodecException before starting anything; start() with zero tracks flips straight to Stopped (as does stopping the last track).

camera.start(context, lifecycleOwner); microphone.start() // 1. captures first
val publisher = Publisher()                               // 2. add ALL tracks before start
publisher.addVideoTrack(name = "camera", source = camera, config = videoConfig)
publisher.addAudioTrack(name = "mic", source = microphone, config = audioConfig)
session.publish(path = "live/android", publisher = publisher) // 3. register
publisher.start()                                         // 4. go live

Observe publisher.state (StateFlow), publisher.events (SharedFlow), and each PublishedTrack.state in coroutines on your scope. Also observe session.state — none of the publisher channels react to the session dying: when the transport drops, publisher.state stays Publishing and no event fires, while session.state goes Error(message) → Closed. A publish screen that watches only the publisher will keep claiming it is live long after the broadcast is gone.

Camera and preview

val camera = CameraCapture(position = CameraPosition.Back, width = 1920, height = 1080, frameRate = 30)
camera.start(context, lifecycleOwner) // suspend; CameraX binds to this lifecycle; CAMERA permission required
camera.switchCamera()                 // suspend
camera.stop()

Preview: camera.setPreviewSurface(surface) with a SurfaceView's surface — same SurfaceHolder.Callback pattern as the player (null it on surfaceDestroyed).

Multi-camera

if (!MultiCameraCapture.isFrontBackSupported(context)) return // suspend; real CameraX pair check
val cameras = MultiCameraCapture(
    front = CameraStreamConfig(CameraPosition.Front, 1280, 720, 30),
    back = CameraStreamConfig(CameraPosition.Back, 1280, 720, 30),
)
cameras.start(context, lifecycleOwner)
publisher.addVideoTrack("front-camera", cameras.frontSource, videoConfig)
publisher.addVideoTrack("back-camera", cameras.backSource, videoConfig)

Two checks: isSupported(context) (cheap PackageManager feature check — gate UI on it) and isFrontBackSupported(context) (suspend; verifies an actual concurrent front/back pair — gate start() on it). They're enforced, not advisory: start() throws IllegalStateException without a concurrent pair, and the constructor requires that front/back positions match their labels. Front and back are two separate sources → two video tracks. The demo previews multi-cam with two TextureViews.

Microphone

val microphone = MicrophoneCapture(sampleRate = 48_000, channels = 1)
microphone.start() // NOT suspend; silently no-ops if RECORD_AUDIO is missing or AudioRecord fails
microphone.stop()

The silent no-op means a missing permission produces a broadcast with no audio and no error — request RECORD_AUDIO before starting. start() is annotated @RequiresPermission(RECORD_AUDIO), so call sites need the permission proven to lint (a checked request, @RequiresPermission on the caller, or an explicit suppression). Keep sampleRate equal to AudioEncoderConfig.sampleRate (Opus wants 48 kHz).

Unlike iOS, start() is not idempotent: calling it twice without stop() leaves the first AudioRecord and its reader thread running while only the second is tracked, so stop() releases one of them and duplicate PCM keeps flowing. Gate re-publish on your own running flag. Stopping first, then starting again, is fine — a stopped capture can be handed to the next Publisher (only the Publisher is single-use).

Encoder configs and codec gating

VideoEncoderConfig(codec = VideoCodec.H264, width = 1920, height = 1080, bitrate = 1_500_000,
                   keyframeIntervalSeconds = 2, frameRate = 30)  // defaults shown; also optional profile
AudioEncoderConfig(codec = AudioCodec.AAC, sampleRate = 48_000, channels = 1, bitrate = 128_000) // Android default codec: aac

Build codec pickers from VideoEncoderConfig.supportedCodecs() / AudioEncoderConfig.supportedCodecs(); check an exact config with .isSupported / .unsupportedReason. Encoder support varies per device — H.264 is the safe default; gate H.265 explicitly.

Custom sources

Implement VideoFrameSource (encoder-Surface-based: attachEncoderSurface/detachEncoderSurface/setPreviewSurface) or AudioFrameSource (onPcmData: (ByteArray, Int, Long) -> Unit, 16-bit PCM). Advanced — the built-in captures cover camera/mic/screen.

Timestamps must share one clock domain. Publisher stamps all of its tracks against a single epoch taken from the first frame of any track, so a source with a private zero-based timeline drifts against a live mic or leaves video scheduled far ahead. Use SystemClock.elapsedRealtimeNanos() / 1_000 for onPcmData's timestampUs (exactly what MicrophoneCapture does) and drive the encoder surface's presentation timestamps off the same clock.

Publisher sets onPcmData when the audio track starts and clears it when the track stops — don't set it yourself on a source you hand to a publisher.

Permissions

Manifest: INTERNET, CAMERA, RECORD_AUDIO — declare and request at runtime (RequestMultiplePermissions) before starting captures. The library does not add them transitively. Screen capture additionally needs the MediaProjection foreground-service setup (see the screen-capture reference).

Teardown

Cancel observer jobs → publisher.stop() → camera.stop() / microphone.stop() → session.close() if no longer needed. session.unpublish(path) is equivalent to publisher.stop() for that path.

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