Quellcode durchsuchen

Adds SIP gateway support.

master
paweldomas vor 11 Jahren
Ursprung
Commit
1a074b12b4
8 geänderte Dateien mit 209 neuen und 4 gelöschten Zeilen
  1. 43
    2
      app.js
  2. 3
    1
      config.js
  3. 3
    0
      css/font.css
  4. 22
    0
      css/videolayout_default.css
  5. 6
    0
      index.html
  6. 94
    0
      libs/rayo.js
  7. 13
    0
      toolbar.js
  8. 25
    1
      videolayout.js

+ 43
- 2
app.js Datei anzeigen

@@ -8,6 +8,7 @@ var nickname = null;
8 8
 var sharedKey = '';
9 9
 var recordingToken ='';
10 10
 var roomUrl = null;
11
+var roomName = null;
11 12
 var ssrc2jid = {};
12 13
 /**
13 14
  * The stats collector that process stats data and triggers updates to app.js.
@@ -182,7 +183,9 @@ function doJoin() {
182 183
         }
183 184
     }
184 185
 
185
-    roomjid = roomnode + '@' + config.hosts.muc;
186
+    roomName = roomnode + '@' + config.hosts.muc;
187
+
188
+    roomjid = roomName;
186 189
 
187 190
     if (config.useNicks) {
188 191
         var nick = window.prompt('Your nickname (optional)');
@@ -631,9 +634,15 @@ $(document).bind('joined.muc', function (event, jid, info) {
631 634
             focus.setEndpointDisplayName(connection.emuc.myroomjid,
632 635
                                          nickname);
633 636
         }
637
+        Toolbar.showSipCallButton(true);
634 638
         Toolbar.showRecordingButton(false);
635 639
     }
636 640
 
641
+    if (!focus)
642
+    {
643
+        Toolbar.showSipCallButton(false);
644
+    }
645
+
637 646
     if (focus && config.etherpad_base) {
638 647
         Etherpad.init();
639 648
     }
@@ -714,6 +723,8 @@ $(document).bind('left.muc', function (event, jid) {
714 723
                                          nickname);
715 724
         }
716 725
 
726
+        Toolbar.showSipCallButton(true);
727
+
717 728
         if (Object.keys(connection.emuc.members).length > 0) {
718 729
             focus.makeConference(Object.keys(connection.emuc.members));
719 730
             Toolbar.showRecordingButton(true);
@@ -730,6 +741,7 @@ $(document).bind('left.muc', function (event, jid) {
730 741
             focus.setEndpointDisplayName(connection.emuc.myroomjid,
731 742
                                          nickname);
732 743
         }
744
+        Toolbar.showSipCallButton(true);
733 745
         Toolbar.showRecordingButton(false);
734 746
     }
735 747
     if (connection.emuc.getPrezi(jid)) {
@@ -781,7 +793,7 @@ $(document).bind('presence.muc', function (event, jid, info, pres) {
781 793
         VideoLayout.ensurePeerContainerExists(jid);
782 794
         VideoLayout.setDisplayName(
783 795
                 'participant_' + Strophe.getResourceFromJid(jid),
784
-                info.displayName);
796
+                info.displayName, info.status);
785 797
     }
786 798
 
787 799
     if (focus !== null && info.displayName !== null) {
@@ -1279,3 +1291,32 @@ $(document).bind('fatalError.jingle',
1279 1291
             "Your browser version is too old. Please update and try again...");
1280 1292
     }
1281 1293
 );
1294
+
1295
+function callSipButtonClicked()
1296
+{
1297
+    $.prompt('<h2>Enter SIP number</h2>' +
1298
+        '<input id="sipNumber" type="text"' +
1299
+        ' value="' + config.defaultSipNumber + '" autofocus>',
1300
+        {
1301
+            persistent: false,
1302
+            buttons: { "Dial": true, "Cancel": false},
1303
+            defaultButton: 2,
1304
+            loaded: function (event)
1305
+            {
1306
+                document.getElementById('sipNumber').focus();
1307
+            },
1308
+            submit: function (e, v, m, f)
1309
+            {
1310
+                if (v)
1311
+                {
1312
+                    var numberInput = document.getElementById('sipNumber');
1313
+                    if (numberInput.value)
1314
+                    {
1315
+                        connection.rayo.dial(
1316
+                            numberInput.value, 'fromnumber', roomName);
1317
+                    }
1318
+                }
1319
+            }
1320
+        }
1321
+    );
1322
+}

+ 3
- 1
config.js Datei anzeigen

@@ -2,7 +2,8 @@ var config = {
2 2
     hosts: {
3 3
         domain: 'jitsi-meet.example.com',
4 4
         muc: 'conference.jitsi-meet.example.com', // FIXME: use XEP-0030
5
-        bridge: 'jitsi-videobridge.jitsi-meet.example.com' // FIXME: use XEP-0030
5
+        bridge: 'jitsi-videobridge.jitsi-meet.example.com', // FIXME: use XEP-0030
6
+        //call_control: 'callcontrol.jitsi-meet.example.com'
6 7
     },
7 8
 //  getroomnode: function (path) { return 'someprefixpossiblybasedonpath'; },
8 9
 //  useStunTurn: true, // use XEP-0215 to fetch STUN and TURN server
@@ -14,6 +15,7 @@ var config = {
14 15
     minChromeExtVersion: '0.1', // Required version of Chrome extension
15 16
     enableRtpStats: true, // Enables RTP stats processing
16 17
     openSctp: true, // Toggle to enable/disable SCTP channels
18
+    //defaultSipNumber: '20669', //Default SIP number used in call dialog
17 19
 //    channelLastN: -1, // The default value of the channel attribute last-n.
18 20
 //    useRtcpMux: true,
19 21
     enableRecording: false

+ 3
- 0
css/font.css Datei anzeigen

@@ -71,6 +71,9 @@
71 71
 .icon-share-doc:before {
72 72
 	content: "\e605";
73 73
 }
74
+.icon-telephone:before {
75
+    content: "\e611";
76
+}
74 77
 .icon-security-locked:before {
75 78
 	content: "\e607";
76 79
 }

+ 22
- 0
css/videolayout_default.css Datei anzeigen

@@ -171,10 +171,31 @@
171 171
     border-radius:20px;
172 172
 }
173 173
 
174
+.videocontainer>span.status {
175
+    display: inline-block;
176
+    position: absolute;
177
+    color: #FFFFFF;
178
+    background: rgba(0,0,0,.7);
179
+    text-align: center;
180
+    text-overflow: ellipsis;
181
+    width: 70%;
182
+    height: 15%;
183
+    left: 15%;
184
+    bottom: 2%;
185
+    padding: 5px;
186
+    font-size: 10pt;
187
+    overflow: hidden;
188
+    white-space: nowrap;
189
+    z-index: 2;
190
+    border-radius:20px;
191
+}
192
+
193
+#localVideoContainer>span.status:hover,
174 194
 #localVideoContainer>span.displayname:hover {
175 195
     cursor: text;
176 196
 }
177 197
 
198
+.videocontainer>span.status,
178 199
 .videocontainer>span.displayname {
179 200
     pointer-events: none;
180 201
 }
@@ -187,6 +208,7 @@
187 208
     pointer-events: auto !important;
188 209
 }
189 210
 
211
+.videocontainer>a.status,
190 212
 .videocontainer>a.displayname {
191 213
     display: inline-block;
192 214
     position: absolute;

+ 6
- 0
index.html Datei anzeigen

@@ -20,6 +20,7 @@
20 20
     <script src="libs/colibri/colibri.focus.js?v=8"></script><!-- colibri focus implementation -->
21 21
     <script src="libs/colibri/colibri.session.js?v=1"></script>
22 22
     <script src="libs/jquery-ui.js"></script>
23
+    <script src="libs/rayo.js?v=1"></script>
23 24
     <script src="libs/tooltip.js?v=1"></script><!-- bootstrap tooltip lib -->
24 25
     <script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib -->
25 26
     <script src="config.js?v=3"></script><!-- adapt to your needs, i.e. set hosts and bosh path -->
@@ -96,6 +97,11 @@
96 97
                 </span>
97 98
                 <a class="button" data-toggle="popover" data-placement="bottom" data-content="Enter / Exit Full Screen" onclick='buttonClick("#fullScreen", "icon-full-screen icon-exit-full-screen");Toolbar.toggleFullScreen();'>
98 99
                     <i id="fullScreen" class="icon-full-screen"></i></a>
100
+                <span id="sipCallButton">
101
+                    <div class="header_button_separator"></div>
102
+                    <a class="button" data-toggle="popover" data-placement="bottom" data-content="Call SIP number" onclick='callSipButtonClicked();'>
103
+                        <i class="icon-telephone"></i></a>
104
+                </span>
99 105
             </span>
100 106
         </div>
101 107
         <div id="subject"></div>

+ 94
- 0
libs/rayo.js Datei anzeigen

@@ -0,0 +1,94 @@
1
+/* jshint -W117 */
2
+Strophe.addConnectionPlugin('rayo',
3
+    {
4
+        RAYO_XMLNS: 'urn:xmpp:rayo:1',
5
+        connection: null,
6
+        init: function (conn)
7
+        {
8
+            this.connection = conn;
9
+            if (this.connection.disco)
10
+            {
11
+                this.connection.disco.addFeature('urn:xmpp:rayo:client:1');
12
+            }
13
+
14
+            this.connection.addHandler(
15
+                this.onRayo.bind(this), this.RAYO_XMLNS, 'iq', 'set', null, null);
16
+        },
17
+        onRayo: function (iq)
18
+        {
19
+            console.info("Rayo IQ", iq);
20
+        },
21
+        dial: function (to, from, roomName)
22
+        {
23
+            var self = this;
24
+            var req = $iq(
25
+                {
26
+                    type: 'set',
27
+                    to: config.hosts.call_control
28
+                }
29
+            );
30
+            req.c('dial',
31
+                {
32
+                    xmlns: this.RAYO_XMLNS,
33
+                    to: to,
34
+                    from: from
35
+                });
36
+            req.c('header',
37
+                {
38
+                    name: 'JvbRoomName',
39
+                    value: roomName
40
+                });
41
+
42
+            this.connection.sendIQ(
43
+                req,
44
+                function (result)
45
+                {
46
+                    console.info('Dial result ', result);
47
+
48
+                    var resource = $(result).find('ref').attr('uri');
49
+                    this.call_resource = resource.substr('xmpp:'.length);
50
+                    console.info(
51
+                        "Received call resource: " + this.call_resource);
52
+                },
53
+                function (error)
54
+                {
55
+                    console.info('Dial error ', error);
56
+                }
57
+            );
58
+        },
59
+        hang_up: function ()
60
+        {
61
+            if (!this.call_resource)
62
+            {
63
+                console.warn("No call in progress");
64
+                return;
65
+            }
66
+
67
+            var self = this;
68
+            var req = $iq(
69
+                {
70
+                    type: 'set',
71
+                    to: this.call_resource
72
+                }
73
+            );
74
+            req.c('hangup',
75
+                {
76
+                    xmlns: this.RAYO_XMLNS
77
+                });
78
+
79
+            this.connection.sendIQ(
80
+                req,
81
+                function (result)
82
+                {
83
+                    console.info('Hangup result ', result);
84
+                    self.call_resource = null;
85
+                },
86
+                function (error)
87
+                {
88
+                    console.info('Hangup error ', error);
89
+                    self.call_resource = null;
90
+                }
91
+            );
92
+        }
93
+    }
94
+);

