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

Commit f0c5988

Browse files
committed
Fix WebRTC agent.
Changes for adding WebTransport support broken WebRTC agent. This change fixes these issues.
1 parent dbc6545 commit f0c5988

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

source/agent/conference/conference.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ var Conference = function (rpcClient, selfRpcId) {
400400
locality: transport.locality,
401401
media: media,
402402
data: rtcInfo.data,
403-
info: { type: 'quic', owner: transport.owner }
403+
info: { type: 'webrtc', owner: transport.owner }
404404
};
405405
sendMsgTo(transport.owner, 'progress', {id: transport.id, sessionId, status: 'ready'});
406406
onSessionEstablished(transport.owner, sessionId, direction, sessionInfo);

source/agent/webrtc/index.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -275,17 +275,26 @@ module.exports = function (rpcClient, selfRpcId, parentRpcId, clusterWorkerIP) {
275275
}
276276

277277
var conn = null;
278-
switch (connectionType) {
279-
case 'internal':
280-
conn = internalConnFactory.fetch(connectionId, 'out');
281-
if (conn)
282-
conn.connect(options);//FIXME: May FAIL here!!!!!
283-
break;
284-
case 'webrtc':
285-
conn = createWebRTCConnection(connectionId, 'out', options, callback);
286-
break;
287-
default:
288-
log.error('Connection type invalid:' + connectionType);
278+
if (connectionType === 'internal') {
279+
conn = internalConnFactory.fetch(operationId, 'out');
280+
if (conn) {
281+
conn.connect(options);
282+
connections.addConnection(operationId, connectionType, options.controller, conn, 'out')
283+
.then(onSuccess(callback), onError(callback));
284+
}
285+
} else if (connectionType === 'webrtc') {
286+
if (!options.transportId) {
287+
// Generate a transportId
288+
289+
}
290+
conn = createWebRTCConnection(options.transportId, options.controller);
291+
options.tracks.forEach(function trackOp(t) {
292+
conn.addTrackOperation(operationId, t.mid, t.type, 'recvonly', t.formatPreference);
293+
});
294+
mappingTransports.set(operationId, options.transportId);
295+
callback('callback', 'ok');
296+
} else {
297+
log.error('Connection type invalid:' + connectionType);
289298
}
290299

291300
if (!conn) {
@@ -313,7 +322,7 @@ module.exports = function (rpcClient, selfRpcId, parentRpcId, clusterWorkerIP) {
313322
};
314323

315324
that.linkup = function (connectionId, audioFrom, videoFrom, dataFrom, callback) {
316-
log.debug('linkup, connectionId:', connectionId, 'audioFrom:', audioFrom, 'videoFrom:', videoFrom, 'callback:', callback);
325+
log.debug('linkup, connectionId:', connectionId, 'audioFrom:', audioFrom, 'videoFrom:', videoFrom, 'dataFrom:', dataFrom);
317326
connections.linkupConnection(connectionId, audioFrom, videoFrom).then(onSuccess(callback), onError(callback));
318327
};
319328

@@ -326,13 +335,8 @@ module.exports = function (rpcClient, selfRpcId, parentRpcId, clusterWorkerIP) {
326335
log.debug('onTransportSignaling, connection id:', connectionId, 'msg:', msg);
327336
var conn = getWebRTCConnection(connectionId);
328337
if (conn) {
329-
if (conn.type === 'webrtc') {//NOTE: Only webrtc connection supports signaling.
330-
conn.connection.onSignalling(msg);
331-
callback('callback', 'ok');
332-
} else {
333-
log.info('signaling on non-webrtc connection');
334-
callback('callback', 'error', 'signaling on non-webrtc connection');
335-
}
338+
conn.onSignalling(msg, connectionId);
339+
callback('callback', 'ok');
336340
} else {
337341
callback('callback', 'error', 'Connection does NOT exist:' + connectionId);
338342
}

0 commit comments

Comments
 (0)