Open Drengel1990 opened 12 months ago
self.setMediaBitrates = (sdp) => {
return self.setMediaBitrate(self.setMediaBitrate(sdp, "video", 2000), "audio", 50);
};
self.setMediaBitrate = (sdp, media, bitrate) => {
let lines = sdp.split("\n");
let lineIndex = -1;
for (let i = 0; i < lines.length; i++) {
if (lines[i].startsWith(`m=${media}`)) {
lineIndex = i;
break;
}
}
if (lineIndex === -1) {
console.debug("Could not find the m line for", media);
return sdp;
}
console.debug("Found the m line for", media, "at line", lineIndex);
lineIndex++;
while(lines[lineIndex].startsWith("i=") || lines[lineIndex].startsWith("c=")) {
lineIndex++;
}
if (lines[lineIndex].startsWith("b")) {
console.debug("Replaced b line at line", lineIndex);
lines[lineIndex] = "b=AS:"+bitrate;
return lines.join("\n");
}
console.debug("Adding new b line before line", lineIndex);
let newLines = lines.slice(0, lineIndex);
newLines.push("b=AS:"+bitrate);
newLines = newLines.concat(lines.slice(lineIndex, lines.length));
return newLines.join("\n");
}
let offer = await self.pc.createOffer(); offer.sdp = self.setMediaBitrates(offer.sdp);
In play method
Is it correct to say that b=AS:
applies only to the sender side?
For instance, if the publishing client sets b=AS:500
, and the server responds with b=AS:800
does it mean the client will send at a bitrate of 500 kbps?
Similarly, if the playing client sets b=AS:500
and the server responds with b=AS:800
, does this imply that the server will send the stream at a maximum of 800 kbps? However, in the latter case, the server (SRS) might have the ability to change the bitrate of the source stream.
I think it's reasonable to support this feature, by including more research on usage and workflow.
https://webrtchacks.com/limit-webrtc-bandwidth-sdp I try to use b=AS:500 and send to the server, but it returns without this parameter