Skip to content

Commit 5b3d3b0

Browse files
Implement sending DTMF tones through iOS native interface
1 parent 3829674 commit 5b3d3b0

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

Monal/Classes/MLCall.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ @interface MLVoIPProcessor()
8989
-(void) removeCall:(MLCall*) call;
9090
-(void) initWebRTCForPendingCall:(MLCall*) call;
9191
-(void) handleIncomingJMIStanza:(MLXMLNode*) messageNode onAccount:(xmpp*) account;
92+
-(CXCallUpdate*) constructUpdateForCall:(MLCall*) call;
9293
@end
9394

9495
@implementation MLCall
@@ -444,7 +445,13 @@ -(void) setIsConnected:(BOOL) isConnected
444445

445446
//start timer once we are fully connected
446447
if(self.isConnected && self.audioSession != nil)
448+
{
447449
[self startCallDuartionTimer];
450+
dispatch_async(dispatch_get_main_queue(), ^{
451+
//update call info to include the right info about dtmf support
452+
[self.voipProcessor.cxProvider reportCallWithUUID:self.uuid updated:[self.voipProcessor constructUpdateForCall:self]];
453+
});
454+
}
448455
}
449456

450457
#ifdef IS_ALPHA
@@ -493,7 +500,13 @@ -(void) setAudioSession:(AVAudioSession*) audioSession
493500

494501
//start timer once we are fully connected
495502
if(self.isConnected && self.audioSession != nil)
503+
{
496504
[self startCallDuartionTimer];
505+
dispatch_async(dispatch_get_main_queue(), ^{
506+
//update call info to include the right info about dtmf support
507+
[self.voipProcessor.cxProvider reportCallWithUUID:self.uuid updated:[self.voipProcessor constructUpdateForCall:self]];
508+
});
509+
}
497510
}
498511
}
499512
-(AVAudioSession*) audioSession

Monal/Classes/MLVoIPProcessor.m

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,25 @@ -(void) provider:(CXProvider*) provider performAnswerCallAction:(CXAnswerCallAct
704704
[appDelegate.activeChats presentCall:call];
705705
}
706706

707+
-(void) provider:(CXProvider*) provider performPlayDTMFCallAction:(CXPlayDTMFCallAction*) action
708+
{
709+
MLCall* call = [self getCallForUUID:action.callUUID];
710+
DDLogDebug(@"CXProvider: performPlayDTMFCallAction with provider=%@, performPlayDTMFCallAction=%@, pendingCallsInfo: %@", provider, action, call);
711+
if(call == nil)
712+
{
713+
DDLogWarn(@"Pending call not present anymore: %@", (@{
714+
@"provider": provider,
715+
@"action": action,
716+
@"uuid": action.callUUID,
717+
}));
718+
[action fail];
719+
return;
720+
}
721+
722+
[call sendDtmf:action.digits];
723+
[action fulfill];
724+
}
725+
707726
-(void) provider:(CXProvider*) provider performEndCallAction:(CXEndCallAction*) action
708727
{
709728
MLCall* call = [self getCallForUUID:action.callUUID];
@@ -804,7 +823,7 @@ -(CXCallUpdate*) constructUpdateForCall:(MLCall*) call
804823
CXCallUpdate* update = [CXCallUpdate new];
805824
update.remoteHandle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:call.contact.contactJid];
806825
update.localizedCallerName = call.contact.contactDisplayName;
807-
update.supportsDTMF = NO;
826+
update.supportsDTMF = call.canSendDtmf;
808827
update.hasVideo = call.callType == MLCallTypeVideo;
809828
update.supportsHolding = NO;
810829
update.supportsGrouping = NO;

0 commit comments

Comments
 (0)