Camera Module Reference
The Camera Module provides comprehensive camera functionality, including photo capture and both managed and unmanaged RTMP streaming capabilities. It allows apps to request photos from connected smart glasses and stream live camera feeds using two different approaches.Overview
The Camera Module is part of the App Session and provides three main capabilities:- Photo Capture: Request individual photos from smart glasses
- Managed Streaming: Zero-infrastructure streaming with automatic HLS/DASH URLs
- Unmanaged Streaming: Full-control streaming to custom RTMP endpoints
Photo Functionality
requestPhoto()
Request a photo from the connected smart glasses.Parameters
| Parameter | Type | Description |
|---|---|---|
options | PhotoRequestOptions | Optional configuration for the photo request |
PhotoRequestOptions
Compression Options
Thecompress option controls image compression during webhook upload to optimize network transfer speed. Defaults to "none" (no compression).
| Level | Dimensions | JPEG Quality | Typical Size Reduction | Use Case |
|---|---|---|---|---|
"none" | Original | Original | 0% (no compression) | High-quality photos, fast WiFi |
"medium" | 75% scale | 80% quality | ~50-60% smaller | Balanced quality/speed |
"heavy" | 50% scale | 60% quality | ~75-85% smaller | Slow connections, large photos |
"none": 1440×1080, full quality → ~280KB"medium": 1080×810, 80% quality → ~140KB (50% smaller)"heavy": 720×540, 60% quality → ~70KB (75% smaller)
"none": 3200×2400, full quality → ~800KB"medium": 2400×1800, 80% quality → ~400KB"heavy": 1600×1200, 60% quality → ~200KB
- Compression only applies to webhook uploads (WiFi/cellular)
- BLE transfers use a different ultra-aggressive compression (AVIF format, 10-15KB) regardless of this setting, controlled by the
sizeparameter - Aspect ratio is always preserved
- Uses JPEG format with bilinear scaling for high-quality results
Understanding Webhook vs BLE Compression
MentraOS uses two different compression algorithms depending on the transfer method: Webhook Compression (controlled bycompress option):
- Format: JPEG
- Algorithm: Percentage-based dimension scaling + JPEG quality control
- Use case: WiFi/cellular uploads where bandwidth is measured in Mbps
- Result: 75-300KB files with good visual quality
size option):
- Format: AVIF (with JPEG fallback)
- Algorithm: Fit-within-box dimension constraint + ultra-low quality AVIF encoding
- Use case: Bluetooth fallback where bandwidth is ~50-100 KB/s
- Result: 10-15KB files with acceptable quality for thumbnails
- First attempts webhook upload (uses
compresssetting) - Falls back to BLE if webhook fails (uses aggressive AVIF compression based on
size)
Returns
Returns aPromise<PhotoData> that resolves with the captured photo data.
PhotoData Interface
Example
Managed Streaming Functionality (Recommended)
Managed streaming provides zero-infrastructure streaming where the cloud handles all RTMP endpoints and returns HLS/DASH URLs for viewing. Multiple apps can access the same managed stream simultaneously.startManagedStream()
Start a managed stream with automatic URL generation.Parameters
| Parameter | Type | Description |
|---|---|---|
options | ManagedStreamOptions | Optional configuration for the managed stream |
ManagedStreamOptions
ManagedStreamResult
Example
stopManagedStream()
Stop the current managed stream.Example
checkExistingStream()
Check if there’s an existing active stream (managed or unmanaged) for the current user.Returns
Returns aPromise<StreamCheckResult> with information about any active stream.
StreamCheckResult Interface
Example
Use Cases
- Reconnection: Apps can check for and reconnect to existing streams after restart
- Multi-app coordination: Detect if another app is already streaming
- Resource management: Avoid creating duplicate streams
- User experience: Inform users about existing streams before starting new ones
Managed Stream Status Monitoring
onManagedStreamStatus()
Subscribe to managed stream status updates.ManagedStreamStatus
Example
Unmanaged RTMP Streaming Functionality
Unmanaged streaming provides full control over RTMP endpoints but requires your own streaming infrastructure. Only one unmanaged stream can be active at a time, and it blocks other apps from using the camera.startStream()
Start an unmanaged RTMP stream to a specific URL.Parameters
| Parameter | Type | Description |
|---|---|---|
options | RtmpStreamOptions | Configuration options for the stream |
RtmpStreamOptions
VideoConfig
AudioConfig
StreamConfig
Example
stopStream()
Stop the current unmanaged RTMP stream.Example
Unmanaged Stream Status Monitoring
onStreamStatus()
Subscribe to unmanaged stream status updates.StreamStatusHandler
RtmpStreamStatus
Example
Unmanaged Stream Utility Methods
isCurrentlyStreaming()
Check if currently streaming (unmanaged).getCurrentStreamUrl()
Get the URL of the current unmanaged stream.getStreamStatus()
Get the current unmanaged stream status.Streaming Comparison
| Feature | Managed Streaming | Unmanaged Streaming |
|---|---|---|
| Infrastructure Required | None | RTMP Server |
| Multiple Apps Can Stream | ✅ Yes | ❌ No (Exclusive) |
| Blocks Other Apps | ❌ No | ✅ Yes |
| Viewer URLs Provided | ✅ HLS/DASH/WebRTC | ❌ You manage |
| Best For | Social media, prototypes, multi-app scenarios | Custom servers, exclusive access |
| Requires Internet | Yes | No |
Error Handling
Photo Errors
- Timeout: Photo requests timeout after 30 seconds
- Cancellation: Requests can be cancelled manually or during session cleanup
- Device Errors: Camera unavailable or hardware issues
Unmanaged Stream Errors
- Already Streaming: Cannot start while any stream (managed or unmanaged) is active
- Invalid URL: RTMP URL validation failures
- Network Issues: Connection problems to RTMP endpoint
- Device Limitations: Hardware doesn’t support requested configuration

