瀏覽代碼

fix(RtxModifier.spec and SDPUtil.spec): random failures

Fixes random tests failures after frameworks upgrade.
release-8443
paweldomas 5 年之前
父節點
當前提交
08d0cd46a8
共有 3 個檔案被更改,包括 85 行新增64 行删除
  1. 59
    57
      modules/xmpp/RtxModifier.spec.js
  2. 1
    1
      modules/xmpp/SDPUtil.spec.js
  3. 25
    6
      modules/xmpp/SampleSdpStrings.js

+ 59
- 57
modules/xmpp/RtxModifier.spec.js 查看文件

1
 /* eslint-disable max-len*/
1
 /* eslint-disable max-len*/
2
-/* eslint-disable no-invalid-this */
3
 import RtxModifier from './RtxModifier.js';
2
 import RtxModifier from './RtxModifier.js';
4
-import * as SampleSdpStrings from './SampleSdpStrings.js';
3
+import { default as SampleSdpStrings } from './SampleSdpStrings.js';
5
 import * as transform from 'sdp-transform';
4
 import * as transform from 'sdp-transform';
6
 import SDPUtil from './SDPUtil';
5
 import SDPUtil from './SDPUtil';
7
 
6
 
76
 }
75
 }
77
 
76
 
78
 describe('RtxModifier', () => {
77
 describe('RtxModifier', () => {
79
-    beforeEach(function() {
80
-        this.rtxModifier = new RtxModifier();
81
-        this.transform = transform;
82
-        this.SDPUtil = SDPUtil;
78
+    let rtxModifier;
79
+
80
+    beforeEach(() => {
81
+        rtxModifier = new RtxModifier();
83
     });
82
     });
84
 
83
 
85
     describe('modifyRtxSsrcs', () => {
84
     describe('modifyRtxSsrcs', () => {
86
         describe('when given an sdp with a single video ssrc', () => {
85
         describe('when given an sdp with a single video ssrc', () => {
87
-            beforeEach(function() {
88
-                this.singleVideoSdp = SampleSdpStrings.plainVideoSdp;
89
-                this.primaryVideoSsrc = getPrimaryVideoSsrc(this.singleVideoSdp);
86
+            let primaryVideoSsrc, singleVideoSdp;
87
+
88
+            beforeEach(() => {
89
+                singleVideoSdp = SampleSdpStrings.plainVideoSdp;
90
+                primaryVideoSsrc = getPrimaryVideoSsrc(singleVideoSdp);
90
             });
91
             });
91
-            it('should add a single rtx ssrc', function() {
92
+            it('should add a single rtx ssrc', () => {
92
                 // Call rtxModifier.modifyRtxSsrcs with an sdp that contains a single video
93
                 // Call rtxModifier.modifyRtxSsrcs with an sdp that contains a single video
93
                 //  ssrc.  The returned sdp should have an rtx ssrc and an fid group.
94
                 //  ssrc.  The returned sdp should have an rtx ssrc and an fid group.
94
-                const newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.singleVideoSdp));
95
+                const newSdpStr = rtxModifier.modifyRtxSsrcs(transform.write(singleVideoSdp));
95
                 const newSdp = transform.parse(newSdpStr);
96
                 const newSdp = transform.parse(newSdpStr);
96
                 const newPrimaryVideoSsrc = getPrimaryVideoSsrc(newSdp);
97
                 const newPrimaryVideoSsrc = getPrimaryVideoSsrc(newSdp);
97
 
98
 
98
-                expect(newPrimaryVideoSsrc).toEqual(this.primaryVideoSsrc);
99
+                expect(newPrimaryVideoSsrc).toEqual(primaryVideoSsrc);
99
 
100
 
100
                 // Should now have an rtx ssrc as well
101
                 // Should now have an rtx ssrc as well
101
                 expect(numVideoSsrcs(newSdp)).toEqual(2);
102
                 expect(numVideoSsrcs(newSdp)).toEqual(2);
108
                 const fidGroup = fidGroups[0];
109
                 const fidGroup = fidGroups[0];
109
                 const fidGroupPrimarySsrc = SDPUtil.parseGroupSsrcs(fidGroup)[0];
110
                 const fidGroupPrimarySsrc = SDPUtil.parseGroupSsrcs(fidGroup)[0];
110
 
111
 
111
-                expect(fidGroupPrimarySsrc).toEqual(this.primaryVideoSsrc);
112
+                expect(fidGroupPrimarySsrc).toEqual(primaryVideoSsrc);
112
             });
113
             });
113
 
114
 
114
-            it('should re-use the same rtx ssrc for a primary ssrc it\'s seen before', function() {
115
+            it('should re-use the same rtx ssrc for a primary ssrc it\'s seen before', () => {
115
                 // Have rtxModifier generate an rtx ssrc via modifyRtxSsrcs.  Then call it again
116
                 // Have rtxModifier generate an rtx ssrc via modifyRtxSsrcs.  Then call it again
116
                 //  with the same primary ssrc in the sdp (but no rtx ssrc).  It should use
117
                 //  with the same primary ssrc in the sdp (but no rtx ssrc).  It should use
117
                 //  the same rtx ssrc as before.
118
                 //  the same rtx ssrc as before.
118
-                let newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.singleVideoSdp));
119
+                let newSdpStr = rtxModifier.modifyRtxSsrcs(transform.write(singleVideoSdp));
119
                 let newSdp = transform.parse(newSdpStr);
120
                 let newSdp = transform.parse(newSdpStr);
120
 
121
 
121
                 let fidGroup = getVideoGroups(newSdp, 'FID')[0];
122
                 let fidGroup = getVideoGroups(newSdp, 'FID')[0];
122
                 const fidGroupRtxSsrc = SDPUtil.parseGroupSsrcs(fidGroup)[1];
123
                 const fidGroupRtxSsrc = SDPUtil.parseGroupSsrcs(fidGroup)[1];
123
 
124
 
124
                 // Now pass the original sdp through again
125
                 // Now pass the original sdp through again
125
-                newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.singleVideoSdp));
126
+                newSdpStr = rtxModifier.modifyRtxSsrcs(transform.write(singleVideoSdp));
126
                 newSdp = transform.parse(newSdpStr);
127
                 newSdp = transform.parse(newSdpStr);
127
                 fidGroup = getVideoGroups(newSdp, 'FID')[0];
128
                 fidGroup = getVideoGroups(newSdp, 'FID')[0];
128
                 const newFidGroupRtxSsrc = SDPUtil.parseGroupSsrcs(fidGroup)[1];
129
                 const newFidGroupRtxSsrc = SDPUtil.parseGroupSsrcs(fidGroup)[1];
130
                 expect(newFidGroupRtxSsrc).toEqual(fidGroupRtxSsrc);
131
                 expect(newFidGroupRtxSsrc).toEqual(fidGroupRtxSsrc);
131
             });
132
             });
132
 
133
 
133
-            it('should NOT re-use the same rtx ssrc for a primary ssrc it\'s seen before if the cache has been cleared', function() {
134
+            it('should NOT re-use the same rtx ssrc for a primary ssrc it\'s seen before if the cache has been cleared', () => {
134
                 // Call modifyRtxSsrcs to generate an rtx ssrc
135
                 // Call modifyRtxSsrcs to generate an rtx ssrc
135
                 // Clear the rtxModifier cache
136
                 // Clear the rtxModifier cache
136
                 // Call modifyRtxSsrcs to generate an rtx ssrc again with the same primary ssrc
137
                 // Call modifyRtxSsrcs to generate an rtx ssrc again with the same primary ssrc
137
                 // --> We should get a different rtx ssrc
138
                 // --> We should get a different rtx ssrc
138
-                let newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.singleVideoSdp));
139
+                let newSdpStr = rtxModifier.modifyRtxSsrcs(transform.write(singleVideoSdp));
139
                 let newSdp = transform.parse(newSdpStr);
140
                 let newSdp = transform.parse(newSdpStr);
140
 
141
 
141
                 let fidGroup = getVideoGroups(newSdp, 'FID')[0];
142
                 let fidGroup = getVideoGroups(newSdp, 'FID')[0];
142
                 const fidGroupRtxSsrc = SDPUtil.parseGroupSsrcs(fidGroup)[1];
143
                 const fidGroupRtxSsrc = SDPUtil.parseGroupSsrcs(fidGroup)[1];
143
 
144
 
144
-                this.rtxModifier.clearSsrcCache();
145
+                rtxModifier.clearSsrcCache();
145
 
146
 
146
                 // Now pass the original sdp through again
147
                 // Now pass the original sdp through again
147
-                newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.singleVideoSdp));
148
+                newSdpStr = rtxModifier.modifyRtxSsrcs(transform.write(singleVideoSdp));
148
                 newSdp = transform.parse(newSdpStr);
149
                 newSdp = transform.parse(newSdpStr);
149
                 fidGroup = getVideoGroups(newSdp, 'FID')[0];
150
                 fidGroup = getVideoGroups(newSdp, 'FID')[0];
150
                 const newFidGroupRtxSsrc = SDPUtil.parseGroupSsrcs(fidGroup)[1];
151
                 const newFidGroupRtxSsrc = SDPUtil.parseGroupSsrcs(fidGroup)[1];
152
                 expect(newFidGroupRtxSsrc).not.toEqual(fidGroupRtxSsrc);
153
                 expect(newFidGroupRtxSsrc).not.toEqual(fidGroupRtxSsrc);
153
             });
154
             });
154
 
155
 
155
-            it('should use the rtx ssrc from the cache when the cache has been manually set', function() {
156
+            it('should use the rtx ssrc from the cache when the cache has been manually set', () => {
156
                 // Manually set an rtx ssrc mapping in the cache
157
                 // Manually set an rtx ssrc mapping in the cache
157
                 // Call modifyRtxSsrcs
158
                 // Call modifyRtxSsrcs
158
                 // -->The rtx ssrc used should be the one we set
159
                 // -->The rtx ssrc used should be the one we set
159
                 const forcedRtxSsrc = 123456;
160
                 const forcedRtxSsrc = 123456;
160
                 const ssrcCache = new Map();
161
                 const ssrcCache = new Map();
161
 
162
 
162
-                ssrcCache.set(this.primaryVideoSsrc, forcedRtxSsrc);
163
-                this.rtxModifier.setSsrcCache(ssrcCache);
164
-                const newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.singleVideoSdp));
163
+                ssrcCache.set(primaryVideoSsrc, forcedRtxSsrc);
164
+                rtxModifier.setSsrcCache(ssrcCache);
165
+                const newSdpStr = rtxModifier.modifyRtxSsrcs(transform.write(singleVideoSdp));
165
                 const newSdp = transform.parse(newSdpStr);
166
                 const newSdp = transform.parse(newSdpStr);
166
 
167
 
167
                 const fidGroup = getVideoGroups(newSdp, 'FID')[0];
168
                 const fidGroup = getVideoGroups(newSdp, 'FID')[0];
172
         });
173
         });
