Adaptive timestamp synchronization for status/audio
A core component of RC2 is keeping audio and status/control data in-sync with each other. WebSocket commands & status messages arrive in realtime (sans any network latency), while audio may arrive with a substantial (~300ms or more) delay. Currently, we use the WebRTC RoundTripTime statistic, plus a manually determined "fudge factor", to come up with a proper timing offset to delay status & command updates to be properly synced with incoming/outgoing audio.
A better method would be to use the RTP extensions for WebRTC to embed the absolute capture NTP timestamp of each audio packet, and embed the same NTP timestamp into each Websocket message. Then, at either end, we can compare these two timestamps and delay the Websocket messages by an appropriate amount of time, updated dynamically every n seconds.
More reference:
SipSorcery: https://github.com/sipsorcery-org/sipsorcery/pull/1182
WebRTC: https://w3c.github.io/webrtc-extensions/#rtp-header-extension-control-transceiver-interface