Skip to content

Commit

Permalink
changes to go from no-media to full-media
Browse files Browse the repository at this point in the history
  • Loading branch information
davehorton committed Nov 18, 2024
1 parent 6b34acf commit 6fcef77
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/call-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
makeFullMediaReleaseKey,
makePartnerFullMediaReleaseKey
} = require('./utils');
const { MediaPath } = require('./constants.json');

const {forwardInDialogRequests} = require('drachtio-fn-b2b-sugar');
const {parseUri, stringifyUri, SipError} = require('drachtio-srf');
Expand Down Expand Up @@ -66,8 +67,7 @@ class CallSession extends Emitter {
this.addKey = req.srf.locals.realtimeDbHelpers.addKey;
this.retrieveKey = req.srf.locals.realtimeDbHelpers.retrieveKey;

this._mediaReleased = false;
this._fullMediaReleased = false;
this._mediaPath = MediaPath.FullMedia;

this.application_sid = req.locals.application_sid;
this.account_sid = req.locals.account_sid;
Expand All @@ -85,7 +85,7 @@ class CallSession extends Emitter {
}

get isMediaReleased() {
return this._mediaReleased;
return this._mediaPath !== MediaPath.FullMedia;
}

get isFive9VoiceStream() {
Expand Down Expand Up @@ -697,7 +697,7 @@ Duration=${payload.duration} `
this.rtpEngineResource.destroy().catch((err) => {
this.logger.info({err}, 'Error destroying rtpengine resource after full media release');
});
this._fullMediaReleased = true;
this._mediaPath = MediaPath.NoMedia;
return;
}

Expand Down Expand Up @@ -730,12 +730,14 @@ Duration=${payload.duration} `
let sdp;
//HL 2024-11-13: previously forwarded re-invites to webrtc clients but further testing has shown to be unnecessary
//if (isReleasingMedia && !this.callerIsUsingSrtp) {
if (isReleasingMedia) {

//DH 2024-11- 18: if we are going from no-media to either partial or full media, we need reinvite the far end
if (isReleasingMedia && this._mediaPath !== MediaPath.NoMedia) {
this.logger.info({response}, `got a reinvite from FS to ${reason}`);
sdp = dlg.other.remote.sdp;
if (!answerMedia.flags.includes('asymmetric')) answerMedia.flags.push('asymmetric');
answerMedia.flags = answerMedia.flags.filter((f) => f !== 'media handover');
this._mediaReleased = 'release-media' === reason;
this._mediaPath = 'release-media' === reason ? MediaPath.PartialMedia : MediaPath.FullMedia;
}
else {
sdp = await dlg.other.modify(response.sdp);
Expand Down
5 changes: 5 additions & 0 deletions lib/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
"ScaleIn": "scale-in",
"StandbyEnter": "standby-enter",
"StandbyExit": "standby-exit"
},
"MediaPath": {
"NoMedia": "no-media",
"PartialMedia": "partial-media",
"FullMedia": "full-media"
}
}

0 comments on commit 6fcef77

Please sign in to comment.