mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
fix webrtc last quality connection.
This commit is contained in:
parent
fcae8156f5
commit
3ca8f9a71c
@ -84,7 +84,7 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
|||||||
webrtcCongestion = 0
|
webrtcCongestion = 0
|
||||||
|
|
||||||
// downgrade video quality
|
// downgrade video quality
|
||||||
const quality = this._webrtcQualityDowngrade()
|
const quality = this._webrtcQualityDowngrade(this._state.webrtc.video)
|
||||||
if (quality) this.setVideo(quality)
|
if (quality) this.setVideo(quality)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -219,15 +219,17 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastQuality: string | undefined
|
|
||||||
this._log.debug(`starting webrtc reconnection`)
|
this._log.debug(`starting webrtc reconnection`)
|
||||||
|
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
|
let lastQuality: string | null = this._state.webrtc.video
|
||||||
while (this.activated && this.websocket.connected) {
|
while (this.activated && this.websocket.connected) {
|
||||||
try {
|
try {
|
||||||
const quality = this._webrtcQualityDowngrade(lastQuality)
|
if (lastQuality != null) {
|
||||||
if (quality) lastQuality = quality
|
lastQuality = this._webrtcQualityDowngrade(lastQuality) || lastQuality
|
||||||
await this._webrtcConnect(lastQuality)
|
}
|
||||||
|
|
||||||
|
await this._webrtcConnect(lastQuality || undefined)
|
||||||
break
|
break
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this._log.debug(`webrtc reconnection failed`, e)
|
this._log.debug(`webrtc reconnection failed`, e)
|
||||||
@ -239,12 +241,9 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
|||||||
}, 0)
|
}, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
_webrtcQualityDowngrade(quality?: string): string | undefined {
|
_webrtcQualityDowngrade(quality: string): string | undefined {
|
||||||
// current quality is not known
|
|
||||||
if (typeof quality === 'undefined' || this._state.webrtc.video == null) return
|
|
||||||
|
|
||||||
// get index of selected or surrent quality
|
// get index of selected or surrent quality
|
||||||
const index = this._state.webrtc.videos.indexOf(quality || this._state.webrtc.video)
|
const index = this._state.webrtc.videos.indexOf(quality)
|
||||||
|
|
||||||
// edge case: current quality is not in qualities list
|
// edge case: current quality is not in qualities list
|
||||||
if (index === -1) return
|
if (index === -1) return
|
||||||
|
Loading…
Reference in New Issue
Block a user