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
Make possible to enable and disable the analysis of audio or video
Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu committed Jul 21, 2020
commit e2aa17ddb8c77482230273226105224f0b75bf84
59 changes: 57 additions & 2 deletions src/utils/webrtc/analyzers/PeerConnectionAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ const PEER_DIRECTION = {
* "setPeerConnection(null)" must be called too if the RTCPeerConnection is
* active but the analyzer is no longer needed.
*
* Similarly, the analysis should be enabled only when audio or video are
* enabled. This is also known from the signaling messages and needs to be
* handled by the user of this class by calling "setAnalysisEnabledAudio(bool)"
* and "setAnalysisEnabledVideo(bool)".
*
* The reason is that when audio or video are disabled the transmitted packets
* are much lower, so it is not possible to get a reliable analysis from them.
* Moreover, when the sent video is disabled in Firefox the stats are
* meaningless, as the packet count is no longer a monotonic increasing value.
*
* The reported connection quality is mainly based on the packets lost ratio,
* but also in other stats, like the amount of transmitted packets. UNKNOWN is
* used when the analysis is started or stopped (including when it is done
Expand Down Expand Up @@ -92,6 +102,11 @@ function PeerConnectionAnalyzer() {
'video': new AverageStatValue(2, STAT_VALUE_TYPE.CUMULATIVE),
}

this._analysisEnabled = {
'audio': true,
'video': true,
}

this._handlers = []

this._peerConnection = null
Expand Down Expand Up @@ -183,6 +198,34 @@ PeerConnectionAnalyzer.prototype = {
}
},

setAnalysisEnabledAudio: function(analysisEnabledAudio) {
this._analysisEnabled['audio'] = analysisEnabledAudio

if (!analysisEnabledAudio) {
this._setConnectionQualityAudio(CONNECTION_QUALITY.UNKNOWN)
} else {
this._packets['audio'].reset()
this._packetsLost['audio'].reset()
this._packetsLostRatio['audio'].reset()
this._packetsPerSecond['audio'].reset()
this._timestamps['audio'].reset()
}
},

setAnalysisEnabledVideo: function(analysisEnabledVideo) {
this._analysisEnabled['video'] = analysisEnabledVideo

if (!analysisEnabledVideo) {
this._setConnectionQualityVideo(CONNECTION_QUALITY.UNKNOWN)
} else {
this._packets['video'].reset()
this._packetsLost['video'].reset()
this._packetsLostRatio['video'].reset()
this._packetsPerSecond['video'].reset()
this._timestamps['video'].reset()
}
},

_handleIceConnectionStateChanged: function() {
// Note that even if the ICE connection state is "disconnected" the
// connection is actually active, media is still transmitted, and the
Expand Down Expand Up @@ -222,8 +265,12 @@ PeerConnectionAnalyzer.prototype = {
this._processReceiverStats(stats)
}

this._setConnectionQualityAudio(this._calculateConnectionQualityAudio())
this._setConnectionQualityVideo(this._calculateConnectionQualityVideo())
if (this._analysisEnabled['audio']) {
this._setConnectionQualityAudio(this._calculateConnectionQualityAudio())
}
if (this._analysisEnabled['video']) {
this._setConnectionQualityVideo(this._calculateConnectionQualityVideo())
}
},

_processSenderStats: function(stats) {
Expand Down Expand Up @@ -278,6 +325,10 @@ PeerConnectionAnalyzer.prototype = {
}

for (const stat of stats.values()) {
if (!this._analysisEnabled[stat.kind]) {
continue
}

if (stat.type === 'outbound-rtp') {
if ('packetsSent' in stat && 'kind' in stat) {
packetsSent[stat.kind] = stat.packetsSent
Expand Down Expand Up @@ -380,6 +431,10 @@ PeerConnectionAnalyzer.prototype = {
}

for (const stat of stats.values()) {
if (!this._analysisEnabled[stat.kind]) {
continue
}

if (stat.type === 'inbound-rtp') {
if ('packetsReceived' in stat && 'kind' in stat) {
packetsReceived[stat.kind] = stat.packetsReceived
Expand Down