|
@@ -48,10 +48,13 @@ function init() {
|
48
|
48
|
if (config.useStunTurn) {
|
49
|
49
|
connection.jingle.getStunAndTurnCredentials();
|
50
|
50
|
}
|
51
|
|
- getUserMediaWithConstraints( ['audio'], audioStreamReady,
|
52
|
|
- function(error){
|
53
|
|
- console.error('failed to obtain audio stream - stop', error);
|
54
|
|
- });
|
|
51
|
+ obtainAudioAndVideoPermissions(function(){
|
|
52
|
+ getUserMediaWithConstraints( ['audio'], audioStreamReady,
|
|
53
|
+ function(error){
|
|
54
|
+ console.error('failed to obtain audio stream - stop', error);
|
|
55
|
+ });
|
|
56
|
+ });
|
|
57
|
+
|
55
|
58
|
document.getElementById('connect').disabled = true;
|
56
|
59
|
} else {
|
57
|
60
|
console.log('status', status);
|
|
@@ -59,6 +62,23 @@ function init() {
|
59
|
62
|
});
|
60
|
63
|
}
|
61
|
64
|
|
|
65
|
+/**
|
|
66
|
+ * We first ask for audio and video combined stream in order to get permissions and not to ask twice.
|
|
67
|
+ * Then we dispose the stream and continue with separate audio, video streams(required for desktop sharing).
|
|
68
|
+ */
|
|
69
|
+function obtainAudioAndVideoPermissions(callback){
|
|
70
|
+ // Get AV
|
|
71
|
+ getUserMediaWithConstraints(
|
|
72
|
+ ['audio', 'video'],
|
|
73
|
+ function(avStream) {
|
|
74
|
+ avStream.stop();
|
|
75
|
+ callback();
|
|
76
|
+ },
|
|
77
|
+ function(error){
|
|
78
|
+ console.error('failed to obtain audio/video stream - stop', error);
|
|
79
|
+ });
|
|
80
|
+}
|
|
81
|
+
|
62
|
82
|
function audioStreamReady(stream) {
|
63
|
83
|
|
64
|
84
|
change_local_audio(stream);
|
|
@@ -965,7 +985,8 @@ $(window).bind('beforeunload', function () {
|
965
|
985
|
|
966
|
986
|
function disposeConference() {
|
967
|
987
|
var handler = getConferenceHandler();
|
968
|
|
- if(handler) {
|
|
988
|
+ if(handler && handler.peerconnection) {
|
|
989
|
+ // FIXME: probably removing streams is not required and close() should be enough
|
969
|
990
|
if(connection.jingle.localAudio) {
|
970
|
991
|
handler.peerconnection.removeStream(connection.jingle.localAudio);
|
971
|
992
|
}
|