mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-05 12:56:42 +02:00
Fix not getting the correct candidate pair
This commit is contained in:
@@ -201,6 +201,7 @@ export class StreamStatsCollector {
|
||||
};
|
||||
|
||||
private lastVideoStat?: RTCInboundRtpStreamStats | null;
|
||||
private selectedCandidatePairId: string | null | undefined = null;
|
||||
|
||||
private constructor() {
|
||||
BxLogger.info(this.LOG_TAG, 'constructor()');
|
||||
@@ -212,6 +213,22 @@ export class StreamStatsCollector {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find selected candidate
|
||||
if (!this.selectedCandidatePairId) {
|
||||
let found = false;
|
||||
stats.forEach(stat => {
|
||||
if (found || stat.type !== 'transport') {
|
||||
return;
|
||||
}
|
||||
|
||||
stat = (stat as unknown as RTCTransportStats);
|
||||
if (stat.iceState === 'connected' && stat.selectedCandidatePairId) {
|
||||
this.selectedCandidatePairId = (stat as unknown as RTCTransportStats).selectedCandidatePairId;
|
||||
found = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
stats.forEach(stat => {
|
||||
if (stat.type === 'inbound-rtp' && stat.kind === 'video') {
|
||||
// FPS
|
||||
@@ -256,7 +273,7 @@ export class StreamStatsCollector {
|
||||
dt.current = dt.total / framesDecodedDiff * 1000;
|
||||
|
||||
this.lastVideoStat = stat;
|
||||
} else if (stat.type === 'candidate-pair' && stat.packetsReceived > 0 && stat.state === 'succeeded') {
|
||||
} else if (this.selectedCandidatePairId && stat.type === 'candidate-pair' && stat.id === this.selectedCandidatePairId) {
|
||||
// Round Trip Time
|
||||
const ping = this.currentStats[StreamStat.PING];
|
||||
ping.current = stat.currentRoundTripTime ? stat.currentRoundTripTime * 1000 : -1;
|
||||
|
Reference in New Issue
Block a user