Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Fixes NPE. Prevents from asking for permission twice(by obtaining audio+video stream and closing it).

paweldomas68b8512b27e4
diff --git a/app.js b/app.js
index f0a73f9212..134db97ca0 100644
--- a/app.js
+++ b/app.js
@@ -48,10 +48,13 @@ function init() {
if (config.useStunTurn) {
connection.jingle.getStunAndTurnCredentials();
}
- getUserMediaWithConstraints( ['audio'], audioStreamReady,
- function(error){
- console.error('failed to obtain audio stream - stop', error);
- });
+ obtainAudioAndVideoPermissions(function(){
+ getUserMediaWithConstraints( ['audio'], audioStreamReady,
+ function(error){
+ console.error('failed to obtain audio stream - stop', error);
+ });
+ });
+
document.getElementById('connect').disabled = true;
} else {
console.log('status', status);
@@ -59,6 +62,23 @@ function init() {
});
}
+/**
+ * We first ask for audio and video combined stream in order to get permissions and not to ask twice.
+ * Then we dispose the stream and continue with separate audio, video streams(required for desktop sharing).
+ */
+function obtainAudioAndVideoPermissions(callback){
+ // Get AV
+ getUserMediaWithConstraints(
+ ['audio', 'video'],
+ function(avStream) {
+ avStream.stop();
+ callback();
+ },
+ function(error){
+ console.error('failed to obtain audio/video stream - stop', error);
+ });
+}
+
function audioStreamReady(stream) {
change_local_audio(stream);
@@ -965,7 +985,8 @@ $(window).bind('beforeunload', function () {
function disposeConference() {
var handler = getConferenceHandler();
- if(handler) {
+ if(handler && handler.peerconnection) {
+ // FIXME: probably removing streams is not required and close() should be enough
if(connection.jingle.localAudio) {
handler.peerconnection.removeStream(connection.jingle.localAudio);
}