Commit 4a6dccff authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Set track parameters at creation time.

We now create a sendonly transceiver, and set the max bitrate at
creation time.
parent be73380f
......@@ -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);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment