Skip to content

WebRTC signaling

At places where WebRTC is needed (e.g. live audio playback), Angelcam uses a simple WebSocket-based signaling protocol.

Keep the WebSocket connection open for the entire WebRTC session — closing it terminates the session.

  • Client SHOULD send WebSocket PING messages at regular intervals and expect a PONG within a reasonable timeout.
  • Client MUST respond to PING messages sent by the server.

Both peers exchange WebSocket TEXT messages containing JSON. Every message must have a type field:

{
"type": "MESSAGE_TYPE",
...
}

MESSAGE_TYPE is one of: offer, answer, candidate.

{
"type": "offer",
"sdp": "v=0\r\n..."
}

The sdp field contains the proposed or selected session description.

{
"type": "candidate",
"candidate": {
"candidate": "candidate:...",
"mid": "0",
"ufrag": "ABCD"
}
}

candidate can be null (end-of-candidates signal) or an ICE candidate object with:

FieldDescription
candidateICE candidate in SDP attribute format (without the leading a=)
midMedia ID of the stream the candidate belongs to
ufragUsername fragment for the media stream