173
 
174
 
174
         describe('when given an sdp with multiple video ssrcs', () => {
175
         describe('when given an sdp with multiple video ssrcs', () => {
175
-            beforeEach(function() {
176
-                this.multipleVideoSdp = SampleSdpStrings.simulcastSdp;
177
-                this.primaryVideoSsrcs = getPrimaryVideoSsrcs(this.multipleVideoSdp);
176
+            let multipleVideoSdp, primaryVideoSsrcs;
177
+
178
+            beforeEach(() => {
179
+                multipleVideoSdp = SampleSdpStrings.simulcastSdp;
180
+                primaryVideoSsrcs = getPrimaryVideoSsrcs(multipleVideoSdp);
178
             });
181
             });
179
 
182
 
180
-            it('should add rtx ssrcs for all of them', function() {
183
+            it('should add rtx ssrcs for all of them', () => {
181
                 // Call rtxModifier.modifyRtxSsrcs with an sdp that contains multiple video
184
                 // Call rtxModifier.modifyRtxSsrcs with an sdp that contains multiple video
182
                 //  ssrcs.  The returned sdp should have an rtx ssrc and an fid group for all of them.
185
                 //  ssrcs.  The returned sdp should have an rtx ssrc and an fid group for all of them.
183
-                const newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.multipleVideoSdp));
186
+                const newSdpStr = rtxModifier.modifyRtxSsrcs(transform.write(multipleVideoSdp));
184
                 const newSdp = transform.parse(newSdpStr);
187
                 const newSdp = transform.parse(newSdpStr);
185
                 const newPrimaryVideoSsrcs = getPrimaryVideoSsrcs(newSdp);
188
                 const newPrimaryVideoSsrcs = getPrimaryVideoSsrcs(newSdp);
186
 
189
 
187
-                expect(newPrimaryVideoSsrcs).toEqual(this.primaryVideoSsrcs);
190
+                expect(newPrimaryVideoSsrcs).toEqual(primaryVideoSsrcs);
188
 
191
 
189
                 // Should now have rtx ssrcs as well
192
                 // Should now have rtx ssrcs as well
190
-                expect(numVideoSsrcs(newSdp)).toEqual(this.primaryVideoSsrcs.length * 2);
193
+                expect(numVideoSsrcs(newSdp)).toEqual(primaryVideoSsrcs.length * 2);
191
 
194
 
192
                 // Should now have FID groups
195
                 // Should now have FID groups
193
                 const fidGroups = getVideoGroups(newSdp, 'FID');
196
                 const fidGroups = getVideoGroups(newSdp, 'FID');
194
 
197
 
195
-                expect(fidGroups.length).toEqual(this.primaryVideoSsrcs.length);
198
+                expect(fidGroups.length).toEqual(primaryVideoSsrcs.length);
196
                 fidGroups.forEach(fidGroup => {
199
                 fidGroups.forEach(fidGroup => {
197
                     const fidGroupPrimarySsrc = SDPUtil.parseGroupSsrcs(fidGroup)[0];
200
                     const fidGroupPrimarySsrc = SDPUtil.parseGroupSsrcs(fidGroup)[0];
198
 
201
 
199
-                    expect(this.primaryVideoSsrcs.indexOf(fidGroupPrimarySsrc)).not.toEqual(-1);
202
+                    expect(primaryVideoSsrcs.indexOf(fidGroupPrimarySsrc)).not.toEqual(-1);
200
                 });
203
                 });
201
             });
204
             });
202
 
205
 
203
-            it('should re-use the same rtx ssrcs for any primary ssrc it\'s seen before', function() {
206
+            it('should re-use the same rtx ssrcs for any primary ssrc it\'s seen before', () => {
204
                 // Have rtxModifier generate an rtx ssrc via modifyRtxSsrcs.  Then call it again
207
                 // Have rtxModifier generate an rtx ssrc via modifyRtxSsrcs.  Then call it again
205
                 //  with the same primary ssrc in the sdp (but no rtx ssrc).  It should use
208
                 //  with the same primary ssrc in the sdp (but no rtx ssrc).  It should use
206
                 //  the same rtx ssrc as before.
209
                 //  the same rtx ssrc as before.
207
-                let newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.multipleVideoSdp));
210
+                let newSdpStr = rtxModifier.modifyRtxSsrcs(transform.write(multipleVideoSdp));
208
                 let newSdp = transform.parse(newSdpStr);
211
                 let newSdp = transform.parse(newSdpStr);
209
 
212
 
210
                 const rtxMapping = new Map();
213
                 const rtxMapping = new Map();
221
                 });
224
                 });
