Bug 192601
Summary: | RTCPeerConnection#getStats returns RTCStatsReport which is very different from the spec. | ||
---|---|---|---|
Product: | WebKit | Reporter: | syerrapragada |
Component: | WebRTC | Assignee: | Nobody <webkit-unassigned> |
Status: | NEW | ||
Severity: | Normal | CC: | 709922234, bfulgham, webkit-bug-importer, youennf |
Priority: | P2 | Keywords: | InRadar |
Version: | Safari 12 | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
syerrapragada
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 | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/96254880>
709922234
[`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