mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
GUACAMOLE-25: Automatically reestablish audio stream when it closes normally.
This commit is contained in:
@@ -262,6 +262,36 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests the creation of a new audio stream, recorded from the user's
|
||||||
|
* local audio input device. If audio input is supported by the connection,
|
||||||
|
* an audio stream will be created which will remain open until the remote
|
||||||
|
* desktop requests that it be closed. If the audio stream is successfully
|
||||||
|
* created but is later closed, a new audio stream will automatically be
|
||||||
|
* established to take its place. The mimetype used for all audio streams
|
||||||
|
* produced by this function is defined by
|
||||||
|
* ManagedClient.AUDIO_INPUT_MIMETYPE.
|
||||||
|
*
|
||||||
|
* @param {Guacamole.Client} client
|
||||||
|
* The Guacamole.Client for which the audio stream is being requested.
|
||||||
|
*/
|
||||||
|
var requestAudioStream = function requestAudioStream(client) {
|
||||||
|
|
||||||
|
// Create new audio stream, associating it with an AudioRecorder
|
||||||
|
var stream = client.createAudioStream(ManagedClient.AUDIO_INPUT_MIMETYPE);
|
||||||
|
var recorder = Guacamole.AudioRecorder.getInstance(stream, ManagedClient.AUDIO_INPUT_MIMETYPE);
|
||||||
|
|
||||||
|
// If creation of the AudioRecorder failed, simply end the stream
|
||||||
|
if (!recorder)
|
||||||
|
stream.sendEnd();
|
||||||
|
|
||||||
|
// Otherwise, ensure that another audio stream is created after this
|
||||||
|
// audio stream is closed
|
||||||
|
else
|
||||||
|
recorder.onclose = requestAudioStream.bind(this, client);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ManagedClient, connecting it to the specified connection
|
* Creates a new ManagedClient, connecting it to the specified connection
|
||||||
* or group.
|
* or group.
|
||||||
@@ -363,9 +393,7 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
|
|||||||
ManagedClientState.ConnectionState.CONNECTED);
|
ManagedClientState.ConnectionState.CONNECTED);
|
||||||
|
|
||||||
// Begin streaming audio input if possible
|
// Begin streaming audio input if possible
|
||||||
var stream = client.createAudioStream(ManagedClient.AUDIO_INPUT_MIMETYPE);
|
requestAudioStream(client);
|
||||||
if (!Guacamole.AudioRecorder.getInstance(stream, ManagedClient.AUDIO_INPUT_MIMETYPE))
|
|
||||||
stream.sendEnd();
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user