diff --git a/swift/HelloLinphone/HelloLinphone/ContentView.swift b/swift/HelloLinphone/HelloLinphone/ContentView.swift index 71d5105..47508fb 100644 --- a/swift/HelloLinphone/HelloLinphone/ContentView.swift +++ b/swift/HelloLinphone/HelloLinphone/ContentView.swift @@ -50,6 +50,8 @@ class LinphoneTutorialContext : ObservableObject /*------------ Call tutorial related variables ---------------*/ let mPhoneStateTracer = LinconePhoneStateTracker() var mCall: Call! + var mVideoDevices : [String] = [] + var mUsedVideoDeviceId : Int = 0 @Published var videoEnabled : Bool = false @Published var speakerEnabled : Bool = false @@ -108,12 +110,14 @@ class LinphoneTutorialContext : ObservableObject mCore.autoIterateEnabled = true try? mCore.start() + mVideoDevices = mCore.videoDevicesList // Important ! Will notify when config are registered so that we can proceed with the chatroom creations mCore.addDelegate(delegate: mRegistrationConfirmDelegate) // Handle chat message reception mCore.addDelegate(delegate: mCoreChatDelegate) + mVideoDevices = mCore.videoDevicesList } @@ -227,6 +231,17 @@ class LinphoneTutorialContext : ObservableObject } } + func changeVideoDevice() + { + mUsedVideoDeviceId = (mUsedVideoDeviceId + 1) % mVideoDevices.count + + do { + try mCore.setVideodevice(newValue: mVideoDevices[mUsedVideoDeviceId]) + } catch { + print(error) + } + } + func createChatRoom(isBasic isBasicChatroom : Bool) { // proxy configuration must first be initialized and registered @@ -355,6 +370,17 @@ struct ContentView: View { Toggle(isOn: $tutorialContext.videoEnabled) { Text("Video") } + HStack { + Button(action: tutorialContext.changeVideoDevice) + { + Text("Camera") + .font(.title) + .foregroundColor(Color.white) + .frame(width: 120.0, height: 35.0) + .background(Color.gray) + } + .padding(.bottom, 5.0) + } HStack { Text("Speaker :") Spacer()