vadimpronin / guacamole-lite

Node.js library for creating Guacamole-compatible servers. Guacamole is a RDP/VNC/SSH/Telnet client for HTML5 browsers.
Apache License 2.0
247 stars 78 forks source link

RDP Audio Support #30

Closed thelamer closed 4 years ago

thelamer commented 4 years ago

First off sorry for the wall of text.

Short and to the point question does anyone have a functional RDP client with audio support for guacamole-lite they could share?

On the surface I think maybe guacamole-lite might not be passing file/audio output and input streams from guacd to the javascript client through the websocket tunnel. Though I am not sure, thus why I am reaching out.

I have been trying to reverse engineer audio support from the stock java client, and as far as I can tell they do not do anything special and the base guacamole-common should negotiate the additional InputStream needed for the raw PCM audio supported by modern browsers. In my custom app and the default java client I am using identical code for the client: https://cdn.jsdelivr.net/npm/guacamole-client@1.0.0/dist/guacamole-client.min.js

When negotiating the connection I am getting identical lines back from guacd with both my custom client/guacamole-lite and the stock java client, so I believe the audio= connectionstring parameters might be redundant as that happens regardless of if they are included or not:

guacd[8]: INFO: Accepted format: 16-bit PCM with 2 channels at 44100 Hz
guacd[8]: INFO: Accepted format: 16-bit PCM with 2 channels at 22050 Hz

From a debugging standpoint I have gone through and captured Guacamole.Tunnel.oninstruction events client side and have noticed that specifically there are no audio opcodes being sent to the client to process that are normally processed by this clientside: https://github.com/apache/guacamole-client/blob/32b106b982dc74e71e1cbb3d2c5e0c5b9b9a8bab/guacamole-common-js/src/main/webapp/modules/Client.js#L884

From a due diligence standpoint I use Docker for development and deployment, if anyone is interested in helping out or debugging you can simply run this Docker container:

docker run --name taisun -d \
--restart always \
-p 3000:3000 \
-p 8000:8000 \
-v /var/run/docker.sock:/var/run/docker.sock \
taisun/webapp

If you hop on port 8000 the rdp client can be found under public/js/rdp.js

You can spinup an RDP client and a guacd instance from the web interface on port 3000 under VDI (no parameters are needed outside of the name)

Also just a side note I have functional audio in the VDI endpoints with xrdp and pulseaudio, I have tested them functional with multiple clients including stock guacamole client 1.0.0 and 1.1.0.

Another thing to mention is after this projects(guacamole-lite) inception Guacamole shifted all the audio tunneling code to raw PCM vs a mix of different mimetypes(ogg vorbis etc) in 0.9.9, not sure if that matters just bringing it up.

cmosguy commented 4 years ago

@thelamer I am interested in helping here, can we hop on a call to understand how to tackle this issue?

zaventh commented 4 years ago

I am also trying to debug this issue. the onaudio event in the Client.js is never raised, though the RDP session sees the remote audio device and I see similar guacd logs

INFO:   Accepted format: 16-bit PCM with 2 channels at 44100 Hz

I looked through the source here but nothing stood out. Did you all make any progress on this?

cblk commented 4 years ago
  1. replace the code in GuacdClient.js this.sendOpCode(['audio']); with this.sendOpCode(['audio', 'audio/L16']);
  2. add onaudio event handler
    guac.onaudio = function clientAudio(stream, mimetype) {
    let context = Guacamole.AudioContextFactory.getAudioContext()
    context.resume().then(() => console.log('play audio'))
    }
zaventh commented 4 years ago

I can confirm @cblk change works. A fully functional handler looks like this:

    onAudioEnabled(stream: Guacamole.InputStream, mimetype: string) {
        const context = Guacamole.AudioContextFactory.getAudioContext()
        context.resume();

        return Guacamole.AudioPlayer.getInstance(stream, mimetype);
    }

@vadimpronin I'm happy to open a PR for this if you would merge it.

thelamer commented 4 years ago

Reference PR: https://github.com/vadimpronin/guacamole-lite/pull/32 Closing this issue , huge thanks to @cblk !!!

AmiSBr commented 1 year ago

Hello, Sorry, I know this is an old issue, but I'm trying to allow audio input (microphone) in my windows RDP connection. Thanks to @cblk, I've managed to establish output audio. But I don't know to configure input audio. Did anyone know how to allow microphone access ?

Any help would be appreciated.

Mariappan-s commented 1 year ago

Hi @AmiSBr Currently, I am encountering the issue you mentioned earlier. Did anyone know how to allow microphone access? @cblk Could you please assist me in resolving the issue?

Mariappan-s commented 1 year ago

Hi @AmiSBr @cblk I added GUAC_AUDIO parameter (GUAC_AUDIO=audio/L8&GUAC_AUDIO=audio/L16) on token. So, output audio works. Does anyone know how to authorize access to the microphone?

takeshicamilo commented 7 months ago

@Mariappan-s Maria, I really love you so much, you could fix my audio problem