<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>192601</bug_id>
          
          <creation_ts>2018-12-11 12:34:09 -0800</creation_ts>
          <short_desc>RTCPeerConnection#getStats returns RTCStatsReport which is very different from the spec.</short_desc>
          <delta_ts>2022-08-26 03:16:16 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebRTC</component>
          <version>Safari 12</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>syerrapragada</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>709922234</cc>
    
    <cc>bfulgham</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1487015</commentid>
    <comment_count>0</comment_count>
    <who name="">syerrapragada</who>
    <bug_when>2018-12-11 12:34:09 -0800</bug_when>
    <thetext>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 () =&gt; {
      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(&apos;audio&apos;)
      pc1.addTransceiver(&apos;audio&apos;)

      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 =&gt; stat.type === &apos;track&apos;);
      
      if (tracksInReport.length &gt; 1) {
      	console.warn(&apos;More than 1 track in stats report.&apos; +
        	&apos;RTCPeerConnection#getStats does not honor selector argument.&apos;);
        var remoteTrackStats = tracksInReport.find(
        	stat =&gt; stat.trackIdentifier === recvrs[0].track.id)
          
        if (!remoteTrackStats) {
        	console.warn(&apos;Cannot correlate remote tracks in stats report.&apos;);
        }
      }
			
      var localCandidateStats = Array.from(statsReport.values()).find(
      	stat =&gt; stat.type === &apos;local-candidate&apos;);
      if (!localCandidateStats) {
      	console.warn(&apos;StatsReport does not have local-Candidate stats type.&apos;);
      }
      
      var remoteCandidateStats = Array.from(statsReport.values()).find(
      	stat =&gt; stat.type === &apos;remote-candidate&apos;);
      if (!remoteCandidateStats) {
      	console.warn(&apos;StatsReport does not have remote-candidate stats type.&apos;);
      }
      
      var codecStats = Array.from(statsReport.values()).find(
      	stat =&gt; stat.type === &apos;codec&apos;);
      if (!codecStats) {
      	console.warn(&apos;StatsReport does not have codec stats type.&apos;);
      }
 				 
    })()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1879586</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-06-30 16:44:11 -0700</bug_when>
    <thetext>&lt;rdar://problem/96254880&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1893943</commentid>
    <comment_count>2</comment_count>
    <who name="">709922234</who>
    <bug_when>2022-08-26 03:16:16 -0700</bug_when>
    <thetext>[`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</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>