From 42f85d9e5431e576ee732f365a1f4cf4ca463884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Thu, 24 Jun 2021 16:50:13 +0200 Subject: [PATCH] add track muted to webrtc stats. --- src/component/internal/webrtc.ts | 9 +++++++++ src/component/types/state.ts | 1 + 2 files changed, 10 insertions(+) diff --git a/src/component/internal/webrtc.ts b/src/component/internal/webrtc.ts index 1c6d0502..cf4b2566 100644 --- a/src/component/internal/webrtc.ts +++ b/src/component/internal/webrtc.ts @@ -16,6 +16,7 @@ export interface WebRTCStats { fps: number width: number height: number + muted: boolean | undefined } export interface ICEServer { @@ -37,6 +38,7 @@ export interface NekoWebRTCEvents { export class NekoWebRTC extends EventEmitter { private _peer?: RTCPeerConnection private _channel?: RTCDataChannel + private _track?: MediaStreamTrack private _state: RTCIceConnectionState = 'disconnected' private _candidates: RTCIceCandidateInit[] = [] private _log: Logger @@ -179,7 +181,9 @@ export class NekoWebRTC extends EventEmitter { this._peer = undefined } + this._track = undefined this._state = 'disconnected' + this._candidates = [] } public send(event: 'wheel' | 'mousemove', data: { x: number; y: number }): void @@ -254,6 +258,10 @@ export class NekoWebRTC extends EventEmitter { return } + if (event.track.kind === 'video') { + this._track = event.track + } + this.emit('track', event) } @@ -372,6 +380,7 @@ export class NekoWebRTC extends EventEmitter { fps: Number(report.framesPerSecond || framesDecodedDiff / (tsDiff / 1000)), width: report.frameWidth || NaN, height: report.frameHeight || NaN, + muted: this._track?.muted, }) } diff --git a/src/component/types/state.ts b/src/component/types/state.ts index f601021a..56ad18c1 100644 --- a/src/component/types/state.ts +++ b/src/component/types/state.ts @@ -31,6 +31,7 @@ export interface WebRTCStats { fps: number width: number height: number + muted: boolean | undefined } /////////////////////////////