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

Initial Support for Spacebar WebRTC #1108

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

CE1CECL
Copy link

@CE1CECL CE1CECL commented Dec 28, 2023

please note: WebRTC was ONLY tested using a test client that was since deleted by spacebar owners, no other clients were tested, nor bot libraries were either (discord.js didn't work for me since it always requires a https connection)

NOTE: This PR DOES NOT add Screen sharing, but adds webcam support and voice
BREAKING CHANGES: Windows can no longer be supported after this PR is merged, because medooze-media-server doesn't support windows WebRTC can now be disabled with a env var to continue support for Windows

Known bugs:

  • Muting, unmuting, deafening, and undeafening makes the voice call reconnect for unknown reason.
  • Defend does not work on test client because of the reconnect bug.
  • Video support can be buggy, requiring both cameras on to fully work (why?)
  • You tell me what other issues there are: this has been a worked on thing by Me, @MaddyUnderStars & was initially created by @SamuelScheit

@TheKrafter

This comment was marked as resolved.

src/api/Server.ts Outdated Show resolved Hide resolved
Copy link
Member

@TheArcaneBrony TheArcaneBrony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a tiny amount of work :)

.gitignore Outdated Show resolved Hide resolved
nginx.conf Outdated Show resolved Hide resolved
src/api/Server.ts Outdated Show resolved Hide resolved
src/api/Server.ts Outdated Show resolved Hide resolved
src/api/Server.ts Outdated Show resolved Hide resolved
tmp/HOST Outdated Show resolved Hide resolved
tmp/IPv4 Outdated Show resolved Hide resolved
tmp/NAME Outdated Show resolved Hide resolved
tmp/PORT Outdated Show resolved Hide resolved
tmp/PROT Outdated Show resolved Hide resolved
@Puyodead1
Copy link
Contributor

if there isn't already, there should be a way to disable webrtc from loading, because I use windows for development, and I am not switching anytime soon. either config, or at the very least an environment variable

@TheArcaneBrony
Copy link
Member

Worst case you could use WSL I guess?
But yeah, this is probably important, even if Windows remains a minimally supported OS.

Signed-off-by: Christopher Lentocha <[email protected]>
@CE1CECL CE1CECL changed the title Initial Support for Spacebar WebRTC & Dynamic URL Support Initial Support for Spacebar WebRTC Dec 28, 2023
Signed-off-by: Christopher Lentocha <[email protected]>
@CE1CECL
Copy link
Author

CE1CECL commented Dec 29, 2023

if there isn't already, there should be a way to disable webrtc from loading, because I use windows for development, and I am not switching anytime soon. either config, or at the very least an environment variable

Added but it needs testing directly on Windows, which I don't have, I have Linux.

@CE1CECL
Copy link
Author

CE1CECL commented Dec 29, 2023

Worst case you could use WSL I guess? But yeah, this is probably important, even if Windows remains a minimally supported OS.

No. WSL Is NOT a option, WSL requires Hyper-v which is garbage in general,, slow, etc... WSL is more like emulation than a layer like WineHQ

@TheArcaneBrony
Copy link
Member

what? Wine is a stdlib overlay + bincompat layer, WSL is a full on vm (and it isnt slow either)

@CE1CECL CE1CECL marked this pull request as ready for review December 30, 2023 21:38
@CE1CECL
Copy link
Author

CE1CECL commented Dec 30, 2023

Marked as ready since its possible to disable webrtc

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to include a separate file for windows, you could use dynamic imports or just, a top level if statement?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to include a separate file for windows, you could use dynamic imports or just, a top level if statement?

I tried, it doesn't seem to work out, because import is required to be used (const require doesn't seem to work) and needs to be at the top without an "if" statement. What I did in my last commit was the easiest and probably cleanest, and understandable by someone else.

You can just (if you want)
diff -aprNu src/bundle/Server.ts src/bundle/WinServer.ts

guild_id: voiceState.guild_id,
user_id: this.user_id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is incorrect. That parameter is used to determine the recipients of this gateway event. Your edit only sends the event to the user who left the channel, which means other users in the voice channel won't be updated.

@@ -84,7 +84,7 @@ export class VoiceState extends BaseClass {
@Column({ nullable: true })
self_stream?: boolean;

@Column()
@Column({ nullable: true })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be nullable, it should just be set to false by default. Regardless, you didn't write migrations for this change.

Copy link
Author

@CE1CECL CE1CECL Jan 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be nullable, it should just be set to false by default.

What do you mean by "false by default"?

Regardless, you didn't write migrations for this change.

Wasn't sure if I would keep the change but I will write mig's once the first question gets answered.

Comment on lines -62 to +63
server: this.server,
noServer: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rory&, this was done so that the websocket server would not be responsible for upgrading http connections, which is now done above with the uncommented update listener. This was done so that voice ws is mounted on /voice

I don't think this is necessary though, I would rather it just use a different port? This makes routing through nginx less difficult when using bundle.

src/webrtc/events/Message.ts Show resolved Hide resolved
src/webrtc/opcodes/BackendVersion.ts Show resolved Hide resolved
src/webrtc/opcodes/Identify.ts Show resolved Hide resolved
src/webrtc/opcodes/SelectProtocol.ts Show resolved Hide resolved
src/webrtc/opcodes/index.ts Show resolved Hide resolved
@MathMan05
Copy link
Contributor

Worst case you could use WSL I guess? But yeah, this is probably important, even if Windows remains a minimally supported OS.

No. WSL Is NOT a option, WSL requires Hyper-v which is garbage in general,, slow, etc... WSL is more like emulation than a layer like WineHQ

WSL 2 needs Hyper-v, the original WSL is to windows what wine is to linux

@TheArcaneBrony
Copy link
Member

honestly, hyper-v/WSL2 is completely fine, the slow part is the 9PFS mount for your windows drive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants