Преглед изворни кода

ref(TPC): add getLocalVideoTrack

...and remove duplication.
dev1
paweldomas пре 4 година
родитељ
комит
fa5daa60f0
1 измењених фајлова са 12 додато и 3 уклоњено
  1. 12
    3
      modules/RTC/TraceablePeerConnection.js

+ 12
- 3
modules/RTC/TraceablePeerConnection.js Прегледај датотеку

@@ -549,6 +549,15 @@ TraceablePeerConnection.prototype.getLocalTracks = function(mediaType) {
549 549
     return tracks;
550 550
 };
551 551
 
552
+/**
553
+ * Retrieves the local video track.
554
+ *
555
+ * @returns {JitsiLocalTrack|undefined} - local video track.
556
+ */
557
+TraceablePeerConnection.prototype.getLocalVideoTrack = function() {
558
+    return this.getLocalTracks(MediaType.VIDEO)[0];
559
+};
560
+
552 561
 /**
553 562
  * Checks whether or not this {@link TraceablePeerConnection} instance contains
554 563
  * any local tracks for given <tt>mediaType</tt>.
@@ -1961,7 +1970,7 @@ TraceablePeerConnection.prototype.setSenderVideoDegradationPreference = function
1961 1970
 
1962 1971
         return Promise.resolve();
1963 1972
     }
1964
-    const localVideoTrack = Array.from(this.localTracks.values()).find(t => t.isVideoTrack());
1973
+    const localVideoTrack = this.getLocalVideoTrack();
1965 1974
     const videoSender = this.findSenderByKind(MediaType.VIDEO);
1966 1975
 
1967 1976
     if (!videoSender) {
@@ -1998,7 +2007,7 @@ TraceablePeerConnection.prototype.setSenderVideoDegradationPreference = function
1998 2007
 TraceablePeerConnection.prototype.setMaxBitRate = function(localTrack = null) {
1999 2008
     if (!localTrack) {
2000 2009
         // eslint-disable-next-line no-param-reassign
2001
-        localTrack = Array.from(this.localTracks.values()).find(t => t.isVideoTrack());
2010
+        localTrack = this.getLocalVideoTrack();
2002 2011
 
2003 2012
         if (!localTrack) {
2004 2013
             return Promise.resolve();
@@ -2162,7 +2171,7 @@ TraceablePeerConnection.prototype.setSenderVideoConstraint = function(frameHeigh
2162 2171
     if (!newHeight) {
2163 2172
         return Promise.resolve();
2164 2173
     }
2165
-    const localVideoTrack = Array.from(this.localTracks.values()).find(t => t.isVideoTrack());
2174
+    const localVideoTrack = this.getLocalVideoTrack();
2166 2175
 
2167 2176
     if (!localVideoTrack || localVideoTrack.isMuted() || localVideoTrack.videoType !== VideoType.CAMERA) {
2168 2177
         return Promise.resolve();

Loading…
Откажи
Сачувај