Video Streaming
The ASG Client supports live video streaming via three protocols: SRT, RTMP/RTMPS, and WHIP (WebRTC). Protocol selection is automatic based on the stream URL provided by the cloud.Overview
Video streaming enables:- Live video broadcasting from glasses
- Real-time video analysis by apps
- Remote assistance scenarios
- Video recording to cloud servers
Supported Protocols
Protocol detection is handled by
StreamCommandHandler.detectProtocol() based on the URL scheme.
Stream Commands
The system uses four commands for stream control. These are sent from the phone to the glasses over BLE.1. start_stream
Initiates a stream to the specified URL. The protocol is auto-detected from the URL scheme. Command Structure:- Active WiFi connection
- Valid stream URL (srt://, rtmp://, rtmps://, http://, or https://)
- Sufficient battery level
- Sufficient bandwidth
2. stop_stream
Terminates the active stream (whichever protocol is running). Command Structure:3. keep_stream_alive
Keep-alive mechanism to prevent stream timeout. Must be sent at least every 60 seconds. Command Structure:4. get_stream_status
Queries the current streaming status. Command Structure:Stream Lifecycle
Starting a Stream
- Request received: Phone sends
start_streamvia BLE - Battery check: Verify sufficient battery level
- WiFi check: Verify WiFi connection is active
- Stop existing: Any running stream is stopped first
- Protocol detection: URL scheme determines which service to use
- Stream init: Initialize encoder and connection for the detected protocol
- 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_streamcommand - Timeout: No keep-alive received for 60 seconds
- Error: Network failure, encoder error, etc.
Implementation Details
StreamCommandHandler
Routes commands to the appropriate streaming service based on URL protocol:Streaming Services
All three services share the sameStreamingStatusCallback interface:
isStreaming()/isReconnecting()— state queriesstopStreaming(context)— stop and clean upresetStreamTimeout(streamId)— keep-alive timeout resetsetStreamingStatusCallback(callback)— status event reporting
Status Messages
All services report status through the shared callback:initializing— Stream setup in progressstreaming/active— Streaming successfullyreconnecting— Attempting to reconnect after failurereconnected— Successfully reconnectedreconnect_failed— All reconnection attempts exhaustederror— 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
Debugging
Log Filters
Common Issues
- Stream stops after ~60 seconds: 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
- Unknown protocol: Verify URL scheme is srt://, rtmp://, rtmps://, http://, or https://

