Преглед на файлове

Implements start muted feature.

j8
hristoterezov преди 10 години
родител
ревизия
099e3340bc

+ 0
- 2
config.js Целия файл

@@ -32,8 +32,6 @@ var config = {
32 32
     enableWelcomePage: true,
33 33
     enableSimulcast: false, // blocks FF support
34 34
     logStats: false, // Enable logging of PeerConnection stats via the focus
35
-    startVideoMuted: false,
36
-    startAudioMuted: false,
37 35
     /*noticeMessage: 'Service update is scheduled for 16th March 2015. ' +
38 36
     'During that time service will not be available. ' +
39 37
     'Apologise for inconvenience.'*/

+ 18
- 0
css/settingsmenu.css Целия файл

@@ -47,3 +47,21 @@
47 47
 #languages_selectbox{
48 48
     height: 40px;
49 49
 }
50
+
51
+
52
+#startMutedOptions {
53
+    padding-left: 10%;
54
+    text-indent: -10%;
55
+}
56
+
57
+#startAudioMuted {
58
+    width: 13px !important;
59
+}
60
+
61
+#startVideoMuted {
62
+    width: 13px !important;
63
+}
64
+
65
+.startMutedLabel {
66
+    float: left;
67
+}

+ 12
- 2
index.html Целия файл

@@ -10,7 +10,7 @@
10 10
     <meta itemprop="description" content="Join a WebRTC video conference powered by the Jitsi Videobridge"/>
11 11
     <meta itemprop="image" content="/images/jitsilogo.png"/>
12 12
     <script src="libs/jquery-2.1.1.min.js"></script>
13
-    <script src="config.js?v=7"></script><!-- adapt to your needs, i.e. set hosts and bosh path -->
13
+    <script src="config.js?v=8"></script><!-- adapt to your needs, i.e. set hosts and bosh path -->
14 14
     <script src="libs/strophe/strophe.min.js?v=1"></script>
15 15
     <script src="libs/strophe/strophe.disco.min.js?v=1"></script>
16 16
     <script src="libs/strophe/strophe.caps.jsonly.min.js?v=1"></script>
@@ -19,7 +19,7 @@
19 19
     <script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib -->
20 20
     <script src="libs/toastr.js?v=1"></script><!-- notifications lib -->
21 21
     <script src="interface_config.js?v=5"></script>
22
-    <script src="libs/app.bundle.js?v=66"></script>
22
+    <script src="libs/app.bundle.js?v=67"></script>
23 23
     <script src="analytics.js?v=1"></script><!-- google analytics plugin -->
24 24
     <link rel="stylesheet" href="css/font.css?v=7"/>
25 25
     <link rel="stylesheet" href="css/toastr.css?v=1">
@@ -299,6 +299,16 @@
299 299
             <div class="arrow-up"></div>
300 300
             <input type="text" id="setDisplayName" data-i18n="[placeholder]settings.name" placeholder="Name">
301 301
             <input type="text" id="setEmail" placeholder="E-Mail">
302
+            <div id = "startMutedOptions">
303
+                <label class = "startMutedLabel">
304
+                    <input type="checkbox" id="startAudioMuted">
305
+                    <span  data-i18n="settings.startAudioMuted"></span>
306
+                </label>
307
+                <label class = "startMutedLabel">
308
+                    <input type="checkbox" id="startVideoMuted">
309
+                    <span data-i18n="settings.startVideoMuted"></span>
310
+                </label>
311
+            </div>
302 312
             <button id="updateSettings" data-i18n="settings.update"></button>
303 313
         </div>
304 314
         <a id="downloadlog" data-container="body" data-toggle="popover" data-placement="right" data-i18n="[data-content]downloadlogs" ><i class="fa fa-cloud-download"></i></a>

+ 3
- 1
lang/main.json Целия файл

@@ -81,7 +81,9 @@
81 81
     {
82 82
         "title": "SETTINGS",
83 83
         "update": "Update",
84
-        "name": "Name"
84
+        "name": "Name",
85
+        "startAudioMuted": "everyone join audio muted",
86
+        "startVideoMuted": "everyone join video muted"
85 87
     },
86 88
     "videothumbnail":
