浏览代码

Stores info from last presence received for participant and dispatch it if any on creating remote streams to reflect video muted state. Race condition detected by tests where we miss presence info cause stream was not created when we receive presence packet.

master
damencho 10 年前
父节点
当前提交
6b94d3fe47
共有 6 个文件被更改,包括 21196 次插入21133 次删除
  1. 1
    1
      index.html
  2. 21164
    21126
      libs/app.bundle.js
  3. 3
    2
      modules/RTC/MediaStream.js
  4. 11
    2
      modules/RTC/RTC.js
  5. 12
    2
      modules/xmpp/strophe.emuc.js
  6. 5
    0
      modules/xmpp/xmpp.js

+ 1
- 1
index.html 查看文件

20
     <script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib -->
20
     <script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib -->
21
     <script src="libs/toastr.js?v=1"></script><!-- notifications lib -->
21
     <script src="libs/toastr.js?v=1"></script><!-- notifications lib -->
22
     <script src="interface_config.js?v=5"></script>
22
     <script src="interface_config.js?v=5"></script>
23
-    <script src="libs/app.bundle.js?v=133"></script>
23
+    <script src="libs/app.bundle.js?v=134"></script>
24
     <script src="analytics.js?v=1"></script><!-- google analytics plugin -->
24
     <script src="analytics.js?v=1"></script><!-- google analytics plugin -->
25
     <link rel="stylesheet" href="css/font.css?v=7"/>
25
     <link rel="stylesheet" href="css/font.css?v=7"/>
26
     <link rel="stylesheet" href="css/toastr.css?v=1">
26
     <link rel="stylesheet" href="css/toastr.css?v=1">

+ 21164
- 21126
libs/app.bundle.js
文件差异内容过多而无法显示
查看文件


+ 3
- 2
modules/RTC/MediaStream.js 查看文件

8
  * the peerjid, etc.
8
  * the peerjid, etc.
9
  * @param sid the session id
9
  * @param sid the session id
10
  * @param ssrc the ssrc corresponding to this MediaStream
10
  * @param ssrc the ssrc corresponding to this MediaStream
11
+ * @param mute the whether this MediaStream is muted
11
  *
12
  *
12
  * @constructor
13
  * @constructor
13
  */
14
  */
14
-function MediaStream(data, sid, ssrc, browser, eventEmitter) {
15
+function MediaStream(data, sid, ssrc, browser, eventEmitter, mute) {
15
 
16
 
16
     // XXX(gp) to minimize headaches in the future, we should build our
17
     // XXX(gp) to minimize headaches in the future, we should build our
17
     // abstractions around tracks and not streams. ORTC is track based API.
18
     // abstractions around tracks and not streams. ORTC is track based API.
30
     this.ssrc = ssrc;
31
     this.ssrc = ssrc;
31
     this.type = (this.stream.getVideoTracks().length > 0)?
32
     this.type = (this.stream.getVideoTracks().length > 0)?
32
         MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
33
         MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
33
-    this.muted = false;
34
+    this.muted = mute;
34
     this.eventEmitter = eventEmitter;
35
     this.eventEmitter = eventEmitter;
35
 }
36
 }
36
 
37
 

+ 11
- 2
modules/RTC/RTC.js 查看文件

96
         }
96
         }
97
     },
97
     },
98
     createRemoteStream: function (data, sid, thessrc) {
98
     createRemoteStream: function (data, sid, thessrc) {
99
-        var remoteStream = new MediaStream(data, sid, thessrc,
100
-            RTCBrowserType.getBrowserType(), eventEmitter);
101
         var jid = data.peerjid || APP.xmpp.myJid();
99
         var jid = data.peerjid || APP.xmpp.myJid();
100
+
101
+        // check the video muted state from last stored presence if any
102
+        var muted = false;
103
+        var pres = APP.xmpp.getLastPresence(jid);
104
+        if(pres != null && pres.videoMuted) {
105
+            muted = pres.videoMuted;
106
+        }
107
+
108
+        var remoteStream = new MediaStream(data, sid, thessrc,
109
+            RTCBrowserType.getBrowserType(), eventEmitter, muted);
110
+
102
         if(!this.remoteStreams[jid]) {
111
         if(!this.remoteStreams[jid]) {
103
             this.remoteStreams[jid] = {};
112
             this.remoteStreams[jid] = {};
104
         }
113
         }

+ 12
- 2
modules/xmpp/strophe.emuc.js 查看文件

14
         list_members: [], // so we can elect a new focus
14
         list_members: [], // so we can elect a new focus
15
         presMap: {},
15
         presMap: {},
16
         preziMap: {},
16
         preziMap: {},
17
+        lastPresenceMap: {},
17
         joined: false,
18
         joined: false,
18
         isOwner: false,
19
         isOwner: false,
19
         role: null,
20
         role: null,
135
                 $(document).trigger('presentationremoved.muc', [from, url]);
136
                 $(document).trigger('presentationremoved.muc', [from, url]);
136
             }
137
             }
137
 
138
 
139
+            // store the last presence for participant
140
+            this.lastPresenceMap[from] = {};
141
+
138
             // Parse audio info tag.
142
             // Parse audio info tag.
139
             var audioMuted = $(pres).find('>audiomuted');
143
             var audioMuted = $(pres).find('>audiomuted');
140
             if (audioMuted.length) {
144
             if (audioMuted.length) {
145
             // Parse video info tag.
149
             // Parse video info tag.
146
             var videoMuted = $(pres).find('>videomuted');
150
             var videoMuted = $(pres).find('>videomuted');
147
             if (videoMuted.length) {
151
             if (videoMuted.length) {
148
-                eventEmitter.emit(XMPPEvents.PARTICIPANT_VIDEO_MUTED,
149
-                    from, (videoMuted.text() === "true"));
152
+                var value = (videoMuted.text() === "true");
153
+                this.lastPresenceMap[from].videoMuted = value;
154
+                eventEmitter.emit(XMPPEvents.PARTICIPANT_VIDEO_MUTED, from, value);
150
             }
155
             }
151
 
156
 
152
             var startMuted = $(pres).find('>startmuted');
157
             var startMuted = $(pres).find('>startmuted');
309
                     eventEmitter.emit(XMPPEvents.KICKED);
314
                     eventEmitter.emit(XMPPEvents.KICKED);
310
                 }
315
                 }
311
             }
316
             }
317
+
318
+            if (this.lastPresenceMap[from] != null) {
319
+                delete this.lastPresenceMap[from];
320
+            }
321
+
312
             return true;
322
             return true;
313
         },
323
         },
314
         onPresenceError: function (pres) {
324
         onPresenceError: function (pres) {

+ 5
- 0
modules/xmpp/xmpp.js 查看文件

336
             return null;
336
             return null;
337
         return Strophe.getResourceFromJid(connection.emuc.myroomjid);
337
         return Strophe.getResourceFromJid(connection.emuc.myroomjid);
338
     },
338
     },
339
+    getLastPresence: function (from) {
340
+        if(!connection)
341
+            return null;
342
+        return connection.emuc.lastPresenceMap[from];
343
+    },
339
     disposeConference: function (onUnload) {
344
     disposeConference: function (onUnload) {
340
         var handler = connection.jingle.activecall;
345
         var handler = connection.jingle.activecall;
341
         if (handler && handler.peerconnection) {
346
         if (handler && handler.peerconnection) {

正在加载...
取消
保存