소스 검색

feat(TS) Migrate `modules\RTC\JitsiLocalTrack.ts` to TS (#2840)

* added interfaces and initialise TS def

* add proper typings avoiding any

* fixing linting errors

---------

Co-authored-by: naman9271 <naman9271@gmail.com>
master
Naman Jain 3 달 전
부모
커밋
d0dbe6067e
No account linked to committer's email address
3개의 변경된 파일132개의 추가작업 그리고 64개의 파일을 삭제
  1. 2
    2
      JitsiConference.js
  2. 129
    61
      modules/RTC/JitsiLocalTrack.ts
  3. 1
    1
      modules/RTC/JitsiTrack.js

+ 2
- 2
JitsiConference.js 파일 보기

818
    *
818
    *
819
    * @param {JitsiLocalTrack} localtrack - The track associated with the local source signaled to the bridge.
819
    * @param {JitsiLocalTrack} localtrack - The track associated with the local source signaled to the bridge.
820
    * @returns {void}
820
    * @returns {void}
821
-   * @private
821
+   * @public
822
    */
822
    */
823
     _sendBridgeVideoTypeMessage(localtrack) {
823
     _sendBridgeVideoTypeMessage(localtrack) {
824
         let videoType = !localtrack || localtrack.isMuted() ? BridgeVideoType.NONE : localtrack.getVideoType();
824
         let videoType = !localtrack || localtrack.isMuted() ? BridgeVideoType.NONE : localtrack.getVideoType();
1436
    * @param {JitsiLocalTrack} localTrack - The local track.
1436
    * @param {JitsiLocalTrack} localTrack - The local track.
1437
    * @param {boolean} isMuted - Whether the track is muted.
1437
    * @param {boolean} isMuted - Whether the track is muted.
1438
    * @return {boolean} <tt>true</tt> when presence was changed, <tt>false</tt> otherwise.
1438
    * @return {boolean} <tt>true</tt> when presence was changed, <tt>false</tt> otherwise.
1439
-   * @private
1439
+   * @public
1440
    */
1440
    */
1441
     _setTrackMuteStatus(mediaType, localTrack, isMuted) {
1441
     _setTrackMuteStatus(mediaType, localTrack, isMuted) {
1442
         let presenceChanged = false;
1442
         let presenceChanged = false;

modules/RTC/JitsiLocalTrack.js → modules/RTC/JitsiLocalTrack.ts 파일 보기

1
 import { getLogger } from '@jitsi/logger';
1
 import { getLogger } from '@jitsi/logger';
2
 
2
 
3
+import JitsiConference from '../../JitsiConference';
3
 import JitsiTrackError from '../../JitsiTrackError';
4
 import JitsiTrackError from '../../JitsiTrackError';
4
 import {
5
 import {
5
     TRACK_IS_DISPOSED,
6
     TRACK_IS_DISPOSED,
25
 
26
 
26
 import JitsiTrack from './JitsiTrack';
27
 import JitsiTrack from './JitsiTrack';
27
 import RTCUtils from './RTCUtils';
28
 import RTCUtils from './RTCUtils';
29
+import TraceablePeerConnection from './TraceablePeerConnection';
28
 
30
 
29
 const logger = getLogger('modules/RTC/JitsiLocalTrack');
31
 const logger = getLogger('modules/RTC/JitsiLocalTrack');
30
 
32
 
33
+export interface IStreamEffect {
34
+    isEnabled: (track: JitsiLocalTrack) => boolean;
35
+    isMuted?: () => boolean;
36
+    setMuted?: (muted: boolean) => void;
37
+    startEffect: (stream: MediaStream) => MediaStream;
38
+    stopEffect: () => void;
39
+}
40
+
41
+export interface ITrackMetadata {
42
+    displaySurface?: string;
43
+    timestamp: number;
44
+}
45
+
46
+export interface ITrackConstraints {
47
+    [key: string]: any;
48
+    height?: any;
49
+    width?: any;
50
+}
51
+
52
+export interface ITrackInfo {
53
+    constraints: ITrackConstraints;
54
+    deviceId: string;
55
+    effects?: IStreamEffect[];
56
+    facingMode?: CameraFacingMode;
57
+    mediaType: MediaType;
58
+    rtcId: number;
59
+    sourceId?: string;
60
+    sourceType?: string;
61
+    stream: MediaStream;
62
+    track: MediaStreamTrack;
63
+    videoType?: VideoType;
64
+}
65
+
66
+export interface IStreamInfo {
67
+    stream: MediaStream;
68
+    track: MediaStreamTrack;
69
+    videoType?: VideoType;
70
+}
71
+
31
 /**
72
 /**
32
  * Represents a single media track(either audio or video).
73
  * Represents a single media track(either audio or video).
33
  * One <tt>JitsiLocalTrack</tt> corresponds to one WebRTC MediaStreamTrack.
74
  * One <tt>JitsiLocalTrack</tt> corresponds to one WebRTC MediaStreamTrack.
34
  */
75
  */
35
 export default class JitsiLocalTrack extends JitsiTrack {
76
 export default class JitsiLocalTrack extends JitsiTrack {
77
+    private _setEffectInProgress: boolean;
78
+    private _constraints: ITrackConstraints;
79
+    private _prevSetMuted: Promise<void>;
80
+    private _facingMode?: CameraFacingMode;
81
+    private _trackEnded: boolean;
82
+    private _hasSentData: boolean;
83
+    private _testDataSent: boolean;
84
+    private _realDeviceId?: string;
85
+    private _sourceName?: string;
86
+    private _ssrc?: number;
87
+    private _trackMutedTS: number;
88
+    private _onDeviceListWillChange: (devices: MediaDeviceInfo[]) => void;
89
+    private _onAudioOutputDeviceChanged?: () => void;
90
+    private _streamEffect?: IStreamEffect;
91
+    private _originalStream?: MediaStream;
92
+    private _stopStreamInProgress: boolean;
93
+    private _effectEnabled?: boolean;
94
+    public metadata: ITrackMetadata;
95
+    public rtcId: number;
96
+    public sourceId?: string;
97
+    public sourceType?: string;
98
+    public deviceId: string;
99
+    public resolution?: number;
100
+    public maxEnabledResolution?: number;
101
+    public conference: JitsiConference | null;
102
+
36
     /**
103
     /**
37
      * Constructs a new JitsiLocalTrack instance.
104
      * Constructs a new JitsiLocalTrack instance.
38
      *
105
      *
63
         track,
130
         track,
64
         videoType,
131
         videoType,
65
         effects = []
132
         effects = []
66
-    }) {
133
+    }: ITrackInfo) {
67
         super(
134
         super(
68
             /* conference */ null,
135
             /* conference */ null,
69
             stream,
136
             stream,
189
 
256
 
190
         this._trackMutedTS = 0;
257
         this._trackMutedTS = 0;
191
 
258
 
192
-        this._onDeviceListWillChange = devices => {
259
+        this._onDeviceListWillChange = (devices: MediaDeviceInfo[]) => {
193
             const oldRealDeviceId = this._realDeviceId;
260
             const oldRealDeviceId = this._realDeviceId;
194
 
261
 
195
             this._setRealDeviceIdFromDeviceList(devices);
262
             this._setRealDeviceIdFromDeviceList(devices);
235
      * @private
302
      * @private
236
      * @returns {Promise}
303
      * @returns {Promise}
237
      */
304
      */
238
-    _addStreamToConferenceAsUnmute() {
305
+    private _addStreamToConferenceAsUnmute(): Promise<void> {
239
         if (!this.conference) {
306
         if (!this.conference) {
240
             return Promise.resolve();
307
             return Promise.resolve();
241
         }
308
         }
248
         // are changed. This would help to separate XMPP from the RTC module.
315
         // are changed. This would help to separate XMPP from the RTC module.
249
         return new Promise((resolve, reject) => {
316
         return new Promise((resolve, reject) => {
250
             this.conference._addLocalTrackToPc(this)
317
             this.conference._addLocalTrackToPc(this)
251
-                .then(resolve, error => reject(new Error(error)));
318
+                .then(resolve, (error: any) => reject(new Error(error)));
252
         });
319
         });
253
     }
320
     }
254
 
321
 
258
      * @private
325
      * @private
259
      * @returns {void}
326
      * @returns {void}
260
      */
327
      */
261
-    _fireNoDataFromSourceEvent() {
328
+    private _fireNoDataFromSourceEvent(): void {
262
         const value = !this.isReceivingData();
329
         const value = !this.isReceivingData();
263
 
330
 
264
         this.emit(NO_DATA_FROM_SOURCE, value);
331
         this.emit(NO_DATA_FROM_SOURCE, value);
275
      * @private
342
      * @private
276
      * @returns {void}
343
      * @returns {void}
277
      */
344
      */
278
-    _initNoDataFromSourceHandlers() {
345
+    private _initNoDataFromSourceHandlers(): void {
279
         if (!this._isNoDataFromSourceEventsEnabled()) {
346
         if (!this._isNoDataFromSourceEventsEnabled()) {
280
             return;
347
             return;
281
         }
348
         }
311
      * @private
378
      * @private
312
      * @returns {boolean} - True if no data from source events are enabled for this JitsiLocalTrack and false otherwise.
379
      * @returns {boolean} - True if no data from source events are enabled for this JitsiLocalTrack and false otherwise.
313
      */
380
      */
314
-    _isNoDataFromSourceEventsEnabled() {
381
+    private _isNoDataFromSourceEventsEnabled(): boolean {
315
         // Disable the events for screen sharing.
382
         // Disable the events for screen sharing.
316
         return !this.isVideoTrack() || this.videoType !== VideoType.DESKTOP;
383
         return !this.isVideoTrack() || this.videoType !== VideoType.DESKTOP;
317
     }
384
     }
325
      * @private
392
      * @private
326
      * @returns {Promise}
393
      * @returns {Promise}
327
      */
394
      */
328
-    _queueSetMuted(muted) {
395
+    private _queueSetMuted(muted: boolean): Promise<void> {
329
         const setMuted = this._setMuted.bind(this, muted);
396
         const setMuted = this._setMuted.bind(this, muted);
330
 
397
 
331
         this._prevSetMuted = this._prevSetMuted.then(setMuted, setMuted);
398
         this._prevSetMuted = this._prevSetMuted.then(setMuted, setMuted);
341
      * @private
408
      * @private
342
      * @returns {Promise}
409
      * @returns {Promise}
343
      */
410
      */
344
-    _removeStreamFromConferenceAsMute(successCallback, errorCallback) {
411
+    private _removeStreamFromConferenceAsMute(successCallback: () => void, errorCallback: (error: Error) => void): void {
345
         if (!this.conference) {
412
         if (!this.conference) {
346
             successCallback();
413
             successCallback();
347
 
414
 
349
         }
416
         }
350
         this.conference._removeLocalTrackFromPc(this).then(
417
         this.conference._removeLocalTrackFromPc(this).then(
351
             successCallback,
418
             successCallback,
352
-            error => errorCallback(new Error(error)));
419
+            (error: any) => errorCallback(new Error(error)));
353
     }
420
     }
354
 
421
 
355
     /**
422
     /**
359
      * @private
426
      * @private
360
      * @returns {void}
427
      * @returns {void}
361
      */
428
      */
362
-    _sendMuteStatus(mute) {
429
+    private _sendMuteStatus(mute: boolean): void {
363
         if (this.conference) {
430
         if (this.conference) {
364
             this.conference._setTrackMuteStatus(this.getType(), this, mute) && this.conference.room.sendPresence();
431
             this.conference._setTrackMuteStatus(this.getType(), this, mute) && this.conference.room.sendPresence();
365
         }
432
         }
372
      * @private
439
      * @private
373
      * @returns {Promise}
440
      * @returns {Promise}
374
      */
441
      */
375
-    _setMuted(muted) {
442
+    private _setMuted(muted: boolean): Promise<void> {
376
         if (this.isMuted() === muted && this.videoType !== VideoType.DESKTOP) {
443
         if (this.isMuted() === muted && this.videoType !== VideoType.DESKTOP) {
377
             return Promise.resolve();
444
             return Promise.resolve();
378
         }
445
         }
381
             return Promise.reject(new JitsiTrackError(TRACK_IS_DISPOSED));
448
             return Promise.reject(new JitsiTrackError(TRACK_IS_DISPOSED));
382
         }
449
         }
383
 
450
 
384
-        let promise = Promise.resolve();
451
+        let promise: Promise<void | IStreamInfo[]> = Promise.resolve();
385
 
452
 
386
         // A function that will print info about muted status transition
453
         // A function that will print info about muted status transition
387
         const logMuteInfo = () => logger.info(`Mute ${this}: ${muted}`);
454
         const logMuteInfo = () => logger.info(`Mute ${this}: ${muted}`);
401
             // If we have a stream effect that implements its own mute functionality, prioritize it before
468
             // If we have a stream effect that implements its own mute functionality, prioritize it before
402
             // normal mute e.g. the stream effect that implements system audio sharing has a custom
469
             // normal mute e.g. the stream effect that implements system audio sharing has a custom
403
             // mute state in which if the user mutes, system audio still has to go through.
470
             // mute state in which if the user mutes, system audio still has to go through.
404
-            if (this._streamEffect && this._streamEffect.setMuted) {
471
+            if (this._streamEffect?.setMuted) {
405
                 this._streamEffect.setMuted(muted);
472
                 this._streamEffect.setMuted(muted);
406
             } else if (this.track) {
473
             } else if (this.track) {
407
                 this.track.enabled = !muted;
474
                 this.track.enabled = !muted;
441
                 = RTCUtils.obtainAudioAndVideoPermissions({
508
                 = RTCUtils.obtainAudioAndVideoPermissions({
442
 
509
 
443
                     ...streamOptions,
510
                     ...streamOptions,
444
-                    constraints: { video: this._constraints } });
511
+                    constraints: { video: this._constraints } } as any) as Promise<IStreamInfo[]>;
445
 
512
 
446
-            promise = promise.then(streamsInfo => {
513
+            promise = promise.then((streamsInfo: IStreamInfo[]) => {
447
                 const streamInfo = streamsInfo.find(info => info.track.kind === this.getType());
514
                 const streamInfo = streamsInfo.find(info => info.track.kind === this.getType());
448
 
515
 
449
                 if (streamInfo) {
516
                 if (streamInfo) {
479
                 this._sendMuteStatus(muted);
546
                 this._sendMuteStatus(muted);
480
 
547
 
481
                 // Send the videoType message to the bridge.
548
                 // Send the videoType message to the bridge.
482
-                this.isVideoTrack() && this.conference && this.conference._sendBridgeVideoTypeMessage(this);
549
+                this.isVideoTrack() && this.conference?._sendBridgeVideoTypeMessage(this);
483
                 this.emit(TRACK_MUTE_CHANGED, this);
550
                 this.emit(TRACK_MUTE_CHANGED, this);
484
             });
551
             });
485
     }
552
     }
492
      * @private
559
      * @private
493
      * @returns {void}
560
      * @returns {void}
494
      */
561
      */
495
-    _setRealDeviceIdFromDeviceList(devices) {
562
+    private _setRealDeviceIdFromDeviceList(devices: MediaDeviceInfo[]): void {
496
         const track = this.getTrack();
563
         const track = this.getTrack();
497
         const kind = `${track.kind}input`;
564
         const kind = `${track.kind}input`;
498
 
565
 
515
         }
582
         }
516
     }
583
     }
517
 
584
 
518
-    /**
519
-     * Sets the stream property of JitsiLocalTrack object and sets all stored handlers to it.
520
-     *
521
-     * @param {MediaStream} stream - The new MediaStream.
522
-     * @private
523
-     * @returns {void}
524
-     */
525
-    _setStream(stream) {
526
-        super._setStream(stream);
527
-    }
528
-
529
     /**
585
     /**
530
      * Starts the effect process and returns the modified stream.
586
      * Starts the effect process and returns the modified stream.
531
      *
587
      *
533
      * @private
589
      * @private
534
      * @returns {void}
590
      * @returns {void}
535
      */
591
      */
536
-    _startStreamEffect(effect) {
592
+    private _startStreamEffect(effect: IStreamEffect): void {
537
         this._streamEffect = effect;
593
         this._streamEffect = effect;
538
         this._originalStream = this.stream;
594
         this._originalStream = this.stream;
539
         this._setStream(this._streamEffect.startEffect(this._originalStream));
595
         this._setStream(this._streamEffect.startEffect(this._originalStream));
546
      * @private
602
      * @private
547
      * @returns {void}
603
      * @returns {void}
548
      */
604
      */
549
-    _stopStreamEffect() {
605
+    private _stopStreamEffect(): void {
550
         if (this._streamEffect) {
606
         if (this._streamEffect) {
551
             this._streamEffect.stopEffect();
607
             this._streamEffect.stopEffect();
552
             this._setStream(this._originalStream);
608
             this._setStream(this._originalStream);
566
      *
622
      *
567
      * @returns {void}
623
      * @returns {void}
568
      */
624
      */
569
-    _switchCamera() {
625
+    private _switchCamera(): void {
570
         if (this.isVideoTrack()
626
         if (this.isVideoTrack()
571
                 && this.videoType === VideoType.CAMERA
627
                 && this.videoType === VideoType.CAMERA
572
                 && typeof this.track._switchCamera === 'function') {
628
                 && typeof this.track._switchCamera === 'function') {
586
      * @private
642
      * @private
587
      * @returns {void}
643
      * @returns {void}
588
      */
644
      */
589
-    _switchStreamEffect(effect) {
645
+    private _switchStreamEffect(effect?: IStreamEffect): void {
590
         if (this._streamEffect) {
646
         if (this._streamEffect) {
591
             this._stopStreamEffect();
647
             this._stopStreamEffect();
592
             this._streamEffect = undefined;
648
             this._streamEffect = undefined;
596
         }
652
         }
597
     }
653
     }
598
 
654
 
655
+    /**
656
+     * Sets the stream property of JitsiLocalTrack object and sets all stored handlers to it.
657
+     *
658
+     * @param {MediaStream} stream - The new MediaStream.
659
+     * @private
660
+     * @returns {void}
661
+     */
662
+    protected _setStream(stream: MediaStream | null): void {
663
+        super._setStream(stream);
664
+    }
665
+
666
+
599
     /**
667
     /**
600
      * @inheritdoc
668
      * @inheritdoc
601
      *
669
      *
604
      * @extends JitsiTrack#dispose
672
      * @extends JitsiTrack#dispose
605
      * @returns {Promise}
673
      * @returns {Promise}
606
      */
674
      */
607
-    async dispose() {
675
+    async dispose(): Promise<void> {
608
         if (this.disposed) {
676
         if (this.disposed) {
609
             return;
677
             return;
610
         }
678
         }
612
         // Remove the effect instead of stopping it so that the original stream is restored
680
         // Remove the effect instead of stopping it so that the original stream is restored
613
         // on both the local track and on the peerconnection.
681
         // on both the local track and on the peerconnection.
614
         if (this._streamEffect) {
682
         if (this._streamEffect) {
615
-            await this.setEffect();
683
+            await this.setEffect(undefined);
616
         }
684
         }
617
 
685
 
618
         if (this.conference) {
686
         if (this.conference) {
639
      *
707
      *
640
      * @returns {CameraFacingMode|undefined}
708
      * @returns {CameraFacingMode|undefined}
641
      */
709
      */
642
-    getCameraFacingMode() {
710
+    getCameraFacingMode(): CameraFacingMode | undefined {
643
         if (this.isVideoTrack() && this.videoType === VideoType.CAMERA) {
711
         if (this.isVideoTrack() && this.videoType === VideoType.CAMERA) {
644
             // MediaStreamTrack#getSettings() is not implemented in many
712
             // MediaStreamTrack#getSettings() is not implemented in many
645
             // browsers, so we need feature checking here. Progress on the
713
             // browsers, so we need feature checking here. Progress on the
651
             const trackSettings = this.track.getSettings?.();
719
             const trackSettings = this.track.getSettings?.();
652
 
720
 
653
             if (trackSettings && 'facingMode' in trackSettings) {
721
             if (trackSettings && 'facingMode' in trackSettings) {
654
-                return trackSettings.facingMode;
722
+                return trackSettings.facingMode as CameraFacingMode;
655
             }
723
             }
656
 
724
 
657
             if (typeof this._facingMode !== 'undefined') {
725
             if (typeof this._facingMode !== 'undefined') {
672
      *
740
      *
673
      * @returns {Number}
741
      * @returns {Number}
674
      */
742
      */
675
-    getCaptureResolution() {
743
+    getCaptureResolution(): number {
676
         if (this.videoType === VideoType.CAMERA || !browser.isWebKitBased()) {
744
         if (this.videoType === VideoType.CAMERA || !browser.isWebKitBased()) {
677
-            return this.resolution;
745
+            return this.resolution!;
678
         }
746
         }
679
 
747
 
680
         return this.getHeight();
748
         return this.getHeight();
685
      *
753
      *
686
      * @returns {string}
754
      * @returns {string}
687
      */
755
      */
688
-    getDeviceId() {
756
+    getDeviceId(): string {
689
         return this._realDeviceId || this.deviceId;
757
         return this._realDeviceId || this.deviceId;
690
     }
758
     }
691
 
759
 
694
      *
762
      *
695
      * @returns {Number} the duration of the track in seconds
763
      * @returns {Number} the duration of the track in seconds
696
      */
764
      */
697
-    getDuration() {
765
+    getDuration(): number {
698
         return (Date.now() / 1000) - (this.metadata.timestamp / 1000);
766
         return (Date.now() / 1000) - (this.metadata.timestamp / 1000);
699
     }
767
     }
700
 
768
 
704
      * @returns {string} the id of the participants. It corresponds to the
772
      * @returns {string} the id of the participants. It corresponds to the
705
      * Colibri endpoint id/MUC nickname in case of Jitsi-meet.
773
      * Colibri endpoint id/MUC nickname in case of Jitsi-meet.
706
      */
774
      */
707
-    getParticipantId() {
708
-        return this.conference && this.conference.myUserId();
775
+    getParticipantId(): string {
776
+        return this.conference?.myUserId();
709
     }
777
     }
710
 
778
 
711
     /**
779
     /**
713
      *
781
      *
714
      * @returns {string | null} source name
782
      * @returns {string | null} source name
715
      */
783
      */
716
-    getSourceName() {
784
+    getSourceName(): string | null {
717
         return this._sourceName;
785
         return this._sourceName;
718
     }
786
     }
719
 
787
 
721
      * Returns the primary SSRC associated with the track.
789
      * Returns the primary SSRC associated with the track.
722
      * @returns {number}
790
      * @returns {number}
723
      */
791
      */
724
-    getSsrc() {
792
+    getSsrc(): number | null {
725
         return this._ssrc;
793
         return this._ssrc;
726
     }
794
     }
727
 
795
 
730
      *
798
      *
731
      * @returns {boolean}
799
      * @returns {boolean}
732
      */
800
      */
733
-    isEnded() {
801
+    isEnded(): boolean {
734
         if (this.isVideoTrack() && this.isMuted()) {
802
         if (this.isVideoTrack() && this.isMuted()) {
735
             // If a video track is muted the readyState will be ended, that's why we need to rely only on the
803
             // If a video track is muted the readyState will be ended, that's why we need to rely only on the
736
             // _trackEnded flag.
804
             // _trackEnded flag.
745
      *
813
      *
746
      * @returns {boolean} <tt>true</tt>
814
      * @returns {boolean} <tt>true</tt>
747
      */
815
      */
748
-    isLocal() {
816
+    isLocal(): boolean {
749
         return true;
817
         return true;
750
     }
818
     }
751
 
819
 
754
      *
822
      *
755
      * @returns {boolean} <tt>true</tt> - if the stream is muted and <tt>false</tt> otherwise.
823
      * @returns {boolean} <tt>true</tt> - if the stream is muted and <tt>false</tt> otherwise.
756
      */
824
      */
757
-    isMuted() {
825
+    isMuted(): boolean {
758
         // this.stream will be null when we mute local video on Chrome
826
         // this.stream will be null when we mute local video on Chrome
759
         if (!this.stream) {
827
         if (!this.stream) {
760
             return true;
828
             return true;
764
         }
832
         }
765
 
833
 
766
         // If currently used stream effect has its own muted state, use that.
834
         // If currently used stream effect has its own muted state, use that.
767
-        if (this._streamEffect && this._streamEffect.isMuted) {
835
+        if (this._streamEffect?.isMuted) {
768
             return this._streamEffect.isMuted();
836
             return this._streamEffect.isMuted();
769
         }
837
         }
770
 
838
 
771
-        return !this.track || !this.track.enabled;
839
+        return !this.track?.enabled;
772
     }
840
     }
773
 
841
 
774
     /**
842
     /**
779
      *
847
      *
780
      * @returns {boolean} true if the stream is receiving data and false this otherwise.
848
      * @returns {boolean} true if the stream is receiving data and false this otherwise.
781
      */
849
      */
782
-    isReceivingData() {
850
+    isReceivingData(): boolean {
783
         if (this.isVideoTrack()
851
         if (this.isVideoTrack()
784
             && (this.isMuted() || this._stopStreamInProgress || this.videoType === VideoType.DESKTOP)) {
852
             && (this.isMuted() || this._stopStreamInProgress || this.videoType === VideoType.DESKTOP)) {
785
             return true;
853
             return true;
807
      *
875
      *
808
      * @returns {Promise}
876
      * @returns {Promise}
809
      */
877
      */
810
-    mute() {
878
+    mute(): Promise<void> {
811
         return this._queueSetMuted(true);
879
         return this._queueSetMuted(true);
812
     }
880
     }
813
 
881
 
818
      * @param {number} bytesSent - The new value.
886
      * @param {number} bytesSent - The new value.
819
      * @returns {void}
887
      * @returns {void}
820
      */
888
      */
821
-    onByteSentStatsReceived(tpc, bytesSent) {
889
+    onByteSentStatsReceived(tpc: TraceablePeerConnection, bytesSent: number): void {
822
         if (bytesSent > 0) {
890
         if (bytesSent > 0) {
823
             this._hasSentData = true;
891
             this._hasSentData = true;
824
         }
892
         }
843
      * @param conference - JitsiConference object.
911
      * @param conference - JitsiConference object.
844
      * @returns {void}
912
      * @returns {void}
845
      */
913
      */
846
-    setConference(conference) {
914
+    setConference(conference: JitsiConference): void {
847
         this.conference = conference;
915
         this.conference = conference;
848
     }
916
     }
849
 
917
 
853
      * @param {Object} effect - Represents the effect instance to be used.
921
      * @param {Object} effect - Represents the effect instance to be used.
854
      * @returns {Promise}
922
      * @returns {Promise}
855
      */
923
      */
856
-    setEffect(effect) {
924
+    setEffect(effect?: IStreamEffect): Promise<void> {
857
         if (typeof this._streamEffect === 'undefined' && typeof effect === 'undefined') {
925
         if (typeof this._streamEffect === 'undefined' && typeof effect === 'undefined') {
858
             return Promise.resolve();
926
             return Promise.resolve();
859
         }
927
         }
907
             .then(() => {
975
             .then(() => {
908
                 this._setEffectInProgress = false;
976
                 this._setEffectInProgress = false;
909
             })
977
             })
910
-            .catch(error => {
978
+            .catch((error: any) => {
911
                 // Any error will be not recovarable and will trigger CONFERENCE_FAILED event. But let's try to cleanup
979
                 // Any error will be not recovarable and will trigger CONFERENCE_FAILED event. But let's try to cleanup
912
                 // everyhting related to the effect functionality.
980
                 // everyhting related to the effect functionality.
913
                 this._setEffectInProgress = false;
981
                 this._setEffectInProgress = false;
922
      *
990
      *
923
      * @param {string} name The source name.
991
      * @param {string} name The source name.
924
      */
992
      */
925
-    setSourceName(name) {
993
+    setSourceName(name: string): void {
926
         this._sourceName = name;
994
         this._sourceName = name;
927
     }
995
     }
928
 
996
 
931
      *
999
      *
932
      * @param {number} ssrc The SSRC.
1000
      * @param {number} ssrc The SSRC.
933
      */
1001
      */
934
-    setSsrc(ssrc) {
1002
+    setSsrc(ssrc: number): void {
935
         if (isValidNumber(ssrc)) {
1003
         if (isValidNumber(ssrc)) {
936
             this._ssrc = ssrc;
1004
             this._ssrc = ssrc;
937
         }
1005
         }
942
      *
1010
      *
943
      * @returns {void}
1011
      * @returns {void}
944
      */
1012
      */
945
-    stopStream() {
1013
+    stopStream(): void {
946
         /**
1014
         /**
947
          * Indicates that we are executing {@link #stopStream} i.e.
1015
          * Indicates that we are executing {@link #stopStream} i.e.
948
          * {@link RTCUtils#stopMediaStream} for the <tt>MediaStream</tt>
1016
          * {@link RTCUtils#stopMediaStream} for the <tt>MediaStream</tt>
965
      *
1033
      *
966
      * @return {string}
1034
      * @return {string}
967
      */
1035
      */
968
-    toString() {
1036
+    toString(): string {
969
         return `LocalTrack[${this.rtcId},${this.getType()}]`;
1037
         return `LocalTrack[${this.rtcId},${this.getType()}]`;
970
     }
1038
     }
971
 
1039
 
974
      *
1042
      *
975
      * @returns {Promise}
1043
      * @returns {Promise}
976
      */
1044
      */
977
-    unmute() {
1045
+    unmute(): Promise<void> {
978
         return this._queueSetMuted(false);
1046
         return this._queueSetMuted(false);
979
     }
1047
     }
980
 }
1048
 }

+ 1
- 1
modules/RTC/JitsiTrack.js 파일 보기

180
 
180
 
181
     /**
181
     /**
182
      * Unregisters all event handlers bound to the underlying media stream/track
182
      * Unregisters all event handlers bound to the underlying media stream/track
183
-     * @private
183
+     * @public
184
      */
184
      */
185
     _unregisterHandlers() {
185
     _unregisterHandlers() {
186
         if (!this.stream) {
186
         if (!this.stream) {

Loading…
취소
저장