Преглед изворни кода

Implements recording through a jirecon instance.

j8
Boris Grozev пре 10 година
родитељ
комит
87f8b91a96
3 измењених фајлова са 69 додато и 8 уклоњено
  1. 1
    0
      config.js
  2. 3
    2
      muc.js
  3. 65
    6
      recording.js

+ 1
- 0
config.js Прегледај датотеку

@@ -4,6 +4,7 @@ var config = {
4 4
         //anonymousdomain: 'guest.example.com',
5 5
         muc: 'conference.jitsi-meet.example.com', // FIXME: use XEP-0030
6 6
         bridge: 'jitsi-videobridge.jitsi-meet.example.com', // FIXME: use XEP-0030
7
+        //jirecon: 'jirecon.jitsi-meet.example.com',
7 8
         //call_control: 'callcontrol.jitsi-meet.example.com',
8 9
         //focus: 'focus.jitsi-meet.example.com' - defaults to 'focus.jitsi-meet.example.com'
9 10
     },

+ 3
- 2
muc.js Прегледај датотеку

@@ -83,8 +83,9 @@ Strophe.addConnectionPlugin('emuc', {
83 83
     },
84 84
     onPresence: function (pres) {
85 85
         var from = pres.getAttribute('from');
86
-        var type = pres.getAttribute('type');
87
-        if (type != null) {
86
+
87
+        // What is this for? A workaround for something?
88
+        if (pres.getAttribute('type')) {
88 89
             return true;
89 90
         }
90 91
 

+ 65
- 6
recording.js Прегледај датотеку

@@ -4,21 +4,76 @@ var Recording = (function (my) {
4 4
     var recordingToken = null;
5 5
     var recordingEnabled;
6 6
 
7
+    /**
8
+     * Whether to use a jirecon component for recording, or use the videobridge
9
+     * through COLIBRI.
10
+     */
11
+    var useJirecon = (typeof config.hosts.jirecon != "undefined");
12
+
13
+    /**
14
+     * The ID of the jirecon recording session. Jirecon generates it when we
15
+     * initially start recording, and it needs to be used in subsequent requests
16
+     * to jirecon.
17
+     */
18
+    var jireconRid = null;
19
+
7 20
     my.setRecordingToken = function (token) {
8 21
         recordingToken = token;
9 22
     };
10 23
 
24
+    my.setRecording = function (state, token, callback) {
25
+        if (useJirecon){
26
+            this.setRecordingJirecon(state, token, callback);
27
+        } else {
28
+            this.setRecordingColibri(state, token, callback);
29
+        }
30
+    };
31
+
32
+    my.setRecordingJirecon = function (state, token, callback) {
33
+        if (state == recordingEnabled){
34
+            return;
35
+        }
36
+
37
+        var iq = $iq({to: config.hosts.jirecon, type: 'set'})
38
+            .c('recording', {xmlns: 'http://jitsi.org/protocol/jirecon',
39
+                action: state ? 'start' : 'stop',
40
+                mucjid: connection.emuc.roomjid});
41
+        if (!state){
42
+            iq.attrs({rid: jireconRid});
43
+        }
44
+
45
+        console.log('Start recording');
46
+
47
+        connection.sendIQ(
48
+            iq,
49
+            function (result) {
50
+                // TODO wait for an IQ with the real status, since this is
51
+                // provisional?
52
+                jireconRid = $(result).find('recording').attr('rid');
53
+                console.log('Recording ' + (state ? 'started' : 'stopped') +
54
+                    '(jirecon)' + result);
55
+                recordingEnabled = state;
56
+                if (!state){
57
+                    jireconRid = null;
58
+                }
59
+
60
+                callback(state);
61
+            },
62
+            function (error) {
63
+                console.log('Failed to start recording, error: ', error);
64
+                callback(recordingEnabled);
65
+            });
66
+    };
67
+
11 68
     // Sends a COLIBRI message which enables or disables (according to 'state')
12 69
     // the recording on the bridge. Waits for the result IQ and calls 'callback'
13 70
     // with the new recording state, according to the IQ.
14
-    my.setRecording = function (state, token, callback) {
15
-        var self = this;
71
+    my.setRecordingColibri = function (state, token, callback) {
16 72
         var elem = $iq({to: focusMucJid, type: 'set'});
17 73
         elem.c('conference', {
18 74
             xmlns: 'http://jitsi.org/protocol/colibri'
19 75
         });
20 76
         elem.c('recording', {state: state, token: token});
21
-        elem.up();
22 77
 
23 78
         connection.sendIQ(elem,
24 79
             function (result) {
@@ -31,6 +86,7 @@ var Recording = (function (my) {
31 86
             },
32 87
             function (error) {
33 88
                 console.warn(error);
89
+                callback(recordingEnabled);
34 90
             }
35 91
         );
36 92
     };
@@ -43,11 +99,13 @@ var Recording = (function (my) {
43 99
             return;
44 100
         }
45 101
 
46
-        if (!recordingToken)
102
+        // Jirecon does not (currently) support a token.
103
+        if (!recordingToken && !useJirecon)
47 104
         {
48 105
             messageHandler.openTwoButtonDialog(null,
49 106
                     '<h2>Enter recording token</h2>' +
50
-                    '<input id="recordingToken" type="text" placeholder="token" autofocus>',
107
+                    '<input id="recordingToken" type="text" ' +
108
+                    'placeholder="token" autofocus>',
51 109
                 false,
52 110
                 "Save",
53 111
                 function (e, v, m, f) {
@@ -63,7 +121,8 @@ var Recording = (function (my) {
63 121
                 },
64 122
                 function (event) {
65 123
                     document.getElementById('recordingToken').focus();
66
-                }
124
+                },
125
+                function () {}
67 126
             );
68 127
 
69 128
             return;

Loading…
Откажи
Сачувај