Procházet zdrojové kódy

Basic recording.

j8
paweldomas před 11 roky
rodič
revize
6afcfb2598
5 změnil soubory, kde provedl 115 přidání a 53 odebrání
  1. 14
    51
      app.js
  2. 2
    2
      config.js
  3. 1
    0
      index.html
  4. 8
    0
      muc.js
  5. 90
    0
      recording.js

+ 14
- 51
app.js Zobrazit soubor

6
 var RTC = null;
6
 var RTC = null;
7
 var nickname = null;
7
 var nickname = null;
8
 var sharedKey = '';
8
 var sharedKey = '';
9
-var recordingToken ='';
9
+var focusJid = null;
10
 var roomUrl = null;
10
 var roomUrl = null;
11
 var roomName = null;
11
 var roomName = null;
12
 var ssrc2jid = {};
12
 var ssrc2jid = {};
676
         document.createTextNode(Strophe.getResourceFromJid(jid) + ' (me)')
676
         document.createTextNode(Strophe.getResourceFromJid(jid) + ' (me)')
677
     );
677
     );
678
 
678
 
679
+    if (connection.emuc.isModerator())
680
+    {
681
+        Toolbar.showSipCallButton(true);
682
+        Toolbar.showRecordingButton(true);
683
+    }
684
+    else
685
+    {
686
+        Toolbar.showSipCallButton(false);
687
+        Toolbar.showRecordingButton(false);
688
+    }
679
 /*    if (Object.keys(connection.emuc.members).length < 1) {
689
 /*    if (Object.keys(connection.emuc.members).length < 1) {
680
         focus = new ColibriFocus(connection, config.hosts.bridge);
690
         focus = new ColibriFocus(connection, config.hosts.bridge);
681
         if (nickname !== null) {
691
         if (nickname !== null) {
737
 
747
 
738
     if (Strophe.getResourceFromJid(jid).indexOf('focus') != -1)
748
     if (Strophe.getResourceFromJid(jid).indexOf('focus') != -1)
739
     {
749
     {
740
-        console.info("Ignore focus");
750
+        focusJid = jid;
751
+        console.info("Ignore focus " + jid);
741
         return;
752
         return;
742
     }
753
     }
743
 
754
 
1036
 
1047
 
1037
 // Starts or stops the recording for the conference.
1048
 // Starts or stops the recording for the conference.
1038
 function toggleRecording() {
1049
 function toggleRecording() {
1039
-    if (focus === null || focus.confid === null) {
1040
-        console.log('non-focus, or conference not yet organized: not enabling recording');
1041
-        return;
1042
-    }
1043
-
1044
-    if (!recordingToken)
1045
-    {
1046
-        messageHandler.openTwoButtonDialog(null,
1047
-            '<h2>Enter recording token</h2>' +
1048
-                '<input id="recordingToken" type="text" placeholder="token" autofocus>',
1049
-            false,
1050
-            "Save",
1051
-            function (e, v, m, f) {
1052
-                if (v) {
1053
-                    var token = document.getElementById('recordingToken');
1054
-
1055
-                    if (token.value) {
1056
-                        setRecordingToken(Util.escapeHtml(token.value));
1057
-                        toggleRecording();
1058
-                    }
1059
-                }
1060
-            },
1061
-            function (event) {
1062
-                document.getElementById('recordingToken').focus();
1063
-            }
1064
-        );
1065
-
1066
-        return;
1067
-    }
1068
-
1069
-    var oldState = focus.recordingEnabled;
1070
-    Toolbar.toggleRecordingButtonState();
1071
-    focus.setRecording(!oldState,
1072
-                        recordingToken,
1073
-                        function (state) {
1074
-                            console.log("New recording state: ", state);
1075
-                            if (state == oldState) //failed to change, reset the token because it might have been wrong
1076
-                            {
1077
-                                Toolbar.toggleRecordingButtonState();
1078
-                                setRecordingToken(null);
1079
-                            }
1080
-                        }
1081
-    );
1082
-
1083
-
1050
+    Recording.toggleRecording();
1084
 }
1051
 }
1085
 
1052
 
1086
 /**
1053
 /**
1472
     sharedKey = sKey;
1439
     sharedKey = sKey;
1473
 }
1440
 }
1474
 
1441
 
1475
-function setRecordingToken(token) {
1476
-    recordingToken = token;
1477
-}
1478
-
1479
 /**
1442
 /**
1480
  * Updates the room invite url.
1443
  * Updates the room invite url.
1481
  */
1444
  */

+ 2
- 2
config.js Zobrazit soubor

25
     adaptiveSimulcast: false,
25
     adaptiveSimulcast: false,
26
     useRtcpMux: true,
26
     useRtcpMux: true,
27
     useBundle: true,
27
     useBundle: true,
28
-    enableRecording: false,
29
-    enableWelcomePage: true,
28
+    enableRecording: true,
29
+    enableWelcomePage: false,
30
     enableSimulcast: false
30
     enableSimulcast: false
31
 };
31
 };

+ 1
- 0
index.html Zobrazit soubor

57
     <script src="bottom_toolbar.js?v=5"></script><!-- media stream -->
57
     <script src="bottom_toolbar.js?v=5"></script><!-- media stream -->
