Skip to content

Commit e9e0902

Browse files
Handle mutliple jingle candidates in one single transport-info message
1 parent 7093c9f commit e9e0902

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

Monal/Classes/MLCall.m

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,16 +1367,44 @@ -(void) processIncomingICECandidate:(NSNotification*) notification
13671367
return;
13681368
}
13691369

1370+
//always fake candidate iqs to only contain one single candidate, even if multiple ones are listed (seems to be allowed as per XEP-0176)
1371+
NSMutableArray<XMPPIQ*>* candidates = [NSMutableArray new];
1372+
for(MLXMLNode* content in [iqNode find:@"{urn:xmpp:jingle:1}jingle/content"])
1373+
{
1374+
MLXMLNode* transport = [content findFirst:@"{urn:xmpp:jingle:transports:ice-udp:1}transport"];
1375+
for(MLXMLNode* candidate in [transport find:@"{urn:xmpp:jingle:transports:ice-udp:1}candidate"])
1376+
{
1377+
XMPPIQ* fakeCandidateIQ = [[XMPPIQ alloc] initWithType:kiqSetType];
1378+
fakeCandidateIQ.from = self.fullRemoteJid;
1379+
fakeCandidateIQ.to = self.account.connectionProperties.identity.fullJid;
1380+
MLXMLNode* shallowTransport = [transport shallowCopyWithData:YES];
1381+
[shallowTransport addChildNode:[transport removeChildNode:candidate]];
1382+
MLXMLNode* shallowContent = [content shallowCopyWithData:YES];
1383+
[shallowContent addChildNode:shallowTransport];
1384+
[fakeCandidateIQ addChildNode:[[MLXMLNode alloc] initWithElement:@"jingle" andNamespace:@"urn:xmpp:jingle:1" withAttributes:@{
1385+
@"action": @"transport-info",
1386+
@"sid": self.jmiid,
1387+
} andChildren:@[shallowContent] andData:nil]];
1388+
DDLogDebug(@"Adding faked incoming ICE candidate iq to candidates list: %@", fakeCandidateIQ);
1389+
[candidates addObject:fakeCandidateIQ];
1390+
}
1391+
}
1392+
13701393
@synchronized(self.candidateQueueLock) {
13711394
//queue candidate if sdp offer or answer have not been processed yet
13721395
if(self.remoteSDP == nil || self.localSDP == nil)
13731396
{
1374-
DDLogDebug(@"Adding incoming ICE candidate iq to candidate queue: %@", iqNode);
1375-
[self.incomingCandidateQueue addObject:iqNode];
1397+
for(XMPPIQ* candidateIq in candidates)
1398+
{
1399+
DDLogDebug(@"Adding incoming ICE candidate iq to candidate queue: %@", candidateIq);
1400+
[self.incomingCandidateQueue addObject:candidateIq];
1401+
}
13761402
return;
13771403
}
13781404
}
1379-
[self processRemoteICECandidate:iqNode];
1405+
1406+
for(XMPPIQ* candidateIq in candidates)
1407+
[self processRemoteICECandidate:candidateIq];
13801408
}
13811409

13821410
-(void) processRemoteICECandidate:(XMPPIQ*) iqNode

0 commit comments

Comments
 (0)