Files
discord-decomp/sources/lib/RTCMediaSinkWantsManager.tsx
2026-07-28 01:06:53 +03:00

1399 lines
67 KiB
TypeScript

/* Metro module 12389; source: lib/RTCMediaSinkWantsManager.tsx; dependencies: [57, 6, 7, 15, 17, 18, 1226, 661, 4291, 672, 4221, 12390, 4460, 21, 477, 628, 22, 4041, 10682, 4406, 4479, 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 SnowflakeUtils from '../utils/SnowflakeUtils.tsx'; /* Metro dependency 21 */
import Module00057 from '../by-id/module-00057.js'; /* Metro dependency 57 */
import AuthenticationStore from '../stores/AuthenticationStore.tsx'; /* Metro dependency 1226 */
import * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as PlatformUtilsModule from '../utils/PlatformUtils.tsx'; /* Metro dependency 477 */
import * as ConstantsModule from '../Constants.tsx'; /* Metro dependency 661 */
import * as TimersModule from '../external/discord_common/js/packages/timers/Timers.tsx'; /* Metro dependency 4041 */
import * as BrowserUtilsModule from '../utils/BrowserUtils.tsx'; /* Metro dependency 4221 */
import * as ConstantsModule2 from '../external/discord_common/js/packages/media-engine/Constants.tsx'; /* Metro dependency 4291 */
import * as MediaEngineModule from '../external/discord_common/js/packages/media-engine/index.tsx'; /* Metro dependency 4406 */
import * as WindowVisibilityVideoManagerModule from './WindowVisibilityVideoManager.tsx'; /* Metro dependency 10682 */
import * as BrowserInvertedWantsExperimentModule from '../modules/media_engine/BrowserInvertedWantsExperiment.tsx'; /* Metro dependency 12390 */
function _fun94367(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#94367, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:6, offset: 0x021153ae, size: 491 bytes, params: 8, frame: 21
const env0_0 = require;
const _arrayLikeToArray_94370 = 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 Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis;
let SECOND = Millis.SECOND;
const env0_13 = 30 * SECOND;
Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis;
SECOND = Millis.SECOND;
const env0_14 = 120 * SECOND;
let value = BrowserUtilsModule;
value = value.getFirefoxVersion();
const result = value !== -1;
value = importDefault(4479) /* metro dependency 4479: TypedEventEmitter */;
value = _fun94375(value);
(FileImportTrackerModule).fileFinishedImporting('lib/RTCMediaSinkWantsManager.tsx');
exports.default = value;
exports.DEFAULT_WANTS_FULL = {any: 100};
exports.DEFAULT_WANTS_DISABLED = {any: 0};
exports.RTCMediaSinkWantsManagerEvent = {UserSSRCUpdate: 'user-ssrc-update', Update: 'update'};
function _createForOfIteratorHelperLoose_94368(a0, a1) { // fn#94368, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:234, offset: 0x02115599, size: 372 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 _fun94369;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_94370(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_94370(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_94370(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun94369;
}
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 _fun94369() { // fn#94369, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:805, 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 _isNativeReflectConstruct_94371() { // fn#94371, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:1144, offset: 0x0211570d, size: 98 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_94371_isNativeReflectConstruct = function() {
return !!result;
})();
}
function getDefaultWants(a0) { // fn#94374, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:1541, offset: 0x0211576f, size: 81 bytes, params: 2, frame: 13
var r0;
var object;
const getBrowserInvertedWantsConfig = BrowserInvertedWantsExperimentModule.getBrowserInvertedWantsConfig;
if (Reflect.apply(getBrowserInvertedWantsConfig, BrowserInvertedWantsExperimentModule,
['RTCMediaSinkWantsManager.getDefaultWants']).invertWants) {
object = {};
copyDataProperties(object, env0_12, BrowserInvertedWantsExperimentModule);
r0 = object;
} else {
r0 = {any: a0};
}
return r0;
}
function _fun94375(a0) { // fn#94375, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:1693, offset: 0x021157c0, size: 613 bytes, params: 2, frame: 16
const RTCMediaSinkWantsManager2 = RTCMediaSinkWantsManager;
Inherits(RTCMediaSinkWantsManager2, a0);
return CreateClass(RTCMediaSinkWantsManager2, [{key: 'getWantsLevel', value: function() {
var value = a0;
return this.ladder.getMaxSinkValue(this.getVideoParticipantCount(), value !== undefined ? value : 0);
}}, {key: 'userVideoDisabled', value: function(a0) {
return this.offscreenDisabledUsers[a0];
}}, {key: 'isOneToOneCall', value: function() {
return this.otherUsers.size === 1;
}}, {key: 'updateCallUserIds', value: value_94387}, {key: 'shouldReceiveFromUser', value: value_94388},
{key: 'invertWants', value: value_94389}, {key: 'getAudioSSRCs', value: function() {
return this.audioSsrcs;
}}, {key: 'setConnection', value: value_94391}, {key: 'setAudioSSRC', value: function(a0, a1) {
if (a1 > 0) {
this.audioSsrcs[a0] = a1;
} else {
delete this.audioSsrcs[a0];
}
return this.update();
}}, {key: 'setVideoSSRCs', value: value_94393}, {key: 'setFirstFrameReceived', value: function(a0) {
this.framesReceived[a0] = true;
return this.update();
}}, {key: 'setStreamId', value: function(a0, a1) {
if (a1 != null) {
this.streamIds[a0] = a1;
} else {
if (a0 in this.streamIds) {
delete this.streamPixelCounts[this.streamIds[a0]];
}
delete this.streamIds[a0];
}
return this.update();
}}, {key: 'destroyUser', value: function(a0) {
delete this.audioSsrcs[a0];
delete this.videoSsrcs[a0];
this.participants.delete(a0);
delete this.streamPixelCounts[this.streamIds[a0]];
delete this.streamIds[a0];
return this.update(global.Array.from(this.participants));
}}, {key: 'reset', value: value_94399}, {key: 'setSelectedParticipant', value: value_94400}, {key: 'setPipOpen',
value: function(a0) {
this.pipOpen = a0;
return this.selectedParticipantId != null ? this.update([this.selectedParticipantId]) : this.latestWants;
}}, {key: 'getOffscreenDisabledUsers', value: function() {
return this.offscreenDisabledUsers;
}}, {key: 'setSimulcastDebugOverride', value: function(a0, a1) {
this.simulcastDebugOverrides.set(a0, a1);
this.update();
}}, {key: 'setVideoSize', value: function(a0, a1) {
if (a1 > 0) {
this.streamPixelCounts[a0] = a1;
} else {
delete this.streamPixelCounts[a0];
}
this.delayedUpdate();
}}, {key: 'getVideoParticipantCount', value: function() {
var r2;
var r3;
var r1;
var r7;
var r0;
var connection;
var value3;
var value4;
var value5;
var value6;
var property = global.Object;
var value = property.keys(this.videoSsrcs);
var value2 = 0;
if (value2 < value.length) {
r2 = value2;
r3 = value2;
while (true) {
property = value[r2];
connection = this.connection;
value3 = connection != null;
if (value3) {
value4 = connection.getLocalVideoDisabled(property);
r1 = value4;
} else {
r1 = value3;
}
if (r1) {
r7 = r3;
continue;
}
value5 = typeof r3 === 'bigint' ? r3 + 1n : +r3 + 1;
r7 = value5;
value6 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
if (value6 < value.length) {
r2 = value6;
r3 = r7;
continue;
}
r0 = r7;
break;
}
} else {
r0 = value2;
}
return r0;
}}, {key: 'getOffscreenTimeoutMs', value: value_94407}, {key: 'getSimulcastOverrideQuality', value: function(a0) {
return this.simulcastDebugOverrides.has(a0) ? this.simulcastDebugOverrides.get(a0) : SimulcastOverrideQuality.NO_OVERRIDE;
}}]);
function RTCMediaSinkWantsManager(a0, a1, a2) { // fn#94376, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:1705, offset: 0x02115a25, size: 665 bytes, params: 4, frame: 22
var environment;
let value = a3;
const r3 = value !== undefined ? value : new (require(4460) /* metro dependency 4460: MediaSinkWantsLadder */).MediaSinkWantsLadder();
value = environment.__proto__;
env1_4(this, RTCMediaSinkWantsManager);
const value3 = env1_7(RTCMediaSinkWantsManager);
const value6 = env1_6(this, _isNativeReflectConstruct_94371() ? global.Reflect.construct(value3, [],
env1_7(this).constructor) : value3.apply(this, undefined));
value6.userId = a0;
value6.isStageChannel = a1;
value6.supportsSeamless = a2;
value6.ladder = r3;
value6.connection = null;
value6.audioSsrcs = {};
value6.videoSsrcs = {};
value6.remoteVideoSsrcs = {};
value6.framesReceived = {};
value6.streamIds = {};
value6.offscreenUsers = {};
value6.offscreenDisabledUsers = {};
value6.streamPixelCounts = {};
value6.latestWants = getDefaultWants(100);
let Set = global.Set;
const value7 = Object.create(Set.prototype, {constructor: {value: Set}});
let set = new Set();
value6.participants = set instanceof Object ? set : value7;
value6.selectedParticipantId = null;
value6.pipOpen = false;
const Map = global.Map;
const value9 = Object.create(Map.prototype, {constructor: {value: Map}});
const map = new Map();
value6.simulcastDebugOverrides = map instanceof Object ? map : value9;
value6.videoHealthManager = null;
Set = global.Set;
const value11 = Object.create(Set.prototype, {constructor: {value: Set}});
set = new Set();
value6.otherUsers = set instanceof Object ? set : value11;
value6.delayedUpdate = delayedUpdate;
value6.addLru = addLru;
value6.updateOffscreenUsers = updateOffscreenUsers;
value6.handleLocalVideoDisabled = handleLocalVideoDisabled;
value6.handleLocalMute = handleLocalMute;
value6.update = update_94382;
value6.incomingVideoEnabledChanged = incomingVideoEnabledChanged_94383;
const DelayedCall = (TimersModule).DelayedCall;
value6.delayedCall = new DelayedCall(100, value6.update);
const Timeout = (TimersModule).Timeout;
value6.offscreenTimeout = new Timeout();
const WindowVisibilityVideoManager = (WindowVisibilityVideoManagerModule).WindowVisibilityVideoManager;
const on = WindowVisibilityVideoManager.on;
const WindowVisibilityEvent = (WindowVisibilityVideoManagerModule).WindowVisibilityEvent;
const IncomingVideoEnabledChanged = WindowVisibilityEvent.IncomingVideoEnabledChanged;
Reflect.apply(on, WindowVisibilityVideoManager, [IncomingVideoEnabledChanged, value6.incomingVideoEnabledChanged]);
return value6;
function delayedUpdate() { // fn#94377, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:2430, owner: RTCMediaSinkWantsManager.delayedUpdate, offset: 0x02115cbe, size: 27 bytes, params: 1, frame: 9
env0_0.delayedCall.delay();
}
function addLru(a0, a1, a2) { // fn#94378, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:2467, owner: RTCMediaSinkWantsManager.addLru, offset: 0x02115cd9, size: 146 bytes, params: 4, frame: 18
var r4;
var r5;
var r6;
var r2;
var value;
var value2;
var property;
var offscreenUsers;
a2.push(a0);
let length = a2.length;
if (!(length <= 3)) {
length = a2.length;
value = 0;
value2 = -1;
if (value < length) {
r4 = value2;
r5 = value2;
r6 = value;
while (true) {
property = a2[r6];
offscreenUsers = env0_0.offscreenUsers;
value = a1 - offscreenUsers[property];
if (value > r5) {
r4 = r6;
r5 = value;
}
value = typeof r6 === 'bigint' ? r6 + 1n : +r6 + 1;
length = a2.length;
if (value < length) {
r6 = value;
continue;
}
r2 = r4;
break;
}
} else {
r2 = value2;
}
env0_0.offscreenDisabledUsers[a2[r2]] = true;
a2.splice(r2, 1);
}
}
function updateOffscreenUsers() { // fn#94379, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:2667, owner: RTCMediaSinkWantsManager.updateOffscreenUsers, offset: 0x02115d6b, size: 603 bytes, params: 1, frame: 29
var r9;
var r3;
var r5;
var r1;
var getActiveOutputSinkTrackingEnabled;
var Date;
var now;
var value2;
var items2;
var value3;
var _createForOfIteratorHelperLoose_94368Binding;
var defaultImport;
var entries;
var streamIds;
var value4;
var value5;
var done;
var value6;
var value7;
var property;
var property2;
var getHasActiveVideoOutputSink;
var offscreenUsers;
var offscreenDisabledUsers;
var value8;
var binding;
var getOffscreenTimeoutMs;
var addLru;
var value9;
var length;
var offscreenTimeout;
var stop;
var value10;
var value11;
var value12;
var value13;
var Math;
var min;
var value14;
var value15;
var start;
var value16;
var update;
let connection = env0_0.connection;
reducibleJoin19: while (true) {
if (connection == null) {
break reducibleJoin19;
}
getActiveOutputSinkTrackingEnabled = connection.getActiveOutputSinkTrackingEnabled;
if (Reflect.apply(getActiveOutputSinkTrackingEnabled, connection, [])) {
Date = global.Date;
now = Date.now;
value2 = Reflect.apply(now, Date, []);
items2 = [];
value3 = environment.__proto__.__proto__;
_createForOfIteratorHelperLoose_94368Binding = _createForOfIteratorHelperLoose_94368;
defaultImport = importDefault(21) /* metro dependency 21: SnowflakeUtils */;
entries = defaultImport.entries;
streamIds = env0_0.streamIds;
value4 = _createForOfIteratorHelperLoose_94368Binding(Reflect.apply(entries, defaultImport, [streamIds]));
value5 = value4();
done = value5.done;
if (!done) {
r9 = value5;
reducibleLoop3: while (true) {
value6 = r9.value;
value7 = env2_3(value6, 2);
property = value7[0];
property2 = value7[1];
reducibleJoin13: while (true) {
if (property2 == null) {
break reducibleJoin13;
}
connection = env0_0.connection;
if (connection != null) {
getHasActiveVideoOutputSink = connection.getHasActiveVideoOutputSink;
if (Reflect.apply(getHasActiveVideoOutputSink, connection, [property2])) {
delete env0_0.offscreenUsers[property];
delete env0_0.offscreenDisabledUsers[property];
break reducibleJoin13;
}
}
offscreenUsers = env0_0.offscreenUsers;
if (offscreenUsers[property] == null) {
env0_0.offscreenUsers[property] = value2;
binding = env0_0;
binding.addLru(property, value2, items2);
break reducibleJoin13;
}
offscreenDisabledUsers = env0_0.offscreenDisabledUsers;
if (offscreenDisabledUsers[property]) {
break reducibleJoin13;
}
offscreenUsers = env0_0.offscreenUsers;
value8 = value2 - offscreenUsers[property];
binding = env0_0;
getOffscreenTimeoutMs = binding.getOffscreenTimeoutMs;
if (value8 >= Reflect.apply(getOffscreenTimeoutMs, binding, [])) {
offscreenDisabledUsers = env0_0.offscreenDisabledUsers;
offscreenDisabledUsers[property] = true;
break reducibleJoin13;
}
binding = env0_0;
addLru = binding.addLru;
Reflect.apply(addLru, binding, [property, value2, items2]);
break reducibleJoin13;
}
value9 = value4();
done = value9.done;
if (done) {
break reducibleLoop3;
}
r9 = value9;
continue reducibleLoop3;
}
}
length = items2.length;
if (length > 0) {
binding = env0_0;
getOffscreenTimeoutMs = binding.getOffscreenTimeoutMs;
value10 = value2 + Reflect.apply(getOffscreenTimeoutMs, binding, []);
value11 = _createForOfIteratorHelperLoose_94368(items2);
value12 = value11();
done = value12.done;
if (done) {
r1 = value10;
} else {
r3 = value10;
r5 = value12;
reducibleLoop17: while (true) {
value13 = r5.value;
Math = global.Math;
min = Math.min;
offscreenUsers = env0_0.offscreenUsers;
property = offscreenUsers[value13];
binding = env0_0;
getOffscreenTimeoutMs = binding.getOffscreenTimeoutMs;
value14 = Reflect.apply(min, Math, [r3, property + Reflect.apply(getOffscreenTimeoutMs, binding,
[])]);
value15 = value11();
done = value15.done;
if (done) {
r1 = value14;
break reducibleLoop17;
}
r3 = value14;
r5 = value15;
continue reducibleLoop17;
}
}
offscreenTimeout = env0_0.offscreenTimeout;
start = offscreenTimeout.start;
value16 = r1 - value2;
update = env0_0.update;
Reflect.apply(start, offscreenTimeout, [value16, update]);
break reducibleJoin19;
}
offscreenTimeout = env0_0.offscreenTimeout;
stop = offscreenTimeout.stop;
Reflect.apply(stop, offscreenTimeout, []);
break reducibleJoin19;
}
break reducibleJoin19;
}
}
function handleLocalVideoDisabled() { // fn#94380, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:3514, owner: RTCMediaSinkWantsManager.handleLocalVideoDisabled, offset: 0x02115fc6, size: 21 bytes, params: 1, frame: 9
env0_0.update();
}
function handleLocalMute() { // fn#94381, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:3549, owner: RTCMediaSinkWantsManager.handleLocalMute, offset: 0x02115fc6, size: 21 bytes, params: 1, frame: 9
env0_0.update();
}
function RTCMediaSinkWantsManagerUpdate() { // fn#94382, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:3575, owner: RTCMediaSinkWantsManager.update, offset: 0x02115fdb, size: 1811 bytes, params: 1, frame: 67
var r56;
var r30;
var r4;
var r3;
var r28;
var r20;
var r32;
var r46;
var r51;
var r47;
var r55;
var r49;
var r45;
var r5;
var r41;
var r42;
var r43;
var r40;
var r11;
var object;
var isOneToOneCall;
var isOneToOneCall2;
var isStageChannel;
var value5;
var value10;
var value11;
var property;
var property2;
var streamPixelCounts;
var streamIds;
var property3;
var value12;
var ssrc;
var shouldReceiveFromUser;
var value13;
var value14;
var value15;
var value16;
var ssrc2;
var value17;
var selectedParticipantId;
var value18;
var pipOpen;
var value19;
var length;
var value20;
var value21;
var value22;
var value23;
var value24;
var quality;
var value25;
var supportsSeamless;
var value26;
var framesReceived;
var value27;
var value28;
var value29;
var value30;
var value31;
var property4;
var push;
var value32;
var getSimulcastOverrideQuality;
var value33;
var HIGH;
var LOW;
var value34;
var value35;
var value36;
var includes;
var value37;
var value38;
var remoteVideoSsrcs;
var value39;
var defaultImport2;
var value40;
var emit;
var UserSSRCUpdate;
var audioSsrcs;
var value41;
var value43;
var property5;
var connection;
var value44;
var getLocalMute;
var value45;
var value46;
var defaultImport3;
var isEqual;
var latestWants;
var isEqual2;
var Update;
const value = a0;
reducibleJoin2: while (true) {
if (value !== undefined) {
r30 = value;
break reducibleJoin2;
}
r30 = [];
break reducibleJoin2;
}
let binding = env0_0;
const wantsLevel = binding.getWantsLevel();
const defaultWants = getDefaultWants(wantsLevel);
const getBrowserInvertedWantsConfig = BrowserInvertedWantsExperimentModule.getBrowserInvertedWantsConfig;
let invertWants = Reflect.apply(getBrowserInvertedWantsConfig, BrowserInvertedWantsExperimentModule,
['RTCMediaSinkWantsManager.update']).invertWants;
reducibleJoin6: while (true) {
if (invertWants) {
binding = env0_0;
invertWants = binding.invertWants;
Reflect.apply(invertWants, binding, [defaultWants, wantsLevel]);
reducibleJoin5: while (true) {
if (result) {
object = {};
copyDataProperties(object, defaultWants, undefined);
r4 = object;
break reducibleJoin5;
}
r4 = defaultWants;
break reducibleJoin5;
}
r3 = r4;
break reducibleJoin6;
}
r3 = defaultWants;
break reducibleJoin6;
}
env0_0.updateOffscreenUsers();
const isDesktop2 = (PlatformUtilsModule).isDesktop();
reducibleJoin8: while (true) {
if (isDesktop2) {
binding = env0_0;
isOneToOneCall = binding.isOneToOneCall;
isOneToOneCall2 = Reflect.apply(isOneToOneCall, binding, []);
r28 = isOneToOneCall2;
break reducibleJoin8;
}
r28 = isDesktop2;
break reducibleJoin8;
}
reducibleJoin10: while (true) {
if (r28) {
isStageChannel = env0_0.isStageChannel;
value5 = !isStageChannel;
r28 = value5;
break reducibleJoin10;
}
break reducibleJoin10;
}
const _createForOfIteratorHelperLoose_94368Binding = _createForOfIteratorHelperLoose_94368;
const defaultImport = SnowflakeUtils;
const value6 = _createForOfIteratorHelperLoose_94368Binding(defaultImport.entries(env0_0.videoSsrcs));
const value7 = value6();
let done = value7.done;
const value8 = 0;
if (!done) {
r20 = value7;
reducibleLoop11: while (true) {
value10 = r20.value;
value11 = env2_3(value10, 2);
property = value11[value8];
property2 = value11[1];
object = [];
streamPixelCounts = env0_0.streamPixelCounts;
streamIds = env0_0.streamIds;
property3 = streamPixelCounts[streamIds[property]];
r32 = property3 ?? value8;
binding = env0_0;
getWantsLevel = binding.getWantsLevel;
value12 = Reflect.apply(getWantsLevel, binding, [r32]);
ssrc = property2[value8].ssrc;
binding = env0_0;
shouldReceiveFromUser = binding.shouldReceiveFromUser;
if (Reflect.apply(shouldReceiveFromUser, binding, [property])) {
selectedParticipantId = env0_0.selectedParticipantId;
value18 = property === selectedParticipantId;
r51 = value18 && wantsLevel !== 100;
reducibleJoin18: while (true) {
if (r51) {
pipOpen = env0_0.pipOpen;
value19 = !pipOpen;
r51 = value19;
break reducibleJoin18;
}
break reducibleJoin18;
}
length = property2.length;
if (length > 1) {
value22 = _createForOfIteratorHelperLoose_94368(property2);
value23 = value22();
done = value23.done;
if (done) {
r49 = ssrc;
} else {
r46 = value23;
r47 = ssrc;
reducibleLoop24: while (true) {
value24 = r46.value;
quality = value24.quality;
if (quality === 100) {
ssrc = value24.ssrc;
if (r51) {
defaultWants[ssrc] = 100;
ssrc = value24.ssrc;
r55 = ssrc;
} else {
defaultWants[ssrc] = value8;
r55 = r47;
}
} else if (r51) {
ssrc = value24.ssrc;
defaultWants[ssrc] = value8;
r55 = r47;
} else {
reducibleJoin28: while (true) {
if (r28) {
ssrc = value24.ssrc;
defaultWants[ssrc] = value12;
break reducibleJoin28;
}
break reducibleJoin28;
}
ssrc = value24.ssrc;
r55 = ssrc;
}
value25 = value22();
done = value25.done;
if (done) {
r49 = r55;
break reducibleLoop24;
}
r46 = value25;
r47 = r55;
continue reducibleLoop24;
}
}
supportsSeamless = env0_0.supportsSeamless;
value26 = false;
reducibleJoin46: while (true) {
if (!supportsSeamless) {
r41 = r49;
r42 = value26;
r43 = object;
break reducibleJoin46;
}
framesReceived = env0_0.framesReceived;
if (framesReceived[r49]) {
r41 = r49;
r42 = value26;
r43 = object;
break reducibleJoin46;
}
object = [r49];
value27 = _createForOfIteratorHelperLoose_94368(property2);
value28 = value27();
done = value28.done;
value29 = true;
if (done) {
r41 = r49;
r42 = value29;
r43 = object;
break reducibleJoin46;
}
r45 = value28;
reducibleLoop37: while (true) {
value30 = r45.value;
ssrc = value30.ssrc;
value31 = ssrc !== r49;
reducibleJoin39: while (true) {
if (value31) {
framesReceived = env0_0.framesReceived;
ssrc = value30.ssrc;
property4 = framesReceived[ssrc];
r5 = property4;
break reducibleJoin39;
}
r5 = value31;
break reducibleJoin39;
}
reducibleJoin45: while (true) {
if (r5) {
quality = value30.quality;
if (quality === 100) {
defaultWants[value30.ssrc] = 100;
} else {
ssrc = value30.ssrc;
r5 = r28 ? value12 : wantsLevel;
defaultWants[ssrc] = r5;
}
push = object.push;
ssrc = value30.ssrc;
Reflect.apply(push, object, [ssrc]);
break reducibleJoin45;
}
break reducibleJoin45;
}
value32 = value27();
done = value32.done;
if (done) {
r41 = r49;
r42 = value29;
r43 = object;
break reducibleJoin46;
}
r45 = value32;
continue reducibleLoop37;
}
}
} else if (r51) {
defaultWants[ssrc] = 100;
value21 = false;
r41 = ssrc;
r42 = value21;
r43 = object;
} else {
value20 = false;
reducibleJoin46: while (true) {
if (r28) {
defaultWants[ssrc] = value12;
r41 = ssrc;
r42 = value20;
r43 = object;
break reducibleJoin46;
}
r41 = ssrc;
r42 = value20;
r43 = object;
break reducibleJoin46;
}
}
} else {
value13 = _createForOfIteratorHelperLoose_94368(property2);
value14 = value13();
done = value14.done;
value15 = false;
if (done) {
r41 = ssrc;
r42 = value15;
r43 = object;
} else {
r46 = value14;
reducibleLoop14: while (true) {
value16 = r46.value;
ssrc2 = value16.ssrc;
defaultWants[ssrc2] = value8;
value17 = value13();
done = value17.done;
if (done) {
r41 = ssrc;
r42 = value15;
r43 = object;
break reducibleLoop14;
}
r46 = value17;
continue reducibleLoop14;
}
}
}
binding = env0_0;
getSimulcastOverrideQuality = binding.getSimulcastOverrideQuality;
value33 = Reflect.apply(getSimulcastOverrideQuality, binding, [property]);
HIGH = SimulcastOverrideQuality.HIGH;
if (value33 === HIGH) {
defaultWants[r41] = 100;
} else {
LOW = SimulcastOverrideQuality.LOW;
reducibleJoin50: while (true) {
if (value33 !== LOW) {
break reducibleJoin50;
}
defaultWants[r41] = 50;
break reducibleJoin50;
}
}
supportsSeamless = env0_0.supportsSeamless;
r5 = supportsSeamless && r42;
reducibleJoin53: while (true) {
if (r5) {
break reducibleJoin53;
}
r43 = [r41];
break reducibleJoin53;
}
value34 = _createForOfIteratorHelperLoose_94368(property2);
value35 = value34();
done = value35.done;
if (!done) {
r40 = value35;
reducibleLoop54: while (true) {
value36 = r40.value;
includes = r43.includes;
ssrc = value36.ssrc;
reducibleJoin56: while (true) {
if (Reflect.apply(includes, r43, [ssrc])) {
break reducibleJoin56;
}
framesReceived = env0_0.framesReceived;
ssrc = value36.ssrc;
delete framesReceived[ssrc];
break reducibleJoin56;
}
value37 = value34();
done = value37.done;
if (done) {
break reducibleLoop54;
}
r40 = value37;
continue reducibleLoop54;
}
}
includes = r30.includes;
value38 = Reflect.apply(includes, r30, [property]);
reducibleJoin61: while (true) {
if (value38) {
r5 = value38;
break reducibleJoin61;
}
remoteVideoSsrcs = env0_0.remoteVideoSsrcs;
value39 = remoteVideoSsrcs[property] !== undefined;
reducibleJoin60: while (true) {
if (value39) {
defaultImport2 = importDefault(628) /* metro dependency 628: shallowEqual */;
remoteVideoSsrcs = env0_0.remoteVideoSsrcs;
value40 = !defaultImport2(remoteVideoSsrcs[property], r43);
r40 = value40;
break reducibleJoin60;
}
r40 = value39;
break reducibleJoin60;
}
r5 = r40;
break reducibleJoin61;
}
reducibleJoin63: while (true) {
if (r5) {
remoteVideoSsrcs = env0_0.remoteVideoSsrcs;
object = [];
arraySpread(object, r43, value8, r56);
remoteVideoSsrcs[property] = object;
binding = env0_0;
emit = binding.emit;
UserSSRCUpdate = env2_16.UserSSRCUpdate;
audioSsrcs = env0_0.audioSsrcs;
Reflect.apply(emit, binding, [UserSSRCUpdate, property, audioSsrcs[property], r43]);
r56 = r43;
break reducibleJoin63;
}
break reducibleJoin63;
}
value41 = value6();
done = value41.done;
if (done) {
break reducibleLoop11;
}
r20 = value41;
continue reducibleLoop11;
}
}
const r0 = result ? r3 : defaultWants;
const Object = global.Object;
const value42 = Object.entries(env0_0.audioSsrcs);
length = value42.length;
if (value8 < length) {
r5 = value8;
reducibleLoop66: while (true) {
property = value42[r5];
value43 = env2_3(property, 2);
property = value43[value8];
property5 = value43[1];
connection = env0_0.connection;
value44 = connection != null;
reducibleJoin68: while (true) {
if (value44) {
getLocalMute = connection.getLocalMute;
value45 = Reflect.apply(getLocalMute, connection, [property]);
r11 = value45;
break reducibleJoin68;
}
r11 = value44;
break reducibleJoin68;
}
reducibleJoin70: while (true) {
if (r11) {
r0[property5] = value8;
break reducibleJoin70;
}
break reducibleJoin70;
}
value46 = typeof r5 === 'bigint' ? r5 + 1n : +r5 + 1;
length = value42.length;
if (value46 < length) {
r5 = value46;
continue reducibleLoop66;
}
break reducibleLoop66;
}
}
const value47 = env0_0.connection == null;
reducibleJoin73: while (true) {
if (value47) {
r3 = value47;
break reducibleJoin73;
}
defaultImport3 = importDefault(22) /* metro dependency 22 */;
isEqual = defaultImport3.isEqual;
latestWants = env0_0.latestWants;
isEqual2 = Reflect.apply(isEqual, defaultImport3, [latestWants, r0]);
r3 = isEqual2;
break reducibleJoin73;
}
reducibleJoin75: while (true) {
if (r3) {
break reducibleJoin75;
}
env0_0.latestWants = r0;
binding = env0_0;
emit = binding.emit;
Update = env2_16.Update;
Reflect.apply(emit, binding, [Update, r0]);
break reducibleJoin75;
}
return r0;
}
function RTCMediaSinkWantsManagerIncomingVideoEnabledChanged() { // fn#94383, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:5369, owner: RTCMediaSinkWantsManager.incomingVideoEnabledChanged, offset: 0x02115fc6, size: 21 bytes, params: 1, frame: 9
env0_0.update();
}
}
function value_94387(a0) { // fn#94387, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:5991, offset: 0x02116747, size: 87 bytes, params: 2, frame: 13
const Set = global.Set;
let set = new Set(a0);
this.otherUsers = set;
const otherUsers = this.otherUsers;
set = environment.__proto__;
const authenticationStoreBinding = AuthenticationStore;
const getId = authenticationStoreBinding.getId;
otherUsers.delete(Reflect.apply(getId, authenticationStoreBinding, []));
this.update();
}
function value_94388(a0) { // fn#94388, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:6115, offset: 0x0211679e, size: 151 bytes, params: 2, frame: 14
var r3;
var r1;
var videoHealthManager;
const connection = this.connection;
let value = connection != null;
let r0 = value && connection.getLocalVideoDisabled(a0);
if (!r0) {
value = this.userVideoDisabled(a0);
if (value) {
videoHealthManager = this.videoHealthManager;
value = undefined;
r3 = videoHealthManager == null ? value : videoHealthManager.getCurrentVideoToggleState(a0);
value = environment.__proto__;
value = r3 !== VideoToggleState.AUTO_PROBING;
r1 = value;
} else {
r1 = value;
}
r0 = r1;
}
value = !r0;
const WindowVisibilityVideoManager = (WindowVisibilityVideoManagerModule).WindowVisibilityVideoManager;
return WindowVisibilityVideoManager.isIncomingVideoEnabled() && value;
}
function value_94389(a0, a1) { // fn#94389, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:6415, offset: 0x02116835, size: 228 bytes, params: 3, frame: 24
var r8;
var r12;
var r4;
var value4;
var value5;
var done;
var value6;
var ssrc;
var quality;
var value7;
var value8;
var value9;
let Object = global.Object;
let value = Object.values(this.videoSsrcs);
let length = value.length;
const value2 = 0;
if (value2 < length) {
r8 = value2;
while (true) {
value4 = _createForOfIteratorHelperLoose_94368(value[r8]);
value5 = value4();
done = value5.done;
if (!done) {
r12 = value5;
while (true) {
value6 = r12.value;
if (result) {
quality = value6.quality;
if (quality !== 100) {
a0[value6.ssrc] = 100;
break;
}
a0[value6.ssrc] = value2;
break;
}
ssrc = value6.ssrc;
a0[ssrc] = a1;
value7 = value4();
done = value7.done;
if (done) {
break;
}
r12 = value7;
continue;
}
}
value8 = typeof r8 === 'bigint' ? r8 + 1n : +r8 + 1;
length = value.length;
if (value8 < length) {
r8 = value8;
continue;
}
break;
}
}
Object = global.Object;
value = Object.values(this.audioSsrcs);
length = value.length;
if (value2 < length) {
for (r4 = value2; true; r4 = value9) {
a0[value[r4]] = 100;
value9 = typeof r4 === 'bigint' ? r4 + 1n : +r4 + 1;
length = value.length;
if (!(value9 < length)) {
break;
}
}
}
}
function value_94391(a0) { // fn#94391, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:6785, offset: 0x02116924, size: 418 bytes, params: 2, frame: 18
var removeListener;
const BaseConnectionEvent = (MediaEngineModule).BaseConnectionEvent;
var addListener;
let value = a1;
const r1 = !(value !== undefined) || value;
let connection = this.connection;
if (connection != null) {
removeListener = connection.removeListener;
value = environment.__proto__;
Reflect.apply(removeListener, connection, [BaseConnectionEvent.LocalVideoDisabled,
this.handleLocalVideoDisabled]);
}
connection = this.connection;
if (connection != null) {
removeListener = connection.removeListener;
value = environment.__proto__;
Reflect.apply(removeListener, connection, [BaseConnectionEvent.LocalMute, this.handleLocalMute]);
}
connection = this.connection;
if (connection != null) {
removeListener = connection.removeListener;
value = environment.__proto__;
Reflect.apply(removeListener, connection, [BaseConnectionEvent.ActiveSinksChange, this.delayedUpdate]);
}
this.connection = a0;
connection = this.connection;
if (connection != null) {
addListener = connection.addListener;
value = environment.__proto__;
Reflect.apply(addListener, connection, [BaseConnectionEvent.LocalVideoDisabled, this.handleLocalVideoDisabled]);
}
connection = this.connection;
if (connection != null) {
addListener = connection.addListener;
value = environment.__proto__;
Reflect.apply(addListener, connection, [BaseConnectionEvent.LocalMute, this.handleLocalMute]);
}
connection = this.connection;
if (connection != null) {
addListener = connection.addListener;
value = environment.__proto__;
Reflect.apply(addListener, connection, [BaseConnectionEvent.ActiveSinksChange, this.delayedUpdate]);
}
if (r1) {
this.update();
}
}
function value_94393(a0, a1) { // fn#94393, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:7671, offset: 0x02116af7, size: 289 bytes, params: 3, frame: 19
var environment;
var r4;
var videoSsrcs;
var _createForOfIteratorHelperLoose_94368Binding;
var value2;
var done;
var value3;
var ssrc;
var framesReceived;
var value4;
var emit;
let value = a1.filter(function(a0) {
var r0;
var value;
var property = a0.active;
if (property) {
property = a0.ssrc;
value = 0;
value = (property ?? value) > value;
r0 = value;
} else {
r0 = property;
}
return r0;
});
value = value.map(function(a0) {
return {quality: a0.quality ?? 100, ssrc: a0.ssrc};
});
if (value.length > 0) {
this.videoSsrcs[a0] = value;
this.participants.add(a0);
} else {
videoSsrcs = this.videoSsrcs;
reducibleJoin4: while (true) {
if (videoSsrcs[a0] === undefined) {
break reducibleJoin4;
}
value = environment.__proto__;
_createForOfIteratorHelperLoose_94368Binding = _createForOfIteratorHelperLoose_94368;
videoSsrcs = this.videoSsrcs;
value = _createForOfIteratorHelperLoose_94368Binding(videoSsrcs[a0]);
value2 = value();
done = value2.done;
if (done) {
break reducibleJoin4;
}
r4 = value2;
reducibleLoop3: while (true) {
value3 = r4.value;
ssrc = value3.ssrc;
framesReceived = this.framesReceived;
delete framesReceived[ssrc];
value4 = value();
done = value4.done;
if (done) {
break reducibleJoin4;
}
r4 = value4;
continue reducibleLoop3;
}
}
delete this.remoteVideoSsrcs[a0];
videoSsrcs = this.videoSsrcs;
delete videoSsrcs[a0];
this.participants.delete(a0);
emit = this.emit;
value = environment.__proto__;
Reflect.apply(emit, this, [env1_16.UserSSRCUpdate, a0, this.audioSsrcs[a0], []]);
}
const update = this.update;
const Array = global.Array;
return Reflect.apply(update, this, [Array.from(this.participants)]);
}
function value_94399() { // fn#94399, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:8786, offset: 0x02116d49, size: 157 bytes, params: 1, frame: 16
this.setConnection(null, false);
this.audioSsrcs = {};
this.videoSsrcs = {};
this.remoteVideoSsrcs = {};
this.framesReceived = {};
this.streamIds = {};
this.streamPixelCounts = {};
this.latestWants = getDefaultWants(100);
const WindowVisibilityVideoManager = (WindowVisibilityVideoManagerModule).WindowVisibilityVideoManager;
const off = WindowVisibilityVideoManager.off;
const WindowVisibilityEvent = (WindowVisibilityVideoManagerModule).WindowVisibilityEvent;
const IncomingVideoEnabledChanged = WindowVisibilityEvent.IncomingVideoEnabledChanged;
Reflect.apply(off, WindowVisibilityVideoManager, [IncomingVideoEnabledChanged, this.incomingVideoEnabledChanged]);
}
function value_94400(a0) { // fn#94400, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:9166, offset: 0x02116de6, size: 188 bytes, params: 2, frame: 16
var participants;
if (a0 === this.selectedParticipantId) {
return this.latestWants;
}
const items2 = [];
if (this.selectedParticipantId != null && this.selectedParticipantId !== this.userId) {
items2.push(this.selectedParticipantId);
}
if (a0 != null) {
participants = this.participants;
if (participants.has(a0)) {
this.selectedParticipantId = a0;
items2.push(a0);
return this.update(items2.filter(_fun94401));
}
if (this.userId !== a0) {
return this.latestWants;
}
this.selectedParticipantId = a0;
} else {
this.selectedParticipantId = null;
}
return this.update(items2.filter(_fun94401));
function _fun94401(a0) { // fn#94401, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:9577, offset: 0x02116ea2, size: 45 bytes, params: 2, frame: 3
return env0_0.videoSsrcs[a0]?.length > 1;
}
}
function value_94407() { // fn#94407, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12575:10352, offset: 0x02116fd8, size: 27 bytes, params: 1, frame: 3
return this.isStageChannel ? env1_14 : env1_13;
}
}
}
global.__d(_fun94367, 12389, [57, 6, 7, 15, 17, 18, 1226, 661, 4291, 672, 4221, 12390, 4460, 21, 477, 628, 22, 4041,
10682, 4406, 4479,
2]) /* metro module 12389, dependencies: [57, 6, 7, 15, 17, 18, 1226, 661, 4291, 672, 4221, 12390, 4460, 21, 477, 628, 22, 4041, 10682, 4406, 4479, 2] */;