Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Commit

Permalink
deploy: 032b69c
Browse files Browse the repository at this point in the history
  • Loading branch information
smartfrigde committed Jun 16, 2024
1 parent c31c1d9 commit e1196a7
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 39 deletions.
38 changes: 0 additions & 38 deletions hello-world/plugin.js

This file was deleted.

1 change: 0 additions & 1 deletion hello-world/plugin.json

This file was deleted.

136 changes: 136 additions & 0 deletions screenshareQualityFix/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
(() => {
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// shltr-res-ns:solid-js/web
var require_web = __commonJS({
"shltr-res-ns:solid-js/web"(exports, module) {
module.exports = shelter.solidWeb;
}
});

// plugins/screenshareQualityFix/index.js
var screenshareQualityFix_exports = {};
__export(screenshareQualityFix_exports, {
onLoad: () => onLoad,
onUnload: () => onUnload,
settings: () => settings_default
});

// plugins/screenshareQualityFix/settings.jsx
var import_web = __toESM(require_web(), 1);
var import_web2 = __toESM(require_web(), 1);
var {
plugin: {
store
},
ui: {
TextBox,
Header,
HeaderTags
}
} = shelter;
var settings_default = () => [(0, import_web2.createComponent)(Header, {
get tag() {
return HeaderTags.H1;
},
children: "Resolution"
}), (0, import_web2.createComponent)(TextBox, {
placeholder: "720/1080/1440",
get value() {
return Number.isSafeInteger(store.resolution) ? store.resolution : "";
},
onInput: (v) => {
store.resolution = parseInt(v);
}
}), (0, import_web2.createComponent)(Header, {
get tag() {
return HeaderTags.H1;
},
children: "FPS"
}), (0, import_web2.createComponent)(TextBox, {
placeholder: "15/30/60",
get value() {
return Number.isSafeInteger(store.fps) ? store.fps : "";
},
onInput: (v) => {
store.fps = parseInt(v);
}
})];

// plugins/screenshareQualityFix/index.js
var {
util: { log },
flux: { stores: { UserStore, MediaEngineStore }, dispatcher, intercept },
plugin: { store: store2 }
} = shelter;
store2.fps ??= 30;
store2.resolution ??= 720;
var unintercept;
function onStreamQualityChange() {
const mediaConnections = [...MediaEngineStore.getMediaEngine().connections];
const currentUserId = UserStore.getCurrentUser().id;
const streamConnection = mediaConnections.find((connection) => connection.streamUserId === currentUserId);
if (streamConnection) {
streamConnection.videoStreamParameters[0].maxFrameRate = store2.fps;
streamConnection.videoStreamParameters[0].maxResolution.height = store2.resolution;
streamConnection.videoStreamParameters[0].maxResolution.width = Math.round(store2.resolution * (16 / 9));
log(`Patched current user stream with resolution: ${store2.resolution} and fps: ${store2.fps}`);
}
}
function onLoad() {
dispatcher.subscribe("MEDIA_ENGINE_VIDEO_SOURCE_QUALITY_CHANGED", onStreamQualityChange);
unintercept = intercept((dispatch) => {
if (dispatch.type == "MEDIA_ENGINE_SET_GO_LIVE_SOURCE") {
if (dispatch.settings.qualityOptions)
dispatch.settings.qualityOptions = {
preset: 2,
resolution: store2.resolution,
frameRate: store2.fps
};
} else if (dispatch.type == "MEDIA_ENGINE_VIDEO_SOURCE_QUALITY_CHANGED") {
dispatch.maxResolution = {
type: "fixed",
width: Math.round(store2.resolution * (16 / 9)),
height: store2.resolution
};
dispatch.maxFrameRate = 60;
} else {
return;
}
});
}
function onUnload() {
dispatcher.unsubscribe("MEDIA_ENGINE_VIDEO_SOURCE_QUALITY_CHANGED", onStreamQualityChange);
unintercept();
}
return __toCommonJS(screenshareQualityFix_exports);
})();
1 change: 1 addition & 0 deletions screenshareQualityFix/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"Screenshare Quality Fix","author":"smartfrigde","description":"Allows ArmCord/Web users to change the quality of their screenshare.","hash":"cc7f607b8a8c547a0ae8753e4f9c977a"}

0 comments on commit e1196a7

Please sign in to comment.