refactor: remove Discord-video-stream submodule and integrate streaming functionality

This commit is contained in:
MythEclipse
2026-05-17 05:10:46 +07:00
parent 7985efbef6
commit 5a926dbd17
11 changed files with 129 additions and 64 deletions
+6 -1
View File
@@ -82,8 +82,13 @@ export class MediaController {
}
// mode === "music"
// Stop screen if active
// If a screen share is active outside of this controller (browser-owned),
// reject to avoid stealing the shared player. If this controller started
// the screenPlayback, stop it and proceed.
if (this.screenPlayback || this.dependencies.screenController?.isActive()) {
if (this.dependencies.screenController?.isActive() && !this.screenPlayback) {
throw new AppError("Another media mode is active", "MEDIA_BUSY", 409);
}
this.screenPlayback?.stop();
this.screenPlayback = null;
this.activeMode = null;
+8 -6
View File
@@ -1,12 +1,11 @@
import type { Readable } from "node:stream";
import type { WebRtcConnWrapper } from "@dank074/discord-video-stream";
import {
playStream as defaultPlayStream,
prepareStream as defaultPrepareStream,
Encoders,
Streamer,
Utils,
} from "@dank074/discord-video-stream";
} from "../streaming";
import { AppError } from "../errors";
import { createChildLogger } from "../logger";
import { discordPlayer } from "../player";
@@ -45,10 +44,7 @@ export interface ScreenShareControllerDependencies {
prepareStream?: PrepareScreenStream;
playStream?: PlayScreenStream;
streamer: Streamer;
joinVoice?: (
guildId: string,
channelId: string,
) => Promise<WebRtcConnWrapper>;
joinVoice?: (guildId: string, channelId: string) => Promise<unknown>;
onStreamStart?: () => void;
onStreamEnd?: () => void;
}
@@ -93,6 +89,12 @@ export function createScreenShareController(
);
}
// If another media owner (e.g. music) holds the shared player, reject
const owner = getPlayerOwner();
if (owner === "music") {
throw new AppError("Another media mode is active", "MEDIA_BUSY", 409);
}
try {
// Join voice via Streamer if not already connected for streaming
if (dependencies.joinVoice) {