222
 
225
 
223
                 // Now pass the original sdp through again and make sure we get the same mapping
226
                 // Now pass the original sdp through again and make sure we get the same mapping
224
-                newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.multipleVideoSdp));
227
+                newSdpStr = rtxModifier.modifyRtxSsrcs(transform.write(multipleVideoSdp));
225
                 newSdp = transform.parse(newSdpStr);
228
                 newSdp = transform.parse(newSdpStr);
226
                 fidGroups = getVideoGroups(newSdp, 'FID');
229
                 fidGroups = getVideoGroups(newSdp, 'FID');
227
                 fidGroups.forEach(fidGroup => {
230
                 fidGroups.forEach(fidGroup => {
234
                 });
237
                 });
235
             });
238
             });
236
 
239
 
237
-            it('should NOT re-use the same rtx ssrcs for any primary ssrc it\'s seen before if the cache has been cleared', function() {
240
+            it('should NOT re-use the same rtx ssrcs for any primary ssrc it\'s seen before if the cache has been cleared', () => {
238
                 // Call modifyRtxSsrcs to generate an rtx ssrc
241
                 // Call modifyRtxSsrcs to generate an rtx ssrc
239
                 // Clear the rtxModifier cache
242
                 // Clear the rtxModifier cache
240
                 // Call modifyRtxSsrcs to generate rtx ssrcs again with the same primary ssrcs
243
                 // Call modifyRtxSsrcs to generate rtx ssrcs again with the same primary ssrcs
241
                 // --> We should get different rtx ssrcs
244
                 // --> We should get different rtx ssrcs
242
-                let newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.multipleVideoSdp));
245
+                let newSdpStr = rtxModifier.modifyRtxSsrcs(transform.write(multipleVideoSdp));
243
                 let newSdp = transform.parse(newSdpStr);
246
                 let newSdp = transform.parse(newSdpStr);
244
 
247
 
245
                 const rtxMapping = new Map();
248
                 const rtxMapping = new Map();
255
                     rtxMapping.set(fidGroupPrimarySsrc, fidGroupRtxSsrc);
258
                     rtxMapping.set(fidGroupPrimarySsrc, fidGroupRtxSsrc);
256
                 });
