1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-12-22 23:35:46 +01:00

Set track parameters at creation time.

We now create a sendonly transceiver, and set the max bitrate at
creation time.
This commit is contained in:
Juliusz Chroboczek 2021-04-29 17:03:25 +02:00
parent be73380f9f
commit 4a6dccff0c

View file

@ -805,9 +805,6 @@ function newUpStream(localId) {
console.error(e);
displayError(e);
};
c.onnegotiationcompleted = function() {
setMaxVideoThroughput(c, getMaxVideoThroughput());
};
return c;
}
@ -1032,6 +1029,25 @@ function isSafari() {
return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0;
}
/**
* @param {Stream} c
* @param {MediaStreamTrack} t
* @param {MediaStream} stream
*/
function addUpTrack(c, t, stream) {
let encodings = [{}];
if(t.kind === 'video') {
let bps = getMaxVideoThroughput();
if(bps > 0)
encodings[0].maxBitrate = bps;
}
c.pc.addTransceiver(t, {
direction: 'sendonly',
streams: [stream],
sendEncodings: encodings,
});
}
/**
* @param {string} [localId]
*/
@ -1128,7 +1144,7 @@ async function addLocalMedia(localId) {
t.contentHint = 'detail';
}
}
c.pc.addTrack(t, stream);
addUpTrack(c, t, stream);
});
c.onstats = gotUpStats;
@ -1169,7 +1185,7 @@ async function addShareMedia() {
delMedia(c.localId);
}
stream.getTracks().forEach(t => {
c.pc.addTrack(t, stream);
addUpTrack(c, t, stream)
t.onended = e => c.close();
});
c.onstats = gotUpStats;
@ -1225,7 +1241,7 @@ async function addFileMedia(file) {
displayWarning('You have been muted');
}
}
c.pc.addTrack(t, stream);
addUpTrack(c, t, stream);
c.onstats = gotUpStats;
c.setStatsInterval(2000);
};