Placeholder-Software / Dissonance

Unity Voice Chat Asset
70 stars 5 forks source link

[help/feature] Network quality stats API #112

Closed haydenjameslee closed 5 years ago

haydenjameslee commented 6 years ago

Is it currently possible to get the packet loss percentage and/or any other network quality stats via the Dissonance API? If not we'd appreciate it as an upcoming feature.

Our goal is to show current network conditions to our users, so they are aware when their internet connection is causing sub-optimal voice quality, along with the network quality of other users in the room. Appreciate any suggestions on how to achieve this!

martindevans commented 6 years ago

The VoicePlayerState class (result from a DissonanceComms.FindPlayer call) has an internal property float? PacketLoss { get; } - this is the percentage of packets lost as detected by the playback pipeline for this player. This isn't exactly what you want, since this is measuring loss of Them -> Server -> You so the loss could have been introduced at either of those hops (i.e. their up link is lossy, or your down link is). However that's all the packet loss information that Dissonance tracks - it infers your upload link loss by taking the median average of the packet loss of all other players (median because then a small number of other players with bad links won't change your estimated link quality at all). Check out Assets/Plugins/Dissonance/Core/PacketLossMonitor.cs to see how that's done.

If that's not enough you could also try accessing the jitter statistics by adding a property like this to VoicePlayerState/RemoteVoicePlayerState:

internal float? Jitter
{
   get
   {
      var p = Playback;
      return p != null ? (float?)p.Jitter : null;
   }
}

That returns a measure of the standard deviation of packet arrival times. Jitter is often a more important measure of link quality than loss because almost any loss is very bad, but every connection has some jitter, so it's a better measure for a slightly bad link.

So I would suggest using either median loss or jitter to display some connectivity bars (like these from Discord) and fading out the bars at predefined loss/jitter levels

untitled

You'll have to experiment where you want to set the thresholds. Some random guesses to start out at might be:

Clumsy is an excellent tool for iterating on this.

martindevans commented 6 years ago

By the way I'll have a look at making those properties public for the next release.

haydenjameslee commented 6 years ago

Appreciate the support as always! I'll let you know how it works out.

martindevans commented 6 years ago

Tom has just merged the PR which exposes this property: [CanBeNull] public abstract float? PacketLoss { get; } on the VoicePlayerState class. That'll be in the next release :)

haydenjameslee commented 6 years ago

Great! We're releasing our voice quality info feature in a week or two and it's coming along well. Just starting to test the threshold values.

martindevans commented 5 years ago

Dissonance 6.2.5 is live on the asset store with the PacketLoss property on the VoicePlayerState class.