Compare commits
3 Commits
autogain
...
58c3ac0b71
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58c3ac0b71 | ||
|
|
2858eb3854 | ||
|
|
94b27f5b6a |
23
.gitignore
vendored
23
.gitignore
vendored
@@ -1,3 +1,20 @@
|
|||||||
/build
|
# Ignore build and output directories
|
||||||
.vscode
|
/build/
|
||||||
/submodules/arrpc
|
/.flatpak-builder/
|
||||||
|
|
||||||
|
# Ignore flatpak-builder cache
|
||||||
|
/.flatpak-builder-cache/
|
||||||
|
|
||||||
|
# Ignore flatpak-builder log files
|
||||||
|
/*.log
|
||||||
|
|
||||||
|
# Ignore flatpak-builder generated files
|
||||||
|
/*.flatpak
|
||||||
|
/*.flatpak-builder
|
||||||
|
/*.flatpak-origin
|
||||||
|
|
||||||
|
# Ignore specific files or directories
|
||||||
|
/override.json
|
||||||
|
/metadata/
|
||||||
|
/manifest.json
|
||||||
|
/CMakeLists.txt.user
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
navigator.mediaDevices.chromiumGetDisplayMedia =
|
navigator.mediaDevices.chromiumGetDisplayMedia =
|
||||||
navigator.mediaDevices.getDisplayMedia;
|
navigator.mediaDevices.getDisplayMedia;
|
||||||
navigator.mediaDevices.chromiumGetUserMedia =
|
|
||||||
navigator.mediaDevices.getUserMedia;
|
|
||||||
|
|
||||||
function sleep(ms) {
|
function sleep(ms) {
|
||||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
const getAudioDevice = async (nameOfAudioDevice) => {
|
const getAudioDevice = async (nameOfAudioDevice) => {
|
||||||
await navigator.mediaDevices.chromiumGetUserMedia({
|
await navigator.mediaDevices.getUserMedia({
|
||||||
audio: true,
|
audio: true,
|
||||||
});
|
});
|
||||||
let audioDevice;
|
let audioDevice;
|
||||||
@@ -25,16 +23,6 @@ const getAudioDevice = async (nameOfAudioDevice) => {
|
|||||||
return audioDevice;
|
return audioDevice;
|
||||||
};
|
};
|
||||||
|
|
||||||
function setGetUserMedia() {
|
|
||||||
const getUserMedia = async (constraints) => {
|
|
||||||
return await navigator.mediaDevices.chromiumGetUserMedia({
|
|
||||||
video: constraints?.video || false,
|
|
||||||
audio: { ...constraints?.audio, autoGainControl },
|
|
||||||
});
|
|
||||||
};
|
|
||||||
navigator.mediaDevices.getUserMedia = getUserMedia;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setGetDisplayMedia(video = true, overrideArgs = undefined) {
|
function setGetDisplayMedia(video = true, overrideArgs = undefined) {
|
||||||
const getDisplayMedia = async (...args) => {
|
const getDisplayMedia = async (...args) => {
|
||||||
var id;
|
var id;
|
||||||
@@ -46,27 +34,26 @@ function setGetDisplayMedia(video = true, overrideArgs = undefined) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
id = "default";
|
id = "default";
|
||||||
}
|
}
|
||||||
let captureSystemAudioStream =
|
let captureSystemAudioStream = await navigator.mediaDevices.getUserMedia({
|
||||||
await navigator.mediaDevices.chromiumGetUserMedia({
|
audio: {
|
||||||
audio: {
|
// We add our audio constraints here, to get a list of supported constraints use navigator.mediaDevices.getSupportedConstraints();
|
||||||
// We add our audio constraints here, to get a list of supported constraints use navigator.mediaDevices.getSupportedConstraints();
|
// We must capture a microphone, we use default since its the only deviceId that is the same for every Chromium user
|
||||||
// We must capture a microphone, we use default since its the only deviceId that is the same for every Chromium user
|
deviceId: {
|
||||||
deviceId: {
|
exact: id,
|
||||||
exact: id,
|
|
||||||
},
|
|
||||||
// We want auto gain control, noise cancellation and noise suppression disabled so that our stream won't sound bad
|
|
||||||
autoGainControl: false,
|
|
||||||
echoCancellation: false,
|
|
||||||
noiseSuppression: false,
|
|
||||||
// By default Chromium sets channel count for audio devices to 1, we want it to be stereo in case we find a way for Discord to accept stereo screenshare too
|
|
||||||
channelCount: 2,
|
|
||||||
// You can set more audio constraints here, bellow are some examples
|
|
||||||
//latency: 0,
|
|
||||||
//sampleRate: 48000,
|
|
||||||
//sampleSize: 16,
|
|
||||||
//volume: 1.0
|
|
||||||
},
|
},
|
||||||
});
|
// We want auto gain control, noise cancellation and noise suppression disabled so that our stream won't sound bad
|
||||||
|
autoGainControl: false,
|
||||||
|
echoCancellation: false,
|
||||||
|
noiseSuppression: false,
|
||||||
|
// By default Chromium sets channel count for audio devices to 1, we want it to be stereo in case we find a way for Discord to accept stereo screenshare too
|
||||||
|
channelCount: 2,
|
||||||
|
// You can set more audio constraints here, bellow are some examples
|
||||||
|
//latency: 0,
|
||||||
|
//sampleRate: 48000,
|
||||||
|
//sampleSize: 16,
|
||||||
|
//volume: 1.0
|
||||||
|
},
|
||||||
|
});
|
||||||
let [track] = captureSystemAudioStream.getAudioTracks();
|
let [track] = captureSystemAudioStream.getAudioTracks();
|
||||||
const gdm = await navigator.mediaDevices.chromiumGetDisplayMedia(
|
const gdm = await navigator.mediaDevices.chromiumGetDisplayMedia(
|
||||||
...(overrideArgs
|
...(overrideArgs
|
||||||
@@ -81,7 +68,6 @@ function setGetDisplayMedia(video = true, overrideArgs = undefined) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setGetDisplayMedia();
|
setGetDisplayMedia();
|
||||||
setGetUserMedia();
|
|
||||||
|
|
||||||
let userscript;
|
let userscript;
|
||||||
let muteBtn;
|
let muteBtn;
|
||||||
@@ -90,7 +76,6 @@ let streamStartBtn;
|
|||||||
let streamStartBtnInitialDisplay;
|
let streamStartBtnInitialDisplay;
|
||||||
let streamStartBtnClone;
|
let streamStartBtnClone;
|
||||||
let resolutionString;
|
let resolutionString;
|
||||||
let autoGainControl = true;
|
|
||||||
const clonedElements = [];
|
const clonedElements = [];
|
||||||
const hiddenElements = [];
|
const hiddenElements = [];
|
||||||
let wasStreamActive = false;
|
let wasStreamActive = false;
|
||||||
@@ -174,10 +159,6 @@ function main() {
|
|||||||
streamStartBtnClone.remove();
|
streamStartBtnClone.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
userscript.getPref("disableAutomaticGain", false).then((disabled) => {
|
|
||||||
autoGainControl = !disabled;
|
|
||||||
});
|
|
||||||
|
|
||||||
function updateUserstyles() {
|
function updateUserstyles() {
|
||||||
userscript.log("Loading userstyles...");
|
userscript.log("Loading userstyles...");
|
||||||
userscript.loadingMessage = "Loading userstyles...";
|
userscript.loadingMessage = "Loading userstyles...";
|
||||||
@@ -387,29 +368,5 @@ function main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const el of document.getElementsByClassName("sensitivity-3A7Gs9")) {
|
|
||||||
if (
|
|
||||||
el.getElementsByTagName("div").length > 0 &&
|
|
||||||
!document.getElementById("discord-screenaudio-gaintoggle")
|
|
||||||
) {
|
|
||||||
const toggle = createSwitch(
|
|
||||||
"Disable automatic gain",
|
|
||||||
await userscript.getPref("disableAutomaticGain", false),
|
|
||||||
async (disabled) => {
|
|
||||||
await userscript.setPref("disableAutomaticGain", disabled);
|
|
||||||
autoGainControl = !disabled;
|
|
||||||
setGetUserMedia();
|
|
||||||
if (disabled)
|
|
||||||
userscript.showInformation(
|
|
||||||
"discord-screenaudio",
|
|
||||||
"If you are currently in a call, this setting may only take effect after you rejoin the call or restart discord-screenaudio."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
toggle.id = "discord-screenaudio-gaintoggle";
|
|
||||||
el.getElementsByTagName("div")[0].appendChild(toggle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
de.shorsh.discord-screenaudio.png
Normal file
BIN
de.shorsh.discord-screenaudio.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
28
install.sh
Executable file
28
install.sh
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Build Flatpak package
|
||||||
|
flatpak-builder build-dir lol.deadzone.discord-awesomeaudio.json --install --user --force-clean
|
||||||
|
|
||||||
|
# Create wrapper script
|
||||||
|
echo '#!/bin/bash
|
||||||
|
RUNNING=$(pgrep -f "discord-screenaudio")
|
||||||
|
if [[ -n $RUNNING ]]; then
|
||||||
|
WM_CLASS="discord-screenaudio"
|
||||||
|
else
|
||||||
|
WM_CLASS=""
|
||||||
|
fi
|
||||||
|
flatpak run --env=WM_CLASS="$WM_CLASS" lol.deadzone.discord-awesomeaudio' > ~/.local/bin/discord-awesomeaudio.sh
|
||||||
|
|
||||||
|
# Make the wrapper script executable
|
||||||
|
chmod +x ~/.local/bin/discord-awesomeaudio.sh
|
||||||
|
|
||||||
|
# Create .desktop file
|
||||||
|
echo "[Desktop Entry]
|
||||||
|
Name=Discord Awesome Audio
|
||||||
|
Exec=flatpak run lol.deadzone.discord-awesomeaudio
|
||||||
|
Icon=/path/to/application/icon.png
|
||||||
|
Type=Application
|
||||||
|
Categories=AudioVideo;Network;" > ~/.local/share/applications/discord-awesomeaudio.desktop
|
||||||
|
|
||||||
|
# Make the .desktop file executable (if necessary)
|
||||||
|
chmod +x ~/.local/share/applications/discord-awesomeaudio.desktop
|
||||||
44
lol.deadzone.discord-awesomeaudio.json
Normal file
44
lol.deadzone.discord-awesomeaudio.json
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"app-id": "lol.deadzone.discord-awesomeaudio",
|
||||||
|
"runtime": "org.kde.Platform",
|
||||||
|
"runtime-version": "5.15-22.08",
|
||||||
|
"sdk": "org.kde.Sdk",
|
||||||
|
"base": "io.qt.qtwebengine.BaseApp",
|
||||||
|
"base-version": "5.15-22.08",
|
||||||
|
"command": "discord-screenaudio",
|
||||||
|
"finish-args": [
|
||||||
|
"--share=ipc",
|
||||||
|
"--share=network",
|
||||||
|
"--socket=wayland",
|
||||||
|
"--socket=fallback-x11",
|
||||||
|
"--socket=pulseaudio",
|
||||||
|
"--filesystem=xdg-videos:ro",
|
||||||
|
"--filesystem=xdg-pictures:ro",
|
||||||
|
"--filesystem=xdg-download",
|
||||||
|
"--filesystem=xdg-run/pipewire-0",
|
||||||
|
"--device=all",
|
||||||
|
"--talk-name=org.kde.StatusNotifierWatcher",
|
||||||
|
"--env=QTWEBENGINEPROCESS_PATH=/app/bin/QtWebEngineProcess",
|
||||||
|
"--talk-name=org.freedesktop.Notifications",
|
||||||
|
"--talk-name=org.kde.kglobalaccel"
|
||||||
|
],
|
||||||
|
"modules": [
|
||||||
|
{
|
||||||
|
"name": "discord-screenaudio",
|
||||||
|
"buildsystem": "cmake-ninja",
|
||||||
|
"config-opts": [
|
||||||
|
"-DCMAKE_BUILD_TYPE=RelWithDebInfo",
|
||||||
|
"-DGIT_SUBMODULE=OFF"
|
||||||
|
],
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"type": "dir",
|
||||||
|
"path": "."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"finish-install": {
|
||||||
|
"desktop-file": "[Desktop Entry]\nName=Discord Awesome Audio\nExec=flatpak run lol.deadzone.discord-awesomeaudio\nIcon=/path/to/application/icon.png\nType=Application\nCategories=AudioVideo;Network;"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QShortcut>
|
||||||
#include <QSpacerItem>
|
#include <QSpacerItem>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@@ -31,6 +32,8 @@ MainWindow::MainWindow(bool useNotifySend, QWidget *parent)
|
|||||||
setCentralWidget(m_centralWidget);
|
setCentralWidget(m_centralWidget);
|
||||||
setupTrayIcon();
|
setupTrayIcon();
|
||||||
setMinimumSize(800, 300);
|
setMinimumSize(800, 300);
|
||||||
|
connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this),
|
||||||
|
&QShortcut::activated, this, &MainWindow::toggleOrCloseWindow);
|
||||||
if (m_settings->contains("geometry")) {
|
if (m_settings->contains("geometry")) {
|
||||||
restoreGeometry(m_settings->value("geometry").toByteArray());
|
restoreGeometry(m_settings->value("geometry").toByteArray());
|
||||||
} else {
|
} else {
|
||||||
@@ -79,12 +82,7 @@ void MainWindow::setupTrayIcon() {
|
|||||||
|
|
||||||
connect(m_trayIcon, &QSystemTrayIcon::activated, [this](auto reason) {
|
connect(m_trayIcon, &QSystemTrayIcon::activated, [this](auto reason) {
|
||||||
if (reason == QSystemTrayIcon::Trigger) {
|
if (reason == QSystemTrayIcon::Trigger) {
|
||||||
if (isVisible()) {
|
toggleOrCloseWindow();
|
||||||
hide();
|
|
||||||
} else {
|
|
||||||
show();
|
|
||||||
activateWindow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -131,3 +129,15 @@ MainWindow *MainWindow::instance() { return m_instance; }
|
|||||||
CentralWidget *MainWindow::centralWidget() {
|
CentralWidget *MainWindow::centralWidget() {
|
||||||
return instance()->m_centralWidget;
|
return instance()->m_centralWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void MainWindow::toggleOrCloseWindow() {
|
||||||
|
if (isVisible()) {
|
||||||
|
if (m_trayIcon == nullptr)
|
||||||
|
QApplication::quit();
|
||||||
|
else
|
||||||
|
hide();
|
||||||
|
} else {
|
||||||
|
show();
|
||||||
|
activateWindow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -36,4 +36,5 @@ private:
|
|||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void setTrayIcon(bool enabled);
|
void setTrayIcon(bool enabled);
|
||||||
void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest);
|
void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest);
|
||||||
|
void toggleOrCloseWindow();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -182,7 +182,3 @@ void UserScript::showThemeDialog() {
|
|||||||
void UserScript::installUserStyles(QString url) {
|
void UserScript::installUserStyles(QString url) {
|
||||||
emit shouldInstallUserStyles(url);
|
emit shouldInstallUserStyles(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserScript::showInformation(QString title, QString message) {
|
|
||||||
QMessageBox::information(MainWindow::instance(), title, message);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ public Q_SLOTS:
|
|||||||
void showShortcutsDialog();
|
void showShortcutsDialog();
|
||||||
void showHelpMenu();
|
void showHelpMenu();
|
||||||
void showStreamDialog();
|
void showStreamDialog();
|
||||||
void showInformation(QString title, QString message);
|
|
||||||
void stopVirtmic();
|
void stopVirtmic();
|
||||||
void startVirtmic(QString target);
|
void startVirtmic(QString target);
|
||||||
void showThemeDialog();
|
void showThemeDialog();
|
||||||
|
|||||||
2
uninstall.sh
Executable file
2
uninstall.sh
Executable file
@@ -0,0 +1,2 @@
|
|||||||
|
flatpak remove lol.deadzone.discord-awesomeaudio
|
||||||
|
rm ~/.local/share/applications/discord-awesomeaudio.desktop
|
||||||
Reference in New Issue
Block a user