Browse Source

Handle jibri errors and busy status

master
yanas 9 years ago
parent
commit
e4928ef6e4
3 changed files with 28 additions and 10 deletions
  1. 2
    0
      JitsiMeetJS.js
  2. 9
    0
      JitsiRecorderErrors.js
  3. 17
    10
      modules/xmpp/recording.js

+ 2
- 0
JitsiMeetJS.js View File

@@ -8,6 +8,7 @@ var JitsiConnectionErrors = require("./JitsiConnectionErrors");
8 8
 var JitsiConferenceErrors = require("./JitsiConferenceErrors");
9 9
 var JitsiTrackEvents = require("./JitsiTrackEvents");
10 10
 var JitsiTrackErrors = require("./JitsiTrackErrors");
11
+var JitsiRecorderErrors = require("./JitsiRecorderErrors");
11 12
 var Logger = require("jitsi-meet-logger");
12 13
 var MediaType = require("./service/RTC/MediaType");
13 14
 var RTC = require("./modules/RTC/RTC");
@@ -48,6 +49,7 @@ var LibJitsiMeet = {
48 49
     errors: {
49 50
         conference: JitsiConferenceErrors,
50 51
         connection: JitsiConnectionErrors,
52
+        recorder: JitsiRecorderErrors,
51 53
         track: JitsiTrackErrors
52 54
     },
53 55
     logLevels: Logger.levels,

+ 9
- 0
JitsiRecorderErrors.js View File

@@ -8,6 +8,11 @@ var JitsiRecorderErrors = {
8 8
      */
9 9
     RECORDER_UNAVAILABLE: "recorder.unavailable",
10 10
 
11
+    /**
12
+     * Indicates that all available recorders are currently busy.
13
+     */
14
+    RECORDER_BUSY: "recorder.busy",
15
+
11 16
     /**
12 17
      * Indicates that the authentication token is missing.
13 18
      */
@@ -18,6 +23,10 @@ var JitsiRecorderErrors = {
18 23
      */
19 24
     STATE_CHANGE_FAILED: "recorder.stateChangeFailed",
20 25
 
26
+    /**
27
+     * Indicates an invalid state.
28
+     */
29
+    INVALID_STATE: "recorder.invalidState"
21 30
 };
22 31
 
23 32
 module.exports = JitsiRecorderErrors;

+ 17
- 10
modules/xmpp/recording.js View File

@@ -40,7 +40,9 @@ Recording.status = {
40 40
     OFF: "off",
41 41
     AVAILABLE: "available",
42 42
     UNAVAILABLE: "unavailable",
43
-    PENDING: "pending"
43
+    PENDING: "pending",
44
+    BUSY: "busy",
45
+    FAILED: "failed"
44 46
 };
45 47
 
46 48
 Recording.action = {
@@ -77,10 +79,11 @@ Recording.prototype.handleJibriPresence = function (jibri) {
77 79
     this.eventEmitter.emit(XMPPEvents.RECORDER_STATE_CHANGED, this.state);
78 80
 };
79 81
 
80
-Recording.prototype.setRecordingJibri = function (state, callback, errCallback,
81
-    options) {
82
+Recording.prototype.setRecordingJibri
83
+    = function (state, callback, errCallback, options) {
84
+
82 85
     if (state == this.state){
83
-        errCallback(new Error("Invalid state!"));
86
+        errCallback(JitsiRecorderErrors.INVALID_STATE);
84 87
     }
85 88
     options = options || {};
86 89
 
@@ -215,9 +218,13 @@ Recording.prototype.toggleRecording = function (options, statusChangeHandler) {
215 218
     var oldState = this.state;
216 219
 
217 220
     // If the recorder is currently unavailable we throw an error.
218
-    if (oldState === Recording.status.UNAVAILABLE)
219
-        statusChangeHandler("error",
220
-            new Error(JitsiRecorderErrors.RECORDER_UNAVAILABLE));
221
+    if (oldState === Recording.status.UNAVAILABLE
222
+        || oldState === Recording.status.FAILED)
223
+        statusChangeHandler(Recording.status.FAILED,
224
+                            JitsiRecorderErrors.RECORDER_UNAVAILABLE);
225
+    else if (oldState === Recording.status.BUSY)
226
+        statusChangeHandler(Recording.status.BUSY,
227
+                            JitsiRecorderErrors.RECORDER_BUSY);
221 228
 
222 229
     // If we're about to turn ON the recording we need either a streamId or
223 230
     // an authentication token depending on the recording type. If we don't
@@ -226,8 +233,8 @@ Recording.prototype.toggleRecording = function (options, statusChangeHandler) {
226 233
         || oldState === Recording.status.AVAILABLE)
227 234
         && ((!options.token && this.type === Recording.types.COLIBRI) ||
228 235
         (!options.streamId && this.type === Recording.types.JIBRI))) {
229
-        statusChangeHandler("error",
230
-            new Error(JitsiRecorderErrors.NO_TOKEN));
236
+        statusChangeHandler(Recording.status.FAILED,
237
+                            JitsiRecorderErrors.NO_TOKEN);
231 238
         logger.error("No token passed!");
232 239
         return;
233 240
     }
@@ -249,7 +256,7 @@ Recording.prototype.toggleRecording = function (options, statusChangeHandler) {
249 256
                 statusChangeHandler(state);
250 257
             }
251 258
         }, function (error) {
252
-            statusChangeHandler("error", error);
259
+            statusChangeHandler(Recording.status.FAILED, error);
253 260
         }, options);
254 261
 };
255 262
 

Loading…
Cancel
Save