87 89
     {

+ 11
- 13
modules/RTC/RTC.js Целия файл

@@ -17,28 +17,26 @@ var eventEmitter = new EventEmitter();
17 17
 function getMediaStreamUsage()
18 18
 {
19 19
     var result = {
20
-        audio: 1,
21
-        video: 1
20
+        audio: true,
21
+        video: true
22 22
     };
23
-    if( config.startAudioMuted === true)
24
-        result.audio = 0;
25
-    if( config.startVideoMuted === true)
26
-        result.video = 0;
27 23
 
28 24
     /** There are some issues with the desktop sharing
29 25
      * when this property is enabled.
26
+     * WARNING: We must change the implementation to start video/audio if we
27
+     * receive from the focus that the peer is not muted.
30 28
 
31
-     if(result.audio > 0 && result.video > 0)
32
-        return result;
33 29
      var isSecureConnection = window.location.protocol == "https:";
34 30
 
35 31
     if(config.disableEarlyMediaPermissionRequests || !isSecureConnection)
36 32
     {
37
-        if(result.audio === 0)
38
-            result.audio = -1;
39
-        if(result.video === 0)
40
-            result.video = -1;
41
-    }**/
33
+        result = {
34
+            audio: false,
35
+            video: false
36
+        };
37
+
38
+    }
39
+    **/
42 40
 
43 41
     return result;
44 42
 }

+ 9
- 6
modules/RTC/RTCUtils.js Целия файл

