Browse Source

Implements recording through a jirecon instance.

j8
Boris Grozev 10 years ago
parent
commit
87f8b91a96
3 changed files with 69 additions and 8 deletions
  1. 1
    0
      config.js
  2. 3
    2
      muc.js
  3. 65
    6
      recording.js

+ 1
- 0
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
+        //jirecon: 'jirecon.jitsi-meet.example.com',
7
         //call_control: 'callcontrol.jitsi-meet.example.com',
8
         //call_control: 'callcontrol.jitsi-meet.example.com',
8
         //focus: 'focus.jitsi-meet.example.com' - defaults to 'focus.jitsi-meet.example.com'
9
         //focus: 'focus.jitsi-meet.example.com' - defaults to 'focus.jitsi-meet.example.com'
9
     },
10
     },

+ 3
- 2
muc.js View File

83
     },
83
     },
84
     onPresence: function (pres) {
84
     onPresence: function (pres) {
85
         var from = pres.getAttribute('from');
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
             return true;
89
             return true;
89
         }
90
         }
90
 
91
 

+ 65
- 6
recording.js View File

4
     var recordingToken = null;
4
     var recordingToken = null;
5
     var recordingEnabled;
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
     my.setRecordingToken = function (token) {
20
     my.setRecordingToken = function (token) {
8
         recordingToken = token;
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
     // Sends a COLIBRI message which enables or disables (according to 'state')
68
     // 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'
69
     // the recording on the bridge. Waits for the result IQ and calls 'callback'
13
     // with the new recording state, according to the IQ.
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
         var elem = $iq({to: focusMucJid, type: 'set'});
72
         var elem = $iq({to: focusMucJid, type: 'set'});
17
         elem.c('conference', {
73
         elem.c('conference', {
18
             xmlns: 'http://jitsi.org/protocol/colibri'
74
             xmlns: 'http://jitsi.org/protocol/colibri'
19
         });
75
         });
20
         elem.c('recording', {state: state, token: token});
76
         elem.c('recording', {state: state, token: token});
21
-        elem.up();
22
 
77
 
23
         connection.sendIQ(elem,
78
         connection.sendIQ(elem,
24
             function (result) {
79
             function (result) {
31
             },
86
             },
32
             function (error) {
87
             function (error) {
33
                 console.warn(error);
88
                 console.warn(error);
89
+                callback(recordingEnabled);
34
             }
90
             }
35
         );
91
         );
36
     };
92
     };
43
             return;
99
             return;
44
         }
100
         }
45
 
101
 
46
-        if (!recordingToken)
102
+        // Jirecon does not (currently) support a token.
103
+        if (!recordingToken && !useJirecon)
47
         {
104
         {
48
             messageHandler.openTwoButtonDialog(null,
105
             messageHandler.openTwoButtonDialog(null,
49
                     '<h2>Enter recording token</h2>' +
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
                 false,
109
                 false,
52
                 "Save",
110
                 "Save",
53
                 function (e, v, m, f) {
111
                 function (e, v, m, f) {
63
                 },
121
                 },
64
                 function (event) {
122
                 function (event) {
65
                     document.getElementById('recordingToken').focus();
123
                     document.getElementById('recordingToken').focus();
66
-                }
124
+                },
125
+                function () {}
67
             );
126
             );
68
 
127
 
69
             return;
128
             return;

Loading…
Cancel
Save