move paused to webrtc stats.

This commit is contained in:
Miroslav Šedivý 2022-03-29 23:39:12 +02:00
parent 7435ff68a6
commit ca49272bf2
4 changed files with 9 additions and 6 deletions

View File

@ -24,7 +24,6 @@ export interface NekoConnectionEvents {
export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
private _open = false
public paused = false
public websocket = new NekoWebSocket()
public logger = new NekoLoggerFactory(this.websocket)
public webrtc = new NekoWebRTC(this.logger.new('webrtc'))
@ -104,9 +103,7 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
Vue.set(this._state.webrtc, 'stats', stats)
// when connection is paused, 0fps and muted track is expected
if (this.paused) {
return
}
if (stats.paused) return
// if automatic quality adjusting is turned off
if (!this._reconnector.webrtc.isOpen) return

View File

@ -34,6 +34,8 @@ export interface NekoWebRTCEvents {
export class NekoWebRTC extends EventEmitter<NekoWebRTCEvents> {
// used for creating snaps from video for fallback mode
public video!: HTMLVideoElement
// information for WebRTC that server video has been paused, 0fps is expected
public paused = false
private _peer?: RTCPeerConnection
private _channel?: RTCDataChannel
@ -519,6 +521,9 @@ export class NekoWebRTC extends EventEmitter<NekoWebRTCEvents> {
const packetsReceivedDiff = report.packetsReceived - packetsReceived
this.emit('stats', {
// Firefox does not emit any event when starting paused
// because there is no video report found in stats.
paused: this.paused,
bitrate: (bytesDiff / tsDiff) * 1000,
packetLoss: (packetsLostDiff / (packetsLostDiff + packetsReceivedDiff)) * 100,
fps: Number(report.framesPerSecond || framesDecodedDiff / (tsDiff / 1000)),

View File

@ -222,8 +222,8 @@
}
@Watch('private_mode_enabled')
private setConnectionPaused(paused: boolean) {
this.connection.paused = paused
private setWebRTCPaused(paused: boolean) {
this.connection.webrtc.paused = paused
}
screencastReady = false

View File

@ -1,4 +1,5 @@
export interface WebRTCStats {
paused: boolean
bitrate: number
packetLoss: number
fps: number