fcr-core
Version:
Core APIs for building online scenes
172 lines (167 loc) • 6.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isTrueValue = exports.isEndpointRegionDisabled = exports.getScribbleForgeIpList = exports.getRtcPresetParameters = exports.getNetlessLogFileSize = exports.getNeedLogUpload = exports.getEasemobRestIpList = exports.getEasemobLogFileSize = exports.getEasemobChatIpList = exports.getCoreLogFileSize = exports.getCoreIpList = void 0;
require("core-js/modules/es.json.stringify.js");
require("core-js/modules/esnext.set.add-all.js");
require("core-js/modules/esnext.set.delete-all.js");
require("core-js/modules/esnext.set.difference.v2.js");
require("core-js/modules/esnext.set.difference.js");
require("core-js/modules/esnext.set.every.js");
require("core-js/modules/esnext.set.filter.js");
require("core-js/modules/esnext.set.find.js");
require("core-js/modules/esnext.set.intersection.v2.js");
require("core-js/modules/esnext.set.intersection.js");
require("core-js/modules/esnext.set.is-disjoint-from.v2.js");
require("core-js/modules/esnext.set.is-disjoint-from.js");
require("core-js/modules/esnext.set.is-subset-of.v2.js");
require("core-js/modules/esnext.set.is-subset-of.js");
require("core-js/modules/esnext.set.is-superset-of.v2.js");
require("core-js/modules/esnext.set.is-superset-of.js");
require("core-js/modules/esnext.set.join.js");
require("core-js/modules/esnext.set.map.js");
require("core-js/modules/esnext.set.reduce.js");
require("core-js/modules/esnext.set.some.js");
require("core-js/modules/esnext.set.symmetric-difference.v2.js");
require("core-js/modules/esnext.set.symmetric-difference.js");
require("core-js/modules/esnext.set.union.v2.js");
require("core-js/modules/esnext.set.union.js");
var _imports = require("../imports");
const DEFAULT_LOG_FILE_SIZE = 512;
/** RTC preset parameters configuration mapping table */
const RTC_PRESET_PARAMS_MAP = {
[_imports.FcrApplicationPlatform.WINDOWS]: [{
'rtc.video.default_hw_decoder_thres': 921600
}, {
'rtc.video.h264_hw_min_res_level': 4
}],
[_imports.FcrApplicationPlatform.MACOS]: [{
'che.video.screenCaptureMode': 1
}, {
'che.video.screen_disable_frame_transparent_check': true
}, {
'rtc.video.h264_hw_min_res_level': 4
}],
[_imports.FcrApplicationPlatform.WEB_DESKTOP]: [{
RESTRICTION_SET_PLAYBACK_DEVICE: false
}],
[_imports.FcrApplicationPlatform.HARMONY]: [{
'engine.video.enable_hw_encoder': false
}]
};
/** HARMONY or ELECTRON common parameters */
const HARMONY_OR_ELECTRON_COMMON_PARAMS = [
// audio parameters settings
{
'che.audio.bitrate_level': 1
}, {
'che.audio.reset_apm_capture_state_for_microphone_track': false
},
// video parameters settings
{
'rtc.video.new_complexity': true
}, {
'rtc.video.default_complexity': 1027
}, {
'che.video.videoCodecIndex': 1
}, {
'che.video.minQP': 21
}, {
'rtc.video.enable_doc_screen_share_sr': true
}, {
'rtc.video.enable_pvc': false
}, {
'rtc.video.enable_sr': {
enabled: false,
mode: 2
}
}, {
'che.video.brightness_detection_enable': false
}, {
'che.video.lowest_dev_score_4_seg': 0
}, {
'che.video.lowest_dev_score_4_beauty': 0
}, {
'rtc.video.downMaxRetryTimes': 5
}, {
'rtc.video.low_stream_enable_hw_encoder': false
}, {
'rtc.video.enable_minor_stream_intra_request': true
}];
/** ELECTRON common parameters */
const ELECTRON_COMMON_PARAMS = [
// video parameters settings
{
'rtc.video.color_space_enable': true
}, {
'rtc.video.videoFullrange': 1
}, {
'rtc.video.matrixCoefficients': 5
}];
/** ELECTRON platforms set */
const ELECTRON_PLATFORMS = new Set([_imports.FcrApplicationPlatform.WINDOWS, _imports.FcrApplicationPlatform.MACOS, _imports.FcrApplicationPlatform.LINUX]);
/** HARMONY or ELECTRON platforms set */
const HARMONY_OR_ELECTRON_PLATFORMS = new Set([_imports.FcrApplicationPlatform.HARMONY, ...ELECTRON_PLATFORMS]);
const isTrueValue = value => {
return value === 'true' || !!value;
};
exports.isTrueValue = isTrueValue;
const getCoreIpList = parameters => {
return parameters?.core?.coreIpList;
};
exports.getCoreIpList = getCoreIpList;
const getEasemobChatIpList = parameters => {
return parameters?.core?.easemobChatIpList;
};
exports.getEasemobChatIpList = getEasemobChatIpList;
const getEasemobRestIpList = parameters => {
return parameters?.core?.easemobRestIpList;
};
exports.getEasemobRestIpList = getEasemobRestIpList;
const getScribbleForgeIpList = parameters => {
return parameters?.core?.scribbleForgeIpList;
};
exports.getScribbleForgeIpList = getScribbleForgeIpList;
const isEndpointRegionDisabled = parameters => {
return isTrueValue(parameters?.core?.disableEndpointRegion);
};
exports.isEndpointRegionDisabled = isEndpointRegionDisabled;
const getNeedLogUpload = parameters => {
if ((0, _imports.isBoolean)(parameters?.core?.needLogUpload)) {
return parameters.core.needLogUpload;
}
return true;
};
exports.getNeedLogUpload = getNeedLogUpload;
const getCoreLogFileSize = parameters => {
if (!(0, _imports.isNumber)(parameters?.core?.coreLogFileSize)) {
return DEFAULT_LOG_FILE_SIZE;
}
return parameters.core.coreLogFileSize;
};
exports.getCoreLogFileSize = getCoreLogFileSize;
const getEasemobLogFileSize = parameters => {
if (!(0, _imports.isNumber)(parameters?.core?.easemobLogFileSize)) {
return DEFAULT_LOG_FILE_SIZE;
}
return parameters.core.easemobLogFileSize;
};
exports.getEasemobLogFileSize = getEasemobLogFileSize;
const getNetlessLogFileSize = parameters => {
if (!(0, _imports.isNumber)(parameters?.core?.netlessLogFileSize)) {
return DEFAULT_LOG_FILE_SIZE;
}
return parameters.core.netlessLogFileSize;
};
/** desktop platforms set */
exports.getNetlessLogFileSize = getNetlessLogFileSize;
const DESKTOP_PLATFORMS = new Set([_imports.FcrApplicationPlatform.WINDOWS, _imports.FcrApplicationPlatform.MACOS]);
const getRtcPresetParameters = () => {
const platform = (0, _imports.getPlatform)();
const platformParams = RTC_PRESET_PARAMS_MAP[platform] ?? [];
const electronParams = ELECTRON_PLATFORMS.has(platform) ? ELECTRON_COMMON_PARAMS : [];
const harmonyOrElectronParams = HARMONY_OR_ELECTRON_PLATFORMS.has(platform) ? HARMONY_OR_ELECTRON_COMMON_PARAMS : [];
return [...platformParams, ...electronParams, ...harmonyOrElectronParams].map(p => JSON.stringify(p));
};
exports.getRtcPresetParameters = getRtcPresetParameters;