Skip to content

Commit

Permalink
Pass scaleResolutionDownBy param
Browse files Browse the repository at this point in the history
  • Loading branch information
friendlymatthew committed Oct 25, 2024
1 parent 72d7bdf commit e477fb3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
6 changes: 5 additions & 1 deletion burrito/burrito.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ let resolutions = [
webCodecVideoElement: spatial240pWebCodecVideoElement,
webCodecTrackGenerator: mediaStreamTrackGenerator240p,
webCodecWritable: mediaStreamWritable240p,
scaleResolutionDownBy: 4.5,
},
{
title: "480p",
Expand All @@ -52,6 +53,7 @@ let resolutions = [
webCodecVideoElement: spatial480pWebCodecVideoElement,
webCodecTrackGenerator: mediaStreamTrackGenerator480p,
webCodecWritable: mediaStreamWritable480p,
scaleResolutionDownBy: 2.25
},
{
title: "720p",
Expand All @@ -65,6 +67,7 @@ let resolutions = [
webCodecVideoElement: spatial720pWebCodecVideoElement,
webCodecTrackGenerator: mediaStreamTrackGenerator720p,
webCodecWritable: mediaStreamWritable720p,
scaleResolutionDownBy: 1.5,
},
];

Expand Down Expand Up @@ -246,7 +249,8 @@ async function call() {

resolution.remoteVideoElement.srcObject = e.streams[0];
},
scalabilityMode
scalabilityMode,
resolution.scaleResolutionDownBy
);

resolution.videoPipe.pc1.getSenders().forEach((s) => {
Expand Down
2 changes: 2 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ async function call() {
gotRemoteStream(e.streams[0], video2);
},
primarySVCModeTitle.innerText,
1.0,
);
startToEnd.pc1.getSenders().forEach((s) => setupSenderTransform(s, true));
await startToEnd.negotiate();
Expand All @@ -400,6 +401,7 @@ async function call() {
gotRemoteStream(e.streams[0], video2a);
},
secondarySVCModeTitle.innerText,
1.0,
);
secondaryStartToEnd.pc1.getSenders().forEach((s) => setupSenderTransform(s, false));
await secondaryStartToEnd.negotiate();
Expand Down
11 changes: 8 additions & 3 deletions js/videopipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
//
'use strict';

function VideoPipe(stream, forceSend, forceReceive, handler, scalabilityMode) {
function VideoPipe(stream, forceSend, forceReceive, handler, scalabilityMode, scaleResolutionDownBy) {
this.pc1 = new RTCPeerConnection({
encodedInsertableStreams: forceSend,
});
Expand All @@ -36,7 +36,12 @@ function VideoPipe(stream, forceSend, forceReceive, handler, scalabilityMode) {
} else {
let tr = this.pc1.addTransceiver(track, {
streams: [stream],
sendEncodings: [{ scalabilityMode: scalabilityMode }],
sendEncodings: [
{
scalabilityMode: scalabilityMode,
scaleResolutionDownBy: scaleResolutionDownBy
}
],
});

const videoCodecs = RTCRtpSender.getCapabilities('video').codecs;
Expand All @@ -59,7 +64,7 @@ VideoPipe.prototype.negotiate = async function () {

const offer = await this.pc1.createOffer();
// Disable video/red to allow for easier inspection in Wireshark.
await this.pc2.setRemoteDescription({ type: 'offer', sdp: offer.sdp.replace('red/90000', 'green/90000') });
await this.pc2.setRemoteDescription({type: 'offer', sdp: offer.sdp.replace('red/90000', 'green/90000')});
await this.pc1.setLocalDescription(offer);

const answer = await this.pc2.createAnswer();
Expand Down

0 comments on commit e477fb3

Please sign in to comment.