RTMP Streaming
The ASG Client supports live video streaming via RTMP (Real-Time Messaging Protocol), allowing real-time video transmission from the glasses to remote servers.Overview
RTMP streaming enables:- Live video broadcasting from glasses
- Real-time video analysis by apps
- Remote assistance scenarios
- Video recording to cloud servers
RTMP Commands
The system uses four main commands for RTMP control:1. start_rtmp_stream
Initiates an RTMP stream to a specified URL. Command Structure:- Active WiFi connection
- Valid RTMP URL
- Sufficient bandwidth
2. stop_rtmp_stream
Terminates the active RTMP stream. Command Structure:3. keep_rtmp_stream_alive
Keep-alive mechanism to prevent stream timeout. Must be sent at least every 60 seconds. Command Structure:4. get_rtmp_status
Queries the current streaming status. Command Structure:Stream Lifecycle
Starting a Stream
- Request received: Phone sends
start_rtmp_stream
via BLE - WiFi check: Verify WiFi connection is active
- Stream init: Initialize RTMP encoder and connection
- Start streaming: Begin sending video data
- Status updates: Send status back to phone/cloud
Keep-Alive Mechanism
The stream has a 60-second timeout that requires periodic keep-alive messages:- Cloud sends keep-alive every 15 seconds with unique
ackId
- Glasses reset timeout and respond with ACK containing same
ackId
- If no keep-alive for 60 seconds, stream automatically stops
- If 3 ACKs are missed, cloud marks connection as degraded
Stopping a Stream
Streams can stop in three ways:- Explicit stop: Via
stop_rtmp_stream
command - Timeout: No keep-alive received for 60 seconds
- Error: Network failure, encoder error, etc.
Implementation Details
RtmpStreamingService
The main service handling RTMP streaming:Stream Timeout Handling
Status Messages
The glasses send various status updates during streaming:initializing
- Stream setup in progressactive
- Streaming successfullyreconnecting
- Attempting to reconnect after failureerror
- Stream failed with error detailsstopped
- Stream terminatedtimeout
- Stream stopped due to keep-alive timeout
Network Requirements
Bandwidth
- Minimum: 1 Mbps upload
- Recommended: 2-3 Mbps upload
- Adapts bitrate based on connection
WiFi Stability
- Requires stable WiFi connection
- Automatic reconnection on brief disconnects
- Stops on extended network loss
Error Handling
Common Errors
-
No WiFi Connection
-
Invalid RTMP URL
-
Stream Timeout
Recovery Mechanisms
- Auto-reconnect: Attempts reconnection on temporary failures
- Backoff strategy: Increasing delays between reconnection attempts
- Clean shutdown: Proper resource cleanup on errors
Best Practices
- Always send keep-alives at 15-second intervals
- Monitor ACK responses to detect connection issues
- Handle status updates to show stream state in UI
- Implement proper cleanup when app disconnects
- Check WiFi before starting streams
- Use unique streamIds for tracking
Debugging
Log Filters
Common Issues
- Stream stops after ~5 minutes: Check keep-alive implementation
- ACKs not received: Verify BLE communication both ways
- Poor quality: Check WiFi signal strength and bandwidth
- Can’t start stream: Ensure only one stream active at a time