Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include local iceParameters in Transport 'connect' event #292

Merged
merged 4 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ export type DtlsParameters = {
* Server DTLS fingerprints.
*/
fingerprints: DtlsFingerprint[];
/**
* ICE ufrag.
*/
iceUfrag?: string;
/**
* ICE password.
*/
icePwd?: string;
};

/**
Expand Down
23 changes: 15 additions & 8 deletions src/handlers/sdp/commonUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,16 @@ export function extractDtlsParameters({
}): DtlsParameters {
let setup = sdpObject.setup;
let fingerprint = sdpObject.fingerprint;
let iceUfrag = sdpObject.iceUfrag;
let icePwd = sdpObject.icePwd;

if (!setup || !fingerprint) {
const mediaObject = (sdpObject.media || []).find(
(m: { port: number }) => m.port !== 0
);
const mediaObject = (sdpObject.media || []).find(
(m: { port: number }) => m.port !== 0
);

if (mediaObject) {
setup ??= mediaObject.setup;
fingerprint ??= mediaObject.fingerprint;
}
if ((!setup || !fingerprint) && mediaObject) {
setup ??= mediaObject.setup;
fingerprint ??= mediaObject.fingerprint;
}

if (!setup) {
Expand All @@ -169,6 +169,11 @@ export function extractDtlsParameters({
throw new Error('no a=fingerprint found at SDP session or media level');
}

if ((!iceUfrag || !icePwd) && mediaObject) {
iceUfrag ??= mediaObject.iceUfrag;
icePwd ??= mediaObject.icePwd;
}

let role: DtlsRole | undefined;

switch (setup) {
Expand Down Expand Up @@ -199,6 +204,8 @@ export function extractDtlsParameters({
value: fingerprint.hash,
},
],
iceUfrag,
icePwd,
};

return dtlsParameters;
Expand Down