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

use receiver-side setCodecPreferences #17

Merged
merged 1 commit into from
Feb 26, 2024
Merged
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
28 changes: 15 additions & 13 deletions simulcast-playground.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@
</tr>
</table>
<button id="start">Start</button>
<button id="stop">Stop</button> |
<button id="stop">Stop</button> |
<button id="copyBookmark">Copy Bookmark</button>
<button id="copyBookmarkWithDevice">Copy Bookmark (+device)</button>
<br />
Source:
Source:
<select id="captureDevice">
<option value="default">Default Device</option>
</select>
Expand Down Expand Up @@ -317,7 +317,7 @@
<div id="recordingListBox" style="display: none">
<details open>
<summary>Recordings</summary>
<div id="recordingList">
<div id="recordingList">
</div>
</details>
</div>
Expand Down Expand Up @@ -536,6 +536,17 @@
}
};
pc2.ontrack = async (e) => {
if (e.transceiver && e.transceiver.setCodecPreferences) {
// Move the desired codecs in front

const wantedCodecs = RTCRtpReceiver.getCapabilities(
'video'
).codecs.filter((c) => c.mimeType.includes(codec.value));
const otherCodecs = RTCRtpReceiver.getCapabilities("video").codecs.filter(
(c) => !c.mimeType.includes(codec.value)
);
e.transceiver.setCodecPreferences(wantedCodecs.concat(otherCodecs));
}
try {
if (splitLayer.value == 'merged') {
intervals.push(setStream(
Expand Down Expand Up @@ -648,15 +659,6 @@
});
sender = transceiver.sender;

// Move the desired codecs in front
const wantedCodecs = RTCRtpSender.getCapabilities(
"video"
).codecs.filter((c) => c.mimeType.includes(codec.value));
const otherCodecs = RTCRtpSender.getCapabilities("video").codecs.filter(
(c) => !c.mimeType.includes(codec.value)
);
transceiver.setCodecPreferences(wantedCodecs.concat(otherCodecs));

lastBitrateMesurementTime = performance.now();
lastBytesSent = 0;
lastBytesReceived = 0;
Expand Down Expand Up @@ -1214,7 +1216,7 @@

const name = `layer${layerId}_${sharingOption}_${codec}_${bitrate}kbps_${framerate}fps_${date}`;
return name;
}
}


const is = (stat, type) => stat.type == type && !stat.isRemote; // skip RTCP
Expand Down