Browse Source

Removes the "src" attribute dependancies. Fixes the issues with not displaying the large video and thumbnails clicking not working on firefox.

j8
hristoterezov 11 years ago
parent
commit
c2f6c9f7bc
5 changed files with 144 additions and 145 deletions
  1. 20
    38
      app.js
  2. 1
    2
      data_channels.js
  3. 47
    43
      libs/strophe/strophe.jingle.adapter.js
  4. 0
    1
      libs/strophe/strophe.jingle.session.js
  5. 76
    61
      videolayout.js

+ 20
- 38
app.js View File

@@ -14,6 +14,7 @@ var ssrc2jid = {};
14 14
 var mediaStreams = [];
15 15
 var bridgeIsDown = false;
16 16
 var notReceivedSSRCs = [];
17
+var jid2Ssrc = {};
17 18
 
18 19
 /**
19 20
  * The stats collector that process stats data and triggers updates to app.js.
@@ -32,7 +33,6 @@ var localStatsCollector = null;
32 33
  * FIXME: remove those maps
33 34
  */
34 35
 var ssrc2videoType = {};
35
-var videoSrcToSsrc = {};
36 36
 /**
37 37
  * Currently focused video "src"(displayed in large video).
38 38
  * @type {String}
@@ -253,7 +253,7 @@ function doJoin() {
253 253
     connection.emuc.doJoin(roomjid);
254 254
 }
255 255
 
256
-function waitForRemoteVideo(selector, ssrc, stream) {
256
+function waitForRemoteVideo(selector, ssrc, stream, jid) {
257 257
     if (selector.removed || !selector.parent().is(":visible")) {
258 258
         console.warn("Media removed before had started", selector);
259 259
         return;
@@ -267,17 +267,17 @@ function waitForRemoteVideo(selector, ssrc, stream) {
267 267
 
268 268
         // FIXME: add a class that will associate peer Jid, video.src, it's ssrc and video type
269 269
         //        in order to get rid of too many maps
270
-        if (ssrc && selector.attr('src')) {
271
-            videoSrcToSsrc[selector.attr('src')] = ssrc;
270
+        if (ssrc && jid) {
271
+            jid2Ssrc[Strophe.getResourceFromJid(jid)] = ssrc;
272 272
         } else {
273
-            console.warn("No ssrc given for video", selector);
273
+            console.warn("No ssrc given for jid", jid);
274 274
 //            messageHandler.showError('Warning', 'No ssrc was given for the video.');
275 275
         }
276 276
 
277 277
         $(document).trigger('videoactive.jingle', [selector]);
278 278
     } else {
279 279
         setTimeout(function () {
280
-            waitForRemoteVideo(selector, ssrc, stream);
280
+            waitForRemoteVideo(selector, ssrc, stream, jid);
281 281
             }, 250);
282 282
     }
283 283
 }
@@ -403,25 +403,6 @@ function waitForPresence(data, sid) {
403 403
     }
404 404
 }
405 405
 
406
-/**
407
- * Returns the JID of the user to whom given <tt>videoSrc</tt> belongs.
408
- * @param videoSrc the video "src" identifier.
409
- * @returns {null | String} the JID of the user to whom given <tt>videoSrc</tt>
410
- *                   belongs.
411
- */
412
-function getJidFromVideoSrc(videoSrc)
413
-{
414
-    if (videoSrc === localVideoSrc)
415
-        return connection.emuc.myroomjid;
416
-
417
-    var ssrc = videoSrcToSsrc[videoSrc];
418
-    if (!ssrc)
419
-    {
420
-        return null;
421
-    }
422
-    return ssrc2jid[ssrc];
423
-}
424
-
425 406
 // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
