0
votes

I have a WebRTC stream which is sending audio/video, I am displaying the volume in a meter widget which is retrieved from a getStats call on the peerConnection.

getStats(function (stats) {
  var results = stats.result()
  for (let i=0; i < results.length; i++) {
    var res = results[i]
    if (res.type == 'ssrc') {
      volume = parseInt(res.stat('audioInputLevel'))
    }
  }
})

This is working fine, the issue is when I run replaceTrack to update the streams audio/video the above getStats returns 0 for the audio level.

navigator.mediaDevices.getUserMedia(media)
  .then(stream => {
    const tracks = stream.getTracks()

    peerConnection.getSenders()
      .forEach(sender => {
        const newTrack = tracks.find(track => track.kind === sender.track.kind)
        sender.replaceTrack(newTrack)
      })
  })

The local stream get's updated, the remote user get's updated and audio / video is working. But getStats is no longer returning the audioInputLevel.

Would anyone be able to help me understand why? Or what a fix maybe.

Thanks

1

1 Answers

1
votes