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

Commit 85411ea

Browse files
authored
Fix unexpected behaviour with single pc client (#696)
1 parent 4b58cb6 commit 85411ea

File tree

4 files changed

+38
-36
lines changed

4 files changed

+38
-36
lines changed

source/agent/analytics/videoGstPipeline/binding.pipeline.gyp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
'./VideoGstAnalyzer.cpp',
88
'../../../core/owt_base/MediaFramePipeline.cpp',
99
'../../../core/owt_base/RawTransport.cpp',
10+
'../../../core/common/IOService.cpp',
1011
'./GstInternalOut.cpp',
1112
'./GstInternalIn.cpp',
1213
],

source/agent/conference/conference.js

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,14 @@ var Conference = function (rpcClient, selfRpcId) {
578578
const addStream = (id, locality, media, info) => {
579579
info.origin = streams[id] ? streams[id].info.origin : {isp:"isp", region:"region"};
580580
if (info.analytics && subscriptions[info.analytics]) {
581-
const sourceTrack = subscriptions[info.analytics].media.tracks
582-
.find(t => t.type === 'video');
583-
const sourceId = streams[sourceTrack.from] ? sourceTrack.from : trackOwners[sourceTrack.from];
581+
let sourceId;
582+
if (subscriptions[info.analytics].isInConnecting) {
583+
sourceId = subscriptions[info.analytics].media.video.from;
584+
} else {
585+
const sourceTrack = subscriptions[info.analytics].media.tracks
586+
.find(t => t.type === 'video');
587+
sourceId = streams[sourceTrack.from] ? sourceTrack.from : trackOwners[sourceTrack.from];
588+
}
584589
if (streams[sourceId]) {
585590
info.origin = streams[sourceId].info.origin;
586591
} else {
@@ -1121,6 +1126,9 @@ var Conference = function (rpcClient, selfRpcId) {
11211126
};
11221127

11231128
const isResolutionAvailable = (streamVideo, resolution) => {
1129+
if (!streamVideo.parameters || !streamVideo.parameters.resolution) {
1130+
return true;
1131+
}
11241132
if (streamVideo.parameters && streamVideo.parameters.resolution && isResolutionEqual(streamVideo.parameters.resolution, resolution)) {
11251133
return true;
11261134
}
@@ -1213,29 +1221,31 @@ var Conference = function (rpcClient, selfRpcId) {
12131221
return callback('callback', 'error', 'Participant has not joined');
12141222
}
12151223

1216-
if ((subDesc.media.audio && !participants[participantId].isSubscribePermitted('audio'))
1217-
|| (subDesc.media.video && !participants[participantId].isSubscribePermitted('video'))) {
1218-
return callback('callback', 'error', 'unauthorized');
1224+
let audioTrack = null;
1225+
let videoTrack = null;
1226+
if (subDesc.type === 'webrtc') {
1227+
audioTrack = subDesc.media.tracks.find(t => t.type === 'audio');
1228+
videoTrack = subDesc.media.tracks.find(t => t.type === 'video');
1229+
} else {
1230+
audioTrack = subDesc.media.audio;
1231+
videoTrack = subDesc.media.video;
12191232
}
1220-
if (subDesc.type === 'webrtc' && subDesc.media.tracks) {
1221-
if ((subDesc.media.tracks.find(t => t.type === 'audio')
1222-
&& !participants[participantId].isSubscribePermitted('audio'))
1223-
|| (subDesc.media.tracks.find(t => t.type === 'video')
1224-
&& !participants[participantId].isSubscribePermitted('video'))) {
1225-
return callback('callback', 'error', 'unauthorized');
1226-
}
1233+
1234+
if ((audioTrack && !participants[participantId].isSubscribePermitted('audio'))
1235+
|| (videoTrack && !participants[participantId].isSubscribePermitted('video'))) {
1236+
return callback('callback', 'error', 'unauthorized');
12271237
}
12281238

12291239
if (subscriptions[subscriptionId]) {
12301240
return callback('callback', 'error', 'Subscription exists');
12311241
}
12321242

12331243
var requestError = { message: '' };
1234-
if (subDesc.media.audio && !validateAudioRequest(subDesc.type, subDesc.media.audio, requestError)) {
1244+
if (audioTrack && !validateAudioRequest(subDesc.type, audioTrack, requestError)) {
12351245
return callback('callback', 'error', 'Target audio stream does NOT satisfy:' + requestError.message);
12361246
}
12371247

1238-
if (subDesc.media.video && !validateVideoRequest(subDesc.type, subDesc.media.video, requestError)) {
1248+
if (videoTrack && !validateVideoRequest(subDesc.type, videoTrack, requestError)) {
12391249
return callback('callback', 'error', 'Target video stream does NOT satisfy:' + requestError.message);
12401250
}
12411251

@@ -1253,9 +1263,10 @@ var Conference = function (rpcClient, selfRpcId) {
12531263
const rtcSubInfo = translateRtcSubIfNeeded(subDesc);
12541264
// Set formatPreference
12551265
rtcSubInfo.tracks.forEach(track => {
1256-
const source = streams[track.from].media.tracks.find(t => t.type === track.type);
1266+
const streamId = streams[track.from]? track.from : trackOwners[track.from];
1267+
const source = getStreamTrack(track.from, track.type);
12571268
const formatPreference = {};
1258-
if (streams[track.from].type === 'forward') {
1269+
if (streams[streamId].type === 'forward') {
12591270
formatPreference.preferred = source.format;
12601271
source.optional && source.optional.format && (formatPreference.optional = source.optional.format);
12611272
} else {

source/agent/conference/rtcController.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -313,25 +313,12 @@ class RtcController extends EventEmitter {
313313
const abortData = { direction: operation.direction, owner, reason };
314314
this.emit('session-aborted', sessionId, abortData);
315315
this.operations.delete(sessionId);
316-
317-
let emptyTransport = true;
318-
for (const [id, op] of this.operations) {
319-
if (op.transportId === transport.id) {
320-
emptyTransport = false;
321-
break;
322-
}
323-
}
324-
if (emptyTransport) {
325-
log.debug(`to recycleWorkerNode: ${locality} task:, ${sessionId}`);
326-
const taskConfig = {room: this.roomId, task: sessionId};
327-
return this.rpcReq.recycleWorkerNode(locality.agent, locality.node, taskConfig)
328-
.catch(reason => {
329-
log.debug(`AccessNode not recycled ${locality}, ${reason}`);
330-
})
331-
.then(() => {
332-
this.transports.delete(transport.id);
333-
});
334-
}
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+
});
335322
}
336323
})
337324
.catch(reason => {

source/portal/versions/requestFormatV1-2.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
const {
1111
StreamControlInfo,
12+
SubscriptionControlInfo,
1213
} = require('./requestFormatV1-0');
1314

1415
const Resolution = {
@@ -143,6 +144,7 @@ const SubscriptionRequest = {
143144
};
144145

145146
// SubscriptionControlInfo
147+
/*
146148
const SubscriptionControlInfo = {
147149
type: 'object',
148150
anyOf: [
@@ -197,6 +199,7 @@ const SubscriptionControlInfo = {
197199
}
198200
}
199201
};
202+
*/
200203

201204
module.exports = {
202205
PublicationRequest,

0 commit comments

Comments
 (0)