Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1a09ea7
Add analyzer for the quality of peer connections
danxuliu Jun 22, 2020
5c45e23
Take round trip time into account when calculating the quality
danxuliu Jul 7, 2020
949f10a
Trigger events when the quality changes
danxuliu Jun 22, 2020
e2aa17d
Make possible to enable and disable the analysis of audio or video
danxuliu Jul 3, 2020
97e12ca
Guard against null screen peer
danxuliu Jul 2, 2020
a205ca4
Move peer and screenPeer to attributes in CallParticipantModel
danxuliu Jul 3, 2020
790c981
Add peer and screenPeer attributes to LocalCallParticipantModel
danxuliu Jul 3, 2020
ca4fdd1
Add analyzer for participants
danxuliu Jul 3, 2020
b5e724e
Add analyzer for calls
danxuliu Jul 3, 2020
58fc1f5
Show warning when the quality of the connection is bad
danxuliu Jul 3, 2020
d4ec4d9
Add a grace period before hiding the quality warning
danxuliu Jul 3, 2020
581d68a
Show tooltip only if the quality warning has not been recently shown
danxuliu Jul 3, 2020
6cb8de5
Take video and screen quality into account in the quality warning
danxuliu Jul 6, 2020
ffe3cf6
Move setting class attributes to its own method
danxuliu Jul 9, 2020
a6b897a
Increase grace period for quality tooltip
danxuliu Jul 9, 2020
087330b
Fix duplicated event listeners in ParticipantAnalyzer
danxuliu Jul 16, 2020
ad27de1
Dedicated connection warning icon
nickvergessen Jul 15, 2020
e12ca19
Add buttons to disable video and screen share to quality warning tooltip
Jul 17, 2020
1bff844
Add button to explicitly dismiss the quality warning tooltip
Jul 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Take round trip time into account when calculating the quality
A high round trip time means that there is a delay in the connection,
which is in itself bad (specially in a conversation instead of in a
"monologue").

Besides that a delay in the connection can also cause that some packets,
even if they are not lost, are discarded anyway to try to keep the
playing rate in real time.

The round trip time is only available for sent data, but not received
data.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu committed Jul 21, 2020
commit 5c45e234dea30d15ccbc727b28746a2229787a06
32 changes: 29 additions & 3 deletions src/utils/webrtc/analyzers/PeerConnectionAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ function PeerConnectionAnalyzer() {
'audio': new AverageStatValue(5, STAT_VALUE_TYPE.RELATIVE),
'video': new AverageStatValue(5, STAT_VALUE_TYPE.RELATIVE),
}
// Latest values have a higher weight than the default one to better detect
// sudden changes in the round trip time, which can lead to discarded (but
// not lost) packets.
this._roundTripTime = {
'audio': new AverageStatValue(5, STAT_VALUE_TYPE.RELATIVE, 5),
'video': new AverageStatValue(5, STAT_VALUE_TYPE.RELATIVE, 5),
}
// Only the last relative value is used, but as it is a cumulative value the
// previous one is needed as a base to calculate the last one.
this._timestamps = {
Expand Down Expand Up @@ -218,6 +225,11 @@ PeerConnectionAnalyzer.prototype = {
'video': -1,
}

const roundTripTime = {
'audio': -1,
'video': -1,
}

for (const stat of stats.values()) {
if (stat.type === 'outbound-rtp') {
if ('packetsSent' in stat && 'kind' in stat) {
Expand All @@ -238,6 +250,9 @@ PeerConnectionAnalyzer.prototype = {
if ('packetsLost' in stat && 'kind' in stat) {
packetsLost[stat.kind] = stat.packetsLost
}
if ('roundTripTime' in stat && 'kind' in stat) {
roundTripTime[stat.kind] = stat.roundTripTime
}
}
}

Expand Down Expand Up @@ -289,6 +304,9 @@ PeerConnectionAnalyzer.prototype = {
const packetsPerSecond = this._packets[kind].getLastRelativeValue() / elapsedSeconds
this._packetsPerSecond[kind].add(packetsPerSecond)
}
if (roundTripTime[kind] >= 0) {
this._roundTripTime[kind].add(roundTripTime[kind])
}
}
},

Expand Down Expand Up @@ -376,14 +394,14 @@ PeerConnectionAnalyzer.prototype = {
},

_calculateConnectionQualityAudio: function() {
return this._calculateConnectionQuality(this._packetsLostRatio['audio'], this._packetsPerSecond['audio'])
return this._calculateConnectionQuality(this._packetsLostRatio['audio'], this._packetsPerSecond['audio'], this._roundTripTime['audio'])
},

_calculateConnectionQualityVideo: function() {
return this._calculateConnectionQuality(this._packetsLostRatio['video'], this._packetsPerSecond['video'])
return this._calculateConnectionQuality(this._packetsLostRatio['video'], this._packetsPerSecond['video'], this._roundTripTime['video'])
},

_calculateConnectionQuality: function(packetsLostRatio, packetsPerSecond) {
_calculateConnectionQuality: function(packetsLostRatio, packetsPerSecond, roundTripTime) {
if (!packetsLostRatio.hasEnoughData() || !packetsPerSecond.hasEnoughData()) {
return CONNECTION_QUALITY.UNKNOWN
}
Expand All @@ -393,6 +411,14 @@ PeerConnectionAnalyzer.prototype = {
return CONNECTION_QUALITY.NO_TRANSMITTED_DATA
}

// A high round trip time means that the delay is high, but it can also
// imply that some packets, even if they are not lost, are anyway
// discarded to try to keep the playing rate in real time.
// Round trip time is measured in seconds.
if (roundTripTime.hasEnoughData() && roundTripTime.getWeightedAverage() > 1.5) {
return CONNECTION_QUALITY.VERY_BAD
}

// In some cases there may be packets being transmitted without any lost
// packet, but if the number of packets is too low the connection is
// most likely in bad shape anyway.
Expand Down