fixed clean dualEp for rest dial dual_stream=true (#468)

* fixed clean dualEp for rest dial dual_stream=true

* fix

* fix

* fix

* fix

* fix
This commit is contained in:
Hoan Luu Huu
2023-09-22 19:12:34 +07:00
committed by GitHub
parent 991fff3386
commit 4e916acf6c
2 changed files with 8 additions and 5 deletions

View File

@@ -134,9 +134,6 @@ router.post('/', async(req, res) => {
if (req.body.dual_streams) { if (req.body.dual_streams) {
dualEp = await ms.createEndpoint(); dualEp = await ms.createEndpoint();
localSdp = mergeSdpMedia(localSdp, dualEp.local.sdp); localSdp = mergeSdpMedia(localSdp, dualEp.local.sdp);
ep.on('destroy', () => {
dualEp.destroy();
});
} }
const connectStream = async(remoteSdp) => { const connectStream = async(remoteSdp) => {
@@ -145,7 +142,8 @@ router.post('/', async(req, res) => {
if (req.body.dual_streams) { if (req.body.dual_streams) {
const [sdpLegA, sdpLebB] = extractSdpMedia(remoteSdp); const [sdpLegA, sdpLebB] = extractSdpMedia(remoteSdp);
await Promise.all([ep.modify(sdpLegA), dualEp.modify(sdpLebB)]); await ep.modify(sdpLegA);
await dualEp.modify(sdpLebB);
await ep.bridge(dualEp); await ep.bridge(dualEp);
} else { } else {
ep.modify(sdp); ep.modify(sdp);
@@ -243,6 +241,7 @@ router.post('/', async(req, res) => {
srf, srf,
req: inviteReq, req: inviteReq,
ep, ep,
ep2: dualEp,
tasks, tasks,
callInfo, callInfo,
accountInfo, accountInfo,
@@ -295,6 +294,9 @@ router.post('/', async(req, res) => {
else console.error(err); else console.error(err);
} }
ep.destroy(); ep.destroy();
if (dualEp) {
dualEp.destroy();
}
setTimeout(restDial.kill.bind(restDial, cs), 5000); setTimeout(restDial.kill.bind(restDial, cs), 5000);
} }
} catch (err) { } catch (err) {

View File

@@ -8,7 +8,7 @@ const moment = require('moment');
* @extends CallSession * @extends CallSession
*/ */
class RestCallSession extends CallSession { class RestCallSession extends CallSession {
constructor({logger, application, srf, req, ep, tasks, callInfo, accountInfo, rootSpan}) { constructor({logger, application, srf, req, ep, ep2, tasks, callInfo, accountInfo, rootSpan}) {
super({ super({
logger, logger,
application, application,
@@ -21,6 +21,7 @@ class RestCallSession extends CallSession {
}); });
this.req = req; this.req = req;
this.ep = ep; this.ep = ep;
this.ep2 = ep2;
// keep restDialTask reference for closing AMD // keep restDialTask reference for closing AMD
if (tasks.length) { if (tasks.length) {
this.restDialTask = tasks[0]; this.restDialTask = tasks[0];