Selaa lähdekoodia

ref(TPC): add getLocalVideoTrack

...and remove duplication.
dev1
paweldomas 4 vuotta sitten
vanhempi
commit
fa5daa60f0
1 muutettua tiedostoa jossa 12 lisäystä ja 3 poistoa
  1. 12
    3
      modules/RTC/TraceablePeerConnection.js

+ 12
- 3
modules/RTC/TraceablePeerConnection.js Näytä tiedosto

549
     return tracks;
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
  * Checks whether or not this {@link TraceablePeerConnection} instance contains
562
  * Checks whether or not this {@link TraceablePeerConnection} instance contains
554
  * any local tracks for given <tt>mediaType</tt>.
563
  * any local tracks for given <tt>mediaType</tt>.
1961
 
1970
 
1962
         return Promise.resolve();
1971
         return Promise.resolve();
1963
     }
1972
     }
1964
-    const localVideoTrack = Array.from(this.localTracks.values()).find(t => t.isVideoTrack());
1973
+    const localVideoTrack = this.getLocalVideoTrack();
1965
     const videoSender = this.findSenderByKind(MediaType.VIDEO);
1974
     const videoSender = this.findSenderByKind(MediaType.VIDEO);
1966
 
1975
 
1967
     if (!videoSender) {
1976
     if (!videoSender) {
1998
 TraceablePeerConnection.prototype.setMaxBitRate = function(localTrack = null) {
2007
 TraceablePeerConnection.prototype.setMaxBitRate = function(localTrack = null) {
1999
     if (!localTrack) {
2008
     if (!localTrack) {
2000
         // eslint-disable-next-line no-param-reassign
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
         if (!localTrack) {
2012
         if (!localTrack) {
2004
             return Promise.resolve();
2013
             return Promise.resolve();
2162
     if (!newHeight) {
2171
     if (!newHeight) {
2163
         return Promise.resolve();
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
     if (!localVideoTrack || localVideoTrack.isMuted() || localVideoTrack.videoType !== VideoType.CAMERA) {
2176
     if (!localVideoTrack || localVideoTrack.isMuted() || localVideoTrack.videoType !== VideoType.CAMERA) {
2168
         return Promise.resolve();
2177
         return Promise.resolve();

Loading…
Peruuta
Tallenna