Capped bitrates for WebRTC Streams
This commit is contained in:
parent
881dcc2e9c
commit
1dfe3454b4
1 changed files with 17 additions and 0 deletions
|
|
@ -359,6 +359,23 @@ class connectedViewer{
|
|||
peer.addTrack(track, this.broadcastingStream);
|
||||
}
|
||||
|
||||
//For each sender for this peer
|
||||
for(let sender of peer.getSenders()){
|
||||
//Set audio tracks to 192kbps and video tracks to 1200kbps
|
||||
const bitrate = (sender.track.kind == "audio") ? 192 * 1000 : 1200 * 1000;
|
||||
//gank parms from the sender
|
||||
const parms = sender.getParameters();
|
||||
|
||||
//Run through all listed encodings in the current sender paramters
|
||||
for(let encodingIndex in parms.encodings){
|
||||
//Set max bitrate to chosen bitrate
|
||||
parms.encodings[encodingIndex].maxBitrate = bitrate;
|
||||
}
|
||||
|
||||
//Set sender parameters to modified parameters
|
||||
sender.setParameters(parms);
|
||||
}
|
||||
|
||||
//Set peer remote description to connection offer from viewer
|
||||
peer.setRemoteDescription(new RTCSessionDescription(offer));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue