瀏覽代碼

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,20 +1,23 @@
1
-
2 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 23
  * Generates a source name.
@@ -24,7 +27,7 @@ import { MediaType } from '../../service/RTC/MediaType';
24 27
  * @param {number} trackIdx - Track index (or sender idx? - to be figured out) starting from 0.
25 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 31
     const firstLetterOfMediaType = mediaType.substring(0, 1);
29 32
 
30 33
     return `${endpointId}-${firstLetterOfMediaType}${trackIdx}`;
@@ -37,7 +40,7 @@ export function getSourceNameForJitsiTrack(endpointId, mediaType, trackIdx) {
37 40
  * @param {SourceName} sourceName - the source name.
38 41
  * @returns {MediaType}
39 42
  */
40
-export function getMediaTypeFromSourceName(sourceName) {
43
+export function getMediaTypeFromSourceName(sourceName: SourceName): MediaType {
41 44
     const firstLetterOfMediaTypeIdx = sourceName.lastIndexOf('-') + 1;
42 45
 
43 46
     if (firstLetterOfMediaTypeIdx <= 0) {
@@ -62,7 +65,7 @@ export function getMediaTypeFromSourceName(sourceName) {
62 65
  * @param {SourceName} sourceName - the source name, eg. endpointA-v0.
63 66
  * @returns {number}
64 67
  */
65
-export function getSourceIndexFromSourceName(sourceName) {
68
+export function getSourceIndexFromSourceName(sourceName: SourceName): number {
66 69
     const nameParts = sourceName.split('-');
67 70
     const trackIdx = Number(nameParts[nameParts.length - 1].substring(1));
68 71
 
@@ -76,7 +79,7 @@ export function getSourceIndexFromSourceName(sourceName) {
76 79
 /**
77 80
  * An object that carries the info about specific media type advertised by
78 81
  * participant in the signaling channel.
79
- * @typedef {Object} PeerMediaInfo
82
+ * @typedef {Object} IPeerMediaInfo
80 83
  * @property {boolean} muted indicates if the media is currently muted
81 84
  * @property {VideoType|undefined} videoType the type of the video if applicable
82 85
  */
@@ -96,13 +99,15 @@ export default class SignalingLayer extends Listenable {
96 99
      * @param {MediaType} mediaType the type of the media for which presence
97 100
      * @param {SourceName} sourceName - The name of the source for which the info is to be obtained.
98 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 103
      * info or <tt>null</tt> either if there is no presence available for given
101 104
      * JID or if the media type given is invalid.
102 105
      *
103 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 111
         throw new Error('not implemented');
107 112
     }
108 113
 
@@ -110,9 +115,11 @@ export default class SignalingLayer extends Listenable {
110 115
      * Obtains the info about a source for given name and endpoint ID.
111 116
      * @param {EndpointId} owner - The owner's endpoint ID.
112 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 123
         throw new Error('not implemented');
117 124
     }
118 125
 
@@ -121,7 +128,7 @@ export default class SignalingLayer extends Listenable {
121 128
      * @param {number} ssrc the SSRC number.
122 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 132
         throw new Error('not implemented');
126 133
     }
127 134
 
@@ -130,7 +137,7 @@ export default class SignalingLayer extends Listenable {
130 137
      * @param {number} ssrc the track's SSRC identifier.
131 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 141
         throw new Error('not implemented');
135 142
     }
136 143
 
@@ -139,7 +146,7 @@ export default class SignalingLayer extends Listenable {
139 146
      * remapped to another source from a different endpoint.
140 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,7 +157,7 @@ export default class SignalingLayer extends Listenable {
150 157
      * @param {string} sourceName - The related source name.
151 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,7 +167,7 @@ export default class SignalingLayer extends Listenable {
160 167
      * @param {boolean} muted - the new muted status.
161 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,7 +176,7 @@ export default class SignalingLayer extends Listenable {
169 176
      * @param {VideoType} videoType - the new video type.
170 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,6 +185,6 @@ export default class SignalingLayer extends Listenable {
178 185
      * @param {string} id endpoint id of the participant leaving the call.
179 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…
取消
儲存