decord/alpha/source/modules/rtc/RTCLatencyTestManager.tsx

91 lines
3.7 KiB
TypeScript
Raw Permalink Normal View History

2026-10-13 12:43:34 +00:00
// Module ID: 18240
// Function ID: 18241
// Name: RTCLatencyTestManager
2026-10-13 12:43:34 +00:00
// Dependencies: [2012, 5211, 5117, 1102, 3, 6808, 18241, 1382, 2]
2026-07-20 16:05:17 +00:00
2026-10-13 12:43:34 +00:00
// Module 18240 (RTCLatencyTestManager)
import LoggerDefault from "Logger" /* 3 */;
2026-10-03 08:58:59 +00:00
import DurationsDefault from "Durations" /* 1102 */;
2026-10-09 10:00:15 +00:00
import PlatformUtils from "PlatformUtils" /* 1382 */;
2026-10-10 08:08:14 +00:00
import Constants from "Constants" /* 5117 */;
2026-10-13 12:43:34 +00:00
import RTCLatencyTestActionCreators from "RTCLatencyTestActionCreators" /* 18241 */;
2026-10-09 10:00:15 +00:00
import MediaEngineStore from "MediaEngineStore" /* 2012 */;
2026-10-10 08:08:14 +00:00
import RTCRegionStore from "RTCRegionStore" /* 5211 */;
2026-10-12 06:59:38 +00:00
import AutomaticLifecycleManager from "AutomaticLifecycleManager" /* 6808 */;
2026-10-03 08:58:59 +00:00
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-10-03 08:58:59 +00:00
let mediaEngine;
const Features = Constants.Features;
const SECOND = DurationsDefault.Millis.SECOND;
let closure_7 = 30 * DurationsDefault.Millis.SECOND;
let obj = new LoggerDefault("RTCLatencyTestManager");
2026-07-29 08:29:29 +00:00
obj.enableNativeLogger(true);
2026-10-03 08:58:59 +00:00
class RTCLatencyTestManager extends AutomaticLifecycleManager {
2026-07-29 08:29:29 +00:00
constructor() {
2026-10-03 08:58:59 +00:00
const applyArgumentsResult = HermesBuiltin.applyArguments(this, new.target);
require = applyArgumentsResult;
2026-07-29 08:29:29 +00:00
applyArgumentsResult.actions = {
POST_CONNECTION_OPEN() {
2026-10-03 08:58:59 +00:00
return require._handleConnectionOpen();
}
2026-07-29 08:29:29 +00:00
};
applyArgumentsResult._handleTestRegionsResponse = function _handleTestRegionsResponse(body) {
const mapped = body.map((region) => region.region);
2026-10-03 08:58:59 +00:00
obj = closure_4;
2026-08-24 06:08:38 +00:00
if (closure_4.shouldPerformLatencyTest(mapped)) {
2026-07-29 08:29:29 +00:00
mediaEngine = mediaEngine.getMediaEngine();
const rankRtcRegionsResult = mediaEngine.rankRtcRegions(body);
2026-10-03 08:58:59 +00:00
const nextPromise = rankRtcRegionsResult.then((result) => {
closure_2_8.verbose("RTC region latency test completed, ranked regions are: ", result);
obj = RTCLatencyTestActionCreators;
result = obj.completeRTCLatencyTest(result, mapped);
2026-07-29 08:29:29 +00:00
});
2026-10-03 08:58:59 +00:00
nextPromise.catch((error) => logger.warn(error));
2026-07-29 08:29:29 +00:00
} else {
const _HermesInternal = HermesInternal;
2026-10-03 08:58:59 +00:00
logger.verbose("RTC cached ranked preferred regions are " + obj.getPreferredRegions());
2026-07-29 08:29:29 +00:00
}
};
applyArgumentsResult._fetchAndScheduleRefetch = function _fetchAndScheduleRefetch() {
2026-10-03 08:58:59 +00:00
let logger;
2026-07-29 08:29:29 +00:00
let num = 1;
if (MediaEngineStore.supports(Features.PORT_AWARE_LATENCY_TESTING)) {
2026-07-29 08:29:29 +00:00
num = 2;
}
2026-10-03 08:58:59 +00:00
obj = RTCLatencyTestActionCreators;
const rTCLatencyTestRegions = obj.fetchRTCLatencyTestRegions(num);
const nextPromise = rTCLatencyTestRegions.then((body) => closure_1_0._handleTestRegionsResponse(body.body));
nextPromise.catch((error) => logger.warn(error));
require.refetchTimeout = setTimeout(require._fetchAndScheduleRefetch, 360 * DurationsDefault.Millis.MINUTE);
2026-07-29 08:29:29 +00:00
};
applyArgumentsResult._handleConnectionOpen = function _handleConnectionOpen() {
2026-07-31 08:44:05 +00:00
if (null != window.GLOBAL_ENV.RTC_LATENCY_ENDPOINT) {
if (PlatformUtils.isPlatformEmbedded) {
2026-07-31 08:44:05 +00:00
const _Math = Math;
const _Math2 = Math;
const rounded = Math.floor(SECOND + Math.random() * closure_7);
2026-10-03 08:58:59 +00:00
if (null != require.refetchTimeout) {
2026-07-31 08:44:05 +00:00
const _clearTimeout = clearTimeout;
2026-10-03 08:58:59 +00:00
clearTimeout(require.refetchTimeout);
2026-07-31 08:44:05 +00:00
}
const _setTimeout = setTimeout;
2026-10-03 08:58:59 +00:00
require.refetchTimeout = setTimeout(require._fetchAndScheduleRefetch, rounded);
2026-07-29 08:29:29 +00:00
}
}
};
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
_terminate() {
if (null != this.refetchTimeout) {
const _clearTimeout = clearTimeout;
clearTimeout(tmp.refetchTimeout);
}
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
}
const prototype = RTCLatencyTestManager.prototype;
2026-07-29 08:29:29 +00:00
const rTCLatencyTestManager = new RTCLatencyTestManager();
let result = size.fileFinishedImporting("modules/rtc/RTCLatencyTestManager.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default rTCLatencyTestManager;