@wazo/sdk 0.38.6 → 0.38.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wazo-sdk.js +1 -1
- package/esm/__tests__/web-rtc-client.test.js +22 -1
- package/esm/checker/Checker.js +22 -1
- package/esm/checker/checks/index.js +22 -1
- package/esm/checker/checks/webrtc-transport.js +22 -1
- package/esm/checker/checks/webrtc.js +22 -1
- package/esm/index.js +22 -1
- package/esm/lib/WazoSessionDescriptionHandler.js +22 -1
- package/esm/simple/Auth.js +22 -1
- package/esm/simple/Configuration.js +22 -1
- package/esm/simple/Phone.js +22 -1
- package/esm/simple/index.js +22 -1
- package/esm/simple/room/LocalParticipant.js +22 -1
- package/esm/simple/room/Participant.js +22 -1
- package/esm/simple/room/RemoteParticipant.js +22 -1
- package/esm/simple/room/Room.js +22 -1
- package/esm/simple/room/SipRoom.js +22 -1
- package/esm/simple/room/Stream.js +22 -1
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +22 -1
- package/esm/simple/utils.js +22 -1
- package/esm/utils/__tests__/sdp.test.js +50 -0
- package/esm/utils/sdp.js +19 -1
- package/esm/web-rtc-client.js +22 -1
- package/lib/__tests__/web-rtc-client.test.js +22 -1
- package/lib/checker/Checker.js +22 -1
- package/lib/checker/checks/index.js +22 -1
- package/lib/checker/checks/webrtc-transport.js +22 -1
- package/lib/checker/checks/webrtc.js +22 -1
- package/lib/index.js +22 -1
- package/lib/lib/WazoSessionDescriptionHandler.js +22 -1
- package/lib/simple/Auth.js +22 -1
- package/lib/simple/Configuration.js +22 -1
- package/lib/simple/Phone.js +22 -1
- package/lib/simple/index.js +22 -1
- package/lib/simple/room/LocalParticipant.js +22 -1
- package/lib/simple/room/Participant.js +22 -1
- package/lib/simple/room/RemoteParticipant.js +22 -1
- package/lib/simple/room/Room.js +22 -1
- package/lib/simple/room/SipRoom.js +22 -1
- package/lib/simple/room/Stream.js +22 -1
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +22 -1
- package/lib/simple/utils.js +22 -1
- package/lib/utils/__tests__/sdp.test.js +50 -0
- package/lib/utils/sdp.js +19 -0
- package/lib/web-rtc-client.js +22 -1
- package/package.json +1 -1
- package/src/lib/WazoSessionDescriptionHandler.js +5 -2
- package/src/utils/__tests__/sdp.test.js +33 -1
- package/src/utils/sdp.js +18 -0
package/lib/simple/room/Room.js
CHANGED
|
@@ -6216,6 +6216,24 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
6216
6216
|
return fixed;
|
|
6217
6217
|
};
|
|
6218
6218
|
|
|
6219
|
+
const addIcesInAllBundles = (sdp ) => {
|
|
6220
|
+
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
6221
|
+
|
|
6222
|
+
const mediaWithCandidate = parsedSdp.media.find(media => !!media.candidates);
|
|
6223
|
+
if (!mediaWithCandidate) {
|
|
6224
|
+
return sdp;
|
|
6225
|
+
}
|
|
6226
|
+
|
|
6227
|
+
const { candidates } = mediaWithCandidate;
|
|
6228
|
+
|
|
6229
|
+
parsedSdp.media = parsedSdp.media.map(media => ({
|
|
6230
|
+
...media,
|
|
6231
|
+
candidates: media.candidates || candidates,
|
|
6232
|
+
}));
|
|
6233
|
+
|
|
6234
|
+
return sdpParser__default['default'].write(parsedSdp);
|
|
6235
|
+
};
|
|
6236
|
+
|
|
6219
6237
|
/* global RTCSessionDescriptionInit, navigator */
|
|
6220
6238
|
|
|
6221
6239
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
@@ -6345,7 +6363,10 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
6345
6363
|
|
|
6346
6364
|
// Check if we got ICEs
|
|
6347
6365
|
if (sdp.indexOf('a=candidate') !== -1) {
|
|
6348
|
-
return
|
|
6366
|
+
return {
|
|
6367
|
+
type: description.type,
|
|
6368
|
+
sdp: addIcesInAllBundles(sdp),
|
|
6369
|
+
};
|
|
6349
6370
|
}
|
|
6350
6371
|
|
|
6351
6372
|
wazoLogger.info('No ICE candidates found in SDP, fixing it with gathered ices', this.gatheredCandidates);
|
|
@@ -6214,6 +6214,24 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
6214
6214
|
return fixed;
|
|
6215
6215
|
};
|
|
6216
6216
|
|
|
6217
|
+
const addIcesInAllBundles = (sdp ) => {
|
|
6218
|
+
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
6219
|
+
|
|
6220
|
+
const mediaWithCandidate = parsedSdp.media.find(media => !!media.candidates);
|
|
6221
|
+
if (!mediaWithCandidate) {
|
|
6222
|
+
return sdp;
|
|
6223
|
+
}
|
|
6224
|
+
|
|
6225
|
+
const { candidates } = mediaWithCandidate;
|
|
6226
|
+
|
|
6227
|
+
parsedSdp.media = parsedSdp.media.map(media => ({
|
|
6228
|
+
...media,
|
|
6229
|
+
candidates: media.candidates || candidates,
|
|
6230
|
+
}));
|
|
6231
|
+
|
|
6232
|
+
return sdpParser__default['default'].write(parsedSdp);
|
|
6233
|
+
};
|
|
6234
|
+
|
|
6217
6235
|
/* global RTCSessionDescriptionInit, navigator */
|
|
6218
6236
|
|
|
6219
6237
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
@@ -6343,7 +6361,10 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
6343
6361
|
|
|
6344
6362
|
// Check if we got ICEs
|
|
6345
6363
|
if (sdp.indexOf('a=candidate') !== -1) {
|
|
6346
|
-
return
|
|
6364
|
+
return {
|
|
6365
|
+
type: description.type,
|
|
6366
|
+
sdp: addIcesInAllBundles(sdp),
|
|
6367
|
+
};
|
|
6347
6368
|
}
|
|
6348
6369
|
|
|
6349
6370
|
wazoLogger.info('No ICE candidates found in SDP, fixing it with gathered ices', this.gatheredCandidates);
|
|
@@ -6214,6 +6214,24 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
6214
6214
|
return fixed;
|
|
6215
6215
|
};
|
|
6216
6216
|
|
|
6217
|
+
const addIcesInAllBundles = (sdp ) => {
|
|
6218
|
+
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
6219
|
+
|
|
6220
|
+
const mediaWithCandidate = parsedSdp.media.find(media => !!media.candidates);
|
|
6221
|
+
if (!mediaWithCandidate) {
|
|
6222
|
+
return sdp;
|
|
6223
|
+
}
|
|
6224
|
+
|
|
6225
|
+
const { candidates } = mediaWithCandidate;
|
|
6226
|
+
|
|
6227
|
+
parsedSdp.media = parsedSdp.media.map(media => ({
|
|
6228
|
+
...media,
|
|
6229
|
+
candidates: media.candidates || candidates,
|
|
6230
|
+
}));
|
|
6231
|
+
|
|
6232
|
+
return sdpParser__default['default'].write(parsedSdp);
|
|
6233
|
+
};
|
|
6234
|
+
|
|
6217
6235
|
/* global RTCSessionDescriptionInit, navigator */
|
|
6218
6236
|
|
|
6219
6237
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
@@ -6343,7 +6361,10 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
6343
6361
|
|
|
6344
6362
|
// Check if we got ICEs
|
|
6345
6363
|
if (sdp.indexOf('a=candidate') !== -1) {
|
|
6346
|
-
return
|
|
6364
|
+
return {
|
|
6365
|
+
type: description.type,
|
|
6366
|
+
sdp: addIcesInAllBundles(sdp),
|
|
6367
|
+
};
|
|
6347
6368
|
}
|
|
6348
6369
|
|
|
6349
6370
|
wazoLogger.info('No ICE candidates found in SDP, fixing it with gathered ices', this.gatheredCandidates);
|
|
@@ -6214,6 +6214,24 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
6214
6214
|
return fixed;
|
|
6215
6215
|
};
|
|
6216
6216
|
|
|
6217
|
+
const addIcesInAllBundles = (sdp ) => {
|
|
6218
|
+
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
6219
|
+
|
|
6220
|
+
const mediaWithCandidate = parsedSdp.media.find(media => !!media.candidates);
|
|
6221
|
+
if (!mediaWithCandidate) {
|
|
6222
|
+
return sdp;
|
|
6223
|
+
}
|
|
6224
|
+
|
|
6225
|
+
const { candidates } = mediaWithCandidate;
|
|
6226
|
+
|
|
6227
|
+
parsedSdp.media = parsedSdp.media.map(media => ({
|
|
6228
|
+
...media,
|
|
6229
|
+
candidates: media.candidates || candidates,
|
|
6230
|
+
}));
|
|
6231
|
+
|
|
6232
|
+
return sdpParser__default['default'].write(parsedSdp);
|
|
6233
|
+
};
|
|
6234
|
+
|
|
6217
6235
|
/* global RTCSessionDescriptionInit, navigator */
|
|
6218
6236
|
|
|
6219
6237
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
@@ -6343,7 +6361,10 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
6343
6361
|
|
|
6344
6362
|
// Check if we got ICEs
|
|
6345
6363
|
if (sdp.indexOf('a=candidate') !== -1) {
|
|
6346
|
-
return
|
|
6364
|
+
return {
|
|
6365
|
+
type: description.type,
|
|
6366
|
+
sdp: addIcesInAllBundles(sdp),
|
|
6367
|
+
};
|
|
6347
6368
|
}
|
|
6348
6369
|
|
|
6349
6370
|
wazoLogger.info('No ICE candidates found in SDP, fixing it with gathered ices', this.gatheredCandidates);
|
package/lib/simple/utils.js
CHANGED
|
@@ -6216,6 +6216,24 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
6216
6216
|
return fixed;
|
|
6217
6217
|
};
|
|
6218
6218
|
|
|
6219
|
+
const addIcesInAllBundles = (sdp ) => {
|
|
6220
|
+
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
6221
|
+
|
|
6222
|
+
const mediaWithCandidate = parsedSdp.media.find(media => !!media.candidates);
|
|
6223
|
+
if (!mediaWithCandidate) {
|
|
6224
|
+
return sdp;
|
|
6225
|
+
}
|
|
6226
|
+
|
|
6227
|
+
const { candidates } = mediaWithCandidate;
|
|
6228
|
+
|
|
6229
|
+
parsedSdp.media = parsedSdp.media.map(media => ({
|
|
6230
|
+
...media,
|
|
6231
|
+
candidates: media.candidates || candidates,
|
|
6232
|
+
}));
|
|
6233
|
+
|
|
6234
|
+
return sdpParser__default['default'].write(parsedSdp);
|
|
6235
|
+
};
|
|
6236
|
+
|
|
6219
6237
|
/* global RTCSessionDescriptionInit, navigator */
|
|
6220
6238
|
|
|
6221
6239
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
@@ -6345,7 +6363,10 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
6345
6363
|
|
|
6346
6364
|
// Check if we got ICEs
|
|
6347
6365
|
if (sdp.indexOf('a=candidate') !== -1) {
|
|
6348
|
-
return
|
|
6366
|
+
return {
|
|
6367
|
+
type: description.type,
|
|
6368
|
+
sdp: addIcesInAllBundles(sdp),
|
|
6369
|
+
};
|
|
6349
6370
|
}
|
|
6350
6371
|
|
|
6351
6372
|
wazoLogger.info('No ICE candidates found in SDP, fixing it with gathered ices', this.gatheredCandidates);
|
|
@@ -104,6 +104,24 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
104
104
|
return fixed;
|
|
105
105
|
};
|
|
106
106
|
|
|
107
|
+
const addIcesInAllBundles = (sdp ) => {
|
|
108
|
+
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
109
|
+
|
|
110
|
+
const mediaWithCandidate = parsedSdp.media.find(media => !!media.candidates);
|
|
111
|
+
if (!mediaWithCandidate) {
|
|
112
|
+
return sdp;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const { candidates } = mediaWithCandidate;
|
|
116
|
+
|
|
117
|
+
parsedSdp.media = parsedSdp.media.map(media => ({
|
|
118
|
+
...media,
|
|
119
|
+
candidates: media.candidates || candidates,
|
|
120
|
+
}));
|
|
121
|
+
|
|
122
|
+
return sdpParser__default['default'].write(parsedSdp);
|
|
123
|
+
};
|
|
124
|
+
|
|
107
125
|
/* eslint-disable max-len */
|
|
108
126
|
|
|
109
127
|
const goodSdp = `
|
|
@@ -268,4 +286,36 @@ describe('SDP utils', () => {
|
|
|
268
286
|
expect(hasAnActiveVideo(inactiveVideo)).toBeFalsy();
|
|
269
287
|
});
|
|
270
288
|
});
|
|
289
|
+
|
|
290
|
+
describe('Adding candidate in all bundles ', () => {
|
|
291
|
+
it('should add candidate everywhere', async () => {
|
|
292
|
+
const audioWithoutCandidate = `
|
|
293
|
+
c=IN IP4 203.0.113.1
|
|
294
|
+
m=audio 54400 RTP/SAVPF 0 96
|
|
295
|
+
m=video 54400 RTP/SAVPF 0 96
|
|
296
|
+
a=candidate:0 1 UDP 2113667327 203.0.113.1 54400 typ host
|
|
297
|
+
a=candidate:3996450952 1 udp 41819903 14.72.21.2 65092 typ relay raddr 0.0.0.0 rport 0 generation 0 network-id 3 network-cost 10
|
|
298
|
+
`;
|
|
299
|
+
const fixedAudioWithoutCandidate = sdpParser__default['default'].parse(addIcesInAllBundles(audioWithoutCandidate));
|
|
300
|
+
|
|
301
|
+
expect(fixedAudioWithoutCandidate.media[0].candidates[0].type).toBe('host');
|
|
302
|
+
expect(fixedAudioWithoutCandidate.media[0].candidates[1].type).toBe('relay');
|
|
303
|
+
expect(fixedAudioWithoutCandidate.media[1].candidates[0].type).toBe('host');
|
|
304
|
+
expect(fixedAudioWithoutCandidate.media[1].candidates[1].type).toBe('relay');
|
|
305
|
+
|
|
306
|
+
// It should not add candidate if already present
|
|
307
|
+
const audioWithCandidate = `
|
|
308
|
+
c=IN IP4 203.0.113.1
|
|
309
|
+
m=audio 54400 RTP/SAVPF 0 96
|
|
310
|
+
a=candidate:0 1 UDP 2113667327 203.0.113.1 54400 typ srflx
|
|
311
|
+
|
|
312
|
+
m=video 54400 RTP/SAVPF 0 96
|
|
313
|
+
a=candidate:0 1 UDP 2113667327 203.0.113.1 54400 typ host
|
|
314
|
+
`;
|
|
315
|
+
const fixedAudioWithCandidate = sdpParser__default['default'].parse(addIcesInAllBundles(audioWithCandidate));
|
|
316
|
+
|
|
317
|
+
expect(fixedAudioWithCandidate.media[0].candidates[0].type).toBe('srflx');
|
|
318
|
+
expect(fixedAudioWithCandidate.media[1].candidates[0].type).toBe('host');
|
|
319
|
+
});
|
|
320
|
+
});
|
|
271
321
|
});
|
package/lib/utils/sdp.js
CHANGED
|
@@ -130,7 +130,26 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
130
130
|
return fixed;
|
|
131
131
|
};
|
|
132
132
|
|
|
133
|
+
const addIcesInAllBundles = (sdp ) => {
|
|
134
|
+
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
135
|
+
|
|
136
|
+
const mediaWithCandidate = parsedSdp.media.find(media => !!media.candidates);
|
|
137
|
+
if (!mediaWithCandidate) {
|
|
138
|
+
return sdp;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const { candidates } = mediaWithCandidate;
|
|
142
|
+
|
|
143
|
+
parsedSdp.media = parsedSdp.media.map(media => ({
|
|
144
|
+
...media,
|
|
145
|
+
candidates: media.candidates || candidates,
|
|
146
|
+
}));
|
|
147
|
+
|
|
148
|
+
return sdpParser__default['default'].write(parsedSdp);
|
|
149
|
+
};
|
|
150
|
+
|
|
133
151
|
exports.activateVideoModifier = activateVideoModifier;
|
|
152
|
+
exports.addIcesInAllBundles = addIcesInAllBundles;
|
|
134
153
|
exports.areCandidateValid = areCandidateValid;
|
|
135
154
|
exports.deactivateVideoModifier = deactivateVideoModifier;
|
|
136
155
|
exports.fixBundle = fixBundle;
|
package/lib/web-rtc-client.js
CHANGED
|
@@ -789,6 +789,24 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
789
789
|
return fixed;
|
|
790
790
|
};
|
|
791
791
|
|
|
792
|
+
const addIcesInAllBundles = (sdp ) => {
|
|
793
|
+
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
794
|
+
|
|
795
|
+
const mediaWithCandidate = parsedSdp.media.find(media => !!media.candidates);
|
|
796
|
+
if (!mediaWithCandidate) {
|
|
797
|
+
return sdp;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
const { candidates } = mediaWithCandidate;
|
|
801
|
+
|
|
802
|
+
parsedSdp.media = parsedSdp.media.map(media => ({
|
|
803
|
+
...media,
|
|
804
|
+
candidates: media.candidates || candidates,
|
|
805
|
+
}));
|
|
806
|
+
|
|
807
|
+
return sdpParser__default['default'].write(parsedSdp);
|
|
808
|
+
};
|
|
809
|
+
|
|
792
810
|
/* global RTCSessionDescriptionInit, navigator */
|
|
793
811
|
|
|
794
812
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
@@ -918,7 +936,10 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
918
936
|
|
|
919
937
|
// Check if we got ICEs
|
|
920
938
|
if (sdp.indexOf('a=candidate') !== -1) {
|
|
921
|
-
return
|
|
939
|
+
return {
|
|
940
|
+
type: description.type,
|
|
941
|
+
sdp: addIcesInAllBundles(sdp),
|
|
942
|
+
};
|
|
922
943
|
}
|
|
923
944
|
|
|
924
945
|
wazoLogger.info('No ICE candidates found in SDP, fixing it with gathered ices', this.gatheredCandidates);
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ import { SessionDescriptionHandler }
|
|
|
12
12
|
import { SessionDescriptionHandlerOptions }
|
|
13
13
|
from 'sip.js/lib/platform/web/session-description-handler/session-description-handler-options';
|
|
14
14
|
import IssueReporter from '../service/IssueReporter';
|
|
15
|
-
import { fixSdp, parseCandidate } from '../utils/sdp';
|
|
15
|
+
import { addIcesInAllBundles, fixSdp, parseCandidate } from '../utils/sdp';
|
|
16
16
|
|
|
17
17
|
const wazoLogger = IssueReporter ? IssueReporter.loggerFor('webrtc-sdh') : console;
|
|
18
18
|
|
|
@@ -141,7 +141,10 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
141
141
|
|
|
142
142
|
// Check if we got ICEs
|
|
143
143
|
if (sdp.indexOf('a=candidate') !== -1) {
|
|
144
|
-
return
|
|
144
|
+
return {
|
|
145
|
+
type: description.type,
|
|
146
|
+
sdp: addIcesInAllBundles(sdp),
|
|
147
|
+
};
|
|
145
148
|
}
|
|
146
149
|
|
|
147
150
|
wazoLogger.info('No ICE candidates found in SDP, fixing it with gathered ices', this.gatheredCandidates);
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
fixSdp,
|
|
10
10
|
fixBundle,
|
|
11
11
|
toggleVideoDirection,
|
|
12
|
-
hasAnActiveVideo,
|
|
12
|
+
hasAnActiveVideo, addIcesInAllBundles,
|
|
13
13
|
} from '../sdp';
|
|
14
14
|
|
|
15
15
|
const goodSdp = `
|
|
@@ -174,4 +174,36 @@ describe('SDP utils', () => {
|
|
|
174
174
|
expect(hasAnActiveVideo(inactiveVideo)).toBeFalsy();
|
|
175
175
|
});
|
|
176
176
|
});
|
|
177
|
+
|
|
178
|
+
describe('Adding candidate in all bundles ', () => {
|
|
179
|
+
it('should add candidate everywhere', async () => {
|
|
180
|
+
const audioWithoutCandidate = `
|
|
181
|
+
c=IN IP4 203.0.113.1
|
|
182
|
+
m=audio 54400 RTP/SAVPF 0 96
|
|
183
|
+
m=video 54400 RTP/SAVPF 0 96
|
|
184
|
+
a=candidate:0 1 UDP 2113667327 203.0.113.1 54400 typ host
|
|
185
|
+
a=candidate:3996450952 1 udp 41819903 14.72.21.2 65092 typ relay raddr 0.0.0.0 rport 0 generation 0 network-id 3 network-cost 10
|
|
186
|
+
`;
|
|
187
|
+
const fixedAudioWithoutCandidate = sdpParser.parse(addIcesInAllBundles(audioWithoutCandidate));
|
|
188
|
+
|
|
189
|
+
expect(fixedAudioWithoutCandidate.media[0].candidates[0].type).toBe('host');
|
|
190
|
+
expect(fixedAudioWithoutCandidate.media[0].candidates[1].type).toBe('relay');
|
|
191
|
+
expect(fixedAudioWithoutCandidate.media[1].candidates[0].type).toBe('host');
|
|
192
|
+
expect(fixedAudioWithoutCandidate.media[1].candidates[1].type).toBe('relay');
|
|
193
|
+
|
|
194
|
+
// It should not add candidate if already present
|
|
195
|
+
const audioWithCandidate = `
|
|
196
|
+
c=IN IP4 203.0.113.1
|
|
197
|
+
m=audio 54400 RTP/SAVPF 0 96
|
|
198
|
+
a=candidate:0 1 UDP 2113667327 203.0.113.1 54400 typ srflx
|
|
199
|
+
|
|
200
|
+
m=video 54400 RTP/SAVPF 0 96
|
|
201
|
+
a=candidate:0 1 UDP 2113667327 203.0.113.1 54400 typ host
|
|
202
|
+
`;
|
|
203
|
+
const fixedAudioWithCandidate = sdpParser.parse(addIcesInAllBundles(audioWithCandidate));
|
|
204
|
+
|
|
205
|
+
expect(fixedAudioWithCandidate.media[0].candidates[0].type).toBe('srflx');
|
|
206
|
+
expect(fixedAudioWithCandidate.media[1].candidates[0].type).toBe('host');
|
|
207
|
+
});
|
|
208
|
+
});
|
|
177
209
|
});
|
package/src/utils/sdp.js
CHANGED
|
@@ -120,3 +120,21 @@ export const fixSdp = (sdp: string, candidates: Object[], forcePort: boolean = t
|
|
|
120
120
|
|
|
121
121
|
return fixed;
|
|
122
122
|
};
|
|
123
|
+
|
|
124
|
+
export const addIcesInAllBundles = (sdp: string) => {
|
|
125
|
+
const parsedSdp = sdpParser.parse(sdp);
|
|
126
|
+
|
|
127
|
+
const mediaWithCandidate = parsedSdp.media.find(media => !!media.candidates);
|
|
128
|
+
if (!mediaWithCandidate) {
|
|
129
|
+
return sdp;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const { candidates } = mediaWithCandidate;
|
|
133
|
+
|
|
134
|
+
parsedSdp.media = parsedSdp.media.map(media => ({
|
|
135
|
+
...media,
|
|
136
|
+
candidates: media.candidates || candidates,
|
|
137
|
+
}));
|
|
138
|
+
|
|
139
|
+
return sdpParser.write(parsedSdp);
|
|
140
|
+
};
|