259
                 });
257
 
260
 
258
-                this.rtxModifier.clearSsrcCache();
261
+                rtxModifier.clearSsrcCache();
259
 
262
 
260
                 // Now pass the original sdp through again and make sure we get the same mapping
263
                 // Now pass the original sdp through again and make sure we get the same mapping
261
-                newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.multipleVideoSdp));
264
+                newSdpStr = rtxModifier.modifyRtxSsrcs(transform.write(multipleVideoSdp));
262
                 newSdp = transform.parse(newSdpStr);
265
                 newSdp = transform.parse(newSdpStr);
263
                 fidGroups = getVideoGroups(newSdp, 'FID');
266
                 fidGroups = getVideoGroups(newSdp, 'FID');
264
                 fidGroups.forEach(fidGroup => {
267
                 fidGroups.forEach(fidGroup => {
271
                 });
274
                 });
272
             });
275
             });
273
 
276
 
274
-            it('should use the rtx ssrcs from the cache when the cache has been manually set', function() {
277
+            it('should use the rtx ssrcs from the cache when the cache has been manually set', () => {
275
                 // Manually set an rtx ssrc mapping in the cache
278
                 // Manually set an rtx ssrc mapping in the cache
276
                 // Call modifyRtxSsrcs
279
                 // Call modifyRtxSsrcs
277
                 // -->The rtx ssrc used should be the one we set
280
                 // -->The rtx ssrc used should be the one we set
278
                 const rtxMapping = new Map();
281
                 const rtxMapping = new Map();
279
 
282
 
280
-                this.primaryVideoSsrcs.forEach(ssrc => {
283
+                primaryVideoSsrcs.forEach(ssrc => {
281
                     rtxMapping.set(ssrc, SDPUtil.generateSsrc());
284
                     rtxMapping.set(ssrc, SDPUtil.generateSsrc());
282
                 });
285
                 });
283
-                this.rtxModifier.setSsrcCache(rtxMapping);
286
+                rtxModifier.setSsrcCache(rtxMapping);
284
 
287
 
285
-                const newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.multipleVideoSdp));
288
+                const newSdpStr = rtxModifier.modifyRtxSsrcs(transform.write(multipleVideoSdp));
286
                 const newSdp = transform.parse(newSdpStr);
289
                 const newSdp = transform.parse(newSdpStr);
287
 
290
 
288
                 const fidGroups = getVideoGroups(newSdp, 'FID');
291
                 const fidGroups = getVideoGroups(newSdp, 'FID');
299
         });
