瀏覽代碼

feat(ts) migrate SignalingLayer to TS

dev0
Naman Jain 6 月之前
父節點
當前提交
d88001b342
沒有連結到貢獻者的電子郵件帳戶。
共有 3 個檔案被更改,包括 37 行新增30 行删除
  1. 0
    0
      service/RTC/Resolutions.ts
  2. 37
    30
      service/RTC/SignalingLayer.ts
  3. 0
    0
      service/authentication/AuthenticationEvents.ts

service/RTC/Resolutions.js → service/RTC/Resolutions.ts 查看文件


service/RTC/SignalingLayer.js → service/RTC/SignalingLayer.ts 查看文件

1
-
2
 import Listenable from '../../modules/util/Listenable';
1
 import Listenable from '../../modules/util/Listenable';
3
-import { MediaType } from '../../service/RTC/MediaType';
4
 
2
 
5
-/**
6
- * @typedef {string} EndpointId
7
- */
8
-/**
9
- * @typedef {string} SourceName
10
- */
11
-/**
12
- * @typedef {Object} SourceInfo
13
- *
14
- * @property {SourceName} sourceName - Name of the media source.
15
- * @property {boolean} [muted=false] - Tells if the source is muted (paused?).
16
- * @property {string} [videoType] - Type of the video for video type.
17
- */
3
+import { MediaType } from './MediaType';
4
+import { VideoType } from './VideoType';
5
+
6
+export type EndpointId = string;
7
+export type SourceName = string;
8
+
9
+export interface ISourceInfo {
10
+    muted?: boolean;
11
+    sourceName: SourceName;
12
+    videoType?: string;
13
+}
14
+
15
+export interface IPeerMediaInfo {
16
+    muted: boolean;
17
+    videoType?: string;
18
+}
19
+/* eslint-disable @typescript-eslint/no-unused-vars */
20
+/* eslint-disable @typescript-eslint/no-empty-function */
18
 
21
 
19
 /**
22
 /**
20
  * Generates a source name.
23
  * Generates a source name.
24
  * @param {number} trackIdx - Track index (or sender idx? - to be figured out) starting from 0.
27
  * @param {number} trackIdx - Track index (or sender idx? - to be figured out) starting from 0.
25
  * @returns {SourceName} eg. endpointA-v0
28
  * @returns {SourceName} eg. endpointA-v0
26
  */
29
  */
