NEW 192601
RTCPeerConnection#getStats returns RTCStatsReport which is very different from the spec.
https://bugs.webkit.org/show_bug.cgi?id=192601
Summary RTCPeerConnection#getStats returns RTCStatsReport which is very different fro...
syerrapragada
Reported 2018-12-11 12:34:09 PST
Spec: https://www.w3.org/TR/webrtc-stats/ RTCPeerConnection#getStats is not according to the spec above. 1. RTCPeerConnection#getStats does not honor selector argument 2. Cannot correlate remote tracks in stats report. 3. StatsReport does not have local-candidate stats type. 4. StatsReport does not have remote-candidate stats type. 5. StatsReport does not have codec stats type. This following fiddle should help reproduce the issues mentioned above. https://jsfiddle.net/o6fc03uw/1/ Code in fiddle: (async () => { const pc1 = new RTCPeerConnection() const pc2 = new RTCPeerConnection() const stream1 = await navigator.mediaDevices.getUserMedia({ audio: true }) const stream2 = await navigator.mediaDevices.getUserMedia({ audio: true }) const [track1] = stream1.getAudioTracks() const [track2] = stream2.getAudioTracks() pc2.addTrack(track1, stream1) pc2.addTrack(track2, stream2) pc1.addTransceiver('audio') pc1.addTransceiver('audio') const offer = await pc1.createOffer() await Promise.all([ pc1.setLocalDescription(offer), pc2.setRemoteDescription(offer) ]) const answer = await pc2.createAnswer() await Promise.all([ pc1.setRemoteDescription(answer), pc2.setLocalDescription(answer) ]) const recvrs = pc1.getReceivers() const statsReport = await pc1.getStats(recvrs[0].track) const tracksInReport = Array.from(statsReport.values()).filter(stat => stat.type === 'track'); if (tracksInReport.length > 1) { console.warn('More than 1 track in stats report.' + 'RTCPeerConnection#getStats does not honor selector argument.'); var remoteTrackStats = tracksInReport.find( stat => stat.trackIdentifier === recvrs[0].track.id) if (!remoteTrackStats) { console.warn('Cannot correlate remote tracks in stats report.'); } } var localCandidateStats = Array.from(statsReport.values()).find( stat => stat.type === 'local-candidate'); if (!localCandidateStats) { console.warn('StatsReport does not have local-Candidate stats type.'); } var remoteCandidateStats = Array.from(statsReport.values()).find( stat => stat.type === 'remote-candidate'); if (!remoteCandidateStats) { console.warn('StatsReport does not have remote-candidate stats type.'); } var codecStats = Array.from(statsReport.values()).find( stat => stat.type === 'codec'); if (!codecStats) { console.warn('StatsReport does not have codec stats type.'); } })()
Attachments
Radar WebKit Bug Importer
Comment 1 2022-06-30 16:44:11 PDT
709922234
Comment 2 2022-08-26 03:16:16 PDT
[`RTCAudioSourceStats.audioLevel`](1) is very important for me, can display the volume of input audio. [1]: https://www.w3.org/TR/webrtc-stats/#dom-rtcaudiosourcestats
Note You need to log in before you can comment on or make changes to this bug.