@@ -300,7 +300,9 @@ RTCUtils.prototype.setAvailableDevices = function (um, available) {
300 300
  * We ask for audio and video combined stream in order to get permissions and
301 301
  * not to ask twice.
302 302
  */
303
-RTCUtils.prototype.obtainAudioAndVideoPermissions = function(devices, callback, usageOptions) {
303
+RTCUtils.prototype.obtainAudioAndVideoPermissions =
304
+    function(devices, callback, usageOptions)
305
+{
304 306
     var self = this;
305 307
     // Get AV
306 308
 
@@ -321,7 +323,7 @@ RTCUtils.prototype.obtainAudioAndVideoPermissions = function(devices, callback,
321 323
         for(var i = 0; i < devices.length; i++)
322 324
         {
323 325
             var device = devices[i];
324
-            if(usageOptions[device] !== -1)
326
+            if(usageOptions[device] === true)
325 327
                 newDevices.push(device);
326 328
         }
327 329
     else
@@ -455,11 +457,12 @@ RTCUtils.prototype.handleLocalStream = function(stream, usageOptions)
455 457
         videoStream = stream.videoStream;
456 458
     }
457 459
 
458
-    var audioMuted = (usageOptions && usageOptions.audio != 1),
459
-        videoMuted = (usageOptions && usageOptions.video != 1);
460
+    var audioMuted = (usageOptions && usageOptions.audio === false),
461
+        videoMuted = (usageOptions && usageOptions.video === false);
462
+
463
+    var audioGUM = (!usageOptions || usageOptions.audio !== false),
464
+        videoGUM = (!usageOptions || usageOptions.video !== false);
460 465
 
461
-    var audioGUM = (!usageOptions || usageOptions.audio != -1),
462
-        videoGUM = (!usageOptions || usageOptions.video != -1);
463 466
 
464 467
     this.service.createLocalStream(audioStream, "audio", null, null,
465 468
         audioMuted, audioGUM);

+ 12
- 6
modules/UI/UI.js Целия файл

@@ -34,10 +34,8 @@ var roomName = null;
34 34
 
35 35
 function notifyForInitialMute()
36 36
 {
37
-    if(config.startAudioMuted || config.startVideoMuted)
38
-    {
39
-        messageHandler.notify(null, "notify.mutedTitle", "connected", "notify.muted", null, {timeOut: 120000});
40
-    }
37
+    messageHandler.notify(null, "notify.mutedTitle", "connected",
38
+        "notify.muted", null, {timeOut: 120000});
41 39
 }
42 40
 
43 41
 function setupPrezi()
@@ -254,6 +252,9 @@ function registerListeners() {
254 252
 
255 253
     APP.members.addListener(MemberEvents.DTMF_SUPPORT_CHANGED,
256 254
                             onDtmfSupportChanged);
255
+    APP.xmpp.addListener(XMPPEvents.START_MUTED, function (audio, video) {
256
+        SettingsMenu.setStartMuted(audio, video);
257
+    });
257 258
 }
258 259
 
259 260
 
@@ -408,8 +409,6 @@ UI.start = function (init) {
408 409
 
409 410
     SettingsMenu.init();
410 411
 
411
-    notifyForInitialMute();
412
-
413 412
 };
414 413
 
415 414
 function chatAddError(errorMessage, originalText)
@@ -485,6 +484,7 @@ function onLocalRoleChanged(jid, info, pres, isModerator)
485 484
     console.info("My role changed, new role: " + info.role);
486 485
     onModeratorStatusChanged(isModerator);
487 486
     VideoLayout.showModeratorIndicator();
487
+    SettingsMenu.onRoleChanged();
488 488
 
489 489
     if (isModerator) {
490 490
         Authentication.closeAuthenticationWindow();
@@ -729,6 +729,12 @@ UI.getRoomName = function () {
729 729
     return roomName;
730 730
 };
731 731
 
732
+UI.setInitialMuteFromFocus = function (muteAudio, muteVideo) {
733
+    if(muteAudio || muteVideo) notifyForInitialMute();
734
+    if(muteAudio) UI.setAudioMuted(true);
735
+    if(muteVideo) UI.setVideoMute(true);
736
+}
737
+
732 738
 /**
733 739
  * Mutes/unmutes the local video.
734 740
  */

+ 30
- 1
modules/UI/side_pannels/settings/SettingsMenu.js Целия файл

@@ -26,7 +26,7 @@ function generateLanguagesSelectBox()
26 26
 var SettingsMenu = {
27 27
 
28 28
     init: function () {
29
-        $("#updateSettings").before(generateLanguagesSelectBox());
29
+        $("#startMutedOptions").before(generateLanguagesSelectBox());
30 30
         APP.translation.translateElement($("#languages_selectbox"));
31 31
         $('#settingsmenu>input').keyup(function(event){
32 32
             if(event.keyCode === 13) {//enter
@@ -34,11 +34,36 @@ var SettingsMenu = {
34 34
             }
35 35
         });
36 36
 
37
+        if(APP.xmpp.isModerator())
38
+        {
39
+            $("#startMutedOptions").css("display", "block");
40
+        }
41
+        else
42
+        {
43
+            $("#startMutedOptions").css("display", "none");
44
+        }
45
+
37 46
         $("#updateSettings").click(function () {
38 47
             SettingsMenu.update();
39 48
         });
40 49
     },
41 50
 
51
+    onRoleChanged: function () {
52
+        if(APP.xmpp.isModerator())
53
+        {
54
+            $("#startMutedOptions").css("display", "block");
55
+        }
56
+        else
57
+        {
58
+            $("#startMutedOptions").css("display", "none");
59
+        }
60
+    },
61
+
62
+    setStartMuted: function (audio, video) {
63
+        $("#startAudioMuted").attr("checked", audio);
64
+        $("#startVideoMuted").attr("checked", video);
65
+    },
66
+
42 67
     update: function() {
43 68
         var newDisplayName = UIUtil.escapeHtml($('#setDisplayName').get(0).value);
44 69
         var newEmail = UIUtil.escapeHtml($('#setEmail').get(0).value);
@@ -55,6 +80,10 @@ var SettingsMenu = {
55 80
         APP.xmpp.addToPresence("email", newEmail);
56 81
         var email = Settings.setEmail(newEmail);
57 82
 
83
+        var startAudioMuted = ($("#startAudioMuted").is(":checked"));
84
+        var startVideoMuted = ($("#startVideoMuted").is(":checked"));
85
+        APP.xmpp.addToPresence("startMuted",
86
+            [startAudioMuted, startVideoMuted]);
58 87
 
59 88
         Avatar.setUserAvatar(APP.xmpp.myJid(), email);
60 89
     },

+ 14
- 0
modules/xmpp/moderator.js Целия файл

@@ -177,6 +177,20 @@ var Moderator = {
177 177
                 { name: 'openSctp', value: config.openSctp})
178 178
                 .up();
179 179
         }
180
+        if(config.startAudioMuted !== undefined)
181
+        {
182
+            elem.c(
183
+                'property',
184
+                { name: 'startAudioMuted', value: config.startAudioMuted})
185
+                .up();
186
+        }
187
+        if(config.startVideoMuted !== undefined)
188
+        {
189
+            elem.c(
190
+                'property',
191
+                { name: 'startVideoMuted', value: config.startVideoMuted})
192
+                .up();
193
+        }
180 194
         elem.up();
181 195
         return elem;
182 196
     },

+ 19
- 0
modules/xmpp/strophe.emuc.js Целия файл

@@ -152,6 +152,13 @@ module.exports = function(XMPP, eventEmitter) {
152 152
                 $(document).trigger('videomuted.muc', [from, videoMuted.text()]);
153 153
             }
154 154
 
155
+            var startMuted = $(pres).find('>startmuted');
156
+            if (startMuted.length)
157
+            {
158
+                eventEmitter.emit(XMPPEvents.START_MUTED,
159
+                    startMuted.attr("audio") === "true", startMuted.attr("video") === "true");
160
+            }
161
+
155 162
             var devices = $(pres).find('>devices');
156 163
             if(devices.length)
157 164
             {
@@ -506,6 +513,15 @@ module.exports = function(XMPP, eventEmitter) {
506 513
                                     || 'sendrecv' }
507 514
                         ).up();
508 515
                     }
516
+                pres.up();
517
+            }
518
+
519
+            if(this.presMap["startMuted"] !== undefined)
520
+            {
521
+                pres.c("startmuted", {audio: this.presMap["startMuted"].audio,
522
+                    video: this.presMap["startMuted"].video,
523
+                    xmlns: "http://jitsi.org/jitmeet/start-muted"});
524
+                delete this.presMap["startMuted"];
509 525
             }
510 526
 
511 527
             pres.up();
@@ -586,6 +602,9 @@ module.exports = function(XMPP, eventEmitter) {
586 602
         addUserIdToPresence: function (userId) {
587 603
             this.presMap['userId'] = userId;
588 604
         },
605
+        addStartMutedToPresence: function (audio, video) {
606
+            this.presMap["startMuted"] = {audio: audio, video: video};
607
+        },
589 608
         isModerator: function () {
590 609
             return this.role === 'moderator';
591 610
         },

+ 8
- 0
modules/xmpp/strophe.jingle.js Целия файл

@@ -108,6 +108,14 @@ module.exports = function(XMPP, eventEmitter)
108 108
             // see http://xmpp.org/extensions/xep-0166.html#concepts-session
109 109
             switch (action) {
110 110
                 case 'session-initiate':
111
+                    var startMuted = $(iq).find('jingle>startmuted');
112
+                    if(startMuted && startMuted.length > 0)
113
+                    {
114
+                        var audioMuted = startMuted.attr("audio");
115
+                        var videoMuted = startMuted.attr("video");
116
+                        APP.UI.setInitialMuteFromFocus((audioMuted === "true"),
117
+                            (videoMuted === "true"));
118
+                    }
111 119
                     sess = new JingleSession(
112 120
                         $(iq).attr('to'), $(iq).find('jingle').attr('sid'),
113 121
                         this.connection, XMPP);

+ 6
- 0
modules/xmpp/xmpp.js Целия файл

@@ -481,6 +481,12 @@ var XMPP = {
481 481
             case "devices":
482 482
                 connection.emuc.addDevicesToPresence(value);
483 483
                 break;
484
+            case "startMuted":
485
+                if(!Moderator.isModerator())
486
+                    return;
487
+                connection.emuc.addStartMutedToPresence(value[0],
488
+                    value[1]);
489
+                break;
484 490
             default :
485 491
                 console.log("Unknown tag for presence: " + name);
486 492
                 return;

+ 2
- 1
service/xmpp/XMPPEvents.js Целия файл

@@ -29,6 +29,7 @@ var XMPPEvents = {
29 29
     AUTHENTICATION_REQUIRED: "xmpp.authentication_required",
30 30
     CHAT_ERROR_RECEIVED: "xmpp.chat_error_received",
31 31
     ETHERPAD: "xmpp.etherpad",
32
-    DEVICE_AVAILABLE: "xmpp.device_available"
32
+    DEVICE_AVAILABLE: "xmpp.device_available",
33
+    START_MUTED: "xmpp.start_muted"
33 34
 };
34 35
 module.exports = XMPPEvents;

Loading…
Отказ
Запис