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
|
||||
|
||||
// downgrade video quality
|
||||
const quality = this._webrtcQualityDowngrade()
|
||||
const quality = this._webrtcQualityDowngrade(this._state.webrtc.video)
|
||||
if (quality) this.setVideo(quality)
|
||||
}
|
||||
})
|
||||
@ -219,15 +219,17 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
||||
return
|
||||
}
|
||||
|
||||
let lastQuality: string | undefined
|
||||
this._log.debug(`starting webrtc reconnection`)
|
||||
|
||||
setTimeout(async () => {
|
||||
let lastQuality: string | null = this._state.webrtc.video
|
||||
while (this.activated && this.websocket.connected) {
|
||||
try {
|
||||
const quality = this._webrtcQualityDowngrade(lastQuality)
|
||||
if (quality) lastQuality = quality
|
||||
await this._webrtcConnect(lastQuality)
|
||||
if (lastQuality != null) {
|
||||
lastQuality = this._webrtcQualityDowngrade(lastQuality) || lastQuality
|
||||
}
|
||||
|
||||
await this._webrtcConnect(lastQuality || undefined)
|
||||
break
|
||||
} catch (e) {
|
||||
this._log.debug(`webrtc reconnection failed`, e)
|
||||
@ -239,12 +241,9 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
||||
}, 0)
|
||||
}
|
||||
|
||||
_webrtcQualityDowngrade(quality?: string): string | undefined {
|
||||
// current quality is not known
|
||||
if (typeof quality === 'undefined' || this._state.webrtc.video == null) return
|
||||
|
||||
_webrtcQualityDowngrade(quality: string): string | undefined {
|
||||
// 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
|
||||
if (index === -1) return
|
||||
|
Loading…
Reference in New Issue
Block a user