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

Add Firefox support #1

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 41 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,8 @@
}
}

console.log('pc2 offer: ' + pc2Offer.sdp);
console.log('pc1 local offer: ' + pc1Offer.sdp);
console.log('pc2 remote offer: ' + pc2Offer.sdp);
await pc2.setRemoteDescription(pc2Offer);

const answer = await pc2.createAnswer();
Expand All @@ -647,7 +648,8 @@
pc1Answer = addConferenceFlag(pc1Answer);
}

console.log('pc1 answer: ' + pc1Answer.sdp);
console.log('pc2 local answer: ' + answer.sdp);
console.log('pc1 remote answer: ' + pc1Answer.sdp);
await pc1.setRemoteDescription(pc1Answer);
};

Expand Down Expand Up @@ -678,13 +680,21 @@
.filter((line) =>
line.includes('urn:ietf:params:rtp-hdrext:sdes:mid'),
)
.map((line) => line.replace('a=extmap:', '').split(' ')[0])[0];
.map((line) => /a=extmap:(\d+)/.exec(line).at(1));

const ridExtmapId = mSection
.filter((line) =>
line.includes('urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id'),
)
.map((line) => line.replace('a=extmap:', '').split(' ')[0])[0];
.map((line) => /a=extmap:(\d+)/.exec(line).at(1));

const ssrcGroups = mSection
.filter((line) =>
line.includes('a=ssrc-group:FID '),
)
.map((line) => line.replace('a=ssrc-group:FID ', '').split(' '));

const hasSsrcGroups = ssrcGroups.length == layerRIDS.length;

sdpLines = sdpLines.map((line) => {
if (line.startsWith('a=group:BUNDLE')) {
Expand All @@ -694,7 +704,10 @@
return line;
});

for (const layerName of layerRIDS) {
for (const [i, layerName] of layerRIDS.entries()) {
const ssrcGroup = ssrcGroups.at(i);
const ssrc = ssrcGroup?.at(0);
const rtxSsrc = ssrcGroup?.at(1);
sdpLines = sdpLines.concat(
mSection.map((line) => {
if (line.match(/a=msid:/)) {
Expand All @@ -706,25 +719,47 @@
}

if (line.startsWith('a=extmap:' + midExtmapId + ' ')) {
if (hasSsrcGroups) {
return null;
}
return (
'a=extmap:' +
midExtmapId +
' urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id'
);
}

if (line.startsWith('a=extmap:' + ridExtmapId + ' ')) {
if (line.match(/^a=extmap:.* urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id/)) {
if (hasSsrcGroups) {
return null;
}
return (
'a=extmap:' +
ridExtmapId +
' urn:ietf:params:rtp-hdrext:sdes:mid'
);
}

if (hasSsrcGroups &&
line.match(/^a=extmap:.* urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id/)) {
return null;
}

if (line.startsWith('a=rid:') || line.startsWith('a=simulcast:')) {
return null;
}

if (line.startsWith('a=ssrc:') &&
!line.startsWith(`a=ssrc:${ssrc}`) &&
!line.startsWith(`a=ssrc:${rtxSsrc}`)) {
return null;
}

if (line.startsWith('a=ssrc-group:FID') &&
!line.startsWith(`a=ssrc-group:FID ${ssrc}`)) {
return null;
}

return line;
}),
);
Expand Down