Browse Source

Focus and debug changes

j8
paweldomas 11 years ago
parent
commit
f629ec17fa
5 changed files with 57 additions and 47 deletions
  1. 43
    45
      app.js
  2. 2
    1
      config.js
  3. 9
    0
      libs/strophe/strophe.jingle.adapter.js
  4. 2
    0
      libs/strophe/strophe.jingle.session.js
  5. 1
    1
      muc.js

+ 43
- 45
app.js View File

2
 /* application specific logic */
2
 /* application specific logic */
3
 var connection = null;
3
 var connection = null;
4
 var authenticatedUser = false;
4
 var authenticatedUser = false;
5
-var focus = null;
6
 var activecall = null;
5
 var activecall = null;
7
 var RTC = null;
6
 var RTC = null;
8
 var nickname = null;
7
 var nickname = null;
595
 
594
 
596
 $(document).bind('callterminated.jingle', function (event, sid, jid, reason) {
595
 $(document).bind('callterminated.jingle', function (event, sid, jid, reason) {
597
     // Leave the room if my call has been remotely terminated.
596
     // Leave the room if my call has been remotely terminated.
598
-    if (connection.emuc.joined && focus == null && reason === 'kick') {
597
+    if (connection.emuc.joined && reason === 'kick') {
599
         sessionTerminated = true;
598
         sessionTerminated = true;
600
         connection.emuc.doLeave();
599
         connection.emuc.doLeave();
601
         messageHandler.openMessageDialog("Session Terminated",
600
         messageHandler.openMessageDialog("Session Terminated",
677
         document.createTextNode(Strophe.getResourceFromJid(jid) + ' (me)')
676
         document.createTextNode(Strophe.getResourceFromJid(jid) + ' (me)')
678
     );
677
     );
679
 
678
 
680
-    if (Object.keys(connection.emuc.members).length < 1) {
679
+/*    if (Object.keys(connection.emuc.members).length < 1) {
681
         focus = new ColibriFocus(connection, config.hosts.bridge);
680
         focus = new ColibriFocus(connection, config.hosts.bridge);
682
         if (nickname !== null) {
681
         if (nickname !== null) {
683
             focus.setEndpointDisplayName(connection.emuc.myroomjid,
682
             focus.setEndpointDisplayName(connection.emuc.myroomjid,
694
 
693
 
695
     if (focus && config.etherpad_base) {
694
     if (focus && config.etherpad_base) {
696
         Etherpad.init();
695
         Etherpad.init();
697
-    }
696
+    }*/
697
+
698
+    var elem = $iq({to: config.hosts.focus, type: 'set'});
699
+    elem.c('conference', {
700
+        xmlns: 'http://jitsi.org/protocol/focus',
701
+        room: roomUrl.substr(roomUrl.lastIndexOf("/") + 1)
702
+    });
703
+    elem.up();
704
+
705
+    connection.sendIQ(elem,
706
+        function (result) {
707
+            console.info("Focus replied ", result);
708
+        },
709
+        function (error) {
710
+            console.warn(error);
711
+        }
712
+    );
698
 
713
 
699
     VideoLayout.showFocusIndicator();
714
     VideoLayout.showFocusIndicator();
700
 
715
 
720
 
735
 
721
     console.log('is focus? ' + (focus ? 'true' : 'false'));
736
     console.log('is focus? ' + (focus ? 'true' : 'false'));
722
 
737
 
738
+    if (Strophe.getResourceFromJid(jid).indexOf('focus') != -1)
739
+    {
740
+        console.info("Ignore focus");
741
+        return;
742
+    }
743
+
723
     // Add Peer's container
744
     // Add Peer's container
724
     VideoLayout.ensurePeerContainerExists(jid);
745
     VideoLayout.ensurePeerContainerExists(jid);
725
 
746
 
728
         APIConnector.triggerEvent("participantJoined",{jid: jid});
749
         APIConnector.triggerEvent("participantJoined",{jid: jid});
729
     }
750
     }
730
 
751
 
731
-    if (focus !== null) {
752
+    /*if (focus !== null) {
732
         // FIXME: this should prepare the video
753
         // FIXME: this should prepare the video
733
         if (focus.confid === null) {
754
         if (focus.confid === null) {
734
             console.log('make new conference with', jid);
755
             console.log('make new conference with', jid);
743
             console.log('invite', jid, 'into conference');
764
             console.log('invite', jid, 'into conference');
744
             focus.addNewParticipant(jid);
765
             focus.addNewParticipant(jid);
745
         }
766
         }
746
-    }
767
+    }*/
747
 });
768
 });
748
 
769
 
749
 $(document).bind('left.muc', function (event, jid) {
770
 $(document).bind('left.muc', function (event, jid) {
784
 
805
 
785
     connection.jingle.terminateByJid(jid);
806
     connection.jingle.terminateByJid(jid);
786
 
807
 
787
-    if (focus == null
788
-            // I shouldn't be the one that left to enter here.
789
-            && jid !== connection.emuc.myroomjid
790
-            && connection.emuc.myroomjid === connection.emuc.list_members[0]
791
-            // If our session has been terminated for some reason
792
-            // (kicked, hangup), don't try to become the focus
793
-            && !sessionTerminated) {
794
-        console.log('welcome to our new focus... myself');
795
-        focus = new ColibriFocus(connection, config.hosts.bridge);
796
-        if (nickname !== null) {
797
-            focus.setEndpointDisplayName(connection.emuc.myroomjid,
798
-                                         nickname);
799
-        }
800
-
801
-        Toolbar.showSipCallButton(true);
802
-
803
-        if (Object.keys(connection.emuc.members).length > 0) {
804
-            focus.makeConference(Object.keys(connection.emuc.members));
805
-            Toolbar.showRecordingButton(true);
806
-        }
807
-        $(document).trigger('focusechanged.muc', [focus]);
808
-    }
809
-    else if (focus && Object.keys(connection.emuc.members).length === 0) {
810
-        console.log('everyone left');
811
-        // FIXME: closing the connection is a hack to avoid some
812
-        // problems with reinit
813
-        disposeConference();
814
-        focus = new ColibriFocus(connection, config.hosts.bridge);
815
-        if (nickname !== null) {
816
-            focus.setEndpointDisplayName(connection.emuc.myroomjid,
817
-                                         nickname);
818
-        }
819
-        Toolbar.showSipCallButton(true);
820
-        Toolbar.showRecordingButton(false);
821
-    }
822
     if (connection.emuc.getPrezi(jid)) {
808
     if (connection.emuc.getPrezi(jid)) {
823
         $(document).trigger('presentationremoved.muc',
809
         $(document).trigger('presentationremoved.muc',
824
                             [jid, connection.emuc.getPrezi(jid)]);
810
                             [jid, connection.emuc.getPrezi(jid)]);
867
     if (displayName && displayName.length > 0)
853
     if (displayName && displayName.length > 0)
868
         $(document).trigger('displaynamechanged',
854
         $(document).trigger('displaynamechanged',
869
                             [jid, displayName]);
855
                             [jid, displayName]);
856
+                            [jid, info.displayName]);
857
+    if (Strophe.getResourceFromJid(jid).indexOf('focus') != -1)
858
+    {
859
+        console.info("Ignore focus");
860
+        return;
861
+    }
870
 
862
 
871
-    if (focus !== null && info.displayName !== null) {
863
+    /*if (focus !== null && info.displayName !== null) {
872
         focus.setEndpointDisplayName(jid, info.displayName);
864
         focus.setEndpointDisplayName(jid, info.displayName);
873
-    }
865
+    }*/
874
 
866
 
875
     //check if the video bridge is available
867
     //check if the video bridge is available
876
     if($(pres).find(">bridgeIsDown").length > 0 && !bridgeIsDown) {
868
     if($(pres).find(">bridgeIsDown").length > 0 && !bridgeIsDown) {
972
 }
964
 }
973
 
965
 
974
 function getConferenceHandler() {
966
 function getConferenceHandler() {
975
-    return focus ? focus : activecall;
967
+    return activecall;
976
 }
968
 }
977
 
969
 
978
 function toggleVideo() {
970
 function toggleVideo() {
1414
     if(onUnload) {
1406
     if(onUnload) {
1415
         stopLocalRtpStatsCollector();
1407
         stopLocalRtpStatsCollector();
1416
     }
1408
     }
1417
-    focus = null;
1418
     activecall = null;
1409
     activecall = null;
1419
 }
1410
 }
1420
 
1411
 
1545
 //    }
1536
 //    }
1546
 }
1537
 }
1547
 
1538
 
1539
+$(document).bind('error.jingle',
1540
+    function (event, session, error)
1541
+    {
1542
+        console.error("Jingle error", error);
1543
+    }
1544
+);
1545
+
1548
 $(document).bind('fatalError.jingle',
1546
 $(document).bind('fatalError.jingle',
1549
     function (event, session, error)
1547
     function (event, session, error)
1550
     {
1548
     {

+ 2
- 1
config.js View File

4
         //anonymousdomain: 'guest.example.com',
4
         //anonymousdomain: 'guest.example.com',
5
         muc: 'conference.jitsi-meet.example.com', // FIXME: use XEP-0030
5
         muc: 'conference.jitsi-meet.example.com', // FIXME: use XEP-0030
6
         bridge: 'jitsi-videobridge.jitsi-meet.example.com', // FIXME: use XEP-0030
6
         bridge: 'jitsi-videobridge.jitsi-meet.example.com', // FIXME: use XEP-0030
7
-        //call_control: 'callcontrol.jitsi-meet.example.com'
7
+        call_control: 'callcontrol.jitsi-meet.example.com',
8
+        focus: 'focus.jitsi-meet.example.com'
8
     },
9
     },
9
 //  getroomnode: function (path) { return 'someprefixpossiblybasedonpath'; },
10
 //  getroomnode: function (path) { return 'someprefixpossiblybasedonpath'; },
10
 //  useStunTurn: true, // use XEP-0215 to fetch STUN and TURN server
11
 //  useStunTurn: true, // use XEP-0215 to fetch STUN and TURN server

+ 9
- 0
libs/strophe/strophe.jingle.adapter.js View File

356
     });
356
     });
357
     this.removessrc = [];
357
     this.removessrc = [];
358
 
358
 
359
+    // FIXME:
360
+    // this was a hack for the situation when only one peer exists
361
+    // in the conference.
362
+    // check if still required and remove
363
+    if (sdp.media[0])
364
+        sdp.media[0] = sdp.media[0].replace('a=recvonly', 'a=sendrecv');
365
+    if (sdp.media[1])
366
+        sdp.media[1] = sdp.media[1].replace('a=recvonly', 'a=sendrecv');
367
+
359
     sdp.raw = sdp.session + sdp.media.join('');
368
     sdp.raw = sdp.session + sdp.media.join('');
360
     this.setRemoteDescription(new RTCSessionDescription({type: 'offer', sdp: sdp.raw}),
369
     this.setRemoteDescription(new RTCSessionDescription({type: 'offer', sdp: sdp.raw}),
361
         function() {
370
         function() {

+ 2
- 0
libs/strophe/strophe.jingle.session.js View File

581
                         reason: $(stanza).find('error :first')[0].tagName,
581
                         reason: $(stanza).find('error :first')[0].tagName,
582
                     }:{};
582
                     }:{};
583
                     error.source = 'answer';
583
                     error.source = 'answer';
584
+                    error.stanza = stanza;
585
+
584
                     $(document).trigger('error.jingle', [self.sid, error]);
586
                     $(document).trigger('error.jingle', [self.sid, error]);
585
                 },
587
                 },
586
                 10000);
588
                 10000);

+ 1
- 1
muc.js View File

139
             $(document).trigger('entered.muc', [from, member, pres]);
139
             $(document).trigger('entered.muc', [from, member, pres]);
140
         }
140
         }
141
         // Always trigger presence to update bindings
141
         // Always trigger presence to update bindings
142
-        console.log('presence change from', from);
142
+        console.log('presence change from', from, pres);
143
         $(document).trigger('presence.muc', [from, member, pres]);
143
         $(document).trigger('presence.muc', [from, member, pres]);
144
 
144
 
145
         // Trigger status message update
145
         // Trigger status message update

Loading…
Cancel
Save