StreamingCodecDisabler: Fix Deprecated Stuff
This commit is contained in:
parent
6ba7fe10d3
commit
c95f667229
2 changed files with 22 additions and 41 deletions
|
|
@ -13,7 +13,7 @@ import unusedImports from "eslint-plugin-unused-imports";
|
||||||
import tseslint from "typescript-eslint";
|
import tseslint from "typescript-eslint";
|
||||||
|
|
||||||
export default defineConfig(
|
export default defineConfig(
|
||||||
{ ignores: ["dist", "browser", "packages/vencord-types"] },
|
{ ignores: ["dist", "browser", "packages/vencord-types", "misc/bundle", "misc/scripts"] },
|
||||||
{
|
{
|
||||||
files: ["src/**/*.{tsx,ts,mts,mjs,js,jsx}", "eslint.config.mjs"],
|
files: ["src/**/*.{tsx,ts,mts,mjs,js,jsx}", "eslint.config.mjs"],
|
||||||
settings: {
|
settings: {
|
||||||
|
|
|
||||||
|
|
@ -4,50 +4,34 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { definePluginSettings, Settings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { EquicordDevs } from "@utils/constants";
|
import { EquicordDevs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { MediaEngineStore } from "@webpack/common";
|
import { CodecInfo } from "@vencord/discord-types";
|
||||||
|
|
||||||
interface Codecs {
|
|
||||||
AV1: boolean;
|
|
||||||
H265: boolean,
|
|
||||||
H264: boolean;
|
|
||||||
VP8: boolean;
|
|
||||||
VP9: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
const originalCodecStatuses: Codecs = {
|
|
||||||
AV1: true,
|
|
||||||
H265: true,
|
|
||||||
H264: true,
|
|
||||||
VP8: true,
|
|
||||||
VP9: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
disableAv1Codec: {
|
disableAv1Codec: {
|
||||||
description: "Make Discord not consider using AV1 for streaming.",
|
description: "Make Discord not consider using AV1 for streaming and cameras.",
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
disableH265Codec: {
|
disableH265Codec: {
|
||||||
description: "Make Discord not consider using H265 for streaming.",
|
description: "Make Discord not consider using H265 for streaming and cameras.",
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
disableH264Codec: {
|
disableH264Codec: {
|
||||||
description: "Make Discord not consider using H264 for streaming.",
|
description: "Make Discord not consider using H264 for streaming and cameras.",
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
disableVP8Codec: {
|
disableVP8Codec: {
|
||||||
description: "Make Discord not consider using VP8 for streaming.",
|
description: "Make Discord not consider using VP8 for streaming and cameras.",
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
disableVP9Codec: {
|
disableVP9Codec: {
|
||||||
description: "Make Discord not consider using VP9 for streaming.",
|
description: "Make Discord not consider using VP9 for streaming and cameras.",
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
|
|
@ -55,33 +39,30 @@ const settings = definePluginSettings({
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "StreamingCodecDisabler",
|
name: "StreamingCodecDisabler",
|
||||||
description: "Disable codecs for streaming of your choice",
|
description: "Disable video codecs of your choice for streaming and cameras.",
|
||||||
tags: ["Utility", "Voice"],
|
tags: ["Utility", "Voice"],
|
||||||
authors: [EquicordDevs.davidkra230],
|
authors: [EquicordDevs.davidkra230],
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: "setVideoBroadcast(this.shouldConnectionBroadcastVideo",
|
find: "lastOverrideCodecDenylist.length",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /setGoLiveSource\(.,.\)\{/,
|
match: /(let \i=)(\i\(\i\))(?=,\i=this\.lastOverrideCodecDenylist\.length)/,
|
||||||
replace: "$&$self.updateDisabledCodecs();"
|
replace: "$1$self.filterCodecs($2)"
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
async updateDisabledCodecs() {
|
filterCodecs(codecs: CodecInfo[]) {
|
||||||
const mediaEngine = MediaEngineStore.getMediaEngine();
|
const { store } = settings;
|
||||||
const options = Object.keys(originalCodecStatuses);
|
const disabled: Record<string, boolean> = {
|
||||||
const CodecCapabilities = JSON.parse(await new Promise(res => mediaEngine.getCodecCapabilities(res)));
|
AV1: store.disableAv1Codec,
|
||||||
CodecCapabilities.forEach((codec: { codec: string; encode: boolean; }) => {
|
H265: store.disableH265Codec,
|
||||||
if (options.includes(codec.codec)) {
|
H264: store.disableH264Codec,
|
||||||
originalCodecStatuses[codec.codec] = codec.encode;
|
VP8: store.disableVP8Codec,
|
||||||
}
|
VP9: store.disableVP9Codec,
|
||||||
});
|
};
|
||||||
|
return codecs.map(c => disabled[c.name] ? { ...c, encode: false } : c);
|
||||||
mediaEngine.setAv1Enabled(originalCodecStatuses.AV1 && !Settings.plugins.StreamingCodecDisabler.disableAv1Codec);
|
|
||||||
mediaEngine.setH265Enabled(originalCodecStatuses.H265 && !Settings.plugins.StreamingCodecDisabler.disableH265Codec);
|
|
||||||
mediaEngine.setH264Enabled(originalCodecStatuses.H264 && !Settings.plugins.StreamingCodecDisabler.disableH264Codec);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue