93 lines
3.4 KiB
TypeScript
93 lines
3.4 KiB
TypeScript
// Metro module 4284 (f4285).
|
|
import ApplicationStreamingSettingsStore from "../../stores/ApplicationStreamingSettingsStore";
|
|
import { StreamLayouts } from "../../Constants";
|
|
import { Interval } from "../../_bundle/Timeout";
|
|
import { now } from "../../_bundle/sleep";
|
|
class VideoStreamStats {
|
|
_targetResolution = 0;
|
|
_targetFPS = 0;
|
|
_streamSettingsChanged = false;
|
|
_lastLayoutChanged = 0;
|
|
_layoutChanges = 0;
|
|
_automaticQualityChanges = 0;
|
|
_incrementLayout = (a0, a1) => {
|
|
if (this._layoutBuckets[a0] == null) {
|
|
this._layoutBuckets[a0] = 0;
|
|
}
|
|
const _layoutBuckets = this._layoutBuckets;
|
|
_layoutBuckets[a0] = _layoutBuckets[a0] + a1;
|
|
};
|
|
_sampleStats = () => {
|
|
const state = ApplicationStreamingSettingsStore.getState();
|
|
const { resolution, fps } = state;
|
|
this._streamSettingsChanged = resolution !== this._targetResolution || fps !== this._targetFPS;
|
|
};
|
|
constructor(a0, a1) {
|
|
this._isSender = a1;
|
|
this._statInterval = new Interval();
|
|
this._lastLayout = a0;
|
|
this._layoutBuckets = {};
|
|
}
|
|
start() {
|
|
const state = ApplicationStreamingSettingsStore.getState();
|
|
const { resolution, fps } = state;
|
|
this._targetResolution = resolution;
|
|
this._targetFPS = fps;
|
|
this._statInterval.start(1000, this._sampleStats);
|
|
this._lastLayoutChanged = now();
|
|
}
|
|
stop() {
|
|
this._statInterval.stop();
|
|
this._streamEnd = now();
|
|
this._incrementLayout(this._lastLayout, (this._streamEnd - this._lastLayoutChanged) / 1000);
|
|
}
|
|
autoQualityChange() {
|
|
this._automaticQualityChanges = this._automaticQualityChanges + 1;
|
|
}
|
|
layoutChange(a0) {
|
|
if (a0 !== this._lastLayout && this._streamEnd == null) {
|
|
const _lastLayoutChanged = now();
|
|
this._incrementLayout(this._lastLayout, (_lastLayoutChanged - this._lastLayoutChanged) / 1000);
|
|
this._layoutChanges = this._layoutChanges + 1;
|
|
this._lastLayout = a0;
|
|
this._lastLayoutChanged = _lastLayoutChanged;
|
|
}
|
|
}
|
|
getLayout() {
|
|
return this._lastLayout;
|
|
}
|
|
getStats() {
|
|
const r9 = this._layoutBuckets[StreamLayouts.FULL_SCREEN];
|
|
const duration_layout_fullscreen = r9 != null ? Math.round(r9) : 0;
|
|
const r18 = this._layoutBuckets[StreamLayouts.THEATRE];
|
|
const duration_layout_theatre = r18 != null ? Math.round(r18) : 0;
|
|
const r26 = this._layoutBuckets[StreamLayouts.PIP];
|
|
const duration_layout_pip = r26 != null ? Math.round(r26) : 0;
|
|
const r34 = this._layoutBuckets[StreamLayouts.POPOUT];
|
|
const duration_layout_popout = r34 != null ? Math.round(r34) : 0;
|
|
const r42 = this._layoutBuckets[StreamLayouts.PORTRAIT];
|
|
const duration_layout_portrait = r42 != null ? Math.round(r42) : 0;
|
|
const r50 = this._layoutBuckets[StreamLayouts.LANDSCAPE];
|
|
const duration_layout_landscape = r50 != null ? Math.round(r50) : 0;
|
|
const r58 = this._layoutBuckets[StreamLayouts.MINIMIZED];
|
|
const r5 = {
|
|
num_layout_changes: this._layoutChanges,
|
|
duration_layout_fullscreen,
|
|
duration_layout_theatre,
|
|
duration_layout_pip,
|
|
duration_layout_popout,
|
|
duration_layout_portrait,
|
|
duration_layout_landscape,
|
|
duration_layout_minimized: r58 != null ? Math.round(r58) : 0
|
|
};
|
|
return this._isSender ? {
|
|
...r5,
|
|
target_fps: this._targetFPS,
|
|
target_resolution_height: this._targetResolution,
|
|
stream_settings_changed: this._streamSettingsChanged,
|
|
num_auto_quality_changes: this._automaticQualityChanges
|
|
} : r5;
|
|
}
|
|
}
|
|
export default VideoStreamStats;
|