decord/source/modules/go_live/VideoStreamStats.tsx

131 lines
4.3 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 4572
// Function ID: 4573
2026-07-29 08:29:29 +00:00
// Name: start
2026-08-24 06:08:38 +00:00
// Dependencies: [4567, 676, 4263, 4553, 2]
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
// Module 4572 (start)
import sleep from "sleep" /* 4553 */;
import closure_2 from "ApplicationStreamPresets" /* 4567 */;
import { StreamLayouts } from "ME" /* 676 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
const result = require("set").fileFinishedImporting("modules/go_live/VideoStreamStats.tsx");
2026-07-29 08:29:29 +00:00
class VideoStreamStats {
constructor(arg0, arg1) {
obj = Object.create(new.target.prototype);
closure_0 = obj;
obj._targetResolution = 0;
obj._targetFPS = 0;
obj._streamSettingsChanged = false;
obj._lastLayoutChanged = 0;
obj._layoutChanges = 0;
obj._automaticQualityChanges = 0;
obj._incrementLayout = function _incrementLayout(_lastLayout, arg1) {
if (null == obj._layoutBuckets[_lastLayout]) {
tmp._layoutBuckets[_lastLayout] = 0;
}
const _layoutBuckets = tmp._layoutBuckets;
_layoutBuckets[_lastLayout] = _layoutBuckets[_lastLayout] + arg1;
};
obj._sampleStats = function _sampleStats() {
2026-08-24 06:08:38 +00:00
const state = closure_1_2.getState();
2026-07-29 08:29:29 +00:00
obj._streamSettingsChanged = state.resolution !== obj._targetResolution || tmp2 !== obj._targetFPS;
};
obj._isSender = arg1;
interval = new require("start").Interval();
obj._statInterval = interval;
obj._lastLayout = global;
obj._layoutBuckets = {};
return obj;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
const prototype = VideoStreamStats.prototype;
prototype["start"] = function start() {
state = state.getState();
({ resolution: this._targetResolution, fps: this._targetFPS } = state);
const _statInterval = this._statInterval;
_statInterval.start(1000, this._sampleStats);
2026-08-24 06:08:38 +00:00
this._lastLayoutChanged = sleep.now();
2026-07-29 08:29:29 +00:00
};
prototype["stop"] = function stop() {
const _statInterval = this._statInterval;
_statInterval.stop();
2026-08-24 06:08:38 +00:00
this._streamEnd = sleep.now();
2026-07-29 08:29:29 +00:00
this._incrementLayout(this._lastLayout, (this._streamEnd - this._lastLayoutChanged) / 1000);
};
prototype["autoQualityChange"] = function autoQualityChange() {
this._automaticQualityChanges = this._automaticQualityChanges + 1;
};
prototype["layoutChange"] = function layoutChange(_lastLayout) {
const self = this;
if (_lastLayout !== this._lastLayout) {
if (null == self._streamEnd) {
2026-08-24 06:08:38 +00:00
const nowResult = sleep.now();
2026-07-29 08:29:29 +00:00
self._incrementLayout(self._lastLayout, (nowResult - self._lastLayoutChanged) / 1000);
self._layoutChanges = self._layoutChanges + 1;
self._lastLayout = _lastLayout;
self._lastLayoutChanged = nowResult;
2026-08-24 06:08:38 +00:00
const obj = sleep;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
};
prototype["getLayout"] = function getLayout() {
return this._lastLayout;
};
prototype["getStats"] = function getStats() {
const self = this;
let obj = { num_layout_changes: this._layoutChanges, duration_layout_fullscreen: null, duration_layout_theatre: null, duration_layout_pip: null, duration_layout_popout: null, duration_layout_portrait: null, duration_layout_landscape: null, duration_layout_minimized: null };
let num = 0;
if (null != this._layoutBuckets[StreamLayouts.FULL_SCREEN]) {
const _Math = Math;
num = Math.round(tmp2);
}
obj[1] = num;
let num2 = 0;
if (null != self._layoutBuckets[StreamLayouts.THEATRE]) {
const _Math2 = Math;
num2 = Math.round(tmp4);
}
obj[2] = num2;
let num3 = 0;
if (null != self._layoutBuckets[StreamLayouts.PIP]) {
const _Math3 = Math;
num3 = Math.round(tmp6);
}
obj[3] = num3;
let num4 = 0;
if (null != self._layoutBuckets[StreamLayouts.POPOUT]) {
const _Math4 = Math;
num4 = Math.round(tmp8);
}
obj[4] = num4;
let num5 = 0;
if (null != self._layoutBuckets[StreamLayouts.PORTRAIT]) {
const _Math5 = Math;
num5 = Math.round(tmp10);
}
obj[5] = num5;
let num6 = 0;
if (null != self._layoutBuckets[StreamLayouts.LANDSCAPE]) {
const _Math6 = Math;
num6 = Math.round(tmp12);
}
obj[6] = num6;
let num7 = 0;
if (null != self._layoutBuckets[StreamLayouts.MINIMIZED]) {
const _Math7 = Math;
num7 = Math.round(tmp14);
}
obj[7] = num7;
let tmp16 = obj;
if (self._isSender) {
obj = {};
const merged = Object.assign(obj);
({ _targetFPS: obj2.target_fps, _targetResolution: obj2.target_resolution_height, _streamSettingsChanged: obj2.stream_settings_changed, _automaticQualityChanges: obj2.num_auto_quality_changes } = self);
tmp16 = obj;
}
return tmp16;
};
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default VideoStreamStats;