58
     <script src="roomname_generator.js?v=1"></script><!-- generator for random room names -->
58
     <script src="roomname_generator.js?v=1"></script><!-- generator for random room names -->
59
     <script src="keyboard_shortcut.js?v=3"></script>
59
     <script src="keyboard_shortcut.js?v=3"></script>
60
+    <script src="recording.js?v=1"></script>
60
     <script src="tracking.js?v=1"></script><!-- tracking -->
61
     <script src="tracking.js?v=1"></script><!-- tracking -->
61
     <script src="jitsipopover.js?v=3"></script>
62
     <script src="jitsipopover.js?v=3"></script>
62
     <script src="message_handler.js?v=2"></script>
63
     <script src="message_handler.js?v=2"></script>

+ 8
- 0
muc.js Zobrazit soubor

12
     preziMap: {},
12
     preziMap: {},
13
     joined: false,
13
     joined: false,
14
     isOwner: false,
14
     isOwner: false,
15
+    role: null,
15
     init: function (conn) {
16
     init: function (conn) {
16
         this.connection = conn;
17
         this.connection = conn;
17
     },
18
     },
127
 
128
 
128
         if (from == this.myroomjid) {
129
         if (from == this.myroomjid) {
129
             if (member.affiliation == 'owner') this.isOwner = true;
130
             if (member.affiliation == 'owner') this.isOwner = true;
131
+            if (this.role !== member.role) {
132
+                this.role = member.role;
133
+                console.info("My role: " + this.role);
134
+            }
130
             if (!this.joined) {
135
             if (!this.joined) {
131
                 this.joined = true;
136
                 this.joined = true;
132
                 $(document).trigger('joined.muc', [from, member]);
137
                 $(document).trigger('joined.muc', [from, member]);
456
     },
461
     },
457
     addBridgeIsDownToPresence: function() {
462
     addBridgeIsDownToPresence: function() {
458
         this.presMap['bridgeIsDown'] = true;
463
         this.presMap['bridgeIsDown'] = true;
464
+    },
465
+    isModerator: function() {
466
+        return this.role === 'moderator';
459
     }
467
     }
460
 });
468
 });

+ 90
- 0
recording.js Zobrazit soubor

1
+/* global $, $iq, config, connection, focusJid, messageHandler, Toolbar, Util */
2
+var Recording = (function (my) {
3
+    var status = false;
4
+    var recordingToken = null;
5
+    var recordingEnabled = false;
6
+
7
+    my.setRecordingToken = function (token) {
8
+        recordingToken = token;
9
+    };
10
+
11
+    // Sends a COLIBRI message which enables or disables (according to 'state')
12
+    // the recording on the bridge. Waits for the result IQ and calls 'callback'
13
+    // with the new recording state, according to the IQ.
14
+    my.setRecording = function (state, token, callback) {
15
+        var self = this;
16
+        var elem = $iq({to: focusJid, type: 'set'});
17
+        elem.c('conference', {
18
+            xmlns: 'http://jitsi.org/protocol/colibri'
19
+        });
20
+        elem.c('recording', {state: state, token: token});
21
+        elem.up();
22
+
23
+        connection.sendIQ(elem,
24
+            function (result) {
25
+                console.log('Set recording "', state, '". Result:', result);
26
+                var recordingElem = $(result).find('>conference>recording');
27
+                var newState = ('true' === recordingElem.attr('state'));
28
+
29
+                recordingEnabled = newState;
30
+                callback(newState);
31
+            },
32
+            function (error) {
33
+                console.warn(error);
34
+            }
35
+        );
36
+    };
37
+
38
+    my.toggleRecording = function () {
39
+        if (!connection.emuc.isModerator()) {
40
+            console.log(
41
+                'non-focus, or conference not yet organized:' +
42
+                ' not enabling recording');
43
+            return;
44
+        }
45
+
46
+        if (!recordingToken)
47
+        {
48
+            messageHandler.openTwoButtonDialog(null,
49
+                    '<h2>Enter recording token</h2>' +
50
+                    '<input id="recordingToken" type="text" placeholder="token" autofocus>',
51
+                false,
52
+                "Save",
53
+                function (e, v, m, f) {
54
+                    if (v) {
55
+                        var token = document.getElementById('recordingToken');
56
+
57
+                        if (token.value) {
58
+                            my.setRecordingToken(
59
+                                Util.escapeHtml(token.value));
60
+                            my.toggleRecording();
61
+                        }
62
+                    }
63
+                },
64
+                function (event) {
65
+                    document.getElementById('recordingToken').focus();
66
+                }
67
+            );
68
+
69
+            return;
70
+        }
71
+
72
+        var oldState = recordingEnabled;
73
+        Toolbar.toggleRecordingButtonState();
74
+        my.setRecording(!oldState,
75
+            recordingToken,
76
+            function (state) {
77
+                console.log("New recording state: ", state);
78
+                if (state == oldState)
79
+                {
80
+                    // Failed to change, reset the token because it might
81
+                    // have been wrong
82
+                    Toolbar.toggleRecordingButtonState();
83
+                    my.setRecordingToken(null);
84
+                }
85
+            }
86
+        );
87
+    };
88
+
89
+    return my;
90
+}(Recording || {}));

Načítá se…
Zrušit
Uložit