feat: add sendDtmf method to send DTMF tones during a call
This commit is contained in:
parent
b95baa6799
commit
f64284f963
9 changed files with 84 additions and 1 deletions
|
|
@ -209,7 +209,21 @@ public class LiblinphoneFlutterPlugin: NSObject, FlutterPlugin {
|
|||
case "syncCurrentState" :
|
||||
linphoneBridge.syncCurrentState()
|
||||
result(true)
|
||||
|
||||
case "sendDtmf":
|
||||
guard let args = call.arguments as? [String: Any],
|
||||
let tone = args["tone"] as? String else {
|
||||
result(FlutterError(
|
||||
code: "INVALID_ARGUMENTS",
|
||||
message: "Missing required arguments",
|
||||
details: nil
|
||||
))
|
||||
return
|
||||
}
|
||||
|
||||
let success = linphoneBridge.sendDtmf(tone: tone)
|
||||
result(success)
|
||||
|
||||
default:
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ class LinphoneBridge {
|
|||
guard let params = currentCall?.currentParams else {
|
||||
return .unknown
|
||||
}
|
||||
|
||||
|
||||
if params.videoEnabled {
|
||||
return .video
|
||||
} else {
|
||||
|
|
@ -249,6 +249,25 @@ class LinphoneBridge {
|
|||
}
|
||||
}
|
||||
|
||||
func sendDtmf(tone: String) -> Bool {
|
||||
guard let call = currentCall else {
|
||||
return false
|
||||
}
|
||||
|
||||
guard !tone.isEmpty else {
|
||||
return false
|
||||
}
|
||||
|
||||
let dtmfChar = tone.first!
|
||||
do {
|
||||
try call.sendDtmf(dtmf: CChar(dtmfChar.asciiValue!))
|
||||
return true
|
||||
} catch {
|
||||
print("Error sending DTMF: \(error)")
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func syncCurrentState() {
|
||||
onRegistrationStateChanged(registrationState.rawValue)
|
||||
onCallStateChanged(callState.rawValue)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue