Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions src/utils/webrtc/analyzers/ParticipantAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,18 @@ ParticipantAnalyzer.prototype = {
this._senderScreenPeerConnectionAnalyzer.setPeerConnection(this._screenPeer.pc, PEER_DIRECTION.SENDER)

this._senderScreenPeerConnectionAnalyzer.on('change:connectionQualityVideo', this._handleConnectionQualityScreenChangeBound)

this._senderScreenPeerConnectionAnalyzer.setAnalysisEnabledAudio(false)
this._senderScreenPeerConnectionAnalyzer.setAnalysisEnabledVideo(true)
}

if (this._callParticipantModel) {
this._receiverScreenPeerConnectionAnalyzer.setPeerConnection(this._screenPeer.pc, PEER_DIRECTION.RECEIVER)

this._receiverScreenPeerConnectionAnalyzer.on('change:connectionQualityVideo', this._handleConnectionQualityScreenChangeBound)

this._receiverScreenPeerConnectionAnalyzer.setAnalysisEnabledAudio(false)
this._receiverScreenPeerConnectionAnalyzer.setAnalysisEnabledVideo(true)
}
},

Expand Down
31 changes: 21 additions & 10 deletions src/utils/webrtc/analyzers/PeerConnectionAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,7 @@ PeerConnectionAnalyzer.prototype = {
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()
this._resetStats('audio')
}
},

Expand All @@ -218,14 +214,18 @@ PeerConnectionAnalyzer.prototype = {
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()
this._resetStats('video')
}
},

_resetStats: function(kind) {
this._packets[kind].reset()
this._packetsLost[kind].reset()
this._packetsLostRatio[kind].reset()
this._packetsPerSecond[kind].reset()
this._timestamps[kind].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 All @@ -244,6 +244,17 @@ PeerConnectionAnalyzer.prototype = {
return
}

// When a connection is started the stats must be reset, as a different
// peer connection could have been used before and its stats would be
// unrelated to the new one.
// When a connection is restarted the reported stats continue from the
// last values. However, during the reconnection the stats will not be
// updated, so the timestamps will suddenly increase once the connection
// is ready again. This could cause a wrong analysis, so the stats
// should be reset too in that case.
this._resetStats('audio')
this._resetStats('video')

this._getStatsInterval = window.setInterval(() => {
this._peerConnection.getStats().then(this._processStatsBound)
}, 1000)
Expand Down