You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+41-13Lines changed: 41 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,15 @@
1
1
# Intercom ClientPython
2
2
3
-
Python device client that streams video from a camera to a remote receiver (browser viewer) using WebRTC, authenticated via OAuth 2.0 Device Authorization Grant.
3
+
Python device client that streams video from a camera to a remote viewer (browser) using WebRTC, authenticated via OAuth 2.0 Device Authorization Grant, with continuous telemetry reporting.
4
4
5
5
## Tech Stack
6
6
7
7
-**Python 3.14+** with **uv** package manager
8
8
-**aiortc** — WebRTC peer connection and media streaming
9
+
-**aioice** — ICE candidate handling (used internally by aiortc; `candidate_from_sdp` from `aiortc.sdp` parses ICE SDP strings)
9
10
-**OpenCV (cv2)** — Camera capture
10
11
-**websockets** — WebSocket signaling client
11
-
-**boto3** — AWS SDK (indirectly via backend)
12
-
-**requests** — HTTP API calls for OAuth flow
12
+
-**requests** — HTTP API calls for OAuth flow and telemetry
-`candidate` — Receives ICE candidates; parsed with `candidate_from_sdp()` from `aiortc.sdp` (strips `candidate:` prefix; sets `sdpMid`/`sdpMLineIndex` manually as they are top-level message fields, not part of the SDP string)
44
+
-`status` with `event: "peer_disconnected"` and `peer_type != "device"` — viewer disconnected; resets RTCPeerConnection in-place (signaling WS stays open) ready for the next offer
45
45
-`icecandidate` events (local) — Sends locally-generated ICE candidates back through signaling server
46
-
- Connection lifecycle: shutdown on `failed`/`closed`, retry on errors with 5s backoff
46
+
- On WebRTC `connectionState == "connected"`, fires a `streaming` telemetry event
47
+
- On WebRTC `connectionState == "failed"`, fires an `error` telemetry event then resets the PC
48
+
49
+
### PC Lifecycle (`setup_peer_connection`)
50
+
- Nulls out `self.pc`**before** closing the old one — prevents stale `connectionstatechange` events from the closing PC from affecting the new connection
51
+
- Uses `if pc is not self.pc: return` guard in all event handlers to discard events from replaced PCs
52
+
- Signaling WebSocket is **never** closed by WebRTC state changes — only by unrecoverable signaling errors
47
53
48
54
### Video Capture (`intercomclient/camera_video_stream_track.py`)
0 commit comments