+ 13
- 0
toolbar.js Datei anzeigen

@@ -303,5 +303,18 @@ var Toolbar = (function (my) {
303 303
         $('#recordButton').toggleClass('active');
304 304
     };
305 305
 
306
+    // Shows or hides SIP calls button
307
+    my.showSipCallButton = function (show)
308
+    {
309
+        if (config.hosts.call_control && show)
310
+        {
311
+            $('#sipCallButton').css({display: "inline"});
312
+        }
313
+        else
314
+        {
315
+            $('#sipCallButton').css({display: "none"});
316
+        }
317
+    };
318
+
306 319
     return my;
307 320
 }(Toolbar || {}));

+ 25
- 1
videolayout.js Datei anzeigen

@@ -323,11 +323,35 @@ var VideoLayout = (function (my) {
323 323
     /**
324 324
      * Shows the display name for the given video.
325 325
      */
326
-    my.setDisplayName = function(videoSpanId, displayName) {
326
+    my.setDisplayName = function(videoSpanId, displayName, statusMsg) {
327 327
         var nameSpan = $('#' + videoSpanId + '>span.displayname');
328 328
         var defaultLocalDisplayName = "Me";
329 329
         var defaultRemoteDisplayName = "Speaker";
330 330
 
331
+        var statusSpan = $('#' + videoSpanId + '>span.status');
332
+        if (!statusSpan.length)
333
+        {
334
+            //Add status span
335
+            statusSpan = document.createElement('span');
336
+            statusSpan.className = 'status';
337
+            statusSpan.id = videoSpanId + '_status';
338
+            $('#' + videoSpanId)[0].appendChild(statusSpan);
339
+
340
+            statusSpan = $('#' + videoSpanId + '>span.status');
341
+        }
342
+
343
+        // Display status
344
+        if (statusMsg && statusMsg.length)
345
+        {
346
+            $('#' + videoSpanId + '_status').text(statusMsg);
347
+            statusSpan.get(0).setAttribute("style", "display:inline-block;");
348
+        }
349
+        else
350
+        {
351
+            // Hide
352
+            statusSpan.get(0).setAttribute("style", "display:none;");
353
+        }
354
+
331 355
         // If we already have a display name for this video.
332 356
         if (nameSpan.length > 0) {
333 357
             var nameSpanElement = nameSpan.get(0);

Laden…
Abbrechen
Speichern