Skip to content

Commit

Permalink
Properly look for a=fingerprint and a=setup attributes at SDP session…
Browse files Browse the repository at this point in the history
… and media levels
  • Loading branch information
ibc committed Aug 25, 2023
1 parent 2454ade commit 0381230
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/handlers/sdp/commonUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,33 @@ export function extractDtlsParameters(
{ sdpObject: any }
): DtlsParameters
{
const mediaObject = (sdpObject.media || [])
.find((m: { port: number; setup: 'active' | 'passive' | 'actpass' }) => (
m.port !== 0 && m.setup
));
let setup = sdpObject.setup;
let fingerprint = sdpObject.fingerprint;

if (!mediaObject)
if (!setup || !fingerprint)
{
throw new Error('no active media section with DTLS role found');
const mediaObject = (sdpObject.media || [])
.find((m: { port: number }) => (m.port !== 0));

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

if (!setup)
{
throw new Error('no a=setup found at SDP session or media level');
}
else if (!fingerprint)
{
throw new Error('no a=fingerprint found at SDP session or media level');
}

const fingerprint = mediaObject.fingerprint || sdpObject.fingerprint;
let role: DtlsRole | undefined;

switch (mediaObject.setup)
switch (setup)
{
case 'active':
role = 'client';
Expand Down

0 comments on commit 0381230

Please sign in to comment.