Skip to content

Commit

Permalink
fix(plugin-meetings): add to peer connection bare turn tcp server (we…
Browse files Browse the repository at this point in the history
  • Loading branch information
k-wasniowski authored and parv_gour committed Sep 27, 2024
1 parent 1477e68 commit d0ad2c7
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 91 deletions.
13 changes: 13 additions & 0 deletions packages/@webex/plugin-meetings/src/media/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,19 @@ Media.createMediaConnection = (
// we might not have any TURN server if TURN discovery failed or wasn't done or
// we might get an empty TURN url if we land on a video mesh node
if (turnServerInfo?.url) {
if (!isBrowser('firefox')) {
let bareTurnServer = turnServerInfo.url;
bareTurnServer = bareTurnServer.replace('turns:', 'turn:');
bareTurnServer = bareTurnServer.replace('443', '5004');

iceServers.push({
urls: bareTurnServer,
username: turnServerInfo.username || '',
credential: turnServerInfo.password || '',
});
}

// TURN-TLS server
iceServers.push({
urls: turnServerInfo.url,
username: turnServerInfo.username || '',
Expand Down
52 changes: 34 additions & 18 deletions packages/@webex/plugin-meetings/test/unit/spec/media/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,39 @@ describe('createMediaConnection', () => {
id: 'roap media connection',
};
const fakeTrack = {
id: 'any fake track'
}
id: 'any fake track',
};
const fakeAudioStream = {
outputStream: {
getTracks: () => {
return [fakeTrack];
}
}
},
},
};
const fakeVideoStream = {
outputStream: {
getTracks: () => {
return [fakeTrack];
}
}
},
},
};
const fakeShareVideoStream = {
outputStream: {
getTracks: () => {
return [fakeTrack];
}
}
},
},
};
const fakeShareAudioStream = {
outputStream: {
getTracks: () => {
return [fakeTrack];
}
}
},
},
};
afterEach(() => {
sinon.restore();
clock.uninstall()
clock.uninstall();
});

it('creates a RoapMediaConnection when multistream is disabled', () => {
Expand Down Expand Up @@ -80,7 +80,7 @@ describe('createMediaConnection', () => {
enableRtx: ENABLE_RTX,
enableExtmap: ENABLE_EXTMAP,
turnServerInfo: {
url: 'turn server url',
url: 'turns:turn-server-url:443?transport=tcp',
username: 'turn username',
password: 'turn password',
},
Expand All @@ -91,7 +91,12 @@ describe('createMediaConnection', () => {
{
iceServers: [
{
urls: 'turn server url',
urls: 'turn:turn-server-url:5004?transport=tcp',
username: 'turn username',
credential: 'turn password',
},
{
urls: 'turns:turn-server-url:443?transport=tcp',
username: 'turn username',
credential: 'turn password',
},
Expand Down Expand Up @@ -146,7 +151,7 @@ describe('createMediaConnection', () => {
},
},
turnServerInfo: {
url: 'turn server url',
url: 'turns:turn-server-url:443?transport=tcp',
username: 'turn username',
password: 'turn password',
},
Expand All @@ -158,7 +163,12 @@ describe('createMediaConnection', () => {
{
iceServers: [
{
urls: 'turn server url',
urls: 'turn:turn-server-url:5004?transport=tcp',
username: 'turn username',
credential: 'turn password',
},
{
urls: 'turns:turn-server-url:443?transport=tcp',
username: 'turn username',
credential: 'turn password',
},
Expand All @@ -171,7 +181,10 @@ describe('createMediaConnection', () => {

[
{testCase: 'turnServerInfo is undefined', turnServerInfo: undefined},
{testCase: 'turnServerInfo.url is empty string', turnServerInfo: {url: '', username: 'turn username', password: 'turn password'}},
{
testCase: 'turnServerInfo.url is empty string',
turnServerInfo: {url: '', username: 'turn username', password: 'turn password'},
},
].forEach(({testCase, turnServerInfo}) => {
it(`passes empty ICE servers array to MultistreamRoapMediaConnection if ${testCase} (multistream enabled)`, () => {
const multistreamRoapMediaConnectionConstructorStub = sinon
Expand All @@ -198,7 +211,7 @@ describe('createMediaConnection', () => {
iceServers: [],
},
'meeting id'
);
);
});
});

Expand Down Expand Up @@ -232,7 +245,10 @@ describe('createMediaConnection', () => {

[
{testCase: 'turnServerInfo is undefined', turnServerInfo: undefined},
{testCase: 'turnServerInfo.url is empty string', turnServerInfo: {url: '', username: 'turn username', password: 'turn password'}},
{
testCase: 'turnServerInfo.url is empty string',
turnServerInfo: {url: '', username: 'turn username', password: 'turn password'},
},
].forEach(({testCase, turnServerInfo}) => {
it(`passes empty ICE servers array to RoapMediaConnection if ${testCase} (multistream disabled)`, () => {
const roapMediaConnectionConstructorStub = sinon
Expand Down
Loading

0 comments on commit d0ad2c7

Please sign in to comment.