diff --git a/src/component/internal/connection.ts b/src/component/internal/connection.ts index 15e03a8b..256e5a70 100644 --- a/src/component/internal/connection.ts +++ b/src/component/internal/connection.ts @@ -24,7 +24,6 @@ export interface NekoConnectionEvents { export class NekoConnection extends EventEmitter { 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 { 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 diff --git a/src/component/internal/webrtc.ts b/src/component/internal/webrtc.ts index 4ecbb573..1fbfa16e 100644 --- a/src/component/internal/webrtc.ts +++ b/src/component/internal/webrtc.ts @@ -34,6 +34,8 @@ export interface NekoWebRTCEvents { export class NekoWebRTC extends EventEmitter { // 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 { 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)), diff --git a/src/component/main.vue b/src/component/main.vue index 9bd91de4..948dd60d 100644 --- a/src/component/main.vue +++ b/src/component/main.vue @@ -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 diff --git a/src/component/types/webrtc.ts b/src/component/types/webrtc.ts index 0c707a55..bedc243c 100644 --- a/src/component/types/webrtc.ts +++ b/src/component/types/webrtc.ts @@ -1,4 +1,5 @@ export interface WebRTCStats { + paused: boolean bitrate: number packetLoss: number fps: number