mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-07 13:43:03 -04:00
create the StreamingCodecDisabler plugin (#277)
* create StreamingCodecDisabler * fixes * fix typo for av1 * Fixes --------- Co-authored-by: thororen1234 <78185467+thororen1234@users.noreply.github.com>
This commit is contained in:
parent
973148d86d
commit
8162a628a1
3 changed files with 87 additions and 1 deletions
|
@ -11,7 +11,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch
|
|||
### Extra included plugins
|
||||
|
||||
<details>
|
||||
<summary>183 additional plugins</summary>
|
||||
<summary>184 additional plugins</summary>
|
||||
|
||||
### All Platforms
|
||||
|
||||
|
@ -160,6 +160,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch
|
|||
- StatusPresets by iamme
|
||||
- SteamStatusSync by niko
|
||||
- StickerBlocker by Samwich
|
||||
- StreamingCodecDisabler by davidkra230
|
||||
- TalkInReverse by Tolgchu
|
||||
- TeX by Kyuuhachi
|
||||
- TextToSpeech by Samwich
|
||||
|
|
81
src/equicordplugins/streamingCodecDisabler/index.ts
Normal file
81
src/equicordplugins/streamingCodecDisabler/index.ts
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2025 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { definePluginSettings, Settings } from "@api/Settings";
|
||||
import { EquicordDevs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findStoreLazy } from "@webpack";
|
||||
|
||||
const mediaEngine = findStoreLazy("MediaEngineStore");
|
||||
|
||||
const originalCodecStatuses: {
|
||||
AV1: boolean,
|
||||
H265: boolean,
|
||||
H264: boolean;
|
||||
} = {
|
||||
AV1: true,
|
||||
H265: true,
|
||||
H264: true
|
||||
};
|
||||
|
||||
const settings = definePluginSettings({
|
||||
disableAv1Codec: {
|
||||
description: "Make Discord not consider using AV1 for streaming.",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: false
|
||||
},
|
||||
disableH265Codec: {
|
||||
description: "Make Discord not consider using H265 for streaming.",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: false
|
||||
},
|
||||
disableH264Codec: {
|
||||
description: "Make Discord not consider using H264 for streaming.",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: false
|
||||
},
|
||||
});
|
||||
|
||||
export default definePlugin({
|
||||
name: "StreamingCodecDisabler",
|
||||
description: "Disable codecs for streaming of your choice",
|
||||
authors: [EquicordDevs.davidkra230],
|
||||
settings,
|
||||
|
||||
patches: [
|
||||
{
|
||||
find: "setVideoBroadcast(this.shouldConnectionBroadcastVideo",
|
||||
replacement: {
|
||||
match: /setGoLiveSource\(.,.\)\{/,
|
||||
replace: "$&$self.updateDisabledCodecs();"
|
||||
},
|
||||
}
|
||||
],
|
||||
|
||||
async updateDisabledCodecs() {
|
||||
mediaEngine.setAv1Enabled(originalCodecStatuses.AV1 && !Settings.plugins.StreamingCodecDisabler.disableAv1Codec);
|
||||
mediaEngine.setH265Enabled(originalCodecStatuses.H265 && !Settings.plugins.StreamingCodecDisabler.disableH265Codec);
|
||||
mediaEngine.setH264Enabled(originalCodecStatuses.H264 && !Settings.plugins.StreamingCodecDisabler.disableH264Codec);
|
||||
},
|
||||
|
||||
async start() {
|
||||
const engine = mediaEngine.getMediaEngine();
|
||||
const options = Object.keys(originalCodecStatuses);
|
||||
// [{"codec":"","decode":false,"encode":false}]
|
||||
const CodecCapabilities = JSON.parse(await new Promise(res => engine.getCodecCapabilities(res)));
|
||||
CodecCapabilities.forEach((codec: { codec: string; encode: boolean; }) => {
|
||||
if (options.includes(codec.codec)) {
|
||||
originalCodecStatuses[codec.codec] = codec.encode;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
async stop() {
|
||||
mediaEngine.setAv1Enabled(originalCodecStatuses.AV1);
|
||||
mediaEngine.setH265Enabled(originalCodecStatuses.H265);
|
||||
mediaEngine.setH264Enabled(originalCodecStatuses.H264);
|
||||
}
|
||||
});
|
|
@ -1082,6 +1082,10 @@ export const EquicordDevs = Object.freeze({
|
|||
name: "bbgaming25k",
|
||||
id: 851222385528274964n,
|
||||
},
|
||||
davidkra230: {
|
||||
name: "davidkra230",
|
||||
id: 652699312631054356n,
|
||||
},
|
||||
GroupXyz: {
|
||||
name: "GroupXyz",
|
||||
id: 950033410229944331n
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue