JsSIP icon indicating copy to clipboard operation
JsSIP copied to clipboard

Setting priority on RTC session sender's encodings

Open marcovidonis opened this issue 1 year ago • 2 comments

I'm looking at adding the option to set the sender's priority when adding local media stream tracks to the peer connection in RTCSession. In some applications, this could be used as a QoS marker, to make sure the user agent allocates a higher bandwidth, for example.

The way I would do it this:

this._localMediaStream = stream;
if (stream)
{
  stream.getTracks().forEach((track) =>
  {
    let sender = this._connection.addTrack(track, stream);
    const params = sender.getParameters();
      params.encodings = params.encodings.map((e) => {
        if (!this.priority) return e;
        if (e.priority) {
          e.priority = this.priority;
        }
        if (e.networkPriority) {
          e.networkPriority = this.priority;
        }
        return e;
      });
      sender.setParameters(params);
  });
}

Would this addition be of interested to the project? If so, I'd be happy to open a PR for it.

Also, I'm not too sure where the best place would be to define this.priority: in RTCSession.js itself, perhaps? Or better pass it to the constructor?

marcovidonis avatar Oct 03 '24 13:10 marcovidonis

I've verified This works in Chrome ( 130.0.6723.117) but does not work in Safari (17.x) - both desktop and mobile (rdcp is set to 0 - can be checked in wireshark capture).

kstarzyk avatar Nov 15 '24 23:11 kstarzyk

I'm curious when/if this will get merged. The attached PR looks good to me and we've been using it as a patch for some time now.

JoshuaGeiger avatar Apr 08 '25 19:04 JoshuaGeiger