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

Commit 7665f4d

Browse files
committed
Fix subscribe method after rebasing.
1 parent fc9039f commit 7665f4d

File tree

6 files changed

+59
-33
lines changed

6 files changed

+59
-33
lines changed

source/agent/conference/conference.js

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,6 @@ var Conference = function (rpcClient, selfRpcId) {
739739

740740
const isAudioPubPermitted = !!participants[info.owner].isPublishPermitted('audio');
741741
const subArgs = subscription.toRoomCtrlSubArgs();
742-
const subInfo = { transport : transport, media : media, data : dataSpec };
743742
const subs = subArgs.map(subArg => new Promise((resolve, reject) => {
744743
if (roomController) {
745744
const subInfo = { transport : transport, media : subArg.media, data : subArg.data };
@@ -948,7 +947,8 @@ var Conference = function (rpcClient, selfRpcId) {
948947
}
949948
const rtcPubInfo = {
950949
type: pubInfo.type,
951-
transportId: pubInfo.transportId,
950+
transport: pubInfo.transport,
951+
transportId: pubInfo.transport.id,
952952
tracks: pubInfo.media.tracks,
953953
legacy: pubInfo.legacy,
954954
data: pubInfo.data
@@ -962,8 +962,10 @@ var Conference = function (rpcClient, selfRpcId) {
962962
}
963963
const rtcSubInfo = {
964964
type: subDesc.type,
965-
transportId: subDesc.transportId,
965+
transport: subDesc.transport,
966+
transportId: subDesc.transport.id,
966967
tracks: subDesc.media.tracks,
968+
data: subDesc.data,
967969
legacy: subDesc.legacy,
968970
};
969971
return rtcSubInfo;
@@ -1272,30 +1274,32 @@ var Conference = function (rpcClient, selfRpcId) {
12721274
});
12731275
} else {
12741276
var format_preference;
1275-
if (subDesc.type === 'webrtc') {
1277+
if (subDesc.type === 'webrtc' || subDesc.type === 'quic') {
12761278
const rtcSubInfo = translateRtcSubIfNeeded(subDesc);
1277-
// Set formatPreference
1278-
rtcSubInfo.tracks.forEach(track => {
1279-
const streamId = streams[track.from]? track.from : trackOwners[track.from];
1280-
const source = getStreamTrack(track.from, track.type);
1281-
const formatPreference = {};
1282-
if (streams[streamId].type === 'forward') {
1283-
formatPreference.preferred = source.format;
1284-
source.optional && source.optional.format && (formatPreference.optional = source.optional.format);
1285-
} else {
1286-
formatPreference.optional = [source.format];
1287-
source.optional && source.optional.format && (formatPreference.optional = formatPreference.optional.concat(source.optional.format));
1288-
}
1289-
track.formatPreference = formatPreference;
1290-
});
1279+
if (rtcSubInfo.tracks){
1280+
// Set formatPreference
1281+
rtcSubInfo.tracks.forEach(track => {
1282+
const streamId = streams[track.from]? track.from : trackOwners[track.from];
1283+
const source = getStreamTrack(track.from, track.type);
1284+
const formatPreference = {};
1285+
if (streams[streamId].type === 'forward') {
1286+
formatPreference.preferred = source.format;
1287+
source.optional && source.optional.format && (formatPreference.optional = source.optional.format);
1288+
} else {
1289+
formatPreference.optional = [source.format];
1290+
source.optional && source.optional.format && (formatPreference.optional = formatPreference.optional.concat(source.optional.format));
1291+
}
1292+
track.formatPreference = formatPreference;
1293+
});
1294+
}
12911295

12921296
initiateSubscription(subscriptionId, subDesc, {owner: participantId, type: subDesc.type});
12931297
return rtcController.initiate(participantId, subscriptionId, 'out', participants[participantId].getOrigin(), rtcSubInfo)
12941298
.then((result) => {
1295-
const releasedSource = rtcSubInfo.tracks.find(track => {
1296-
const sourceStreamId = trackOwners[track.from] || track.from;
1297-
return !streams[sourceStreamId];
1298-
});
1299+
const releasedSource = rtcSubInfo.tracks ? rtcSubInfo.tracks.find(track => {
1300+
const sourceStreamId = trackOwners[track.from] || track.from;
1301+
return !streams[sourceStreamId];
1302+
}) : undefined;
12991303
if (releasedSource) {
13001304
rtcController.terminate(participantId, subscriptionId, 'Participant terminate');
13011305
return Promise.reject('Target audio/video stream early released');
@@ -1671,11 +1675,11 @@ var Conference = function (rpcClient, selfRpcId) {
16711675

16721676
return removeSubscription(subscriptionId)
16731677
.then((result) => {
1674-
return addSubscription(subscriptionId, oldSub.locality, newSubMedia, oldSub.info);
1678+
return addSubscription(subscriptionId, oldSub.locality, newSubMedia, oldSub.data, oldSub.info);
16751679
}).catch((err) => {
16761680
log.info('Update subscription failed:', err.message ? err.message : err);
16771681
log.info('And is recovering the previous subscription:', JSON.stringify(old_su));
1678-
return addSubscription(subscriptionId, oldSub.locality, oldSub.media, oldSub.info)
1682+
return addSubscription(subscriptionId, oldSub.locality, oldSub.media, oldSub.data, oldSub.info)
16791683
.then(() => {
16801684
return Promise.reject('Update subscription failed');
16811685
}, () => {

source/agent/conference/stream.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ class Stream {
224224
rid: track.rid,
225225
}))
226226
},
227+
data: this.data,
227228
info: (this.type === 'mixed') ? this.info : forwardInfo,
228229
};
229230
return portalFormat;

source/agent/conference/subscription.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ class Subscription {
186186
id: track.id, // Use track ID for webrtc publication
187187
locality: this.locality,
188188
type: this.info.type,
189-
media
189+
media,
190+
data: this.data
190191
};
191192
});
192193
} else {

source/agent/quic/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ module.exports = function (rpcClient, selfRpcId, parentRpcId, clusterWorkerIP) {
237237
conn.connect(options);//FIXME: May FAIL here!!!!!
238238
break;
239239
case 'quic':
240-
quicTransportServer.addTransportId(options.transport.id);
241240
conn = createStreamPipeline(connectionId, 'out', options, callback);
242241
const stream = quicTransportServer.createSendStream(options.transport.id, connectionId);
243242
conn.quicStream(stream);

source/portal/client.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ var Client = function(clientId, sigConnection, portal, version) {
9999
} else {
100100
req.type = 'webrtc'; //FIXME: For backend compatibility with v3.4 clients.
101101
req.transport = { type : 'webrtc', id : stream_id };
102+
if (req.transportId) {
103+
req.transport.id = req.transportId;
104+
}
102105
}
103106
transportId = req.transport.id;
104107
return portal.publish(clientId, stream_id, req);
@@ -139,15 +142,24 @@ var Client = function(clientId, sigConnection, portal, version) {
139142
}
140143

141144
//FIXME: move the id assignment to conference
142-
var subscription_id = Math.round(Math.random() * 1000000000000000000) + '';
145+
var subscription_id = uuidWithoutDash();
143146
var transportId;
144147
return adapter.translateReq(ReqType.Sub, subReq)
145148
.then((req) => {
146-
req.type = 'webrtc';//FIXME: For backend compatibility with v3.4 clients.
147-
if (!req.transportId) {
148-
req.transportId = subscription_id;
149+
if (req.transport && req.transport.type == 'quic') {
150+
req.type = 'quic';
151+
if (!req.transport.id) {
152+
req.transport.id = uuidWithoutDash();
153+
}
154+
transportId = req.transport.id;
155+
} else {
156+
req.type = 'webrtc'; //FIXME: For backend compatibility with v3.4 clients.
157+
req.transport = { type : 'webrtc', id : subscription_id };
158+
if (req.transportId) {
159+
req.transport.id = req.transportId;
160+
}
149161
}
150-
transportId = req.transportId;
162+
transportId = req.transport.id;
151163
return portal.subscribe(clientId, subscription_id, req);
152164
}).then((result) => {
153165
safeCall(callback, 'ok', {id: subscription_id, transportId});

source/portal/versions/requestFormatV1-2.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const SubscriptionRequest = {
9191
},
9292
additionalProperties: false,
9393
},
94-
'data': {type: 'boolean'}
94+
'data': { $ref: '#/definitions/DataSubOptions' },
9595
},
9696
additionalProperties: false,
9797
required: ['media']
@@ -100,7 +100,7 @@ const SubscriptionRequest = {
100100

101101
definitions: {
102102
'MediaSubOptions': {
103-
type: 'object',
103+
type: ['object', 'null'],
104104
properties: {
105105
'tracks': {
106106
type: 'array',
@@ -125,6 +125,15 @@ const SubscriptionRequest = {
125125
required: ['tracks']
126126
},
127127

128+
'DataSubOptions': {
129+
type: 'object',
130+
properties: {
131+
'from': {type: 'string'}
132+
},
133+
additionalProperties: false,
134+
required: ['from']
135+
},
136+
128137
'AudioFormat': {
129138
type: 'object',
130139
properties: {

0 commit comments

Comments
 (0)