426 407
 function sendKeyframe(pc) {
427 408
     console.log('sendkeyframe', pc.iceConnectionState);
@@ -805,14 +786,13 @@ $(document).bind('left.muc', function (event, jid) {
805 786
         APIConnector.triggerEvent("participantLeft",{jid: jid});
806 787
     }
807 788
 
789
+    delete jid2Ssrc[jid];
790
+
808 791
     // Unlock large video
809
-    if (focusedVideoSrc)
792
+    if (focusedVideoSrc && focusedVideoSrc.jid === jid)
810 793
     {
811
-        if (getJidFromVideoSrc(focusedVideoSrc) === jid)
812
-        {
813
-            console.info("Focused video owner has left the conference");
814
-            focusedVideoSrc = null;
815
-        }
794
+        console.info("Focused video owner has left the conference");
795
+        focusedVideoSrc = null;
816 796
     }
817 797
 
818 798
     connection.jingle.terminateByJid(jid);
@@ -864,8 +844,6 @@ $(document).bind('presence.muc', function (event, jid, info, pres) {
864 844
     Object.keys(ssrc2jid).forEach(function (ssrc) {
865 845
         if (ssrc2jid[ssrc] == jid) {
866 846
             delete ssrc2jid[ssrc];
867
-        }
868
-        if (ssrc2videoType[ssrc] == jid) {
869 847
             delete ssrc2videoType[ssrc];
870 848
         }
871 849
     });
@@ -980,16 +958,20 @@ $(document).bind('passwordrequired.main', function (event) {
980 958
  * blob:https%3A//pawel.jitsi.net/9a46e0bd-131e-4d18-9c14-a9264e8db395
981 959
  * @returns {boolean}
982 960
  */
983
-function isVideoSrcDesktop(videoSrc) {
961
+function isVideoSrcDesktop(jid) {
984 962
     // FIXME: fix this mapping mess...
985 963
     // figure out if large video is desktop stream or just a camera
964
+
965
+    if(!jid)
966
+        return false;
986 967
     var isDesktop = false;
987
-    if (localVideoSrc === videoSrc) {
968
+    if (connection.emuc.myroomjid &&
969
+        Strophe.getResourceFromJid(connection.emuc.myroomjid) === jid) {
988 970
         // local video
989 971
         isDesktop = isUsingScreenStream;
990 972
     } else {
991 973
         // Do we have associations...
992
-        var videoSsrc = videoSrcToSsrc[videoSrc];
974
+        var videoSsrc = jid2Ssrc[jid];
993 975
         if (videoSsrc) {
994 976
             var videoType = ssrc2videoType[videoSsrc];
995 977
             if (videoType) {
@@ -999,7 +981,7 @@ function isVideoSrcDesktop(videoSrc) {
999 981
                 console.error("No video type for ssrc: " + videoSsrc);
1000 982
             }
1001 983
         } else {
1002
-            console.error("No ssrc for src: " + videoSrc);
984
+            console.error("No ssrc for jid: " + jid);
1003 985
         }
1004 986
     }
1005 987
     return isDesktop;
@@ -1602,7 +1584,7 @@ function onSelectedEndpointChanged(userJid)
1602 1584
                 dataChannel.send(JSON.stringify({
1603 1585
                     'colibriClass': 'SelectedEndpointChangedEvent',
1604 1586
                     'selectedEndpoint': (!userJid || userJid == null)
1605
-                        ? null : Strophe.getResourceFromJid(userJid)
1587
+                        ? null : userJid
1606 1588
                 }));
1607 1589
 
1608 1590
                 return true;

+ 1
- 2
data_channels.js View File

@@ -26,8 +26,7 @@ function onDataChannel(event)
26 26
 
27 27
         // when the data channel becomes available, tell the bridge about video
28 28
         // selections so that it can do adaptive simulcast,
29
-        var largeVideoSrc = $('#largeVideo').attr('src');
30
-        var userJid = getJidFromVideoSrc(largeVideoSrc);
29
+        var userJid = VideoLayout.getLargeVideoState().userJid;
31 30
         // we want the notification to trigger even if userJid is undefined,
32 31
         // or null.
33 32
         onSelectedEndpointChanged(userJid);

+ 47
- 43
libs/strophe/strophe.jingle.adapter.js View File

@@ -510,7 +510,40 @@ function setupRTC() {
510 510
                     element[0].mozSrcObject = stream;
511 511
                     element[0].play();
512 512
                 },
513
-                pc_constraints: {}
513
+                pc_constraints: {},
514
+                getLocalSSRC: function (session, callback) {
515
+                    session.peerconnection.getStats(function (s) {
516
+                            var ssrcs = {};
517
+                            s.forEach(function (item) {
518
+                                if (item.type == "outboundrtp" && !item.isRemote)
519
+                                {
520
+                                    ssrcs[item.id.split('_')[2]] = item.ssrc;
521
+                                }
522
+                            });
523
+                            session.localStreamsSSRC = {
524
+                                "audio": ssrcs.audio,//for stable 0
525
+                                "video": ssrcs.video// for stable 1
526
+                            };
527
+                            callback(session.localStreamsSSRC);
528
+                        },
529
+                        function () {
530
+                            callback(null);
531
+                        });
532
+                },
533
+                getStreamID: function (stream) {
534
+                    var tracks = stream.getVideoTracks();
535
+                    if(!tracks || tracks.length == 0)
536
+                    {
537
+                        tracks = stream.getAudioTracks();
538
+                    }
539
+                    return tracks[0].id.replace(/[\{,\}]/g,"");
540
+                },
541
+                getVideoSrc: function (element) {
542
+                    return element.mozSrcObject;
543
+                },
544
+                setVideoSrc: function (element, src) {
545
+                    element.mozSrcObject = src;
546
+                }
514 547
             };
515 548
             if (!MediaStream.prototype.getVideoTracks)
516 549
                 MediaStream.prototype.getVideoTracks = function () { return []; };
@@ -518,41 +551,6 @@ function setupRTC() {
518 551
                 MediaStream.prototype.getAudioTracks = function () { return []; };
519 552
             RTCSessionDescription = mozRTCSessionDescription;
520 553
             RTCIceCandidate = mozRTCIceCandidate;
521
-            RTC.getLocalSSRC = function (session, callback) {
522
-                session.peerconnection.getStats(function (s) {
523
-                        var keys = Object.keys(s);
524
-                        var audio = null;
525
-                        var video = null;
526
-                        for(var i = 0; i < keys.length; i++)
527
-                        {
528
-                            if(keys[i].indexOf("outbound_rtp_audio") != -1)
529
-                            {
530
-                                audio = s[keys[i]].ssrc;
531
-                            }
532
-
533
-                            if(keys[i].indexOf("outbound_rtp_video") != -1)
534
-                            {
535
-                                video = s[keys[i]].ssrc;
536
-                            }
537
-                        }
538
-                        session.localStreamsSSRC = {
539
-                            "audio": audio,//for stable 0
540
-                            "video": video// for stable 1
541
-                        };
542
-                        callback(session.localStreamsSSRC);
543
-                    },
544
-                    function () {
545
-                        callback(null);
546
-                    });
547
-            };
548
-            RTC.getStreamID = function (stream) {
549
-                var tracks = stream.getVideoTracks();
550
-                if(!tracks || tracks.length == 0)
551
-                {
552
-                    tracks = stream.getAudioTracks();
553
-                }
554
-                return tracks[0].id.replace(/[\{,\}]/g,"");
555
-            }
556 554
         }
557 555
     } else if (navigator.webkitGetUserMedia) {
558 556
         console.log('This appears to be Chrome');
@@ -564,7 +562,19 @@ function setupRTC() {
564 562
                 element.attr('src', webkitURL.createObjectURL(stream));
565 563
             },
566 564
             // DTLS should now be enabled by default but..
567
-            pc_constraints: {'optional': [{'DtlsSrtpKeyAgreement': 'true'}]}
565
+            pc_constraints: {'optional': [{'DtlsSrtpKeyAgreement': 'true'}]},
566
+            getLocalSSRC: function (session, callback) {
567
+                callback(null);
568
+            },
569
+            getStreamID: function (stream) {
570
+                return stream.id;
571
+            },
572
+            getVideoSrc: function (element) {
573
+                return element.getAttribute("src");
574
+            },
575
+            setVideoSrc: function (element, src) {
576
+                element.setAttribute("src", src);
577
+            }
568 578
         };
569 579
         if (navigator.userAgent.indexOf('Android') != -1) {
570 580
             RTC.pc_constraints = {}; // disable DTLS on Android
@@ -579,12 +589,6 @@ function setupRTC() {
579 589
                 return this.audioTracks;
580 590
             };
581 591
         }
582
-        RTC.getLocalSSRC = function (session, callback) {
583
-            callback(null);
584
-        }
585
-        RTC.getStreamID = function (stream) {
586
-            return stream.id;
587
-        }
588 592
     }
589 593
     if (RTC === null) {
590 594
         try { console.log('Browser does not appear to be WebRTC-capable'); } catch (e) { }

+ 0
- 1
libs/strophe/strophe.jingle.session.js View File

@@ -107,7 +107,6 @@ JingleSession.prototype.accept = function () {
107 107
 
108 108
     var pranswer = this.peerconnection.localDescription;
109 109
     if (!pranswer || pranswer.type != 'pranswer') {
110
-        console.error("No local sdp set!");
111 110
         return;
112 111
     }
113 112
     console.log('going from pranswer to answer');

+ 76
- 61
videolayout.js View File

@@ -6,6 +6,9 @@ var VideoLayout = (function (my) {
6 6
         updateInProgress: false,
7 7
         newSrc: ''
8 8
     };
9
+
10
+    var defaultLocalDisplayName = "Me";
11
+
9 12
     my.connectionIndicators = {};
10 13
 
11 14
     my.changeLocalAudio = function(stream) {
@@ -45,10 +48,10 @@ var VideoLayout = (function (my) {
45 48
         // Add click handler to both video and video wrapper elements in case
46 49
         // there's no video.
47 50
         localVideoSelector.click(function () {
48
-            VideoLayout.handleVideoThumbClicked(localVideo.src);
51
+            VideoLayout.handleVideoThumbClicked(RTC.getVideoSrc(localVideo), connection.emuc.myroomjid);
49 52
         });
50 53
         $('#localVideoContainer').click(function () {
51
-            VideoLayout.handleVideoThumbClicked(localVideo.src);
54
+            VideoLayout.handleVideoThumbClicked(RTC.getVideoSrc(localVideo), connection.emuc.myroomjid);
52 55
         });
53 56
 
54 57
         // Add hover handler
@@ -58,14 +61,14 @@ var VideoLayout = (function (my) {
58 61
             },
59 62
             function() {
60 63
                 if (!VideoLayout.isLargeVideoVisible()
61
-                        || localVideo.src !== $('#largeVideo').attr('src'))
64
+                        || RTC.getVideoSrc(localVideo) !== RTC.getVideoSrc($('#largeVideo')[0]))
62 65
                     VideoLayout.showDisplayName('localVideoContainer', false);
63 66
             }
64 67
         );
65 68
         // Add stream ended handler
66 69
         stream.onended = function () {
67 70
             localVideoContainer.removeChild(localVideo);
68
-            VideoLayout.updateRemovedVideo(localVideo.src);
71
+            VideoLayout.updateRemovedVideo(RTC.getVideoSrc(localVideo));
69 72
         };
70 73
         // Flip video x axis if needed
71 74
         flipXLocalVideo = flipX;
@@ -76,9 +79,16 @@ var VideoLayout = (function (my) {
76 79
         var videoStream = simulcast.getLocalVideoStream();
77 80
         RTC.attachMediaStream(localVideoSelector, videoStream);
78 81
 
79
-        localVideoSrc = localVideo.src;
82
+        localVideoSrc = RTC.getVideoSrc(localVideo);
83
+
84
+        var myResourceJid = null;
85
+        if(connection.emuc.myroomjid)
86
+        {
87
+           myResourceJid = Strophe.getResourceFromJid(connection.emuc.myroomjid);
88
+        }
89
+        VideoLayout.updateLargeVideo(localVideoSrc, 0,
90
+            myResourceJid);
80 91
 
81
-        VideoLayout.updateLargeVideo(localVideoSrc, 0);
82 92
     };
83 93
 
84 94
     /**
@@ -87,7 +97,7 @@ var VideoLayout = (function (my) {
87 97
      * @param removedVideoSrc src stream identifier of the video.
88 98
      */
89 99
     my.updateRemovedVideo = function(removedVideoSrc) {
90
-        if (removedVideoSrc === $('#largeVideo').attr('src')) {
100
+        if (removedVideoSrc === RTC.getVideoSrc($('#largeVideo')[0])) {
91 101
             // this is currently displayed as large
92 102
             // pick the last visible video in the row
93 103
             // if nobody else is left, this picks the local video
@@ -99,7 +109,7 @@ var VideoLayout = (function (my) {
99 109
                 console.info("Last visible video no longer exists");
100 110
                 pick = $('#remoteVideos>span[id!="mixedstream"]>video').get(0);
101 111
 
102
-                if (!pick || !pick.src) {
112
+                if (!pick || !RTC.getVideoSrc(pick)) {
103 113
                     // Try local video
104 114
                     console.info("Fallback to local video...");
105 115
                     pick = $('#remoteVideos>span>span>video').get(0);
@@ -108,20 +118,28 @@ var VideoLayout = (function (my) {
108 118
 
109 119
             // mute if localvideo
110 120
             if (pick) {
111
-                VideoLayout.updateLargeVideo(pick.src, pick.volume);
121
+                var container = pick.parentNode;
122
+                var jid = null;
123
+                if(container)
124
+                    jid = VideoLayout.getPeerContainerResourceJid(container);
125
+                VideoLayout.updateLargeVideo(RTC.getVideoSrc(pick), pick.volume, jid);
112 126
             } else {
113 127
                 console.warn("Failed to elect large video");
114 128
             }
115 129
         }
116 130
     };
117 131
 
132
+    my.getLargeVideoState = function () {
133
+        return largeVideoState;
134
+    }
135
+
118 136
     /**
119 137
      * Updates the large video with the given new video source.
120 138
      */
121
-    my.updateLargeVideo = function(newSrc, vol) {
139
+    my.updateLargeVideo = function(newSrc, vol, jid) {
122 140
         console.log('hover in', newSrc);
123 141
 
124
-        if ($('#largeVideo').attr('src') != newSrc) {
142
+        if (RTC.getVideoSrc($('#largeVideo')[0]) != newSrc) {
125 143
 
126 144
             // Due to the simulcast the localVideoSrc may have changed when the
127 145
             // fadeOut event triggers. In that case the getJidFromVideoSrc and
@@ -133,15 +151,13 @@ var VideoLayout = (function (my) {
133 151
 
134 152
             largeVideoState.newSrc = newSrc;
135 153
             largeVideoState.isVisible = $('#largeVideo').is(':visible');
136
-            largeVideoState.isDesktop = isVideoSrcDesktop(newSrc);
137
-            largeVideoState.userJid = getJidFromVideoSrc(newSrc);
154
+            largeVideoState.isDesktop = isVideoSrcDesktop(jid);
155
+            largeVideoState.oldJid = largeVideoState.userJid;
156
+            largeVideoState.userJid = jid;
138 157
 
139 158
             // Screen stream is already rotated
140 159
             largeVideoState.flipX = (newSrc === localVideoSrc) && flipXLocalVideo;
141 160
 
142
-            var oldSrc = $('#largeVideo').attr('src');
143
-            largeVideoState.oldJid = getJidFromVideoSrc(oldSrc);
144
-
145 161
             var userChanged = false;
146 162
             if (largeVideoState.oldJid != largeVideoState.userJid) {
147 163
                 userChanged = true;
@@ -157,7 +173,8 @@ var VideoLayout = (function (my) {
157 173
 
158 174
                     if (!userChanged && largeVideoState.preload
159 175
                         && largeVideoState.preload != null
160
-                        && $(largeVideoState.preload).attr('src') == newSrc) {
176
+                        && RTC.getVideoSrc($(largeVideoState.preload)[0]) == newSrc)
177
+                    {
161 178
 
162 179
                         console.info('Switching to preloaded video');
163 180
                         var attributes = $('#largeVideo').prop("attributes");
@@ -183,7 +200,7 @@ var VideoLayout = (function (my) {
183 200
                         largeVideoState.preload = null;
184 201
                         largeVideoState.preload_ssrc = 0;
185 202
                     } else {
186
-                        $('#largeVideo').attr('src', largeVideoState.newSrc);
203
+                        RTC.setVideoSrc($('#largeVideo')[0], largeVideoState.newSrc);
187 204
                     }
188 205
 
189 206
                     var videoTransform = document.getElementById('largeVideo')
@@ -211,14 +228,12 @@ var VideoLayout = (function (my) {
211 228
                     // Only if the large video is currently visible.
212 229
                     // Disable previous dominant speaker video.
213 230
                     if (largeVideoState.oldJid) {
214
-                        var oldResourceJid = Strophe.getResourceFromJid(largeVideoState.oldJid);
215
-                        VideoLayout.enableDominantSpeaker(oldResourceJid, false);
231
+                        VideoLayout.enableDominantSpeaker(largeVideoState.oldJid, false);
216 232
                     }
217 233
 
218 234
                     // Enable new dominant speaker in the remote videos section.
219 235
                     if (largeVideoState.userJid) {
220
-                        var resourceJid = Strophe.getResourceFromJid(largeVideoState.userJid);
221
-                        VideoLayout.enableDominantSpeaker(resourceJid, true);
236
+                        VideoLayout.enableDominantSpeaker(largeVideoState.userJid, true);
222 237
                     }
223 238
 
224 239
                     if (userChanged && largeVideoState.isVisible) {
@@ -239,17 +254,20 @@ var VideoLayout = (function (my) {
239 254
         }
240 255
     };
241 256
 
242
-    my.handleVideoThumbClicked = function(videoSrc) {
257
+    my.handleVideoThumbClicked = function(videoSrc, jid) {
243 258
         // Restore style for previously focused video
244
-        var focusJid = getJidFromVideoSrc(focusedVideoSrc);
245
-        var oldContainer = getParticipantContainer(focusJid);
259
+        var oldContainer = null;
260
+        if(focusedVideoSrc) {
261
+            var focusJid = focusedVideoSrc.jid;
262
+            oldContainer = getParticipantContainer(focusJid);
263
+        }
246 264
 
247 265
         if (oldContainer) {
248 266
             oldContainer.removeClass("videoContainerFocused");
249 267
         }
250 268
 
251 269
         // Unlock current focused. 
252
-        if (focusedVideoSrc === videoSrc)
270
+        if (focusedVideoSrc && focusedVideoSrc.src === videoSrc)
253 271
         {
254 272
             focusedVideoSrc = null;
255 273
             var dominantSpeakerVideo = null;
@@ -260,7 +278,7 @@ var VideoLayout = (function (my) {
260 278
                         .get(0);
261 279
 
262 280
                 if (dominantSpeakerVideo) {
263
-                    VideoLayout.updateLargeVideo(dominantSpeakerVideo.src, 1);
281
+                    VideoLayout.updateLargeVideo(RTC.getVideoSrc(dominantSpeakerVideo), 1, currentDominantSpeaker);
264 282
                 }
265 283
             }
266 284
 
@@ -268,13 +286,15 @@ var VideoLayout = (function (my) {
268 286
         }
269 287
 
270 288
         // Lock new video
271
-        focusedVideoSrc = videoSrc;
289
+        focusedVideoSrc = {
290
+            src: videoSrc,
291
+            jid: jid
292
+        };
272 293
 
273 294
         // Update focused/pinned interface.
274
-        var userJid = getJidFromVideoSrc(videoSrc);
275
-        if (userJid)
295
+        if (jid)
276 296
         {
277
-            var container = getParticipantContainer(userJid);
297
+            var container = getParticipantContainer(jid);
278 298
             container.addClass("videoContainerFocused");
279 299
         }
280 300
 
@@ -282,7 +302,7 @@ var VideoLayout = (function (my) {
282 302
         // this isn't a prezi.
283 303
         $(document).trigger("video.selected", [false]);
284 304
 
285
-        VideoLayout.updateLargeVideo(videoSrc, 1);
305
+        VideoLayout.updateLargeVideo(videoSrc, 1, Strophe.getResourceFromJid(jid));
286 306
 
287 307
         $('audio').each(function (idx, el) {
288 308
             if (el.id.indexOf('mixedmslabel') !== -1) {
@@ -328,8 +348,7 @@ var VideoLayout = (function (my) {
328 348
      * Shows/hides the large video.
329 349
      */
330 350
     my.setLargeVideoVisible = function(isVisible) {
331
-        var largeVideoJid = getJidFromVideoSrc($('#largeVideo').attr('src'));
332
-        var resourceJid = Strophe.getResourceFromJid(largeVideoJid);
351
+        var resourceJid = largeVideoState.userJid;
333 352
 
334 353
         if (isVisible) {
335 354
             $('#largeVideo').css({visibility: 'visible'});
@@ -458,7 +477,7 @@ var VideoLayout = (function (my) {
458 477
                 RTC.attachMediaStream(sel, videoStream);
459 478
 
460 479
                 if (isVideo)
461
-                    waitForRemoteVideo(sel, thessrc, stream);
480
+                    waitForRemoteVideo(sel, thessrc, stream, peerJid);
462 481
             }
463 482
 
464 483
             stream.onended = function () {
@@ -480,7 +499,7 @@ var VideoLayout = (function (my) {
480 499
                 var videoThumb = $('#' + container.id + '>video').get(0);
481 500
 
482 501
                 if (videoThumb)
483
-                    VideoLayout.handleVideoThumbClicked(videoThumb.src);
502
+                    VideoLayout.handleVideoThumbClicked(RTC.getVideoSrc(videoThumb), peerJid);
484 503
 
485 504
                 event.preventDefault();
486 505
                 return false;
@@ -495,13 +514,13 @@ var VideoLayout = (function (my) {
495 514
                     var videoSrc = null;
496 515
                     if ($('#' + container.id + '>video')
497 516
                             && $('#' + container.id + '>video').length > 0) {
498
-                        videoSrc = $('#' + container.id + '>video').get(0).src;
517
+                        videoSrc = RTC.getVideoSrc($('#' + container.id + '>video').get(0));
499 518
                     }
500 519
 
501 520
                     // If the video has been "pinned" by the user we want to
502 521
                     // keep the display name on place.
503 522
                     if (!VideoLayout.isLargeVideoVisible()
504
-                            || videoSrc !== $('#largeVideo').attr('src'))
523
+                            || videoSrc !== RTC.getVideoSrc($('#largeVideo')[0]))
505 524
                         VideoLayout.showDisplayName(container.id, false);
506 525
                 }
507 526
             );
@@ -526,13 +545,11 @@ var VideoLayout = (function (my) {
526 545
         var removedVideoSrc = null;
527 546
         if (isVideo) {
528 547
             select = $('#' + container.id + '>video');
529
-            removedVideoSrc = select.get(0).src;
548
+            removedVideoSrc = RTC.getVideoSrc(select.get(0));
530 549
         }
531 550
         else
532 551
             select = $('#' + container.id + '>audio');
533 552
 
534
-        // Remove video source from the mapping.
535
-        delete videoSrcToSsrc[removedVideoSrc];
536 553
 
537 554
         // Mark video as removed to cancel waiting loop(if video is removed
538 555
         // before has started)
@@ -586,7 +603,6 @@ var VideoLayout = (function (my) {
586 603
      */
587 604
     function setDisplayName(videoSpanId, displayName) {
588 605
         var nameSpan = $('#' + videoSpanId + '>span.displayname');
589
-        var defaultLocalDisplayName = "Me";
590 606
 
591 607
         // If we already have a display name for this video.
592 608
         if (nameSpan.length > 0) {
@@ -1339,7 +1355,7 @@ var VideoLayout = (function (my) {
1339 1355
             // Update the large video if the video source is already available,
1340 1356
             // otherwise wait for the "videoactive.jingle" event.
1341 1357
             if (video.length && video[0].currentTime > 0)
1342
-                VideoLayout.updateLargeVideo(video[0].src);
1358
+                VideoLayout.updateLargeVideo(RTC.getVideoSrc(video[0]), resourceJid);
1343 1359
         }
1344 1360
     });
1345 1361
 
@@ -1392,7 +1408,7 @@ var VideoLayout = (function (my) {
1392 1408
                             waitForRemoteVideo(
1393 1409
                                     sel,
1394 1410
                                     mediaStream.ssrc,
1395
-                                    mediaStream.stream);
1411
+                                    mediaStream.stream, resourceJid);
1396 1412
                             return true;
1397 1413
                         }
1398 1414
                     });
@@ -1421,7 +1437,7 @@ var VideoLayout = (function (my) {
1421 1437
                 || (parentResourceJid
1422 1438
                 && VideoLayout.getDominantSpeakerResourceJid()
1423 1439
                     === parentResourceJid)) {
1424
-                VideoLayout.updateLargeVideo(videoelem.attr('src'), 1);
1440
+                VideoLayout.updateLargeVideo(RTC.getVideoSrc(videoelem[0]), 1, parentResourceJid);
1425 1441
             }
1426 1442
 
1427 1443
             VideoLayout.showFocusIndicator();
@@ -1443,10 +1459,8 @@ var VideoLayout = (function (my) {
1443 1459
                 console.info([esl, primarySSRC, msid, session, electedStream]);
1444 1460
 
1445 1461
                 var msidParts = msid.split(' ');
1446
-                var selRemoteVideo = $(['#', 'remoteVideo_', session.sid, '_', msidParts[0]].join(''));
1447 1462
 
1448
-                var preload = (ssrc2jid[videoSrcToSsrc[selRemoteVideo.attr('src')]]
1449
-                    == ssrc2jid[videoSrcToSsrc[largeVideoState.newSrc]]);
1463
+                var preload = (Strophe.getResourceFromJid(ssrc2jid[primarySSRC]) == largeVideoState.userJid);
1450 1464
 
1451 1465
                 if (preload) {
1452 1466
                     if (largeVideoState.preload)
@@ -1458,9 +1472,7 @@ var VideoLayout = (function (my) {
1458 1472
                     // ssrcs are unique in an rtp session
1459 1473
                     largeVideoState.preload_ssrc = primarySSRC;
1460 1474
 
1461
-                    var electedStreamUrl = webkitURL.createObjectURL(electedStream);
1462
-                    largeVideoState.preload
1463
-                        .attr('src', electedStreamUrl);
1475
+                    RTC.attachMediaStream(largeVideoState.preload, electedStream)
1464 1476
                 }
1465 1477
 
1466 1478
             } else {
@@ -1491,14 +1503,15 @@ var VideoLayout = (function (my) {
1491 1503
                 var msidParts = msid.split(' ');
1492 1504
                 var selRemoteVideo = $(['#', 'remoteVideo_', session.sid, '_', msidParts[0]].join(''));
1493 1505
 
1494
-                var updateLargeVideo = (ssrc2jid[videoSrcToSsrc[selRemoteVideo.attr('src')]]
1495
-                    == ssrc2jid[videoSrcToSsrc[largeVideoState.newSrc]]);
1496
-                var updateFocusedVideoSrc = (selRemoteVideo.attr('src') == focusedVideoSrc);
1506
+                var updateLargeVideo = (Strophe.getResourceFromJid(ssrc2jid[primarySSRC])
1507
+                    == largeVideoState.userJid);
1508
+                var updateFocusedVideoSrc = (focusedVideoSrc &&
1509
+                    (RTC.getVideoSrc(selRemoteVideo[0]) == focusedVideoSrc.src));
1497 1510
 
1498 1511
                 var electedStreamUrl;
1499 1512
                 if (largeVideoState.preload_ssrc == primarySSRC)
1500 1513
                 {
1501
-                    electedStreamUrl = $(largeVideoState.preload).attr('src');
1514
+                    RTC.setVideoSrc(selRemoteVideo, RTC.getVideoSrc(largeVideoState.preload[0]));
1502 1515
                 }
1503 1516
                 else
1504 1517
                 {
@@ -1509,21 +1522,23 @@ var VideoLayout = (function (my) {
1509 1522
 
1510 1523
                     largeVideoState.preload_ssrc = 0;
1511 1524
 
1512
-                    electedStreamUrl = webkitURL.createObjectURL(electedStream);
1525
+                    RTC.attachMediaStream(selRemoteVideo, electedStream);
1513 1526
                 }
1514 1527
 
1515
-                selRemoteVideo.attr('src', electedStreamUrl);
1516
-                videoSrcToSsrc[selRemoteVideo.attr('src')] = primarySSRC;
1528
+
1529
+                var jid = ssrc2jid[primarySSRC];
1530
+                jid2Ssrc[jid] = primarySSRC;
1517 1531
 
1518 1532
                 if (updateLargeVideo) {
1519
-                    VideoLayout.updateLargeVideo(electedStreamUrl);
1533
+                    VideoLayout.updateLargeVideo(RTC.getVideoSrc(selRemoteVideo[0]), null,
1534
+                        Strophe.getResourceFromJid(jid));
1520 1535
                 }
1521 1536
 
1522 1537
                 if (updateFocusedVideoSrc) {
1523
-                    focusedVideoSrc = electedStreamUrl;
1538
+                    focusedVideoSrc.src = RTC.getVideoSrc(selRemoteVideo[0]);
1524 1539
                 }
1525 1540
 
1526
-                var jid = ssrc2jid[primarySSRC];
1541
+
1527 1542
                 var videoId;
1528 1543
                 if(jid == connection.emuc.myroomjid)
1529 1544
                 {

Loading…
Cancel
Save