Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding method to modify MRF SDP before its sent back to client #65

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lylepratt
Copy link
Collaborator

@lylepratt lylepratt commented Nov 5, 2022

I needed to add some SDP fields to improve WebRTC video quality on Chrome and Safari. This required that I intercept the SDP coming back from FreeSwitch before its passed back to the WebRTC client.

In my case I'm adding these fields on all a=fmtp lines:

x-google-max-bitrate=6000;x-google-min-bitrate=2000;x-google-start-bitrate=2000

I enabled this functionality by adding an optional function that can be passed to mediaserver.connectCaller called modifyMrfSdpResponse.

Here is an example of it being used:

        var {endpoint, dialog} = await thisMediaServer.connectCaller(this.req, this.res, {modifyMrfSdpResponse: function(sdp) {
          var remoteArr = sdp.split('\r\n');
          remoteArr.forEach((str, i) => {
            if (/^a=fmtp:\d*/.test(str)) {
              remoteArr[i] = str + ';x-google-max-bitrate=6000;x-google-min-bitrate=2000;x-google-start-bitrate=4000';
            } else if (/^a=mid:(1|video)/.test(str)) {
              remoteArr[i] += '\r\nb=AS:6000';
            }
          });
          var newRemote = remoteArr.join('\r\n');
          return newRemote;
        }})  

With this implemented I have improved the quality of my video calls by many times. These SDP parameters are respected by both Chrome and Safar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant