mumble icon indicating copy to clipboard operation
mumble copied to clipboard

Headless Mumble Client

Open Krzmbrzl opened this issue 5 years ago • 14 comments

Today an idea came to my mind: Would it be possible to provide a headless Mumble client (with reasonable effort)? What I mean by that is a Mumble client without a GUI, essentially converting Mumble into some sort of command-line version (though without interactivity from the command-line of course)

What could this be useful for?

  • Testing: With such an approach we could create test-cases that e.g. test client-server-interaction which can be run on a machine without a graphical interface (like the servers we're using for CI)
  • Facilitating 3rd-party software to integrate Mumble as a voice-backend: For instance there could be a mod for a game that wants to do audio-transmission but it would like to do so without the user having to open another application. With a headless Mumble client, the mod could start Mumble in headless mode and remotely controlling it via e.g. the new plugin interface. Thus it could connect the user to a server, transmit audio, etc. and all that without any extra work on the user's side and most important: No UI that pops up mid-game just to get minimized right after that.

In terms of implementation I guess this greatly depends on how well the UI and the functionality are separated in the code base. Digging through the code for more than 3 months now, I have the impression that this is actually fairly well. Thus making a headless version should more or less "only" require us to not show the UI in the first place, leaving everything else as it is. I did a quick test commenting the following line https://github.com/mumble-voip/mumble/blob/ccdb88f872b85e04733e1e39ed78b23142ab581c/src/mumble/main.cpp#L447 but it didn't seem to change anything. The UI jumped back at me normally when starting Mumble. Thus I'd appreciate some feedback on this whole issue from people that have studied the UI part of the code base more closely than I have.

Krzmbrzl avatar Oct 31 '19 18:10 Krzmbrzl

https://github.com/mumble-voip/mumble/blob/ccdb88f872b85e04733e1e39ed78b23142ab581c/src/mumble/MainWindow.cpp#L171-L173

https://github.com/mumble-voip/mumble/blob/ccdb88f872b85e04733e1e39ed78b23142ab581c/src/mumble/MainWindow.cpp#L958-L968

https://github.com/mumble-voip/mumble/blob/ccdb88f872b85e04733e1e39ed78b23142ab581c/src/mumble/MainWindow.cpp#L1103

https://github.com/mumble-voip/mumble/blob/ccdb88f872b85e04733e1e39ed78b23142ab581c/src/mumble/MainWindow.cpp#L3086-L3094

davidebeatrici avatar Oct 31 '19 18:10 davidebeatrici

Thanks :) Do you think that a headless client could be useful as well? Don't really want to invest too much into it just to find out nobody can make any use of it xDD

Krzmbrzl avatar Oct 31 '19 19:10 Krzmbrzl

You're welcome! :)

A headless client could definitely be useful.

Ideally MainWindow should not be created in that case, meaning that we have to check what accesses it outside the class itself.

davidebeatrici avatar Oct 31 '19 20:10 davidebeatrici

Actually, there is no need to remove any of the GUI code. Qt offers a rendering platform, that automatically does not render anything at all. To start Mumble this way, use mumble -platform offscreen. In the application you can simply check for the offscreen platform with QGuiApplication::platformName() == "offscreen", then the only thing left to implement, is to write a command line interface.

I did something like this for a small online multiplayer game of mine to enable a headless server. If you are interested, you can check out my code here: https://github.com/magnus-gross/quickcurver/blob/c9be19b400a7081a5030f3028ffee11722f7f65e/src/main.cpp#L59

My implementation is pretty basic though. Ideally a headless Mumble client would support autocompletions, CLI menus or fancy stuff like that.

vimpostor avatar Nov 04 '19 18:11 vimpostor

Neat! :+1: Do you happen to know how a platform deals with "offscreen rendering" if it doesn't support any graphical widgets at all (like a server terminal)?

Also did you test that? From what I have seen, this option would not be recognized by mumble. There had to be a way of forwarding that option to qt...

Krzmbrzl avatar Nov 04 '19 19:11 Krzmbrzl

Offscreen rendering should work with server terminals: It does not require an X server to be running at all.

Yes, I tested that. There is no extra action required to pass this option to Qt, it is automatically forwarded.

vimpostor avatar Nov 05 '19 00:11 vimpostor

Perfect - for what I had in mind I don't think that any code changes are required then (unless maybe a better option name that gets processed by Mumble itself).

And for the "CLI" I believe that this job is taken by Mumble's grpc capability that can be triggered via command line

Krzmbrzl avatar Nov 05 '19 05:11 Krzmbrzl

Offscreen rendering should work with server terminals: It does not require an X server to be running at all.

Yes, I tested that. There is no extra action required to pass this option to Qt, it is automatically forwarded.

Unfortunately this doesn't seem to work on our headless debian server. Issuing "mumble -platform offscreen" results in:

GlobalShortcutX: Unable to open dedicated display connection. Segmentation fault

It does work on a laptop with X installed. Is it necessary to install a virtual "dummy" X on the server so that mumble doesn't choke or is there a way to circumvent the error?

ormf avatar May 30 '20 10:05 ormf

I don't know, it works for me and I don't get this error on my system when I open Mumble from a tty.

Theoretically it should work with the normal Mumble and I don't have anything special going on on my system.

Note however, that we do not have any Terminal interface for Mumble yet, so you wouldn't be able to do anything even if it was starting.

On Sat, May 30, 2020 at 03:21:04AM -0700, ormf wrote:

Offscreen rendering should work with server terminals: It does not require an X server to be running at all.

Yes, I tested that. There is no extra action required to pass this option to Qt, it is automatically forwarded.

Unfortunately this doesn't seem to work here. Issuing "mumble -platform offscreen" results in:

GlobalShortcutX: Unable to open dedicated display connection. Segmentation fault

Why does it even try to open a display? Am I doing something wrong or do I need a specially compiled mumble for that?

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/mumble-voip/mumble/issues/3877#issuecomment-636310507

vimpostor avatar May 30 '20 13:05 vimpostor

I got it working by installing xvfb and then issuing xvfb-run mumble "mumble://<user>:<passwd>@<server-URL>:<portnum>/<channel-name>"&

The setup serves as a sound server (using jack) and for the mumble client there is no user interaction needed: As soon as the audio output from any program is connected to the mumble client input via jack and the program sends audio, it will be sent to the selected channel of the murmur server. Very elegant and low latency, albeit mono only :-(

ormf avatar May 30 '20 13:05 ormf

I would be interested in how a headless mumble client could be integrated into another application. What would be the C-code to start the client, load a plugin with the new plugin interface, let it connect to a server and join a specified channel, and; on user request, disconnect again? -> I think, this should also be documented somewhere.

hbeni avatar Jun 29 '20 19:06 hbeni

-> I think, this should also be documented somewhere.

Uhm... But it's not really possible as of now :thinking:

Krzmbrzl avatar Jun 30 '20 05:06 Krzmbrzl

"plugin" is to be understood in Qt terms - that's what the offscreen option uses: a different (rendering?) plugin. This entire offscreen functionality is completely Qt-based, so you should research this as a general Qt problem. Mumble doesn't implement any of this.

Krzmbrzl avatar Sep 22 '23 13:09 Krzmbrzl

Headless commandline mumble would be very usefull to crosslink setups maybe. I use mumble to connect with teamspeak and jackqtl on a VM same with zello but alot of other funn IO - I use mumble output to make input to OBS but making audio pipes to maybe https://github.com/datarhei/restreamer -Im am are building a mumble network with cb-radio link and connecting cb/pmr some radiotranceivers have VOX Voice activated PTT but old CB don't - we use small raspberrypi to keep it lowpower - every day we are getting users who can't setup a big antenne but they would like to use the radio-link in some area in some other countries they do simular but use zello and teamspeak because a PTT plugin exist, I am sure they would all move to mumble/mumla if a plugin did exist because it opensource but also usefull to use small Singleboard computers but a command line headless solution is maybe close to what the talkkonnect is https://github.com/talkkonnect/ I know I can just make a mumble plugin if I only did have the skills

FilipStadler avatar Feb 29 '24 08:02 FilipStadler