Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit 228a6c0

Browse files
authored
Merge branch 'master' into intel-mediasdk-20.2.1
2 parents 5ea59d8 + 5dc3063 commit 228a6c0

File tree

4 files changed

+44
-74
lines changed

4 files changed

+44
-74
lines changed

source/agent/conference/conference.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,7 @@ var Conference = function (rpcClient, selfRpcId) {
915915

916916
return accessController.participantLeave(participantId)
917917
.then(() => rtcController.terminateByOwner(participantId))
918+
.then(() => removeParticipant(participantId))
918919
.then((result) => {
919920
callback('callback', 'ok');
920921
selfClean();

source/agent/conference/rtcController.js

Lines changed: 32 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ class Track {
6565

6666
class Operation {
6767

68-
constructor(id, transport, direction, tracks) {
68+
constructor(id, transport, direction, tracks, legacy) {
6969
this.id = id;
7070
this.transport = transport;
7171
this.transportId = transport.id;
7272
this.direction = direction;
7373
this.tracks = tracks.map(t => new Track(this, t));
74+
this.legacy = legacy;
7475
this.promise = Promise.resolve();
7576
}
7677

@@ -159,7 +160,15 @@ class RtcController extends EventEmitter {
159160
// Destroy transport
160161
if (transport.locality) {
161162
log.debug(`Destroy transport ${transportId}`);
162-
this.rpcReq.destroyTransport(transport.locality.node, transportId);
163+
this.rpcReq.destroyTransport(transport.locality.node, transportId)
164+
.catch((e) => {
165+
log.debug(`Faild to clean up transport ${transportId}: ${e}`);
166+
}).then(() => {
167+
const locality = transport.locality;
168+
log.debug(`to recycleWorkerNode: ${locality} task:, ${transportId}`);
169+
const taskConfig = {room: this.roomId, task: transportId};
170+
return this.rpcReq.recycleWorkerNode(locality.agent, locality.node, taskConfig)
171+
}).catch((e) => log.debug(`Failed to recycleWorkerNode ${locality}`));
163172
} else {
164173
log.warn(`No locality for failed transport ${transportId}`);
165174
}
@@ -231,36 +240,26 @@ class RtcController extends EventEmitter {
231240
}
232241
} else if (info.type === 'tracks-complete') {
233242
const operation = this.operations.get(info.operationId);
234-
operation.state = COMPLETED;
235-
if (operation.transport.state === COMPLETED) {
236-
// Only emit when transport is completed
237-
this.emit('session-established', operation);
243+
if (operation) {
244+
operation.state = COMPLETED;
245+
if (operation.transport.state === COMPLETED) {
246+
// Only emit when transport is completed
247+
this.emit('session-established', operation);
248+
}
238249
}
239250
}
240251
}
241252

242-
_createTransportIfNeeded(ownerId, sessionId, origin, tId) {
253+
async _createTransportIfNeeded(ownerId, sessionId, origin, tId) {
243254
if (!this.transports.has(tId)) {
244-
this.transports.set(tId, new Transport(tId, ownerId, origin));
245-
const taskConfig = {room: this.roomId, task: sessionId};
255+
const taskConfig = {room: this.roomId, task: tId};
246256
log.debug(`getWorkerNode ${this.clusterRpcId}, ${taskConfig}, ${origin}`);
247-
return this.rpcReq.getWorkerNode(this.clusterRpcId, 'webrtc', taskConfig, origin)
248-
.then((locality) => {
249-
if (!this.transports.has(tId)) {
250-
log.debug(`Transport destroyed after getWorkerNode ${tId}`);
251-
this.rpcReq.recycleWorkerNode(locality.agent, locality.node, taskConfig)
252-
.catch(reason => {
253-
log.debug('AccessNode not recycled', locality);
254-
});
255-
return Promise.reject('Session has been aborted');
256-
}
257-
log.debug(`getWorkerNode ok, sessionId: ${sessionId}, locality: ${locality}`);
258-
this.transports.get(tId).setup(locality);
259-
return this.transports.get(tId);
260-
});
261-
} else {
262-
return Promise.resolve(this.transports.get(tId));
257+
const locality = await this.rpcReq.getWorkerNode(
258+
this.clusterRpcId, 'webrtc', taskConfig, origin);
259+
this.transports.set(tId, new Transport(tId, ownerId, origin));
260+
this.transports.get(tId).setup(locality);
263261
}
262+
return this.transports.get(tId);
264263
}
265264

266265
// tracks = [ {mid, type, formatPreference, from} ]
@@ -271,7 +270,7 @@ class RtcController extends EventEmitter {
271270

272271
return this._createTransportIfNeeded(ownerId, sessionId, origin, transportId)
273272
.then(transport => {
274-
if (transport.state !== PENDING && transport.state !== COMPLETED) {
273+
if (!this.transports.has(transportId)) {
275274
return Promise.reject(`Transport ${transportId} is not ready`);
276275
}
277276
const locality = transport.locality;
@@ -281,12 +280,11 @@ class RtcController extends EventEmitter {
281280
log.debug(`operation exists:${sessionId}`);
282281
return Promise.reject(`operation exists:${sessionId}`);
283282
}
284-
const op = new Operation(sessionId, transport, direction, tracks);
283+
const op = new Operation(sessionId, transport, direction, tracks, legacy);
285284
this.operations.set(sessionId, op);
286-
// Save promise for this operation
285+
// Return promise for this operation
287286
const options = {transportId, tracks, controller: this.roomRpcId};
288-
op.promise = this.rpcReq.initiate(locality.node, sessionId, 'webrtc', direction, options);
289-
return op.promise;
287+
return this.rpcReq.initiate(locality.node, sessionId, 'webrtc', direction, options);
290288
});
291289
}
292290

@@ -301,30 +299,17 @@ class RtcController extends EventEmitter {
301299
const operation = this.operations.get(sessionId);
302300
const transport = this.transports.get(operation.transportId);
303301
const locality = transport.locality;
304-
operation.promise = operation.promise.then(() => {
305-
if (!this.operations.has(sessionId)) {
306-
log.debug(`operation does NOT exist:${sessionId}`);
307-
return Promise.reject(`operation does NOT exist:${sessionId}`);
308-
}
309-
return this.rpcReq.terminate(locality.node, sessionId, direction);
310-
}).then(() => {
302+
return this.rpcReq.terminate(locality.node, sessionId, direction).then(() => {
311303
if (this.operations.has(sessionId)) {
312304
const owner = transport.owner;
313305
const abortData = { direction: operation.direction, owner, reason };
314306
this.emit('session-aborted', sessionId, abortData);
315307
this.operations.delete(sessionId);
316-
log.debug(`to recycleWorkerNode: ${locality} task:, ${sessionId}`);
317-
const taskConfig = {room: this.roomId, task: sessionId};
318-
return this.rpcReq.recycleWorkerNode(locality.agent, locality.node, taskConfig)
319-
.catch(reason => {
320-
log.debug(`AccessNode not recycled ${locality}, ${reason}`);
321-
});
322308
}
323309
})
324310
.catch(reason => {
325311
log.debug(`Operation terminate failed ${operation}, ${reason}`);
326312
});
327-
return operation.promise;
328313
};
329314

330315
terminateByOwner(ownerId) {
@@ -374,29 +359,17 @@ class RtcController extends EventEmitter {
374359

375360
setMute(sessionId, tracks, muted) {
376361
log.debug(`setMute, sessionId: ${sessionId} tracks: ${tracks} muted: ${muted}`);
377-
378362
if (!this.operations.has(sessionId)) {
379363
log.debug(`operation does NOT exist:${sessionId}`);
380364
return Promise.reject(`operation does NOT exist:${sessionId}`);
381365
}
382-
383366
const operation = this.operations.get(sessionId);
384367
const transport = this.transports.get(operation.transportId);
385368
const locality = transport.locality;
386369
const onOff = muted ? 'off' : 'on';
387-
388-
operation.promise = operation.promise.then(() => {
389-
if (!this.operations.has(sessionId)) {
390-
log.debug(`operation does NOT exist:${sessionId}`);
391-
return Promise.reject(`operation does NOT exist:${sessionId}`);
392-
}
393-
return this.rpcReq.mediaOnOff(
394-
locality.node, sessionId, tracks, operation.direction, onOff);
395-
});
396-
const ret = operation.promise;
397-
operation.promise = operation.promise
398-
.catch(reason => log.debug(`setMute failed ${sessionId}`));
399-
return ret;
370+
return this.rpcReq.mediaOnOff(
371+
locality.node, sessionId, tracks, operation.direction, onOff)
372+
.catch(reason => log.debug(`setMute failed ${sessionId}`));;
400373
};
401374

402375
}

source/agent/webrtc/sdpInfo.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,10 @@ class SdpInfo {
105105
if (mediaInfo && mediaInfo.type === 'audio') {
106106
let rtp, fmtp;
107107
// Keep payload order in m line
108-
if (typeof mediaInfo.payloads === 'string') {
109-
mediaInfo.payloads.split(' ')
110-
.forEach((p, index) => {
111-
payloadOrder.set(parseInt(p), index);
112-
});
113-
}
108+
mediaInfo.payloads.toString().split(' ')
109+
.forEach((p, index) => {
110+
payloadOrder.set(parseInt(p), index);
111+
});
114112

115113
for (let i = 0; i < mediaInfo.rtp.length; i++) {
116114
rtp = mediaInfo.rtp[i];
@@ -153,7 +151,7 @@ class SdpInfo {
153151
mediaInfo.rtcpFb = mediaInfo.rtcpFb.filter(
154152
(rtcp) => relatedPayloads.has(rtcp.payload));
155153
}
156-
mediaInfo.payloads = mediaInfo.payloads.split(' ')
154+
mediaInfo.payloads = mediaInfo.payloads.toString().split(' ')
157155
.filter((p) => relatedPayloads.has(parseInt(p)))
158156
.filter((v, index, self) => self.indexOf(v) === index)
159157
.join(' ');
@@ -180,12 +178,10 @@ class SdpInfo {
180178
let rtp, fmtp;
181179
let payloads;
182180
// Keep payload order in m line
183-
if (typeof mediaInfo.payloads === 'string') {
184-
mediaInfo.payloads.split(' ')
185-
.forEach((p, index) => {
186-
payloadOrder.set(parseInt(p), index);
187-
});
188-
}
181+
mediaInfo.payloads.toString().split(' ')
182+
.forEach((p, index) => {
183+
payloadOrder.set(parseInt(p), index);
184+
});
189185

190186
for (let i = 0; i < mediaInfo.rtp.length; i++) {
191187
rtp = mediaInfo.rtp[i];
@@ -227,7 +223,7 @@ class SdpInfo {
227223
mediaInfo.rtcpFb = mediaInfo.rtcpFb.filter(
228224
(rtcp) => relatedPayloads.has(rtcp.payload));
229225
}
230-
mediaInfo.payloads = mediaInfo.payloads.split(' ')
226+
mediaInfo.payloads = mediaInfo.payloads.toString().split(' ')
231227
.filter((p) => relatedPayloads.has(parseInt(p)))
232228
.filter((v, index, self) => self.indexOf(v) === index)
233229
.join(' ');

source/portal/versions/portalDataAdapter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ const AdatperV1_1 = {
123123
}
124124
if (evt === 'progress') {
125125
if (data.sessionId && data.status === 'ready') {
126-
return {};
126+
evt = 'session-progress';
127127
}
128128
}
129129
return {evt, data};

0 commit comments

Comments
 (0)