Procházet zdrojové kódy

Adds getters for peer video selectors and simplifies the code a little bit.

master
paweldomas před 10 roky
rodič
revize
879fb9a590
3 změnil soubory, kde provedl 48 přidání a 47 odebrání
  1. 2
    2
      modules/RTC/RTC.js
  2. 2
    2
      modules/RTC/RTCUtils.js
  3. 44
    43
      modules/UI/videolayout/VideoLayout.js

+ 2
- 2
modules/RTC/RTC.js Zobrazit soubor

119
         return this.rtcUtils.getUserMediaWithConstraints(um, success_callback,
119
         return this.rtcUtils.getUserMediaWithConstraints(um, success_callback,
120
             failure_callback, resolution, bandwidth, fps, desktopStream);
120
             failure_callback, resolution, bandwidth, fps, desktopStream);
121
     },
121
     },
122
-    attachMediaStream:  function (element, stream) {
123
-        this.rtcUtils.attachMediaStream(element, stream);
122
+    attachMediaStream:  function (elSelector, stream) {
123
+        this.rtcUtils.attachMediaStream(elSelector, stream);
124
     },
124
     },
125
     getStreamID:  function (stream) {
125
     getStreamID:  function (stream) {
126
         return this.rtcUtils.getStreamID(stream);
126
         return this.rtcUtils.getStreamID(stream);

+ 2
- 2
modules/RTC/RTCUtils.js Zobrazit soubor

237
 
237
 
238
             self.peerconnection = RTCPeerConnection;
238
             self.peerconnection = RTCPeerConnection;
239
             self.getUserMedia = getUserMedia;
239
             self.getUserMedia = getUserMedia;
240
-            self.attachMediaStream = function (element, stream) {
240
+            self.attachMediaStream = function (elSel, stream) {
241
 
241
 
242
                 if (stream.id === "dummyAudio" || stream.id === "dummyVideo") {
242
                 if (stream.id === "dummyAudio" || stream.id === "dummyVideo") {
243
                     return;
243
                     return;
244
                 }
244
                 }
245
 
245
 
246
-                attachMediaStream(element[0], stream);
246
+                attachMediaStream(elSel[0], stream);
247
             };
247
             };
248
             self.getStreamID = function (stream) {
248
             self.getStreamID = function (stream) {
249
                 var id = SDPUtil.filter_special_chars(stream.label);
249
                 var id = SDPUtil.filter_special_chars(stream.label);

+ 44
- 43
modules/UI/videolayout/VideoLayout.js Zobrazit soubor

456
             return containerElement.id.substring(i + 12); 
456
             return containerElement.id.substring(i + 12); 
457
     };
457
     };
458
 
458
 
459
+    my.getPeerVideoSel = function (peerResourceJid) {
460
+        return $('#participant_'  + peerResourceJid +
461
+                 '>' + APP.RTC.getVideoElementName());
462
+    };
463
+
459
     /**
464
     /**
460
      * On contact list item clicked.
465
      * On contact list item clicked.
461
      */
466
      */
464
             return;
469
             return;
465
         }
470
         }
466
 
471
 
472
+        if (jid == APP.xmpp.myJid()) {
473
+            $("#localVideoContainer").click();
474
+            return;
475
+        }
476
+
467
         var resource = Strophe.getResourceFromJid(jid);
477
         var resource = Strophe.getResourceFromJid(jid);
