add track muted to webrtc stats.

This commit is contained in:
Miroslav Šedivý 2021-06-24 16:50:13 +02:00
parent 9d423738c4
commit 42f85d9e54
2 changed files with 10 additions and 0 deletions

View File

@ -16,6 +16,7 @@ export interface WebRTCStats {
fps: number fps: number
width: number width: number
height: number height: number
muted: boolean | undefined
} }
export interface ICEServer { export interface ICEServer {
@ -37,6 +38,7 @@ export interface NekoWebRTCEvents {
export class NekoWebRTC extends EventEmitter<NekoWebRTCEvents> { export class NekoWebRTC extends EventEmitter<NekoWebRTCEvents> {
private _peer?: RTCPeerConnection private _peer?: RTCPeerConnection
private _channel?: RTCDataChannel private _channel?: RTCDataChannel
private _track?: MediaStreamTrack
private _state: RTCIceConnectionState = 'disconnected' private _state: RTCIceConnectionState = 'disconnected'
private _candidates: RTCIceCandidateInit[] = [] private _candidates: RTCIceCandidateInit[] = []
private _log: Logger private _log: Logger
@ -179,7 +181,9 @@ export class NekoWebRTC extends EventEmitter<NekoWebRTCEvents> {
this._peer = undefined this._peer = undefined
} }
this._track = undefined
this._state = 'disconnected' this._state = 'disconnected'
this._candidates = []
} }
public send(event: 'wheel' | 'mousemove', data: { x: number; y: number }): void public send(event: 'wheel' | 'mousemove', data: { x: number; y: number }): void
@ -254,6 +258,10 @@ export class NekoWebRTC extends EventEmitter<NekoWebRTCEvents> {
return return
} }
if (event.track.kind === 'video') {
this._track = event.track
}
this.emit('track', event) this.emit('track', event)
} }
@ -372,6 +380,7 @@ export class NekoWebRTC extends EventEmitter<NekoWebRTCEvents> {
fps: Number(report.framesPerSecond || framesDecodedDiff / (tsDiff / 1000)), fps: Number(report.framesPerSecond || framesDecodedDiff / (tsDiff / 1000)),
width: report.frameWidth || NaN, width: report.frameWidth || NaN,
height: report.frameHeight || NaN, height: report.frameHeight || NaN,
muted: this._track?.muted,
}) })
} }

View File

@ -31,6 +31,7 @@ export interface WebRTCStats {
fps: number fps: number
width: number width: number
height: number height: number
muted: boolean | undefined
} }
///////////////////////////// /////////////////////////////