Switch spaces for tabs in indentation
This commit is contained in:
@@ -11,27 +11,22 @@ import UIKit
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
return true
|
||||
}
|
||||
|
||||
// MARK: UISceneSession Lifecycle
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
return true
|
||||
}
|
||||
|
||||
// MARK: UISceneSession Lifecycle
|
||||
|
||||
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
||||
// Called when a new scene session is being created.
|
||||
// Use this method to select a configuration to create the new scene with.
|
||||
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
|
||||
// Called when the user discards a scene session.
|
||||
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
|
||||
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
||||
// Called when a new scene session is being created.
|
||||
// Use this method to select a configuration to create the new scene with.
|
||||
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
|
||||
// Called when the user discards a scene session.
|
||||
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
|
||||
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,209 +11,194 @@ import AVFoundation
|
||||
|
||||
class CallExampleContext : ObservableObject
|
||||
{
|
||||
var mCore: Core! // We need a Core for... anything, basically
|
||||
@Published var coreVersion: String = Core.getVersion
|
||||
|
||||
/*------------ Logs related variables ------------------------*/
|
||||
var loggingUnit = LoggingUnit()
|
||||
|
||||
/*------------ Call tutorial related variables ---------------*/
|
||||
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 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 loggedIn: Bool = false
|
||||
var mCore: Core! // We need a Core for... anything, basically
|
||||
@Published var coreVersion: String = Core.getVersion
|
||||
|
||||
|
||||
init()
|
||||
{
|
||||
mCallStateTracer.tutorialContext = self
|
||||
mRegistrationDelegate.tutorialContext = self
|
||||
|
||||
// Initialize Linphone Core
|
||||
try? mCore = Factory.Instance.createCore(configPath: "", factoryConfigPath: "", systemContext: nil)
|
||||
/*------------ Logs related variables ------------------------*/
|
||||
var loggingUnit = LoggingUnit()
|
||||
|
||||
// main loop for receiving notifications and doing background linphonecore work:
|
||||
mCore.autoIterateEnabled = true
|
||||
mCore.callkitEnabled = true
|
||||
mCore.pushNotificationEnabled = true
|
||||
try? mCore.start()
|
||||
|
||||
mVideoDevices = mCore.videoDevicesList
|
||||
/*------------ Call tutorial related variables ---------------*/
|
||||
let mCallStateTracer = CallStateDelegate()
|
||||
var mCall: Call!
|
||||
var proxy_cfg : ProxyConfig!
|
||||
var mVideoDevices : [String] = []
|
||||
var mUsedVideoDeviceId : Int = 0
|
||||
var callAlreadyStopped = false;
|
||||
|
||||
mCore.addDelegate(delegate: mCallStateTracer)
|
||||
mCore.addDelegate(delegate: mRegistrationDelegate)
|
||||
|
||||
}
|
||||
|
||||
func registrationExample()
|
||||
{
|
||||
if (!loggedIn)
|
||||
{
|
||||
do {
|
||||
proxy_cfg = try createAndInitializeProxyConfig(core : mCore, identity: id, password: passwd)
|
||||
try mCore.addProxyConfig(config: proxy_cfg!)
|
||||
if ( mCore.defaultProxyConfig == nil)
|
||||
{
|
||||
// IMPORTANT : default proxy config setting MUST be done AFTER adding the config to the core !
|
||||
mCore.defaultProxyConfig = proxy_cfg
|
||||
}
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 {
|
||||
if (!callRunning)
|
||||
{
|
||||
let callDest = try Factory.Instance.createAddress(addr: dest)
|
||||
// Place an outgoing call
|
||||
mCall = mCore.inviteAddressWithParams(addr: callDest, params: try createCallParams())
|
||||
|
||||
if (mCall == nil) {
|
||||
print("Could not place call to \(dest)\n")
|
||||
} else {
|
||||
print("Call to \(dest) is in progress...")
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try mCall.update(params: createCallParams())
|
||||
}
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Terminate a call
|
||||
func stopCall()
|
||||
{
|
||||
if ((callRunning || isCallIncoming) && mCall.state != Call.State.End)
|
||||
{
|
||||
callAlreadyStopped = true;
|
||||
// terminate the call
|
||||
print("Terminating the call...\n")
|
||||
do {
|
||||
try mCall.terminate()
|
||||
} catch
|
||||
{
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func microphoneMuteToggle()
|
||||
{
|
||||
if (callRunning)
|
||||
{
|
||||
mCall.microphoneMuted = !mCall.microphoneMuted
|
||||
}
|
||||
}
|
||||
|
||||
func speaker()
|
||||
{
|
||||
speakerEnabled = !speakerEnabled
|
||||
do {
|
||||
try AVAudioSession.sharedInstance().overrideOutputAudioPort(
|
||||
speakerEnabled ?
|
||||
AVAudioSession.PortOverride.speaker : AVAudioSession.PortOverride.none
|
||||
)
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
|
||||
func changeVideoDevice()
|
||||
{
|
||||
mUsedVideoDeviceId = (mUsedVideoDeviceId + 1) % mVideoDevices.count
|
||||
@Published var audioEnabled : Bool = true
|
||||
@Published var videoEnabled : Bool = false
|
||||
@Published var speakerEnabled : Bool = false
|
||||
@Published var callRunning : Bool = false
|
||||
@Published var isCallIncoming : Bool = false
|
||||
@Published var dest : String = "sip:arguillq@sip.linphone.org"
|
||||
|
||||
do {
|
||||
try mCore.setVideodevice(newValue: mVideoDevices[mUsedVideoDeviceId])
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
|
||||
func acceptCall()
|
||||
{
|
||||
do {
|
||||
try mCall.accept()
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
|
||||
let mRegistrationDelegate = LinphoneRegistrationDelegate()
|
||||
@Published var id : String = "sip:peche5@sip.linphone.org"
|
||||
@Published var passwd : String = "peche5"
|
||||
@Published var loggedIn: Bool = false
|
||||
|
||||
|
||||
init()
|
||||
{
|
||||
mCallStateTracer.tutorialContext = self
|
||||
mRegistrationDelegate.tutorialContext = self
|
||||
|
||||
// Initialize Linphone Core
|
||||
try? mCore = Factory.Instance.createCore(configPath: "", factoryConfigPath: "", systemContext: nil)
|
||||
|
||||
// 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()
|
||||
{
|
||||
if (!loggedIn) {
|
||||
do {
|
||||
proxy_cfg = try createAndInitializeProxyConfig(core : mCore, identity: id, password: passwd)
|
||||
try mCore.addProxyConfig(config: proxy_cfg!)
|
||||
if ( mCore.defaultProxyConfig == nil) {
|
||||
// IMPORTANT : default proxy config setting MUST be done AFTER adding the config to the core !
|
||||
mCore.defaultProxyConfig = proxy_cfg
|
||||
}
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 {
|
||||
if (!callRunning)
|
||||
{
|
||||
let callDest = try Factory.Instance.createAddress(addr: dest)
|
||||
// Place an outgoing call
|
||||
mCall = mCore.inviteAddressWithParams(addr: callDest, params: try createCallParams())
|
||||
|
||||
if (mCall == nil) {
|
||||
print("Could not place call to \(dest)\n")
|
||||
} else {
|
||||
print("Call to \(dest) is in progress...")
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try mCall.update(params: createCallParams())
|
||||
}
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
|
||||
// Terminate a call
|
||||
func stopCall() {
|
||||
if ((callRunning || isCallIncoming) && mCall.state != Call.State.End) {
|
||||
callAlreadyStopped = true;
|
||||
// terminate the call
|
||||
print("Terminating the call...\n")
|
||||
do {
|
||||
try mCall.terminate()
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func microphoneMuteToggle()
|
||||
{
|
||||
if (callRunning) {
|
||||
mCall.microphoneMuted = !mCall.microphoneMuted
|
||||
}
|
||||
}
|
||||
|
||||
func speaker()
|
||||
{
|
||||
speakerEnabled = !speakerEnabled
|
||||
do {
|
||||
try AVAudioSession.sharedInstance().overrideOutputAudioPort(
|
||||
speakerEnabled ?
|
||||
AVAudioSession.PortOverride.speaker : AVAudioSession.PortOverride.none)
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
|
||||
func changeVideoDevice()
|
||||
{
|
||||
mUsedVideoDeviceId = (mUsedVideoDeviceId + 1) % mVideoDevices.count
|
||||
do {
|
||||
try mCore.setVideodevice(newValue: mVideoDevices[mUsedVideoDeviceId])
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
|
||||
func acceptCall()
|
||||
{
|
||||
do {
|
||||
try mCall.accept()
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Callback for actions when a change in the Registration State happens
|
||||
class LinphoneRegistrationDelegate: CoreDelegate {
|
||||
|
||||
var tutorialContext : CallExampleContext!
|
||||
|
||||
override func onRegistrationStateChanged(core lc: Core, proxyConfig cfg: ProxyConfig, state cstate: RegistrationState, message: String?) {
|
||||
print("New registration state \(cstate) for user id \( String(describing: cfg.identityAddress?.asString()))\n")
|
||||
if (cstate == .Ok)
|
||||
{
|
||||
tutorialContext.loggedIn = true
|
||||
}
|
||||
}
|
||||
|
||||
var tutorialContext : CallExampleContext!
|
||||
|
||||
override func onRegistrationStateChanged(core lc: Core, proxyConfig cfg: ProxyConfig, state cstate: RegistrationState, message: String?) {
|
||||
print("New registration state \(cstate) for user id \( String(describing: cfg.identityAddress?.asString()))\n")
|
||||
if (cstate == .Ok) {
|
||||
tutorialContext.loggedIn = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Callback for actions when a change in the Call State happens
|
||||
class CallStateDelegate: CoreDelegate {
|
||||
|
||||
var tutorialContext : CallExampleContext!
|
||||
|
||||
override func onCallStateChanged(core lc: Core, call: Call, state cstate: Call.State, message: String) {
|
||||
print("CallTrace - \(cstate)")
|
||||
if (cstate == .IncomingReceived) {
|
||||
// We're being called by someone
|
||||
tutorialContext.mCall = call
|
||||
tutorialContext.isCallIncoming = true
|
||||
|
||||
} else if (cstate == .OutgoingRinging) {
|
||||
// We're calling someone
|
||||
tutorialContext.callRunning = true
|
||||
} else if (cstate == .End) {
|
||||
// Call has been terminated by any side
|
||||
tutorialContext.callRunning = false
|
||||
tutorialContext.isCallIncoming = false
|
||||
} else if (cstate == .StreamsRunning)
|
||||
{
|
||||
// Call has successfully began
|
||||
tutorialContext.callRunning = true
|
||||
} else if (cstate == .PushIncomingReceived)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
var tutorialContext : CallExampleContext!
|
||||
|
||||
override func onCallStateChanged(core lc: Core, call: Call, state cstate: Call.State, message: String) {
|
||||
print("CallTrace - \(cstate)")
|
||||
if (cstate == .IncomingReceived) {
|
||||
// We're being called by someone
|
||||
tutorialContext.mCall = call
|
||||
tutorialContext.isCallIncoming = true
|
||||
} else if (cstate == .OutgoingRinging) {
|
||||
// We're calling someone
|
||||
tutorialContext.callRunning = true
|
||||
} else if (cstate == .End) {
|
||||
// Call has been terminated by any side
|
||||
tutorialContext.callRunning = false
|
||||
tutorialContext.isCallIncoming = false
|
||||
} else if (cstate == .StreamsRunning) {
|
||||
// Call has successfully began
|
||||
tutorialContext.callRunning = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,162 +9,158 @@
|
||||
import SwiftUI
|
||||
|
||||
struct ContentView: View {
|
||||
|
||||
@ObservedObject var tutorialContext = CallExampleContext()
|
||||
|
||||
func getCallButtonText() -> String
|
||||
{
|
||||
if (tutorialContext.callRunning) {
|
||||
return "Update Call"
|
||||
}
|
||||
else if (tutorialContext.isCallIncoming) {
|
||||
return "Answer"
|
||||
}
|
||||
else {
|
||||
return "Call"
|
||||
}
|
||||
}
|
||||
|
||||
func callStateString() -> String
|
||||
{
|
||||
if (tutorialContext.callRunning) {
|
||||
return "Call running"
|
||||
}
|
||||
else if (tutorialContext.isCallIncoming) {
|
||||
return "Incoming call"
|
||||
}
|
||||
else {
|
||||
return "No Call"
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
Group {
|
||||
HStack {
|
||||
Text("Identity :")
|
||||
.font(.subheadline)
|
||||
TextField("", text : $tutorialContext.id)
|
||||
.textFieldStyle(RoundedBorderTextFieldStyle())
|
||||
}
|
||||
HStack {
|
||||
Text("Password :")
|
||||
.font(.subheadline)
|
||||
TextField("", text : $tutorialContext.passwd)
|
||||
.textFieldStyle(RoundedBorderTextFieldStyle())
|
||||
}
|
||||
HStack {
|
||||
Button(action: tutorialContext.registrationExample)
|
||||
{
|
||||
Text("Login")
|
||||
.font(.largeTitle)
|
||||
.foregroundColor(Color.white)
|
||||
.frame(width: 90.0, height: 42.0)
|
||||
.background(Color.gray)
|
||||
}
|
||||
Text("Login State : ")
|
||||
.font(.footnote)
|
||||
Text(tutorialContext.loggedIn ? "Logged in" : "Unregistered")
|
||||
.font(.footnote)
|
||||
.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)
|
||||
}
|
||||
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)
|
||||
HStack {
|
||||
Text("Speaker :")
|
||||
Button(action: tutorialContext.speaker)
|
||||
{
|
||||
Text(tutorialContext.speakerEnabled ? "ON" : "OFF")
|
||||
.font(.title)
|
||||
.foregroundColor(Color.white)
|
||||
.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)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.top, 5.0)
|
||||
Spacer()
|
||||
VStack {
|
||||
HStack {
|
||||
Button(action: {
|
||||
if (self.tutorialContext.isCallIncoming) {
|
||||
self.tutorialContext.acceptCall()
|
||||
}
|
||||
else {
|
||||
self.tutorialContext.outgoingCallExample()
|
||||
}
|
||||
})
|
||||
{
|
||||
Text(getCallButtonText())
|
||||
.font(.largeTitle)
|
||||
.foregroundColor(Color.white)
|
||||
.frame(width: 180.0, height: 42.0)
|
||||
.background(Color.green)
|
||||
}
|
||||
Button(action: tutorialContext.stopCall) {
|
||||
Text(tutorialContext.isCallIncoming ? "Decline" : "Stop Call")
|
||||
.font(.largeTitle)
|
||||
.foregroundColor(Color.white)
|
||||
.frame(width: 180.0, height: 42.0)
|
||||
.background(Color.red)
|
||||
}
|
||||
}
|
||||
HStack {
|
||||
Text(callStateString())
|
||||
.font(.footnote)
|
||||
.foregroundColor(tutorialContext.callRunning || tutorialContext.isCallIncoming ? Color.green : Color.black)
|
||||
}
|
||||
.padding(.top)
|
||||
}
|
||||
Spacer()
|
||||
Group {
|
||||
Toggle(isOn: $tutorialContext.loggingUnit.logsEnabled.value) {
|
||||
Text("Logs collection")
|
||||
.multilineTextAlignment(.trailing)
|
||||
}
|
||||
Text("Core Version is \(tutorialContext.coreVersion)")
|
||||
.font(.footnote)
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
|
||||
@ObservedObject var tutorialContext = CallExampleContext()
|
||||
|
||||
func getCallButtonText() -> String {
|
||||
if (tutorialContext.callRunning) {
|
||||
return "Update Call"
|
||||
}
|
||||
else if (tutorialContext.isCallIncoming) {
|
||||
return "Answer"
|
||||
}
|
||||
else {
|
||||
return "Call"
|
||||
}
|
||||
}
|
||||
|
||||
func callStateString() -> String {
|
||||
if (tutorialContext.callRunning) {
|
||||
return "Call running"
|
||||
}
|
||||
else if (tutorialContext.isCallIncoming) {
|
||||
return "Incoming call"
|
||||
}
|
||||
else {
|
||||
return "No Call"
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
Group {
|
||||
HStack {
|
||||
Text("Identity :")
|
||||
.font(.subheadline)
|
||||
TextField("", text : $tutorialContext.id)
|
||||
.textFieldStyle(RoundedBorderTextFieldStyle())
|
||||
}
|
||||
HStack {
|
||||
Text("Password :")
|
||||
.font(.subheadline)
|
||||
TextField("", text : $tutorialContext.passwd)
|
||||
.textFieldStyle(RoundedBorderTextFieldStyle())
|
||||
}
|
||||
HStack {
|
||||
Button(action: tutorialContext.registrationExample)
|
||||
{
|
||||
Text("Login")
|
||||
.font(.largeTitle)
|
||||
.foregroundColor(Color.white)
|
||||
.frame(width: 90.0, height: 42.0)
|
||||
.background(Color.gray)
|
||||
}
|
||||
Text("Login State : ")
|
||||
.font(.footnote)
|
||||
Text(tutorialContext.loggedIn ? "Logged in" : "Unregistered")
|
||||
.font(.footnote)
|
||||
.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)
|
||||
}
|
||||
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)
|
||||
HStack {
|
||||
Text("Speaker :")
|
||||
Button(action: tutorialContext.speaker)
|
||||
{
|
||||
Text(tutorialContext.speakerEnabled ? "ON" : "OFF")
|
||||
.font(.title)
|
||||
.foregroundColor(Color.white)
|
||||
.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)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.top, 5.0)
|
||||
Spacer()
|
||||
VStack {
|
||||
HStack {
|
||||
Button(action: {
|
||||
if (self.tutorialContext.isCallIncoming) {
|
||||
self.tutorialContext.acceptCall()
|
||||
}
|
||||
else {
|
||||
self.tutorialContext.outgoingCallExample()
|
||||
}
|
||||
})
|
||||
{
|
||||
Text(getCallButtonText())
|
||||
.font(.largeTitle)
|
||||
.foregroundColor(Color.white)
|
||||
.frame(width: 180.0, height: 42.0)
|
||||
.background(Color.green)
|
||||
}
|
||||
Button(action: tutorialContext.stopCall) {
|
||||
Text(tutorialContext.isCallIncoming ? "Decline" : "Stop Call")
|
||||
.font(.largeTitle)
|
||||
.foregroundColor(Color.white)
|
||||
.frame(width: 180.0, height: 42.0)
|
||||
.background(Color.red)
|
||||
}
|
||||
}
|
||||
HStack {
|
||||
Text(callStateString())
|
||||
.font(.footnote)
|
||||
.foregroundColor(tutorialContext.callRunning || tutorialContext.isCallIncoming ? Color.green : Color.black)
|
||||
}.padding(.top)
|
||||
}
|
||||
Spacer()
|
||||
Group {
|
||||
Toggle(isOn: $tutorialContext.loggingUnit.logsEnabled.value) {
|
||||
Text("Logs collection").multilineTextAlignment(.trailing)
|
||||
}
|
||||
Text("Core Version is \(tutorialContext.coreVersion)")
|
||||
.font(.footnote)
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
|
||||
struct ContentView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ContentView()
|
||||
}
|
||||
static var previews: some View {
|
||||
ContentView()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,54 +11,51 @@ import SwiftUI
|
||||
|
||||
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
|
||||
var window: UIWindow?
|
||||
var window: UIWindow?
|
||||
|
||||
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
||||
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
|
||||
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
|
||||
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
||||
|
||||
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
||||
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
|
||||
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
|
||||
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
||||
// Create the SwiftUI view that provides the window contents.
|
||||
let contentView = ContentView()
|
||||
|
||||
// Create the SwiftUI view that provides the window contents.
|
||||
let contentView = ContentView()
|
||||
// Use a UIHostingController as window root view controller.
|
||||
if let windowScene = scene as? UIWindowScene {
|
||||
let window = UIWindow(windowScene: windowScene)
|
||||
window.rootViewController = UIHostingController(rootView: contentView)
|
||||
self.window = window
|
||||
window.makeKeyAndVisible()
|
||||
}
|
||||
}
|
||||
|
||||
// Use a UIHostingController as window root view controller.
|
||||
if let windowScene = scene as? UIWindowScene {
|
||||
let window = UIWindow(windowScene: windowScene)
|
||||
window.rootViewController = UIHostingController(rootView: contentView)
|
||||
self.window = window
|
||||
window.makeKeyAndVisible()
|
||||
}
|
||||
}
|
||||
func sceneDidDisconnect(_ scene: UIScene) {
|
||||
// Called as the scene is being released by the system.
|
||||
// This occurs shortly after the scene enters the background, or when its session is discarded.
|
||||
// Release any resources associated with this scene that can be re-created the next time the scene connects.
|
||||
// The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).
|
||||
}
|
||||
|
||||
func sceneDidDisconnect(_ scene: UIScene) {
|
||||
// Called as the scene is being released by the system.
|
||||
// This occurs shortly after the scene enters the background, or when its session is discarded.
|
||||
// Release any resources associated with this scene that can be re-created the next time the scene connects.
|
||||
// The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).
|
||||
}
|
||||
func sceneDidBecomeActive(_ scene: UIScene) {
|
||||
// Called when the scene has moved from an inactive state to an active state.
|
||||
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
|
||||
}
|
||||
|
||||
func sceneDidBecomeActive(_ scene: UIScene) {
|
||||
// Called when the scene has moved from an inactive state to an active state.
|
||||
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
|
||||
}
|
||||
|
||||
func sceneWillResignActive(_ scene: UIScene) {
|
||||
// Called when the scene will move from an active state to an inactive state.
|
||||
// This may occur due to temporary interruptions (ex. an incoming phone call).
|
||||
}
|
||||
|
||||
func sceneWillEnterForeground(_ scene: UIScene) {
|
||||
// Called as the scene transitions from the background to the foreground.
|
||||
// Use this method to undo the changes made on entering the background.
|
||||
}
|
||||
|
||||
func sceneDidEnterBackground(_ scene: UIScene) {
|
||||
// Called as the scene transitions from the foreground to the background.
|
||||
// Use this method to save data, release shared resources, and store enough scene-specific state information
|
||||
// to restore the scene back to its current state.
|
||||
}
|
||||
func sceneWillResignActive(_ scene: UIScene) {
|
||||
// Called when the scene will move from an active state to an inactive state.
|
||||
// This may occur due to temporary interruptions (ex. an incoming phone call).
|
||||
}
|
||||
|
||||
func sceneWillEnterForeground(_ scene: UIScene) {
|
||||
// Called as the scene transitions from the background to the foreground.
|
||||
// Use this method to undo the changes made on entering the background.
|
||||
}
|
||||
|
||||
func sceneDidEnterBackground(_ scene: UIScene) {
|
||||
// Called as the scene transitions from the foreground to the background.
|
||||
// Use this method to save data, release shared resources, and store enough scene-specific state information
|
||||
// to restore the scene back to its current state.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,54 +7,52 @@ import linphonesw
|
||||
|
||||
|
||||
func createAndInitializeProxyConfig(core: Core, identity: String, password: String) throws -> ProxyConfig {
|
||||
let factory = Factory.Instance
|
||||
let proxy_cfg = try core.createProxyConfig()
|
||||
let address = try factory.createAddress(addr: identity)
|
||||
let info = try factory.createAuthInfo(username: address.username, userid: "", passwd: password, ha1: "", realm: "", domain: address.domain)
|
||||
core.addAuthInfo(info: info)
|
||||
|
||||
try proxy_cfg.setIdentityaddress(newValue: address)
|
||||
let server_addr = "sip:" + address.domain + ";transport=tls"
|
||||
try proxy_cfg.setServeraddr(newValue: server_addr)
|
||||
proxy_cfg.registerEnabled = true
|
||||
|
||||
return proxy_cfg
|
||||
let factory = Factory.Instance
|
||||
let proxy_cfg = try core.createProxyConfig()
|
||||
let address = try factory.createAddress(addr: identity)
|
||||
let info = try factory.createAuthInfo(username: address.username, userid: "", passwd: password, ha1: "", realm: "", domain: address.domain)
|
||||
core.addAuthInfo(info: info)
|
||||
|
||||
try proxy_cfg.setIdentityaddress(newValue: address)
|
||||
let server_addr = "sip:" + address.domain + ";transport=tls"
|
||||
try proxy_cfg.setServeraddr(newValue: server_addr)
|
||||
proxy_cfg.registerEnabled = true
|
||||
|
||||
return proxy_cfg
|
||||
}
|
||||
|
||||
|
||||
class LoggingUnit
|
||||
{
|
||||
class BoolHolder : ObservableObject
|
||||
{
|
||||
@Published var value : Bool
|
||||
init(val : Bool)
|
||||
{
|
||||
value = val
|
||||
}
|
||||
}
|
||||
|
||||
class LinphoneLoggingServiceImpl: LoggingServiceDelegate {
|
||||
var logsEnabled : BoolHolder!
|
||||
override func onLogMessageWritten(logService: LoggingService, domain: String, level: LogLevel, message: String) {
|
||||
if (logsEnabled.value)
|
||||
{
|
||||
print("Logging service log: \(message)s\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var logsEnabled : BoolHolder
|
||||
var logDelegate : LinphoneLoggingServiceImpl
|
||||
var log : LoggingService
|
||||
|
||||
init()
|
||||
{
|
||||
logsEnabled = BoolHolder(val: true)
|
||||
logDelegate = LinphoneLoggingServiceImpl()
|
||||
logDelegate.logsEnabled = logsEnabled;
|
||||
log = LoggingService.Instance
|
||||
log.addDelegate(delegate: logDelegate)
|
||||
log.logLevel = LogLevel.Debug
|
||||
Factory.Instance.enableLogCollection(state: LogCollectionState.Enabled)
|
||||
}
|
||||
class BoolHolder : ObservableObject
|
||||
{
|
||||
@Published var value : Bool
|
||||
init(val : Bool) {
|
||||
value = val
|
||||
}
|
||||
}
|
||||
|
||||
class LinphoneLoggingServiceImpl: LoggingServiceDelegate {
|
||||
var logsEnabled : BoolHolder!
|
||||
override func onLogMessageWritten(logService: LoggingService, domain: String, level: LogLevel, message: String) {
|
||||
if (logsEnabled.value) {
|
||||
print("Logging service log: \(message)s\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var logsEnabled : BoolHolder
|
||||
var logDelegate : LinphoneLoggingServiceImpl
|
||||
var log : LoggingService
|
||||
|
||||
init()
|
||||
{
|
||||
logsEnabled = BoolHolder(val: true)
|
||||
logDelegate = LinphoneLoggingServiceImpl()
|
||||
logDelegate.logsEnabled = logsEnabled;
|
||||
log = LoggingService.Instance
|
||||
log.addDelegate(delegate: logDelegate)
|
||||
log.logLevel = LogLevel.Debug
|
||||
Factory.Instance.enableLogCollection(state: LogCollectionState.Enabled)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user