From 8d234d6634d941e9459223605f34ee1e1ce532e8 Mon Sep 17 00:00:00 2001 From: QuentinArguillere Date: Tue, 25 Aug 2020 15:37:59 +0200 Subject: [PATCH] Remove video-related parts of the CallTutorial --- .../CallTutorial/CallExample.swift | 40 ++------------- .../CallTutorial/ContentView.swift | 51 +++++++------------ 2 files changed, 22 insertions(+), 69 deletions(-) diff --git a/swift/CallTutorial/CallTutorial/CallExample.swift b/swift/CallTutorial/CallTutorial/CallExample.swift index 8ceabf1..de9d2f2 100644 --- a/swift/CallTutorial/CallTutorial/CallExample.swift +++ b/swift/CallTutorial/CallTutorial/CallExample.swift @@ -21,20 +21,17 @@ class CallExampleContext : ObservableObject let mCallStateTracer = CallStateDelegate() var mCall: Call! var proxy_cfg : ProxyConfig! - var mVideoDevices : [String] = [] - var mUsedVideoDeviceId : Int = 0 var callAlreadyStopped = false; - @Published var audioEnabled : Bool = true - @Published var videoEnabled : Bool = false @Published var speakerEnabled : Bool = false + @Published var microphoneMuted : Bool = false @Published var callRunning : Bool = false @Published var isCallIncoming : Bool = false @Published var dest : String = "sip:arguillq@sip.linphone.org" let mRegistrationDelegate = LinphoneRegistrationDelegate() - @Published var id : String = "sip:peche5@sip.linphone.org" - @Published var passwd : String = "peche5" + @Published var id : String = "sip:quetindev@sip.linphone.org" + @Published var passwd : String = "dev" @Published var loggedIn: Bool = false @@ -48,16 +45,10 @@ class CallExampleContext : ObservableObject // main loop for receiving notifications and doing background linphonecore work: mCore.autoIterateEnabled = true - mCore.callkitEnabled = true - mCore.pushNotificationEnabled = true - mCore.disableRecordOnMute = true try? mCore.start() - mVideoDevices = mCore.videoDevicesList - mCore.addDelegate(delegate: mCallStateTracer) mCore.addDelegate(delegate: mRegistrationDelegate) - } func registrationExample() @@ -78,14 +69,6 @@ class CallExampleContext : ObservableObject } - func createCallParams() throws -> CallParams { - let callParams = try mCore.createCallParams(call: nil) - callParams.videoEnabled = videoEnabled; - callParams.audioEnabled = audioEnabled; - - return callParams - } - // Initiate a call func outgoingCallExample() { do { @@ -93,7 +76,7 @@ class CallExampleContext : ObservableObject { let callDest = try Factory.Instance.createAddress(addr: dest) // Place an outgoing call - mCall = mCore.inviteAddressWithParams(addr: callDest, params: try createCallParams()) + mCall = mCore.inviteAddressWithParams(addr: callDest, params: try mCore.createCallParams(call: nil)) if (mCall == nil) { print("Could not place call to \(dest)\n") @@ -101,10 +84,6 @@ class CallExampleContext : ObservableObject print("Call to \(dest) is in progress...") } } - else - { - try mCall.update(params: createCallParams()) - } } catch { print(error) } @@ -128,6 +107,7 @@ class CallExampleContext : ObservableObject { if (callRunning) { mCall.microphoneMuted = !mCall.microphoneMuted + microphoneMuted = mCall.microphoneMuted } } @@ -143,16 +123,6 @@ class CallExampleContext : ObservableObject } } - func changeVideoDevice() - { - mUsedVideoDeviceId = (mUsedVideoDeviceId + 1) % mVideoDevices.count - do { - try mCore.setVideodevice(newValue: mVideoDevices[mUsedVideoDeviceId]) - } catch { - print(error) - } - } - func acceptCall() { do { diff --git a/swift/CallTutorial/CallTutorial/ContentView.swift b/swift/CallTutorial/CallTutorial/ContentView.swift index d4c69f0..fb302c8 100644 --- a/swift/CallTutorial/CallTutorial/ContentView.swift +++ b/swift/CallTutorial/CallTutorial/ContentView.swift @@ -67,32 +67,13 @@ struct ContentView: View { .foregroundColor(tutorialContext.loggedIn ? Color.green : Color.black) } } - VStack(spacing: 0.0) { - Text("Call Settings") - .font(.largeTitle) - .padding(.top, 5) - HStack { - Text("Call destination :") - TextField("", text : $tutorialContext.dest) - .textFieldStyle(RoundedBorderTextFieldStyle()) - } - .padding(.top, 5) + HStack { + Text("Call destination :") + TextField("", text : $tutorialContext.dest) + .textFieldStyle(RoundedBorderTextFieldStyle()) } - VStack(alignment: .leading) { - Toggle(isOn: $tutorialContext.audioEnabled) { - Text("Audio") - }.frame(width : 140.0) - Toggle(isOn: $tutorialContext.videoEnabled) { - Text("Video") - }.frame(width : 140.0) - Button(action: tutorialContext.changeVideoDevice) - { - Text(" Change camera ") - .font(.title) - .foregroundColor(Color.white) - .background(Color.gray) - } - .padding(.vertical) + .padding(.top, 5) + VStack { HStack { Text("Speaker :") Button(action: tutorialContext.speaker) @@ -103,17 +84,19 @@ struct ContentView: View { .frame(width: 60.0, height: 30.0) .background(Color.gray) } - Spacer() - Button(action: tutorialContext.microphoneMuteToggle) { - Text("Mute Mic") - .font(.largeTitle) - .foregroundColor(Color.white) - .frame(width: 180.0, height: 42.0) - .background(Color.red) - } } + HStack { + Text("Microphone :") + Button(action: tutorialContext.microphoneMuteToggle) + { + Text(tutorialContext.microphoneMuted ? "Unmute" : "Mute") + .font(.title) + .foregroundColor(Color.white) + .frame(width: 110.0, height: 30.0) + .background(Color.gray) + } + }.padding(.top) } - .padding(.top, 5.0) Spacer() VStack { HStack {