27
-export function getSourceNameForJitsiTrack(endpointId, mediaType, trackIdx) {
30
+export function getSourceNameForJitsiTrack(endpointId: EndpointId, mediaType: MediaType, trackIdx: number): SourceName {
28
     const firstLetterOfMediaType = mediaType.substring(0, 1);
31
     const firstLetterOfMediaType = mediaType.substring(0, 1);
29
 
32
 
30
     return `${endpointId}-${firstLetterOfMediaType}${trackIdx}`;
33
     return `${endpointId}-${firstLetterOfMediaType}${trackIdx}`;
37
  * @param {SourceName} sourceName - the source name.
40
  * @param {SourceName} sourceName - the source name.
38
  * @returns {MediaType}
41
  * @returns {MediaType}
39
  */
42
  */
40
-export function getMediaTypeFromSourceName(sourceName) {
43
+export function getMediaTypeFromSourceName(sourceName: SourceName): MediaType {
41
     const firstLetterOfMediaTypeIdx = sourceName.lastIndexOf('-') + 1;
44
     const firstLetterOfMediaTypeIdx = sourceName.lastIndexOf('-') + 1;
42
 
45
 
43
     if (firstLetterOfMediaTypeIdx <= 0) {
46
     if (firstLetterOfMediaTypeIdx <= 0) {
62
  * @param {SourceName} sourceName - the source name, eg. endpointA-v0.
65
  * @param {SourceName} sourceName - the source name, eg. endpointA-v0.
63
  * @returns {number}
66
  * @returns {number}
64
  */
67
  */
65
-export function getSourceIndexFromSourceName(sourceName) {
68
+export function getSourceIndexFromSourceName(sourceName: SourceName): number {
66
     const nameParts = sourceName.split('-');
69
     const nameParts = sourceName.split('-');
67
     const trackIdx = Number(nameParts[nameParts.length - 1].substring(1));
70
     const trackIdx = Number(nameParts[nameParts.length - 1].substring(1));
68
 
71
 
76
 /**
79
 /**
77
  * An object that carries the info about specific media type advertised by
80
  * An object that carries the info about specific media type advertised by
78
  * participant in the signaling channel.
81
  * participant in the signaling channel.
79
- * @typedef {Object} PeerMediaInfo
82
+ * @typedef {Object} IPeerMediaInfo
80
  * @property {boolean} muted indicates if the media is currently muted
83
  * @property {boolean} muted indicates if the media is currently muted
81
  * @property {VideoType|undefined} videoType the type of the video if applicable
84
  * @property {VideoType|undefined} videoType the type of the video if applicable
82
  */
85
  */
96
      * @param {MediaType} mediaType the type of the media for which presence
99
      * @param {MediaType} mediaType the type of the media for which presence
97
      * @param {SourceName} sourceName - The name of the source for which the info is to be obtained.
100
      * @param {SourceName} sourceName - The name of the source for which the info is to be obtained.
98
      * info will be obtained.
101
      * info will be obtained.
99
-     * @return {PeerMediaInfo|null} presenceInfo an object with media presence
102
+     * @return {IPeerMediaInfo|null} presenceInfo an object with media presence
100
      * info or <tt>null</tt> either if there is no presence available for given
103
      * info or <tt>null</tt> either if there is no presence available for given
101
      * JID or if the media type given is invalid.
104
      * JID or if the media type given is invalid.
102
      *
105
      *
103
      * @deprecated This method is to be replaced with getPeerSourceInfo.
106
      * @deprecated This method is to be replaced with getPeerSourceInfo.
104
      */
107
      */
105
-    getPeerMediaInfo(owner, mediaType, sourceName) { // eslint-disable-line no-unused-vars
108
+    getPeerMediaInfo(
109
+            owner: string, mediaType: MediaType, sourceName: SourceName
110
+    ): IPeerMediaInfo | null {
106
         throw new Error('not implemented');
111
         throw new Error('not implemented');
107
     }
112
     }
108
 
113
 
110
      * Obtains the info about a source for given name and endpoint ID.
115
      * Obtains the info about a source for given name and endpoint ID.
111
      * @param {EndpointId} owner - The owner's endpoint ID.
116
      * @param {EndpointId} owner - The owner's endpoint ID.
112
      * @param {SourceName} sourceName - The name of the source for which the info is to be obtained.
117
      * @param {SourceName} sourceName - The name of the source for which the info is to be obtained.
113
-     * @returns {SourceInfo | undefined}
118
+     * @returns {ISourceInfo | undefined}
114
      */
119
      */
115
-    getPeerSourceInfo(owner, sourceName) { // eslint-disable-line no-unused-vars
120
+    getPeerSourceInfo(
121
+            owner: EndpointId, sourceName: SourceName
122
+    ): ISourceInfo | undefined {
116
         throw new Error('not implemented');
123
         throw new Error('not implemented');
117
     }
124
     }
118
 
125
 
121
      * @param {number} ssrc the SSRC number.
128
      * @param {number} ssrc the SSRC number.
122
      * @return {string|null} the endpoint ID for given media SSRC.
129
      * @return {string|null} the endpoint ID for given media SSRC.
123
      */
130
      */
124
-    getSSRCOwner(ssrc) { // eslint-disable-line no-unused-vars
131
+    getSSRCOwner(ssrc: number): string | null {
125
         throw new Error('not implemented');
132
         throw new Error('not implemented');
126
     }
133
     }
127
 
134
 
130
      * @param {number} ssrc the track's SSRC identifier.
137
      * @param {number} ssrc the track's SSRC identifier.
131
      * @returns {SourceName | undefined} the track's source name.
138
      * @returns {SourceName | undefined} the track's source name.
132
      */
139
      */
133
-    getTrackSourceName(ssrc) { // eslint-disable-line no-unused-vars
140
+    getTrackSourceName(ssrc: number): SourceName | undefined {
134
         throw new Error('not implemented');
141
         throw new Error('not implemented');
135
     }
142
     }
136
 
143
 
139
      * remapped to another source from a different endpoint.
146
      * remapped to another source from a different endpoint.
140
      * @param {number} ssrc a list of SSRCs.
147
      * @param {number} ssrc a list of SSRCs.
141
      */
148
      */
142
-    removeSSRCOwners(ssrcList) { // eslint-disable-line no-unused-vars
149
+    removeSSRCOwners(ssrcList: number[]): void {
143
     }
150
     }
144
 
151
 
145
     /**
152
     /**
150
      * @param {string} sourceName - The related source name.
157
      * @param {string} sourceName - The related source name.
151
      * @throws TypeError if <tt>ssrc</tt> is not a number.
158
      * @throws TypeError if <tt>ssrc</tt> is not a number.
152
      */
159
      */
153
-    setSSRCOwner(ssrc, endpointId, sourceName) { // eslint-disable-line no-unused-vars
160
+    setSSRCOwner(ssrc: number, endpointId: string, sourceName: string): void {
154
     }
161
     }
155
 
162
 
156
     /**
163
     /**
160
      * @param {boolean} muted - the new muted status.
167
      * @param {boolean} muted - the new muted status.
161
      * @returns {boolean}
168
      * @returns {boolean}
162
      */
169
      */
163
-    setTrackMuteStatus(sourceName, muted) { // eslint-disable-line no-unused-vars
170
+    setTrackMuteStatus(sourceName: SourceName, muted: boolean) {
164
     }
171
     }
165
 
172
 
166
     /**
173
     /**
169
      * @param {VideoType} videoType - the new video type.
176
      * @param {VideoType} videoType - the new video type.
170
      * @returns {boolean}
177
      * @returns {boolean}
171
      */
178
      */
172
-    setTrackVideoType(sourceName, videoType) { // eslint-disable-line no-unused-vars
179
+    setTrackVideoType(sourceName: SourceName, videoType: VideoType) {
173
     }
180
     }
174
 
181
 
175
     /**
182
     /**
178
      * @param {string} id endpoint id of the participant leaving the call.
185
      * @param {string} id endpoint id of the participant leaving the call.
179
      * @returns {void}
186
      * @returns {void}
180
      */
187
      */
181
-    updateSsrcOwnersOnLeave(id) { // eslint-disable-line no-unused-vars
188
+    updateSsrcOwnersOnLeave(id: string): void {
182
     }
189
     }
183
 }
190
 }

service/authentication/AuthenticationEvents.js → service/authentication/AuthenticationEvents.ts 查看文件


Loading…
取消
儲存