Browse Source

feat(ts) migrate LiteModeContext to TS

dev0
Naman Jain 6 months ago
parent
commit
9a3eab4c0e
No account linked to committer's email address
2 changed files with 14 additions and 3 deletions
  1. 6
    0
      globals.d.ts
  2. 8
    3
      modules/litemode/LiteModeContext.ts

+ 6
- 0
globals.d.ts View File

@@ -4,4 +4,10 @@ declare global {
4 4
     interface Window {
5 5
         connectionTimes: any;
6 6
     }
7
+    interface RTCRtpReceiver {
8
+        createEncodedStreams?: () => {
9
+            readable: ReadableStream<RTCEncodedAudioFrame | RTCEncodedVideoFrame>;
10
+            writable: WritableStream<RTCEncodedAudioFrame | RTCEncodedVideoFrame>;
11
+        }
12
+    }
7 13
 }

modules/litemode/LiteModeContext.js → modules/litemode/LiteModeContext.ts View File

@@ -1,6 +1,9 @@
1 1
 import { getLogger } from '@jitsi/logger';
2 2
 
3
+import JitsiConference from '../../JitsiConference';
3 4
 import RTCEvents from '../../service/RTC/RTCEvents';
5
+import JitsiRemoteTrack from '../RTC/JitsiRemoteTrack';
6
+import TraceablePeerConnection from '../RTC/TraceablePeerConnection';
4 7
 import FeatureFlags from '../flags/FeatureFlags';
5 8
 
6 9
 // Flag to set on receivers to avoid setting up the lite mode
@@ -13,11 +16,13 @@ const logger = getLogger(__filename);
13 16
  * This module implements a discard-all insertable stream.  Use to reduce decoder CPU load for testing.
14 17
  */
15 18
 export class LiteModeContext {
19
+    private enabled: boolean;
20
+
16 21
     /**
17 22
      * A constructor.
18 23
      * @param {JitsiConference} conference - The conference instance for which lite mode is to be enabled.
19 24
      */
20
-    constructor(conference) {
25
+    constructor(conference: JitsiConference) {
21 26
         this.enabled = FeatureFlags.isRunInLiteModeEnabled();
22 27
         if (!this.enabled) {
23 28
             return;
@@ -25,7 +30,7 @@ export class LiteModeContext {
25 30
 
26 31
         conference.rtc.on(
27 32
             RTCEvents.REMOTE_TRACK_ADDED,
28
-            (track, tpc) => this._setupLiteModeForTrack(tpc, track));
33
+            (track: JitsiRemoteTrack, tpc: TraceablePeerConnection) => this._setupLiteModeForTrack(tpc, track));
29 34
     }
30 35
 
31 36
     /**
@@ -33,7 +38,7 @@ export class LiteModeContext {
33 38
      *
34 39
      * @private
35 40
      */
36
-    _setupLiteModeForTrack(tpc, track) {
41
+    private _setupLiteModeForTrack(tpc: TraceablePeerConnection, track: JitsiRemoteTrack): void {
37 42
         if (!this.enabled) {
38 43
             return;
39 44
         }

Loading…
Cancel
Save