468
-        var videoContainer = $("#participant_" + resource);
469
-        if (videoContainer.length > 0) {
470
-            var videoThumb
471
-                    = $(RTC.getVideoElementName(), videoContainer).get(0);
478
+        var videoSel = VideoLayout.getVideoSelector(resource);
479
+        if (videoSel.length > 0) {
480
+            var videoThumb = videoSel[0];
472
             // It is not always the case that a videoThumb exists (if there is
481
             // It is not always the case that a videoThumb exists (if there is
473
             // no actual video).
482
             // no actual video).
474
-            if (videoThumb) {
475
-                if (videoThumb.src && videoThumb.src != '') {
476
-
477
-                    // We have a video src, great! Let's update the large video
478
-                    // now.
479
-
480
-                    VideoLayout.handleVideoThumbClicked(
481
-                        false,
482
-                        Strophe.getResourceFromJid(jid));
483
-                } else {
484
-
485
-                    // If we don't have a video src for jid, there's absolutely
486
-                    // no point in calling handleVideoThumbClicked; Quite
487
-                    // simply, it won't work because it needs an src to attach
488
-                    // to the large video.
489
-                    //
490
-                    // Instead, we trigger the pinned endpoint changed event to
491
-                    // let the bridge adjust its lastN set for myjid and store
492
-                    // the pinned user in the lastNPickupJid variable to be
493
-                    // picked up later by the lastN changed event handler.
494
-
495
-                    lastNPickupJid = jid;
496
-                    eventEmitter.emit(UIEvents.PINNED_ENDPOINT,
497
-                        Strophe.getResourceFromJid(jid));
498
-                }
499
-            } else if (jid == APP.xmpp.myJid()) {
500
-                $("#localVideoContainer").click();
483
+            // FIXME: checking on .src will not work with Temasys plugin
484
+            if (videoThumb.src && videoThumb.src !== '') {
485
+
486
+                // We have a video src, great! Let's update the large video
487
+                // now.
488
+                VideoLayout.handleVideoThumbClicked(
489
+                    false,
490
+                    Strophe.getResourceFromJid(jid));
491
+            } else {
492
+
493
+                // If we don't have a video src for jid, there's absolutely
494
+                // no point in calling handleVideoThumbClicked; Quite
495
+                // simply, it won't work because it needs an src to attach
496
+                // to the large video.
497
+                //
498
+                // Instead, we trigger the pinned endpoint changed event to
499
+                // let the bridge adjust its lastN set for myjid and store
500
+                // the pinned user in the lastNPickupJid variable to be
501
+                // picked up later by the lastN changed event handler.
502
+
503
+                lastNPickupJid = jid;
504
+                eventEmitter.emit(UIEvents.PINNED_ENDPOINT,
505
+                    Strophe.getResourceFromJid(jid));
501
             }
506
             }
502
         }
507
         }
503
     });
508
     });
530
         if (jid === APP.xmpp.myJid()) {
535
         if (jid === APP.xmpp.myJid()) {
531
             localVideoThumbnail.showVideoIndicator(value);
536
             localVideoThumbnail.showVideoIndicator(value);
532
         } else {
537
         } else {
538
+            var resource = Strophe.getResourceFromJid(jid);
539
+
533
             VideoLayout.ensurePeerContainerExists(jid);
540
             VideoLayout.ensurePeerContainerExists(jid);
534
-            remoteVideos[Strophe.getResourceFromJid(jid)].showVideoIndicator(value);
541
+            remoteVideos[resource].showVideoIndicator(value);
535
 
542
 
536
-            var el = $('#participant_'  + Strophe.getResourceFromJid(jid)
537
-                        + '>' + APP.RTC.getVideoElementName());
543
+            var el = VideoLayout.getPeerVideoSel(resource);
538
             if (!value)
544
             if (!value)
539
                 el.show();
545
                 el.show();
540
             else
546
             else
587
         }
593
         }
588
 
594
 
589
         // Obtain container for new dominant speaker.
595
         // Obtain container for new dominant speaker.
590
-        var container  = document.getElementById(
591
-                'participant_' + resourceJid);
596
+        var videoSel  = VideoLayout.getPeerVideoSel(resourceJid);
592
 
597
 
593
         // Local video will not have container found, but that's ok
598
         // Local video will not have container found, but that's ok
594
         // since we don't want to switch to local video.
599
         // since we don't want to switch to local video.
595
-        if (container && !focusedVideoResourceJid)
600
+        if (!focusedVideoResourceJid && videoSel.length)
596
         {
601
         {
597
-            var video
598
-                = container.getElementsByTagName(RTC.getVideoElementName());
599
-
600
             // Update the large video if the video source is already available,
602
             // Update the large video if the video source is already available,
601
             // otherwise wait for the "videoactive.jingle" event.
603
             // otherwise wait for the "videoactive.jingle" event.
602
-            if (video.length && video[0].currentTime > 0) {
604
+            if (videoSel[0].currentTime > 0) {
603
                 LargeVideo.updateLargeVideo(resourceJid);
605
                 LargeVideo.updateLargeVideo(resourceJid);
604
             }
606
             }
605
         }
607
         }
697
 
699
 
698
                     var jid = APP.xmpp.findJidFromResource(resourceJid);
700
                     var jid = APP.xmpp.findJidFromResource(resourceJid);
699
                     var mediaStream = APP.RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE];
701
                     var mediaStream = APP.RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE];
700
-                    var sel = $('#participant_' + resourceJid +
701
-                                '>' + RTC.getVideoElementName());
702
+                    var sel = VideoLayout.getPeerVideoSel(resourceJid);
702
 
703
 
703
                     APP.RTC.attachMediaStream(sel, mediaStream.stream);
704
                     APP.RTC.attachMediaStream(sel, mediaStream.stream);
704
                     if (lastNPickupJid == mediaStream.peerjid) {
705
                     if (lastNPickupJid == mediaStream.peerjid) {

Načítá se…
Zrušit
Uložit