mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
GUACAMOLE-25: Only capture as long as stream is open.
This commit is contained in:
@@ -212,6 +212,14 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) {
|
|||||||
*/
|
*/
|
||||||
var writtenSamples = 0;
|
var writtenSamples = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The audio stream provided by the browse, if allowed. If no stream has
|
||||||
|
* yet been received, this will be null.
|
||||||
|
*
|
||||||
|
* @type MediaStream
|
||||||
|
*/
|
||||||
|
var mediaStream = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The source node providing access to the local audio input device.
|
* The source node providing access to the local audio input device.
|
||||||
*
|
*
|
||||||
@@ -386,9 +394,17 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) {
|
|||||||
if (processor)
|
if (processor)
|
||||||
processor.disconnect();
|
processor.disconnect();
|
||||||
|
|
||||||
|
// Stop capture
|
||||||
|
if (mediaStream) {
|
||||||
|
var tracks = mediaStream.getTracks();
|
||||||
|
for (var i = 0; i < tracks.length; i++)
|
||||||
|
tracks[i].stop();
|
||||||
|
}
|
||||||
|
|
||||||
// Remove references to now-unneeded components
|
// Remove references to now-unneeded components
|
||||||
processor = null;
|
processor = null;
|
||||||
source = null;
|
source = null;
|
||||||
|
mediaStream = null;
|
||||||
|
|
||||||
writer.sendEnd();
|
writer.sendEnd();
|
||||||
return;
|
return;
|
||||||
@@ -396,7 +412,7 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to retrieve an audio input stream from the browser
|
// Attempt to retrieve an audio input stream from the browser
|
||||||
getUserMedia({ 'audio' : true }, function streamReceived(mediaStream) {
|
getUserMedia({ 'audio' : true }, function streamReceived(stream) {
|
||||||
|
|
||||||
// Create processing node which receives appropriately-sized audio buffers
|
// Create processing node which receives appropriately-sized audio buffers
|
||||||
processor = context.createScriptProcessor(BUFFER_SIZE, format.channels, format.channels);
|
processor = context.createScriptProcessor(BUFFER_SIZE, format.channels, format.channels);
|
||||||
@@ -408,9 +424,12 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Connect processing node to user's audio input source
|
// Connect processing node to user's audio input source
|
||||||
source = context.createMediaStreamSource(mediaStream);
|
source = context.createMediaStreamSource(stream);
|
||||||
source.connect(processor);
|
source.connect(processor);
|
||||||
|
|
||||||
|
// Save stream for later cleanup
|
||||||
|
mediaStream = stream;
|
||||||
|
|
||||||
}, function streamDenied() {
|
}, function streamDenied() {
|
||||||
|
|
||||||
// Simply end stream if audio access is not allowed
|
// Simply end stream if audio access is not allowed
|
||||||
|
Reference in New Issue
Block a user