Browse Source

Merge pull request #118 from jitsi/handle-jibri-errors-and-busy

Handle jibri errors and busy status
master
hristoterezov 9 years ago
parent
commit
a6bdae70dd
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");
@@ -49,6 +50,7 @@ var LibJitsiMeet = {
49 50
     errors: {
50 51
         conference: JitsiConferenceErrors,
51 52
         connection: JitsiConnectionErrors,
53
+        recorder: JitsiRecorderErrors,
52 54
         track: JitsiTrackErrors
53 55
     },
54 56
     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

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

Loading…
Cancel
Save