mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 07:37:19 +02:00
Improve IPv6 server detection
This commit is contained in:
parent
f3b9ebdb22
commit
584509a53d
@ -3033,7 +3033,7 @@ class StreamBadges {
|
||||
let totalIn = 0;
|
||||
let totalOut = 0;
|
||||
stats.forEach(stat => {
|
||||
if (stat.type === 'candidate-pair' && stat.state == 'succeeded') {
|
||||
if (stat.type === 'candidate-pair' && stat.state === 'succeeded') {
|
||||
totalIn += stat.bytesReceived;
|
||||
totalOut += stat.bytesSent;
|
||||
}
|
||||
@ -6793,6 +6793,9 @@ function onStreamStarted($video) {
|
||||
const allAudioCodecs = {};
|
||||
let audioCodecId;
|
||||
|
||||
const allCandidates = {};
|
||||
let candidateId;
|
||||
|
||||
stats.forEach(stat => {
|
||||
if (stat.type == 'codec') {
|
||||
const mimeType = stat.mimeType.split('/');
|
||||
@ -6810,6 +6813,10 @@ function onStreamStarted($video) {
|
||||
} else if (stat.kind === 'audio') {
|
||||
audioCodecId = stat.codecId;
|
||||
}
|
||||
} else if (stat.type === 'candidate-pair' && stat.state === 'succeeded') {
|
||||
candidateId = stat.remoteCandidateId;
|
||||
} else if (stat.type === 'remote-candidate') {
|
||||
allCandidates[stat.id] = stat.address;
|
||||
}
|
||||
});
|
||||
|
||||
@ -6837,6 +6844,12 @@ function onStreamStarted($video) {
|
||||
}
|
||||
}
|
||||
|
||||
// Get server type
|
||||
if (candidateId) {
|
||||
console.log(candidateId, allCandidates);
|
||||
StreamBadges.ipv6 = allCandidates[candidateId].includes(':');
|
||||
}
|
||||
|
||||
if (PREFS.get(Preferences.STATS_SHOW_WHEN_PLAYING)) {
|
||||
StreamStats.start();
|
||||
}
|
||||
@ -6934,16 +6947,6 @@ if (PREFS.get(Preferences.AUDIO_ENABLE_VOLUME_CONTROL)) {
|
||||
}
|
||||
}
|
||||
|
||||
RTCPeerConnection.prototype.orgAddIceCandidate = RTCPeerConnection.prototype.addIceCandidate;
|
||||
RTCPeerConnection.prototype.addIceCandidate = function(...args) {
|
||||
const candidate = args[0].candidate;
|
||||
if (candidate && candidate.startsWith('a=candidate:1 ')) {
|
||||
StreamBadges.ipv6 = candidate.substring(20).includes(':');
|
||||
}
|
||||
|
||||
return this.orgAddIceCandidate.apply(this, args);
|
||||
}
|
||||
|
||||
if (PREFS.get(Preferences.STREAM_TOUCH_CONTROLLER) === 'all') {
|
||||
TouchController.setup();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user