Bladeren bron

ref(JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED): reorder args

Reorders JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED event arguments by
putting TraceablePeerConnection at the end. This way it's easier to
treat it as "library internal".
release-8443
paweldomas 8 jaren geleden
bovenliggende
commit
da19b721a8
5 gewijzigde bestanden met toevoegingen van 23 en 15 verwijderingen
  1. 5
    5
      JitsiConference.js
  2. 1
    2
      JitsiMeetJS.js
  3. 9
    0
      JitsiTrackEvents.js
  4. 7
    7
      modules/RTC/JitsiTrack.js
  5. 1
    1
      modules/RTC/RTC.js

+ 5
- 5
JitsiConference.js Bestand weergeven

@@ -616,11 +616,11 @@ JitsiConference.prototype.addTrack = function(track) {
616 616
 
617 617
 /**
618 618
  * Fires TRACK_AUDIO_LEVEL_CHANGED change conference event (for local tracks).
619
- * @param {TraceablePeerConnection|null} tpc
620
- * @param audioLevel the audio level
619
+ * @param {number} audioLevel the audio level
620
+ * @param {TraceablePeerConnection} [tpc]
621 621
  */
622 622
 JitsiConference.prototype._fireAudioLevelChangeEvent
623
-= function(tpc, audioLevel) {
623
+= function(audioLevel, tpc) {
624 624
     const activeTpc = this.getActivePeerConnection();
625 625
 
626 626
     // There will be no TraceablePeerConnection if audio levels do not come from
@@ -628,7 +628,7 @@ JitsiConference.prototype._fireAudioLevelChangeEvent
628 628
     // Audio Analyser API and emits local audio levels events through
629 629
     // JitsiTrack.setAudioLevel, but does not provide TPC instance which is
630 630
     // optional.
631
-    if (tpc === null || activeTpc === tpc) {
631
+    if (!tpc || activeTpc === tpc) {
632 632
         this.eventEmitter.emit(
633 633
             JitsiConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED,
634 634
             this.myUserId(), audioLevel);
@@ -1184,7 +1184,7 @@ JitsiConference.prototype.onRemoteTrackAdded = function(track) {
1184 1184
         () => emitter.emit(JitsiConferenceEvents.TRACK_MUTE_CHANGED, track));
1185 1185
     track.addEventListener(
1186 1186
         JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
1187
-        (tpc, audioLevel) => {
1187
+        (audioLevel, tpc) => {
1188 1188
             const activeTPC = this.getActivePeerConnection();
1189 1189
 
1190 1190
             if (activeTPC === tpc) {

+ 1
- 2
JitsiMeetJS.js Bestand weergeven

@@ -275,8 +275,7 @@ export default {
275 275
 
276 276
                         if (track.getType() === MediaType.AUDIO) {
277 277
                             Statistics.startLocalStats(mStream,
278
-                                track.setAudioLevel.bind(
279
-                                    track, null /* no TPC */));
278
+                                track.setAudioLevel.bind(track));
280 279
                             track.addEventListener(
281 280
                                 JitsiTrackEvents.LOCAL_TRACK_STOPPED,
282 281
                                 () => {

+ 9
- 0
JitsiTrackEvents.js Bestand weergeven

@@ -5,6 +5,15 @@ export const LOCAL_TRACK_STOPPED = 'track.stopped';
5 5
 
6 6
 /**
7 7
  * Audio levels of a this track was changed.
8
+ * The first argument is a number with audio level value in range [0, 1].
9
+ * The second argument is a <tt>TraceablePeerConnection</tt> which is the peer
10
+ * connection which measured the audio level (one audio track can be added
11
+ * to multiple peer connection at the same time). This argument is optional for
12
+ * local tracks for which we can measure audio level without the peer
13
+ * connection (the value will be <tt>undefined</tt>).
14
+ *
15
+ * NOTE The second argument should be treated as library internal and can be
16
+ * removed at any time.
8 17
  */
9 18
 export const TRACK_AUDIO_LEVEL_CHANGED = 'track.audioLevelsChanged';
10 19
 

+ 7
- 7
modules/RTC/JitsiTrack.js Bestand weergeven

@@ -381,19 +381,19 @@ JitsiTrack.prototype.removeEventListener = JitsiTrack.prototype.off;
381 381
 
382 382
 /**
383 383
  * Sets the audio level for the stream
384
- * @param {TraceablePeerConnection|null} tpc the peerconnection instance which
385
- * is source for the audio level. It can be <tt>null</tt> for a local track if
386
- * the audio level was measured outside of the peerconnection
387
- * (see /modules/statistics/LocalStatsCollector.js).
388 384
  * @param {number} audioLevel value between 0 and 1
385
+ * @param {TraceablePeerConnection} [tpc] the peerconnection instance which
386
+ * is source for the audio level. It can be <tt>undefined</tt> for
387
+ * a local track if the audio level was measured outside of the peerconnection
388
+ * (see /modules/statistics/LocalStatsCollector.js).
389 389
  */
390
-JitsiTrack.prototype.setAudioLevel = function(tpc, audioLevel) {
390
+JitsiTrack.prototype.setAudioLevel = function(audioLevel, tpc) {
391 391
     if (this.audioLevel !== audioLevel) {
392 392
         this.audioLevel = audioLevel;
393 393
         this.eventEmitter.emit(
394 394
             JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
395
-            tpc,
396
-            audioLevel);
395
+            audioLevel,
396
+            tpc);
397 397
     }
398 398
 };
399 399
 

+ 1
- 1
modules/RTC/RTC.js Bestand weergeven

@@ -698,7 +698,7 @@ export default class RTC extends Listenable {
698 698
                 `${track} was expected to ${isLocal ? 'be' : 'not be'} local`);
699 699
         }
700 700
 
701
-        track.setAudioLevel(tpc, audioLevel);
701
+        track.setAudioLevel(audioLevel, tpc);
702 702
     }
703 703
 
704 704
     /* eslint-enable max-params */

Laden…
Annuleren
Opslaan