302
         });
300
 
303
 
301
         describe('when given an sdp with a flexfec stream', () => {
304
         describe('when given an sdp with a flexfec stream', () => {
302
-            it('should not add rtx for the flexfec ssrc', function() {
305
+            it('should not add rtx for the flexfec ssrc', () => {
303
                 const flexFecSdp = SampleSdpStrings.flexFecSdp;
306
                 const flexFecSdp = SampleSdpStrings.flexFecSdp;
304
-                const newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(flexFecSdp));
307
+                const newSdpStr = rtxModifier.modifyRtxSsrcs(transform.write(flexFecSdp));
305
                 const newSdp = transform.parse(newSdpStr);
308
                 const newSdp = transform.parse(newSdpStr);
306
                 const fidGroups = getVideoGroups(newSdp, 'FID');
309
                 const fidGroups = getVideoGroups(newSdp, 'FID');
307
 
310
 
310
         });
313
         });
311
 
314
 
312
         describe('(corner cases)', () => {
315
         describe('(corner cases)', () => {
313
-            it('should handle a recvonly video mline', function() {
316
+            it('should handle a recvonly video mline', () => {
314
                 const sdp = SampleSdpStrings.plainVideoSdp;
317
                 const sdp = SampleSdpStrings.plainVideoSdp;
315
                 const videoMLine = sdp.media.find(m => m.type === 'video');
318
                 const videoMLine = sdp.media.find(m => m.type === 'video');
316
 
319
 
317
                 videoMLine.direction = 'recvonly';
320
                 videoMLine.direction = 'recvonly';
318
-                const newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(sdp));
321
+                const newSdpStr = rtxModifier.modifyRtxSsrcs(transform.write(sdp));
319
 
322
 
320
-                expect(newSdpStr).toEqual(this.transform.write(sdp));
323
+                expect(newSdpStr).toEqual(transform.write(sdp));
321
             });
324
             });
322
 
325
 
323
-            it('should handle a video mline with no video ssrcs', function() {
326
+            it('should handle a video mline with no video ssrcs', () => {
324
                 const sdp = SampleSdpStrings.plainVideoSdp;
327
                 const sdp = SampleSdpStrings.plainVideoSdp;
325
                 const videoMLine = sdp.media.find(m => m.type === 'video');
328
                 const videoMLine = sdp.media.find(m => m.type === 'video');
326
 
329
 
327
                 videoMLine.ssrcs = [];
330
                 videoMLine.ssrcs = [];
328
-                const newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(sdp));
331
+                const newSdpStr = rtxModifier.modifyRtxSsrcs(transform.write(sdp));
329
 
332
 
330
-                expect(newSdpStr).toEqual(this.transform.write(sdp));
333
+                expect(newSdpStr).toEqual(transform.write(sdp));
331
             });
334
             });
332
         });
335
         });
333
     });
