Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing AudioCallbackDriver #87

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions extension/scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,39 @@ function overrideGdm () {
}
})
const [track] = captureSystemAudioStream.getAudioTracks()

// Discord workaround
let fakegdm;
if (new RegExp('^(.+\.)?discord.com$').test(window.location.host) && sessionType === "wayland") {
fakegdm = navigator.mediaDevices.chromiumGetDisplayMedia({
video: true
})
}

// Firefox 121+ workaround
const randomText = 'Pending PipeWire - ' + (Math.random() * 256 + 1).toString(36).substring(3)
const getTitleWithRandom = (title) => `${title} | ${randomText}`

let lastTitle = document.title
let lastTitleWithRandom = getTitleWithRandom(lastTitle)
document.title = lastTitleWithRandom
const titleWatcher = new MutationObserver(function(mutations) {
const newTitle = mutations[0].target.nodeValue
if (newTitle !== lastTitleWithRandom) {
lastTitle = newTitle
lastTitleWithRandom = getTitleWithRandom(newTitle)
document.title = lastTitleWithRandom
}
}).observe(
document.querySelector('title'),
{ subtree: true, characterData: true, childList: true }
)

// Send $lastTitleWithRandom to native


// Wait for confirmation

const gdm = await navigator.mediaDevices.chromiumGetDisplayMedia({
video: true,
audio: true
Expand All @@ -68,6 +95,8 @@ function overrideGdm () {

overrideGdm()

const onMessageHooks = {}

// Store the session type we get (either "x11" or "wayland") into sessionType
// This message gets sent from the onload listener in injector.js
const onMessage = (event) => {
Expand All @@ -77,6 +106,8 @@ const onMessage = (event) => {
sessionType = event.data.type
window.removeEventListener("message", onMessage);
}

Object.values(onMessageHooks).forEach(hook => hook(event))
};

window.addEventListener("message", onMessage);