Files
2026-07-28 01:06:53 +03:00

468 lines
21 KiB
TypeScript

/* Metro module 4394; source: modules/media_engine/MediaEngineStatsStore.tsx; dependencies: [6, 7, 15, 17, 18, 1226, 4395, 4285, 566, 694, 2] */
import ClassCallCheck from '../../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */
import CreateClass from '../../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */
import PossibleConstructorReturn from '../../by-id/module-00015-PossibleConstructorReturn.js'; /* Metro dependency 15 */
import Module00017 from '../../by-id/module-00017.js'; /* Metro dependency 17 */
import Inherits from '../../by-id/module-00018-Inherits.js'; /* Metro dependency 18 */
import Flux from '../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
import AuthenticationStore from '../../stores/AuthenticationStore.tsx'; /* Metro dependency 1226 */
import StreamRTCConnectionStore from '../../stores/StreamRTCConnectionStore.tsx'; /* Metro dependency 4395 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as StreamKeyUtilsModule from '../go_live/utils/StreamKeyUtils.tsx'; /* Metro dependency 4285 */
function _fun37183(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#37183, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4566:6, offset: 0x0109dde1, size: 412 bytes, params: 8, frame: 19
const env0_0 = require;
const _arrayLikeToArray_37189 = function(a0, a1) {
var r0;
var r1;
var r2;
var value3;
var length;
var value5;
var value = undefined;
var value2 = value == null;
reducibleJoin2: while (true) {
if (value2) {
r0 = value2;
break reducibleJoin2;
}
value3 = value > a0.length;
r0 = value3;
break reducibleJoin2;
}
reducibleJoin4: while (true) {
if (r0) {
length = a0.length;
r1 = length;
break reducibleJoin4;
}
r1 = value;
break reducibleJoin4;
}
value = (0, global.Array)(r1);
var value4 = 0;
if (value4 < r1) {
r2 = value4;
reducibleLoop5: while (true) {
value[r2] = a0[r2];
value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
if (value5 < r1) {
r2 = value5;
continue reducibleLoop5;
}
break reducibleLoop5;
}
}
return value;
};
const isStatsOutbound = function(a0) {
return 'packetsSent' in a0;
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_9 = {};
const env0_10 = {};
const env0_11 = {};
const Store = (Flux).Store;
let value = _fun37197(Store);
value.displayName = 'MediaEngineStatsStore';
value = new value(importDefault(694) /* metro dependency 694: Dispatcher */,
{MEDIA_ENGINE_CONNECTION_STATS: MEDIA_ENGINE_CONNECTION_STATS,
MEDIA_ENGINE_CONNECTION_STATS_HISTORY_RESET: MEDIA_ENGINE_CONNECTION_STATS_HISTORY_RESET,
STREAM_UPDATE: STREAM_UPDATE, RTC_CONNECTION_VIDEO: function({userId, mediaEngineConnectionId}) {
if (mediaEngineConnectionId == null) {
return false;
}
resetAccumulatedStats(mediaEngineConnectionId, userId);
}});
(FileImportTrackerModule).fileFinishedImporting('modules/media_engine/MediaEngineStatsStore.tsx');
exports.default = value;
function _isNativeReflectConstruct_37184() { // fn#37184, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4566:170, offset: 0x0109df7d, size: 94 bytes, params: 1, frame: 18
var Boolean;
var prototype;
var valueOf;
var call;
var Reflect;
var construct;
var closure;
var value;
var error;
try {
Boolean = global.Boolean;
prototype = Boolean.prototype;
valueOf = prototype.valueOf;
call = valueOf.call;
Reflect = global.Reflect;
construct = Reflect.construct;
Boolean = global.Boolean;
closure = function() {
};
value = Reflect.apply(construct, Reflect, [Boolean, [], closure]);
value = Reflect.apply(call, valueOf, [value]);
var result = !value;
} catch (error) {
}
return (_isNativeReflectConstruct_37184_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _createForOfIteratorHelperLoose_37187(a0, a1) { // fn#37187, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4566:363, offset: 0x0109dfdb, size: 370 bytes, params: 3, frame: 20
var r6;
var r9;
var r5;
var value3;
var regexp;
const env0_0 = a0;
const Symbol = global.Symbol;
let value = typeof Symbol !== 'undefined';
let r1 = value && a0[global.Symbol.iterator];
r1 = !r1 ? a0['@@iterator'] : r1;
if (r1) {
value = r1.call(a0);
return value.next.bind(value);
}
const Array = global.Array;
if (Array.isArray(a0)) {
if (r1) {
}
return _fun37188;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_37189(a0, value);
r5 = value;
} else {
value3 = ({}).toString.call(a0).slice(8, -1);
r6 = value3 === 'Object' && a0.constructor;
r9 = r6 ? a0.constructor.name : value3;
if (r9 === 'Map') {
r6 = global.Array.from(a0);
} else if (r9 === 'Set') {
r6 = global.Array.from(a0);
} else if (r9 === 'Arguments') {
value = _arrayLikeToArray_37189(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_37189(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun37188;
}
const TypeError = global.TypeError;
throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.');
function _fun37188() { // fn#37188, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4566:934, offset: 0x00c39d73, size: 69 bytes, params: 1, frame: 5
return env0_1 >= env0_0.length ? {done: true} : {done: false,
value: env0_0[typeof env0_1 === 'bigint' ? env0_1 : +env0_1]};
}
}
function updateAveragedStatsHelper(a0, a1, a2, a3, a4) { // fn#37191, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4566:1344, offset: 0x0109e15a, size: 808 bytes, params: 6, frame: 22
var r2;
var r8;
var r13;
var r3;
var r1;
var r6;
var r7;
var isStatsOutbound3;
var value13;
const value = a2;
const value2 = a3.find(function(a0) {
return a0.type === 'video';
});
const r0 = value ?? ({'packetsSentOrReceived': 0, 'packetsLost': 0, 'packetLossRate': 0, 'frameRate': 0,
'resolution': 0, 'entropy': 0, 'numDatapoints': 0, 'frameRateAggregated': 0, 'resolutionAggregated': 0,
'entropyAggregated': 0, minVersion: a0});
if (value2 != null) {
var isStatsOutboundBinding = isStatsOutbound;
var value3 = undefined;
var r4 = isStatsOutboundBinding(value2) ? value2.packetsSent ?? 0 : value2.packetsReceived ?? 0;
var isStatsOutbound2 = isStatsOutbound(value2);
var packetsLost = value2.packetsLost;
var value6 = packetsLost != null;
r2 = isStatsOutbound2 ? value6 ? packetsLost : 0 : value6 ? packetsLost : 0;
r13 = isStatsOutbound(value2) ? value2.frameRateEncode ?? 0 : value2.frameRateDecode ?? 0;
var resolution = value2.resolution;
var height = resolution == null ? value3 : resolution.height;
var value11 = 0;
var r12 = height ?? value11;
var r10 = isStatsOutbound(value2) && value2.videoEntropy != null ? value2.videoEntropy : value11;
r0.numDatapoints = r0.numDatapoints + 1;
r0.frameRateAggregated = r0.frameRateAggregated + r13;
r0.resolutionAggregated = r0.resolutionAggregated + r12;
r0.entropyAggregated = r0.entropyAggregated + r10;
r10 = a4 == null ? value3 : a4.find(function(a0) {
return a0.type === 'video';
});
if (r10 == null) {
r0.packetsSentOrReceived = r4;
r0.packetsLost = r2;
} else if (a1 >= r0.minVersion) {
r0.numDatapoints = r0.numDatapoints - 1;
r3 = isStatsOutbound(r10) ? r10.packetsSent ?? value11 : r10.packetsReceived ?? value11;
isStatsOutbound3 = isStatsOutbound(r10);
packetsLost = r10.packetsLost;
value13 = packetsLost != null;
r1 = isStatsOutbound3 ? value13 ? packetsLost : value11 : value13 ? packetsLost : value11;
r8 = isStatsOutbound(r10) ? r10.frameRateEncode ?? value11 : r10.frameRateDecode ?? value11;
r6 = isStatsOutbound(r10) && r10.videoEntropy != null ? r10.videoEntropy : value11;
resolution = r10.resolution;
r7 = (resolution == null ? value3 : resolution.height) ?? value11;
r0.frameRateAggregated = r0.frameRateAggregated - r8;
r0.resolutionAggregated = r0.resolutionAggregated - r7;
r0.entropyAggregated = r0.entropyAggregated - r6;
r0.packetsSentOrReceived = r4 - r3;
r0.packetsLost = r2 - r1;
} else {
r0.packetsSentOrReceived = r4;
r0.packetsLost = r2;
}
r0.frameRate = r0.frameRateAggregated / r0.numDatapoints;
r0.resolution = r0.resolutionAggregated / r0.numDatapoints;
r0.entropy = r0.entropyAggregated / r0.numDatapoints;
r0.packetLossRate = r0.packetsLost / (r0.packetsSentOrReceived + r0.packetsLost);
}
return r0;
}
function updateAveragedStats(a0, a1, a2, a3) { // fn#37194, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4566:2978, offset: 0x0109e482, size: 369 bytes, params: 5, frame: 31
var r2;
var r15;
var r1;
var property3;
var version3;
var property4;
var property5;
var property6;
var value6;
if (a0[a1] == null) {
a0[a1] = {};
}
const id = AuthenticationStore.getId();
let property = a0[a1];
let updateAveragedStatsHelperBinding = updateAveragedStatsHelper;
const version2 = a2.version;
const value3 = undefined;
let version = a3 == null ? value3 : a3.version;
const value4 = 0;
const r13 = version ?? value4;
const property2 = a0[a1][id];
let stats = a2.stats;
let rtp = stats.rtp;
property[id] = updateAveragedStatsHelperBinding(version2, r13, property2, rtp.outbound,
a3 == null ? value3 : a3.stats.rtp.outbound);
const Object = global.Object;
const keys = Object.keys;
let inbound = a2.stats.rtp.inbound;
const value5 = Reflect.apply(keys, Object, [inbound]);
let length = value5.length;
if (value4 < length) {
r2 = value4;
while (true) {
property = value5[r2];
property3 = a0[a1];
updateAveragedStatsHelperBinding = updateAveragedStatsHelper;
version3 = a2.version;
version = a3 == null ? value3 : a3.version;
if (version != null) {
r15 = version;
continue;
}
r15 = value4;
continue;
property4 = a0[a1][property];
stats = a2.stats;
rtp = stats.rtp;
inbound = rtp.inbound;
property5 = inbound[property];
if (a3 == null) {
r1 = value3;
continue;
}
stats = a3.stats;
rtp = stats.rtp;
inbound = rtp.inbound;
property6 = inbound[property];
r1 = property6;
property3[property] = updateAveragedStatsHelperBinding(version3, r15, property4, property5, r1);
value6 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
length = value5.length;
if (value6 < length) {
r2 = value6;
continue;
}
break;
}
}
return value3;
}
function resetAccumulatedStats(a0, a1) { // fn#37195, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4566:3439, offset: 0x0109e5f3, size: 89 bytes, params: 3, frame: 8
let property = env0_10[a0];
const value2 = undefined;
if ((property == null ? value2 : property[a1]) != null) {
delete env0_10[a0][a1];
}
property = env0_11[a0];
if ((property == null ? value2 : property[a1]) != null) {
delete env0_11[a0][a1];
}
return value2;
}
function getStatsHistoryAtIndex(a0, a1) { // fn#37196, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4566:3585, offset: 0x0109e64c, size: 70 bytes, params: 3, frame: 5
const value = null;
if (value == a0) {
return value;
}
const property = env0_9[a0];
return value == property || property.length <= a1 ? value : property[property.length - a1 - 1];
}
function _fun37197(a0) { // fn#37197, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4566:3711, offset: 0x0109e692, size: 164 bytes, params: 2, frame: 16
const MediaEngineStatsStore2 = MediaEngineStatsStore;
Inherits(MediaEngineStatsStore2, a0);
return CreateClass(MediaEngineStatsStore2, [{key: 'initialize', value: function() {
this.waitFor(AuthenticationStore, StreamRTCConnectionStore);
}}, {key: 'getConnectionStats', value: function(a0) {
return getStatsHistoryAtIndex(a0, 0);
}}, {key: 'getLastConnectionStats', value: function(a0) {
return getStatsHistoryAtIndex(a0, 1);
}}, {key: 'getStatsHistory', value: value_37202}, {key: 'getAccumulatedPerformanceStats', value: value_37203}]);
function MediaEngineStatsStore() { // fn#37198, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4566:3723, offset: 0x00de700a, size: 113 bytes, params: 1, frame: 20
const value = environment.__proto__;
env1_2(this, MediaEngineStatsStore);
const value3 = env1_5(MediaEngineStatsStore);
return env1_4(this, _isNativeReflectConstruct_37184() ? global.Reflect.construct(value3, arguments,
env1_5(this).constructor) : value3.apply(this, arguments));
}
function value_37202(a0) { // fn#37202, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4566:4272, offset: 0x0109e763, size: 36 bytes, params: 2, frame: 3
return a0 == null ? [] : env1_9[a0] ?? [];
}
function value_37203(a0, a1, a2) { // fn#37203, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4566:4374, offset: 0x0109e787, size: 78 bytes, params: 4, frame: 5
var r2;
var r0;
var property;
const value = null;
if (value == a0) {
r0 = value;
} else {
r2 = a2 === 'long' ? env1_10 : env1_11;
property = r2[a0];
r2 = value == property ? undefined : property[a1];
r0 = value != r2 ? r2 : value;
}
return r0;
}
}
function MEDIA_ENGINE_CONNECTION_STATS({connectionStats}) { // fn#37204, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4566:4586, offset: 0x0109e7d5, size: 260 bytes, params: 2, frame: 30
var r4;
var r1;
var r13;
var value5;
var mediaEngineConnectionId;
var length;
var binding;
var property;
var value6;
var updateAveragedStatsBinding;
var statsHistoryAtIndex;
var value8;
const object = {};
const value3 = _createForOfIteratorHelperLoose_37187(connectionStats);
const value4 = value3();
let done = value4.done;
if (!done) {
r4 = value4;
while (true) {
value5 = r4.value;
mediaEngineConnectionId = value5.mediaEngineConnectionId;
length = mediaEngineConnectionId.length;
if (length !== 0) {
object[mediaEngineConnectionId] = value5;
if (mediaEngineConnectionId in env0_9) {
continue;
}
env0_9[mediaEngineConnectionId] = [];
property = env0_9[mediaEngineConnectionId];
property.push(value5);
length = env0_9[mediaEngineConnectionId].length;
if (!(length > 30)) {
r1 = undefined;
continue;
}
property = env0_9[mediaEngineConnectionId];
value6 = property.shift();
r1 = value6;
updateAveragedStatsBinding = updateAveragedStats;
binding = env0_11;
statsHistoryAtIndex = getStatsHistoryAtIndex(mediaEngineConnectionId, 15);
if (statsHistoryAtIndex != null) {
r13 = statsHistoryAtIndex;
continue;
}
r13 = undefined;
continue;
updateAveragedStatsBinding(binding, mediaEngineConnectionId, value5, r13);
updateAveragedStats(env0_10, mediaEngineConnectionId, value5, r1);
}
value8 = value3();
done = value8.done;
if (done) {
break;
}
r4 = value8;
continue;
}
}
}
function MEDIA_ENGINE_CONNECTION_STATS_HISTORY_RESET({mediaEngineConnectionId}) { // fn#37205, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4566:5013, offset: 0x0109e8d9, size: 46 bytes, params: 2, frame: 3
if (mediaEngineConnectionId != null) {
delete env0_9[mediaEngineConnectionId];
delete env0_10[mediaEngineConnectionId];
delete env0_11[mediaEngineConnectionId];
}
}
function STREAM_UPDATE(a0) { // fn#37206, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4566:5130, offset: 0x0109e907, size: 120 bytes, params: 2, frame: 16
const streamKey = a0.streamKey;
if (a0.paused) {
return false;
}
const rTCConnection = StreamRTCConnectionStore.getRTCConnection(streamKey);
const value3 = undefined;
const r3 = rTCConnection == null ? value3 : rTCConnection.getMediaEngineConnectionId();
if (r3 == null) {
return false;
}
const resetAccumulatedStatsBinding = resetAccumulatedStats;
resetAccumulatedStatsBinding(r3, StreamKeyUtilsModule.decodeStreamKey(streamKey).ownerId);
return value3;
}
}
global.__d(_fun37183, 4394, [6, 7, 15, 17, 18, 1226, 4395, 4285, 566, 694,
2]) /* metro module 4394, dependencies: [6, 7, 15, 17, 18, 1226, 4395, 4285, 566, 694, 2] */;