Repository: incubator-guacamole-client
Updated Branches:
  refs/heads/master a6ccb36bd -> 3da02bd0a


GUACAMOLE-25: Automatically reestablish audio stream when it closes normally.


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/42129449
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/42129449
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/42129449

Branch: refs/heads/master
Commit: 421294490b2e44367fca1c6b97533035eb78a950
Parents: c32a779
Author: Michael Jumper <[email protected]>
Authored: Mon May 2 00:39:03 2016 -0700
Committer: Michael Jumper <[email protected]>
Committed: Mon May 23 21:08:54 2016 -0700

----------------------------------------------------------------------
 .../webapp/app/client/types/ManagedClient.js    | 34 ++++++++++++++++++--
 1 file changed, 31 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/42129449/guacamole/src/main/webapp/app/client/types/ManagedClient.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/client/types/ManagedClient.js 
b/guacamole/src/main/webapp/app/client/types/ManagedClient.js
index 64418e0..9a3ffb1 100644
--- a/guacamole/src/main/webapp/app/client/types/ManagedClient.js
+++ b/guacamole/src/main/webapp/app/client/types/ManagedClient.js
@@ -263,6 +263,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
      * or group.
      *
@@ -363,9 +393,7 @@ angular.module('client').factory('ManagedClient', 
['$rootScope', '$injector',
                             ManagedClientState.ConnectionState.CONNECTED);
 
                         // Begin streaming audio input if possible
-                        var stream = 
client.createAudioStream(ManagedClient.AUDIO_INPUT_MIMETYPE);
-                        if (!Guacamole.AudioRecorder.getInstance(stream, 
ManagedClient.AUDIO_INPUT_MIMETYPE))
-                            stream.sendEnd();
+                        requestAudioStream(client);
 
                         break;
 

Reply via email to