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";
|
||||
|
||||
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"],
|
||||
settings: {
|
||||
|
|
|
|||
|
|
@ -4,50 +4,34 @@
|
|||
* 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 definePlugin, { OptionType } from "@utils/types";
|
||||
import { MediaEngineStore } from "@webpack/common";
|
||||
|
||||
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,
|
||||
};
|
||||
import { CodecInfo } from "@vencord/discord-types";
|
||||
|
||||
const settings = definePluginSettings({
|
||||
disableAv1Codec: {
|
||||
description: "Make Discord not consider using AV1 for streaming.",
|
||||
description: "Make Discord not consider using AV1 for streaming and cameras.",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: false
|
||||
},
|
||||
disableH265Codec: {
|
||||
description: "Make Discord not consider using H265 for streaming.",
|
||||
description: "Make Discord not consider using H265 for streaming and cameras.",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: false
|
||||
},
|
||||
disableH264Codec: {
|
||||
description: "Make Discord not consider using H264 for streaming.",
|
||||
description: "Make Discord not consider using H264 for streaming and cameras.",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: false
|
||||
},
|
||||
disableVP8Codec: {
|
||||
description: "Make Discord not consider using VP8 for streaming.",
|
||||
description: "Make Discord not consider using VP8 for streaming and cameras.",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: false
|
||||
},
|
||||
disableVP9Codec: {
|
||||
description: "Make Discord not consider using VP9 for streaming.",
|
||||
description: "Make Discord not consider using VP9 for streaming and cameras.",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: false
|
||||
},
|
||||
|
|
@ -55,33 +39,30 @@ const settings = definePluginSettings({
|
|||
|
||||
export default definePlugin({
|
||||
name: "StreamingCodecDisabler",
|
||||
description: "Disable codecs for streaming of your choice",
|
||||
description: "Disable video codecs of your choice for streaming and cameras.",
|
||||
tags: ["Utility", "Voice"],
|
||||
authors: [EquicordDevs.davidkra230],
|
||||
settings,
|
||||
|
||||
patches: [
|
||||
{
|
||||
find: "setVideoBroadcast(this.shouldConnectionBroadcastVideo",
|
||||
find: "lastOverrideCodecDenylist.length",
|
||||
replacement: {
|
||||
match: /setGoLiveSource\(.,.\)\{/,
|
||||
replace: "$&$self.updateDisabledCodecs();"
|
||||
match: /(let \i=)(\i\(\i\))(?=,\i=this\.lastOverrideCodecDenylist\.length)/,
|
||||
replace: "$1$self.filterCodecs($2)"
|
||||
},
|
||||
}
|
||||
],
|
||||
|
||||
async updateDisabledCodecs() {
|
||||
const mediaEngine = MediaEngineStore.getMediaEngine();
|
||||
const options = Object.keys(originalCodecStatuses);
|
||||
const CodecCapabilities = JSON.parse(await new Promise(res => mediaEngine.getCodecCapabilities(res)));
|
||||
CodecCapabilities.forEach((codec: { codec: string; encode: boolean; }) => {
|
||||
if (options.includes(codec.codec)) {
|
||||
originalCodecStatuses[codec.codec] = codec.encode;
|
||||
}
|
||||
});
|
||||
|
||||
mediaEngine.setAv1Enabled(originalCodecStatuses.AV1 && !Settings.plugins.StreamingCodecDisabler.disableAv1Codec);
|
||||
mediaEngine.setH265Enabled(originalCodecStatuses.H265 && !Settings.plugins.StreamingCodecDisabler.disableH265Codec);
|
||||
mediaEngine.setH264Enabled(originalCodecStatuses.H264 && !Settings.plugins.StreamingCodecDisabler.disableH264Codec);
|
||||
filterCodecs(codecs: CodecInfo[]) {
|
||||
const { store } = settings;
|
||||
const disabled: Record<string, boolean> = {
|
||||
AV1: store.disableAv1Codec,
|
||||
H265: store.disableH265Codec,
|
||||
H264: store.disableH264Codec,
|
||||
VP8: store.disableVP8Codec,
|
||||
VP9: store.disableVP9Codec,
|
||||
};
|
||||
return codecs.map(c => disabled[c.name] ? { ...c, encode: false } : c);
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue