w3c / webrtc-extensions

A repository for experimental additions to the WebRTC API
https://w3c.github.io/webrtc-extensions/
Other
60 stars 19 forks source link

senderReceiverTimeOffset should use remoteOutboundRtpStats.roundTripTime #109

Open yuanchao0310 opened 2 years ago

yuanchao0310 commented 2 years ago

in https://github.com/w3c/webrtc-extensions/blob/main/explainer.md#api-2-sendercapturetimeoffset

senderReceiverTimeOffset = remoteOutboundRtpStats.timestamp - (remoteOutboundRtpStats.remoteTimestamp + remoteInboundRtpStats.roundTripTime / 2);

if receiver is a recv only endpoint, it cannot get remoteInboundRtpStats.roundTripTime, because remoteInboundRtpStats.roundTripTime use SR and RR to get rtt time, that means the receiver must send RTP to remote peer.

so need use remoteOutboundRtpStats.roundTripTime, which can be calculated by XR RTCP at receiver side. after update:

stats = peerconnection.getStats(); remoteOutboundRtpStats = getRequiredStats(stats, "remote-outbound-rtp"); senderReceiverTimeOffset = remoteOutboundRtpStats.timestamp - (remoteOutboundRtpStats.remoteTimestamp + remoteOutboundRtpStats.roundTripTime / 2)

henbos commented 2 years ago

Makes sense to me, and in terms of implementation, this was implemented in chromium/libwebrtc in M95. However it looks like it was only implemented for the audio case, not the video case. Anyway that's an implementation issue, not a spec issue.