camera-streaming

द्वारा facebook

स्ट्रीम, वीडियो फ्रेम, फोटो कैप्चर, रिज़ॉल्यूशन/फ्रेम दर कॉन्फ़िगरेशन

npx skills add https://github.com/facebook/meta-wearables-dat-ios --skill camera-streaming

Camera Streaming (iOS)

Guide for implementing camera streaming and photo capture with the DAT SDK.

Key concepts

  • Stream: Main interface for camera streaming
  • VideoFrame: Individual video frames — call .makeUIImage() to render
  • StreamConfiguration: Configure resolution, frame rate, and codec
  • PhotoData: Still image captured from glasses

Creating a DeviceSession

import MWDATCamera
import MWDATCore

let wearables = Wearables.shared
let deviceSelector = AutoDeviceSelector(wearables: wearables)
// Or for a specific device: SpecificDeviceSelector(device: deviceId)
let deviceSession = try wearables.createSession(deviceSelector: deviceSelector)
try deviceSession.start()

// Wait for the device session to reach the started state
for await state in deviceSession.stateStream() {
    if state == .started { break }
}

Adding a Camera

Once the DeviceSession is started, add a Camera capability and get its stream:

let config = StreamConfiguration(
    videoCodec: .raw,
    resolution: .medium,  // 504x896
    frameRate: 24
)

guard let camera = try deviceSession.addCamera(config: config) else {
    // DeviceSession must be in the started state before adding a camera
    return
}
let stream = camera.stream

Resolution options

ResolutionSize
.high720 x 1280
.medium504 x 896
.low360 x 640

Frame rate options

Valid values: 2, 7, 15, 24, 30 FPS.

Lower resolution and frame rate yield higher visual quality due to less Bluetooth compression.

Observing stream state

StreamState transitions: stoppingstoppedwaitingForDevicestartingstreamingpaused

let stateToken = stream.statePublisher.listen { state in
    Task { @MainActor in
        switch state {
        case .streaming:
            // Stream is active, frames are flowing
        case .waitingForDevice:
            // Waiting for glasses to connect
        case .stopped:
            // Stream ended — release resources
        case .paused:
            // Temporarily suspended — keep connection, wait
        default:
            break
        }
    }
}

Receiving video frames

let frameToken = stream.videoFramePublisher.listen { frame in
    guard let image = frame.makeUIImage() else { return }
    Task { @MainActor in
        self.previewImage = image
    }
}

Starting and stopping

// Start the stream capability
stream.start()

// Stop the camera (teardown cascades to the stream)
camera.stop()

// Stop the parent device session when you're done with all capabilities
deviceSession.stop()

Photo capture

Capture a still photo while streaming:

// Listen for photo data
let photoToken = stream.photoDataPublisher.listen { photoData in
    let imageData = photoData.data
    // Convert to UIImage or save
}

// Trigger capture
stream.capturePhoto(format: .jpeg)

Bandwidth and quality

Resolution and frame rate are constrained by Bluetooth Classic bandwidth. The SDK automatically reduces quality when bandwidth is limited:

  1. First lowers resolution (e.g., High → Medium)
  2. Then reduces frame rate (e.g., 30 → 24), never below 15 FPS

Request lower settings for higher visual quality per frame.

Links

facebook की और Skills

api-health
facebook
Monitor API health for a Meta app — check rate limits, call volume, and API deprecations. Use to diagnose throttling, plan capacity, or prepare for API version…
official
api-integration
facebook
किसी डेवलपर को शुरू से Meta API इंटीग्रेशन सेट करने में मार्गदर्शन करें — सही APIs खोजें, सेटअप गाइड प्राप्त करें, प्रमाणीकरण आवश्यकताएँ,…
official
app-review-prep
facebook
Prepare a Meta app for App Review — checks current status, outstanding requirements, granted privileges, and submission history. Use before submitting an app…
official
debug-webhooks
facebook
Troubleshoot webhook issues for a Meta app — inspect active subscriptions, identify misconfiguration, and send test payloads to verify delivery. Use when…
official
webhook-setup
facebook
Set up webhooks for a Meta app end-to-end — discover available topics, subscribe to fields, and verify with a test payload. Use when configuring webhooks for…
official
buck2-rule-basics
facebook
उपयोगकर्ताओं को उनका पहला Buck2 rule लिखने में मार्गदर्शन करें ताकि वे मूलभूत अवधारणाएँ सीख सकें, जिनमें rules, actions, targets, configurations, analysis और select() शामिल हैं। उपयोग…
official
add-ir-instruction
facebook
Guide for adding a new IR instruction to the Hermes compiler. Use when the user asks to add, create, or define a new IR instruction (Inst/Instruction) in the…
official
binary-size-analysis
facebook
This skill should be used when the user wants to analyze hermesvm binary size changes across a range of commits. Use when the user mentions "binary size",…
official