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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/mediaserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class MediaServer extends Emitter {
}
else {
// waiting for outbound connection
obj.connTimeout = setTimeout(timeoutFn.bind(this, dlg, uuid), 4000);
obj.connTimeout = setTimeout(timeoutFn.bind(this, dlg, uuid), 10000);
obj.fn = produceEndpoint.bind(this, obj.dialog);
}
} catch (err) {
Expand Down Expand Up @@ -363,6 +363,10 @@ class MediaServer extends Emitter {
remoteSdp: opts.remoteSdp || req.body,
codecs: opts.codecs
});
if(opts.modifyMrfSdpResponse instanceof Function) {
debug(`MediaServer#connectCaller - modifying (normal scenario) sdp returned using opts.modifyMrfSdpResponse on ${uuid}`) ;
endpoint.local.sdp = opts.modifyMrfSdpResponse(endpoint.local.sdp)
}
const dialog = await this.srf.createUAS(req, res, {
localSdp: endpoint.local.sdp,
headers: opts.headers
Expand Down Expand Up @@ -395,11 +399,14 @@ class MediaServer extends Emitter {
}
// eslint-disable-next-line max-len
debug(`MediaServer#connectCaller - createUAC (srtp scenario) produced dialog for ${uuid}: ${JSON.stringify(dlg)}`) ;

if(opts.modifyMrfSdpResponse instanceof Function) {
debug(`MediaServer#connectCaller - modifying (srtp scenario) sdp returned using opts.modifyMrfSdpResponse on ${uuid}`) ;
dlg.remote.sdp = opts.modifyMrfSdpResponse(dlg.remote.sdp)
}
/* update pending connection state now that freeswitch has answered */
const obj = this.pendingConnections.get(uuid);
obj.dialog = dlg;
obj.connTimeout = setTimeout(timeoutFn.bind(this, dlg, uuid), 4000);
obj.connTimeout = setTimeout(timeoutFn.bind(this, dlg, uuid), 10000);
obj.fn = produceEndpoint.bind(this, obj.dialog);

/* propagate answer back to caller, allowing dtls handshake to proceed */
Expand Down