mirror of
https://github.com/jech/galene.git
synced 2024-11-22 08:35:57 +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:
parent
be73380f9f
commit
4a6dccff0c
1 changed files with 22 additions and 6 deletions
|
@ -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);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue