Selkies
Developer Reference

webrtc_utils

WebRTC support utilities: ICE configuration, metrics, and resource monitors.

Three groups of helpers live here:

  • RTC ICE configuration: builders and parsers for RTCPeerConnection-style ICE server JSON, the prioritized get_rtc_configuration resolver, and refresh monitors (HMAC shared-secret, TURN REST, Cloudflare, and a config-file watcher) that push updated credentials through an on_rtc_config callback.
  • Metrics: Prometheus gauges/histograms plus an optional per-connection CSV dump of client-reported WebRTC statistics. CSV writes run on a dedicated single-worker thread pool so they preserve row order, never block the event loop, and can be drained deterministically at teardown.
  • System/GPU monitors: asyncio polling loops that off-load blocking psutil and GPU queries to worker threads and report through async callbacks.

All periodic loops share the same shutdown idiom: an asyncio.Event waited on with a timeout, so stop() interrupts the sleep immediately instead of waiting out the period.

attributelogger_rtcice
= logging.getLogger('rtcice')
attributeDEFAULT_RTC_CONFIG
= '{\n "lifetimeDuration": "86400s",\n "iceServers": [\n {\n "urls": [\n "stun:stun.l.google.com:19302"\n ]\n }\n ],\n "blockStatus": "NOT_BLOCKED",\n "iceTransportPolicy": "all"\n}'
attributeDEFAULT_STUN_SERVERS
= [('stun.l.google.com', 19302), ('stun.cloudflare.com', 3478)]
attributelogger_metrics
= logging.getLogger('metrics')
attributeFPS_HIST_BUCKETS
= (0, 20, 40, 60)
attributeWEBRTC_CSV_MAX_HEADERS
= 2048
attributeWEBRTC_CSV_MAX_RETAINED_ROWS
= 100000
attributelogger_system
= logging.getLogger('system_monitor')
attributelogger_gpu
= logging.getLogger('gpu_monitor')

On this page

No Headings
Edit on GitHub