136 lines
4.3 KiB
CoffeeScript
136 lines
4.3 KiB
CoffeeScript
$ = jQuery
|
|
context = window
|
|
logger = context.JK.logger
|
|
rest = context.JK.Rest()
|
|
EVENTS = context.JK.EVENTS
|
|
MIX_MODES = context.JK.MIX_MODES
|
|
|
|
SessionActions = @SessionActions
|
|
|
|
SessionStatThresholds = gon.session_stat_thresholds
|
|
NetworkThresholds = SessionStatThresholds.network
|
|
SystemThresholds = SessionStatThresholds.system
|
|
AudioThresholds = SessionStatThresholds.audio
|
|
|
|
@SessionStatsStore = Reflux.createStore(
|
|
{
|
|
listenables: @SessionStatsActions
|
|
rawStats: null
|
|
|
|
onPushStats: (stats) ->
|
|
@rawStats = stats
|
|
@changed()
|
|
|
|
classify: (holder, field, threshold) ->
|
|
value = holder[field]
|
|
fieldLevel = field + '_level'
|
|
fieldThreshold = threshold[field]
|
|
if value? && fieldThreshold?
|
|
|
|
if fieldThreshold.inverse
|
|
if value <= fieldThreshold.poor
|
|
holder[fieldLevel] = 'poor'
|
|
@participantClassification = 3
|
|
else if value <= fieldThreshold.warn
|
|
holder[fieldLevel] = 'warn'
|
|
@participantClassification = 2 if @participantClassification == 1
|
|
else
|
|
holder[fieldLevel] = 'good'
|
|
else if fieldThreshold.eql
|
|
if value == fieldThreshold.poor
|
|
holder[fieldLevel] = 'poor'
|
|
@participantClassification = 3
|
|
else if value == fieldThreshold.warn
|
|
holder[fieldLevel] = 'warn'
|
|
@participantClassification = 2 if @participantClassification == 1
|
|
else
|
|
holder[fieldLevel] = 'good'
|
|
else
|
|
if value >= fieldThreshold.poor
|
|
holder[fieldLevel] = 'poor'
|
|
@participantClassification = 3
|
|
else if value >= fieldThreshold.warn
|
|
holder[fieldLevel] = 'warn'
|
|
@participantClassification = 2 if @participantClassification == 1
|
|
else
|
|
holder[fieldLevel] = 'good'
|
|
|
|
|
|
changed: () ->
|
|
@stats = {}
|
|
|
|
console.log("raw stats", @rawStats)
|
|
for participant in @rawStats
|
|
|
|
@participantClassification = 1 # 1=good, 2=warn, 3=poor
|
|
|
|
# CPU is 0-100
|
|
if participant.cpu?
|
|
system = {cpu: participant.cpu}
|
|
|
|
@classify(system, 'cpu', SystemThresholds)
|
|
|
|
participant.system = system
|
|
|
|
network = participant.network
|
|
|
|
if network?
|
|
# audio_bitrate: 256
|
|
# net_bitrate: 286.19244384765625
|
|
# ping: 0.08024691045284271
|
|
# ping_var: 0.6403124332427979
|
|
# pkt_loss: 100
|
|
# wifi: false
|
|
|
|
@classify(network, 'audiojq_median', NetworkThresholds)
|
|
@classify(network, 'net_bitrate', NetworkThresholds)
|
|
@classify(network, 'ping', NetworkThresholds)
|
|
@classify(network, 'pkt_loss', NetworkThresholds)
|
|
@classify(network, 'wifi', NetworkThresholds)
|
|
|
|
audio = participant.audio
|
|
|
|
if audio?
|
|
# acpu: 5.148329734802246
|
|
# audio_in: "Fast Track"
|
|
# audio_in_type: "Core Audio"
|
|
# cpu: 22.44668960571289
|
|
# framesize: 2.5
|
|
# in_latency: 5.020833492279053
|
|
# input_iio_jitter: -0.0015926361083984375
|
|
# input_jitter: 0.2977011799812317
|
|
# input_median: 400.16632080078125
|
|
# io_out_latency: "Expected Latency = 9.54 +/- 1.00 ms [Raw/PaBuff/PaRing Latency: 9.54 / 12.04 / 0.00 ms]"
|
|
# out_latency: 4.520833492279053
|
|
# output_iio_jitter: -0.07366180419921875
|
|
# output_jitter: 0.40290364623069763
|
|
# output_median: 400.0581970214844
|
|
# output_name: 4
|
|
# samplerate: 48000
|
|
|
|
if audio.cpu?
|
|
system = {cpu: audio.cpu}
|
|
@classify(system, 'cpu', SystemThresholds)
|
|
participant.system = system
|
|
|
|
if audio.in_latency? and audio.out_latency?
|
|
audio.latency = audio.in_latency + audio.out_latency
|
|
|
|
|
|
@classify(audio, 'framesize', AudioThresholds)
|
|
@classify(audio, 'latency', AudioThresholds)
|
|
@classify(audio, 'input_jitter', AudioThresholds)
|
|
@classify(audio, 'output_jitter', AudioThresholds)
|
|
|
|
switch @participantClassification
|
|
when 1 then participant.classification = 'good'
|
|
when 2 then participant.classification = 'warn'
|
|
when 3 then participant.classification = 'poor'
|
|
else
|
|
participant.classification = 'unknown'
|
|
|
|
@stats[participant.id] = participant
|
|
|
|
@trigger(@stats)
|
|
}
|
|
) |