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 } /////////////////////////////