refactor: Migrate screen sharing media handling from direct WebRTC to Mediasoup.
This commit is contained in:
@@ -5,8 +5,10 @@ const PipewireHelper = require('./pipewire');
|
||||
// Ensure Chromium tries to use PipeWire for screen sharing on Linux
|
||||
app.commandLine.appendSwitch('enable-features', 'WebRTCPipeWireCapturer');
|
||||
|
||||
let mainWindow = null;
|
||||
|
||||
function createWindow() {
|
||||
const win = new BrowserWindow({
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 1000,
|
||||
height: 800,
|
||||
icon: path.join(__dirname, 'icon.png'),
|
||||
@@ -17,7 +19,11 @@ function createWindow() {
|
||||
}
|
||||
});
|
||||
|
||||
win.loadFile('index.html');
|
||||
mainWindow.loadFile('index.html');
|
||||
|
||||
mainWindow.on('closed', () => {
|
||||
mainWindow = null;
|
||||
});
|
||||
}
|
||||
|
||||
app.whenReady().then(async () => {
|
||||
@@ -26,6 +32,18 @@ app.whenReady().then(async () => {
|
||||
|
||||
createWindow();
|
||||
|
||||
// Monitor PipeWire graph for new/removed audio streams
|
||||
PipewireHelper.startMonitoring(async () => {
|
||||
try {
|
||||
const apps = await PipewireHelper.getAudioApplications();
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('audio-apps-updated', apps);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to refresh audio apps:', e);
|
||||
}
|
||||
});
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow();
|
||||
@@ -34,6 +52,7 @@ app.whenReady().then(async () => {
|
||||
});
|
||||
|
||||
app.on('will-quit', async () => {
|
||||
PipewireHelper.stopMonitoring();
|
||||
await PipewireHelper.destroyVirtualMic();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user