336
     });
334
 
337
 
335
     describe('stripRtx', () => {
338
     describe('stripRtx', () => {
336
         beforeEach(() => { }); // eslint-disable-line no-empty-function
339
         beforeEach(() => { }); // eslint-disable-line no-empty-function
337
-        it('should strip all rtx streams from an sdp with rtx', function() {
340
+        it('should strip all rtx streams from an sdp with rtx', () => {
338
             const sdpStr = transform.write(SampleSdpStrings.rtxVideoSdp);
341
             const sdpStr = transform.write(SampleSdpStrings.rtxVideoSdp);
339
-            const newSdpStr = this.rtxModifier.stripRtx(sdpStr);
342
+            const newSdpStr = rtxModifier.stripRtx(sdpStr);
340
             const newSdp = transform.parse(newSdpStr);
343
             const newSdp = transform.parse(newSdpStr);
341
             const fidGroups = getVideoGroups(newSdp, 'FID');
344
             const fidGroups = getVideoGroups(newSdp, 'FID');
342
 
345
 
343
             expect(fidGroups.length).toEqual(0);
346
             expect(fidGroups.length).toEqual(0);
344
             expect(numVideoSsrcs(newSdp)).toEqual(1);
347
             expect(numVideoSsrcs(newSdp)).toEqual(1);
345
         });
348
         });
346
-        it('should do nothing to an sdp with no rtx', function() {
349
+        it('should do nothing to an sdp with no rtx', () => {
347
             const sdpStr = transform.write(SampleSdpStrings.plainVideoSdp);
350
             const sdpStr = transform.write(SampleSdpStrings.plainVideoSdp);
348
-            const newSdpStr = this.rtxModifier.stripRtx(sdpStr);
351
+            const newSdpStr = rtxModifier.stripRtx(sdpStr);
349
 
352
 
350
             expect(newSdpStr).toEqual(sdpStr);
353
             expect(newSdpStr).toEqual(sdpStr);
351
         });
354
         });
352
     });
355
     });
