Browse Source

Fix off recording state handling

dev1
yanas 9 years ago
parent
commit
d4be648c45
1 changed files with 15 additions and 7 deletions
  1. 15
    7
      modules/xmpp/recording.js

+ 15
- 7
modules/xmpp/recording.js View File

40
     OFF: "off",
40
     OFF: "off",
41
     AVAILABLE: "available",
41
     AVAILABLE: "available",
42
     UNAVAILABLE: "unavailable",
42
     UNAVAILABLE: "unavailable",
43
-    START: "start",
44
-    STOP: "stop",
45
     PENDING: "pending"
43
     PENDING: "pending"
46
 };
44
 };
47
 
45
 
46
+Recording.action = {
47
+    START: "start",
48
+    STOP: "stop"
49
+};
50
+
48
 Recording.prototype.handleJibriPresence = function (jibri) {
51
 Recording.prototype.handleJibriPresence = function (jibri) {
49
     var attributes = jibri.attributes;
52
     var attributes = jibri.attributes;
50
     if(!attributes)
53
     if(!attributes)
60
         this.state = Recording.status.UNAVAILABLE;
63
         this.state = Recording.status.UNAVAILABLE;
61
     }
64
     }
62
     else if (newState === "off") {
65
     else if (newState === "off") {
63
-        this.state = Recording.status.AVAILABLE;
66
+        if (!this.state
67
+            || this.state === "undefined"
68
+            || this.state === Recording.status.UNAVAILABLE)
69
+            this.state = Recording.status.AVAILABLE;
70
+        else
71
+            this.state = Recording.status.OFF;
64
     }
72
     }
65
     else {
73
     else {
66
         this.state = newState;
74
         this.state = newState;
81
         .c('jibri', {
89
         .c('jibri', {
82
         "xmlns": 'http://jitsi.org/protocol/jibri',
90
         "xmlns": 'http://jitsi.org/protocol/jibri',
83
         "action": (state === Recording.status.ON)
91
         "action": (state === Recording.status.ON)
84
-                    ? Recording.status.START
85
-                    : Recording.status.STOP,
92
+                    ? Recording.action.START
93
+                    : Recording.action.STOP,
86
         "streamid": options.streamId,
94
         "streamid": options.streamId,
87
         }).up();
95
         }).up();
88
 
96
 
111
     var iq = $iq({to: this.jirecon, type: 'set'})
119
     var iq = $iq({to: this.jirecon, type: 'set'})
112
         .c('recording', {xmlns: 'http://jitsi.org/protocol/jirecon',
120
         .c('recording', {xmlns: 'http://jitsi.org/protocol/jirecon',
113
             action: (state === Recording.status.ON)
121
             action: (state === Recording.status.ON)
114
-                ? Recording.status.START
115
-                : Recording.status.STOP,
122
+                ? Recording.action.START
123
+                : Recording.action.STOP,
116
             mucjid: this.roomjid});
124
             mucjid: this.roomjid});
117
     if (state === 'off'){
125
     if (state === 'off'){
118
         iq.attrs({rid: this.jireconRid});
126
         iq.attrs({rid: this.jireconRid});

Loading…
Cancel
Save