Skip to content

Commit

Permalink
Merge pull request #770 from cordova-rtc/bug/insertDTMF
Browse files Browse the repository at this point in the history
fix PluginRTCDTMFSender insertDTMF when no senders is available
  • Loading branch information
hthetiot authored Aug 14, 2024
2 parents a8a1c78 + 0852429 commit a37d385
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/PluginRTCDTMFSender.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ class PluginRTCDTMFSender : NSObject {

self.eventListener = eventListener

// TODO check if new rtcRtpSender can be used one Unified-Plan merged
//let streamIds = [streamId]
//self.rtcRtpSender = rtcPeerConnection.add(track, streamIds: streamIds);
self.rtcRtpSender = rtcPeerConnection.senders[0]
if !rtcPeerConnection.senders.isEmpty {
self.rtcRtpSender = rtcPeerConnection.senders[0]
} else {
// TODO check if new rtcRtpSender can be used one Unified-Plan merged
//self.rtcRtpSender = rtcPeerConnection.add(track, streamIds: [streamId]);
}

if self.rtcRtpSender == nil {
NSLog("PluginRTCDTMFSender#init() | rtcPeerConnection.createDTMFSenderForTrack() failed")
Expand All @@ -41,6 +43,12 @@ class PluginRTCDTMFSender : NSObject {
NSLog("PluginRTCDTMFSender#insertDTMF()")

let dtmfSender = self.rtcRtpSender?.dtmfSender

if dtmfSender == nil {
NSLog("RTCDTMFSender#insertDTMF() | RTCDTMFSender.insertDTMF() failed")
return
}

let durationMs = duration / 100
let interToneGapMs = interToneGap / 100
let result = dtmfSender!.insertDtmf(tones, duration: durationMs, interToneGap: interToneGapMs)
Expand Down

0 comments on commit a37d385

Please sign in to comment.