mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
move paused to webrtc stats.
This commit is contained in:
parent
7435ff68a6
commit
ca49272bf2
@ -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
|
||||
|
@ -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)),
|
||||
|
@ -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
|
||||
|
@ -1,4 +1,5 @@
|
||||
export interface WebRTCStats {
|
||||
paused: boolean
|
||||
bitrate: number
|
||||
packetLoss: number
|
||||
fps: number
|
||||
|
Loading…
Reference in New Issue
Block a user