From 6fcef77803c9beb285904cf940cbe37a9e5373f1 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Mon, 18 Nov 2024 15:32:01 -0500 Subject: [PATCH] changes to go from no-media to full-media --- lib/call-session.js | 14 ++++++++------ lib/constants.json | 5 +++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/call-session.js b/lib/call-session.js index ebcf582..1271e23 100644 --- a/lib/call-session.js +++ b/lib/call-session.js @@ -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'); @@ -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; @@ -85,7 +85,7 @@ class CallSession extends Emitter { } get isMediaReleased() { - return this._mediaReleased; + return this._mediaPath !== MediaPath.FullMedia; } get isFive9VoiceStream() { @@ -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; } @@ -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); diff --git a/lib/constants.json b/lib/constants.json index f4a5173..08ca0af 100644 --- a/lib/constants.json +++ b/lib/constants.json @@ -3,5 +3,10 @@ "ScaleIn": "scale-in", "StandbyEnter": "standby-enter", "StandbyExit": "standby-exit" + }, + "MediaPath": { + "NoMedia": "no-media", + "PartialMedia": "partial-media", + "FullMedia": "full-media" } }