353
 });
356
 });
354
 
357
 
355
-/* eslint-enable no-invalid-this */
356
 /* eslint-enable max-len*/
358
 /* eslint-enable max-len*/

+ 1
- 1
modules/xmpp/SDPUtil.spec.js 查看文件

1
 import SDPUtil from './SDPUtil';
1
 import SDPUtil from './SDPUtil';
2
-import * as SampleSdpStrings from './SampleSdpStrings.js';
2
+import { default as SampleSdpStrings } from './SampleSdpStrings.js';
3
 
3
 
4
 describe('SDPUtil', () => {
4
 describe('SDPUtil', () => {
5
     it('should parse an ice ufrag correctly', () => {
5
     it('should parse an ice ufrag correctly', () => {

+ 25
- 6
modules/xmpp/SampleSdpStrings.js 查看文件

262
 // A full sdp string representing a client doing a single video stream with flexfec
262
 // A full sdp string representing a client doing a single video stream with flexfec
263
 const flexFecSdpStr = baseSessionSdp + baseAudioMLineSdp + flexFecVideoMLineSdp + baseDataMLineSdp;
263
 const flexFecSdpStr = baseSessionSdp + baseAudioMLineSdp + flexFecVideoMLineSdp + baseDataMLineSdp;
264
 
264
 
265
-export const simulcastSdp = transform.parse(simulcastSdpStr);
266
-export const simulcastRtxSdp = transform.parse(simulcastRtxSdpStr);
267
-export const plainVideoSdp = transform.parse(plainVideoSdpStr);
268
-export const rtxVideoSdp = transform.parse(rtxVideoSdpStr);
269
-export const multiCodecVideoSdp = transform.parse(multiCodecVideoSdpStr);
270
-export const flexFecSdp = transform.parse(flexFecSdpStr);
265
+export default {
266
+    get simulcastSdp() {
267
+        return transform.parse(simulcastSdpStr);
268
+    },
269
+
270
+    get simulcastRtxSdp() {
271
+        return transform.parse(simulcastRtxSdpStr);
272
+    },
273
+
274
+    get plainVideoSdp() {
275
+        return transform.parse(plainVideoSdpStr);
276
+    },
277
+
278
+    get rtxVideoSdp() {
279
+        return transform.parse(rtxVideoSdpStr);
280
+    },
281
+
282
+    get multiCodecVideoSdp() {
283
+        return transform.parse(multiCodecVideoSdpStr);
284
+    },
285
+
286
+    get flexFecSdp() {
287
+        return transform.parse(flexFecSdpStr);
288
+    }
289
+};
271
 
290
 
272
 /* eslint-enable max-len*/
291
 /* eslint-enable max-len*/

Loading…
取消
儲存