Last active
January 20, 2021 22:07
-
-
Save kwindla/bf016dfa76275efc3323f84e8a45803e to your computer and use it in GitHub Desktop.
Daily.co video API high bitrate simulcast sample code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>test high bitrate simulcast</title> | |
<script src="https://unpkg.com/@daily-co/daily-js"></script> | |
</head> | |
<body onload="main()"> | |
<div id="videos"></div> | |
<script> | |
async function main() { | |
const ROOM_URL = ... ROOM URL HERE ...; | |
window.callObject = DailyIframe.createCallObject({ | |
dailyConfig: { | |
experimentalChromeVideoMuteLightOff: true, | |
camSimulcastEncodings: [ | |
{ maxBitrate: 1000000, scaleResolutionDownBy: 4 }, | |
{ maxBitrate: 2000000, scaleResolutionDownBy: 2 }, | |
{ maxBitrate: 4000000, scaleResolutionDownBy: 1 }, | |
], | |
}, | |
}); | |
callObject.on("track-started", displayVideo); | |
await callObject.join({ url: ROOM_URL }); | |
await callObject.setNetworkTopology({ topology: "sfu" }); | |
callObject.setBandwidth({ | |
kbs: 7000, | |
trackConstraints: { width: 1920, height: 1080 }, | |
}); | |
} | |
function displayVideo(evt) { | |
console.log(evt); | |
if (!(evt.track.kind === "video")) { | |
return; | |
} | |
let videosDiv = document.getElementById("videos"); | |
let videoEl = document.createElement("video"); | |
videosDiv.appendChild(videoEl); | |
videoEl.style.width = "100%"; | |
videoEl.srcObject = new MediaStream([evt.track]); | |
videoEl.play(); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment