Просмотр исходного кода

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".
dev1
paweldomas 8 лет назад
Родитель
Сommit
da19b721a8
5 измененных файлов: 23 добавлений и 15 удалений
  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 Просмотреть файл

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

+ 1
- 2
JitsiMeetJS.js Просмотреть файл

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

+ 9
- 0
JitsiTrackEvents.js Просмотреть файл

5
 
5
 
6
 /**
6
 /**
7
  * Audio levels of a this track was changed.
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
 export const TRACK_AUDIO_LEVEL_CHANGED = 'track.audioLevelsChanged';
18
 export const TRACK_AUDIO_LEVEL_CHANGED = 'track.audioLevelsChanged';
10
 
19
 

+ 7
- 7
modules/RTC/JitsiTrack.js Просмотреть файл

381
 
381
 
382
 /**
382
 /**
383
  * Sets the audio level for the stream
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
  * @param {number} audioLevel value between 0 and 1
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
     if (this.audioLevel !== audioLevel) {
391
     if (this.audioLevel !== audioLevel) {
392
         this.audioLevel = audioLevel;
392
         this.audioLevel = audioLevel;
393
         this.eventEmitter.emit(
393
         this.eventEmitter.emit(
394
             JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
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 Просмотреть файл

698
                 `${track} was expected to ${isLocal ? 'be' : 'not be'} local`);
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
     /* eslint-enable max-params */
704
     /* eslint-enable max-params */

Загрузка…
Отмена
Сохранить