forked from mirrors/linphone-iphone
Multi call various fixes
This commit is contained in:
parent
c49013aa2b
commit
987ea21e05
6 changed files with 52 additions and 28 deletions
|
|
@ -374,7 +374,6 @@ static RootViewManager *rootViewManagerInstance = nil;
|
|||
}
|
||||
break;
|
||||
}
|
||||
case LinphoneCallOutgoingInit:
|
||||
case LinphoneCallOutgoingEarlyMedia:
|
||||
case LinphoneCallOutgoingProgress:
|
||||
case LinphoneCallOutgoingRinging: {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import AVFoundation
|
|||
@objc class CallAppData: NSObject {
|
||||
@objc var batteryWarningShown = false
|
||||
@objc var videoRequested = false /*set when user has requested for video*/
|
||||
@objc var isConference = true
|
||||
@objc var isConference = false
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,10 +39,7 @@ extension Call {
|
|||
|
||||
extension Call : CustomStringConvertible {
|
||||
public var description: String {
|
||||
if let callId = callLog?.callId {
|
||||
return "<Call-ID: \(callId)>"
|
||||
}
|
||||
return "<Raw pointer:\(Unmanaged.passUnretained(self).toOpaque())>"
|
||||
return "<Call-ID: \(callLog?.callId ?? "pending") pointer:\(Unmanaged.passUnretained(self).toOpaque()) is conference:\(conference != nil) >"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ class CallsViewModel {
|
|||
let callConnectedEvent = MutableLiveData<Call>()
|
||||
let callUpdateEvent = MutableLiveData<Call>()
|
||||
let noMoreCallEvent = MutableLiveData(false)
|
||||
|
||||
|
||||
var core : Core { get { Core.get() } }
|
||||
|
||||
|
||||
static let shared = CallsViewModel()
|
||||
|
||||
private var coreDelegate : CoreDelegateStub?
|
||||
|
|
@ -44,7 +44,11 @@ class CallsViewModel {
|
|||
coreDelegate = CoreDelegateStub(
|
||||
onCallStateChanged : { (core: Core, call: Call, state: Call.State, message:String) -> Void in
|
||||
Log.i("[Calls] Call state changed: \(call) : \(state)")
|
||||
if (state == .IncomingEarlyMedia || state == .IncomingReceived || state == .OutgoingInit) {
|
||||
self.addCallToList(call:call)
|
||||
}
|
||||
let currentCall = core.currentCall
|
||||
Log.i("[Calls] Current call is \(currentCall)")
|
||||
if (currentCall != nil && self.currentCallData.value??.call.getCobject != currentCall?.getCobject) {
|
||||
self.updateCurrentCallData(currentCall: currentCall)
|
||||
} else if (currentCall == nil && core.callsNb > 0) {
|
||||
|
|
@ -120,13 +124,17 @@ class CallsViewModel {
|
|||
if let removeCandidate = callsData.value?.filter{$0.call.getCobject == call.getCobject}.first {
|
||||
removeCandidate.destroy()
|
||||
}
|
||||
|
||||
|
||||
callsData.value = callsData.value?.filter(){$0.call.getCobject != call.getCobject}
|
||||
callsData.notifyValue()
|
||||
}
|
||||
|
||||
private func addCallToList(call: Call) {
|
||||
Log.i("[Calls] Adding call \(call) to calls list")
|
||||
guard self.callsData.value?.filter({$0.call.getCobject == call.getCobject}).first == nil else {
|
||||
Log.i("[Calls] \(call) already present in the list")
|
||||
return
|
||||
}
|
||||
callsData.value?.append(CallData(call: call))
|
||||
callsData.notifyValue()
|
||||
}
|
||||
|
|
@ -162,29 +170,39 @@ class CallsViewModel {
|
|||
var callToUse = currentCall
|
||||
if (currentCall == nil) {
|
||||
Log.w("[Calls] Current call is now null")
|
||||
|
||||
if (Core.get().callsNb == 1) {
|
||||
let firstData = callsData.value?.first
|
||||
if (firstData != nil && currentCallData.value??.call.getCobject != firstData?.call.getCobject) {
|
||||
Log.i("[Calls] Only one call in Core and the current call data doesn't match it, updating it")
|
||||
currentCallData.value = firstData
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
let firstCall = core.calls.first
|
||||
let firstCall = core.calls.filter {$0.state != .Error && $0.state != .End && $0.state != .Released}.first
|
||||
if (firstCall != nil && currentCallData.value??.call.getCobject != firstCall?.getCobject) {
|
||||
Log.i("[Calls] Using first call as \"current\" call")
|
||||
Log.i("[Calls] Using \(firstCall?.callLog?.callId) as \"current\" call")
|
||||
callToUse = firstCall
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
guard let callToUse = callToUse else {
|
||||
Log.w("[Calls] No call found to be used as \"current\"")
|
||||
return
|
||||
}
|
||||
|
||||
let firstToUse = callsData.value?.filter{$0.call.getCobject != callToUse.getCobject}.first
|
||||
|
||||
let firstToUse = callsData.value?.filter{$0.call.getCobject == callToUse.getCobject}.first
|
||||
if (firstToUse != nil) {
|
||||
Log.i("[Calls] Updating current call to : \(firstToUse?.call)")
|
||||
currentCallData.value = firstToUse
|
||||
} else {
|
||||
Log.w("[Calls] Call not found in calls data list, shouldn't happen!")
|
||||
Log.w("[Calls] Call not found in calls data list, shouldn't happen! currentCallData is \(callToUse)")
|
||||
currentCallData.value = CallData(call: callToUse)
|
||||
}
|
||||
|
||||
updateUnreadChatCount()
|
||||
ControlsViewModel.shared.updateMicState()
|
||||
//updateUnreadChatCount()
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,13 +86,16 @@ import linphonesw
|
|||
fullScreenMutableContainerView.addSubview(currentCallView!)
|
||||
CallsViewModel.shared.currentCallData.readCurrentAndObserve { (currentCallData) in
|
||||
self.updateNavigation()
|
||||
self.currentCallView!.isHidden = currentCallData == nil || ConferenceViewModel.shared.conferenceExists.value == true
|
||||
self.currentCallView!.callData = currentCallData != nil ? currentCallData! : nil
|
||||
let isConferenceCall = currentCallData??.call.conference != nil
|
||||
self.currentCallView!.isHidden = isConferenceCall
|
||||
if (!isConferenceCall) {
|
||||
self.currentCallView!.callData = currentCallData != nil ? currentCallData! : nil
|
||||
}
|
||||
currentCallData??.isRemotelyPaused.readCurrentAndObserve { remotelyPaused in
|
||||
self.callPausedByRemoteView?.isHidden = remotelyPaused != true || ConferenceViewModel.shared.conferenceExists.value == true
|
||||
self.callPausedByRemoteView?.isHidden = remotelyPaused != true || isConferenceCall
|
||||
}
|
||||
currentCallData??.isPaused.readCurrentAndObserve { locallyPaused in
|
||||
self.callPausedByLocalView?.isHidden = locallyPaused != true || ConferenceViewModel.shared.conferenceExists.value == true
|
||||
self.callPausedByLocalView?.isHidden = locallyPaused != true || isConferenceCall
|
||||
}
|
||||
if (currentCallData == nil) {
|
||||
self.callPausedByRemoteView?.isHidden = true
|
||||
|
|
@ -103,8 +106,9 @@ import linphonesw
|
|||
currentCallData??.isOutgoing.readCurrentAndObserve { _ in self.updateNavigation() }
|
||||
}
|
||||
self.extraButtonsView.isHidden = true
|
||||
self.conferencePausedView?.isHidden = true
|
||||
if (ConferenceViewModel.shared.conferenceExists.value != true) {
|
||||
self.conferencePausedView?.isHidden = currentCallData??.call.conference == nil || ConferenceViewModel.shared.isConferenceLocallyPaused.value != true
|
||||
|
||||
if (isConferenceCall) {
|
||||
self.conferenceGridView?.isHidden = true
|
||||
self.conferenceActiveSpeakerView?.isHidden = true
|
||||
self.conferenceAudioOnlyView?.isHidden = true
|
||||
|
|
@ -144,20 +148,22 @@ import linphonesw
|
|||
conferenceGridView?.isHidden = true
|
||||
ConferenceViewModel.shared.conferenceExists.readCurrentAndObserve { (exists) in
|
||||
self.updateNavigation()
|
||||
if (exists == true) {
|
||||
let activeCallIsConference = CallsViewModel.shared.currentCallData.value??.call.conference != nil
|
||||
if (activeCallIsConference) {
|
||||
self.currentCallView!.isHidden = true
|
||||
self.extraButtonsView.isHidden = true
|
||||
self.conferencePausedView?.isHidden = true
|
||||
self.conferencePausedView?.isHidden = ConferenceViewModel.shared.isConferenceLocallyPaused.value != true
|
||||
self.displaySelectedConferenceLayout()
|
||||
} else {
|
||||
self.conferenceGridView?.isHidden = true
|
||||
self.conferenceActiveSpeakerView?.isHidden = true
|
||||
self.conferenceActiveSpeakerView?.isHidden = true
|
||||
self.conferencePausedView?.isHidden = true
|
||||
}
|
||||
}
|
||||
|
||||
ConferenceViewModel.shared.conferenceCreationPending.readCurrentAndObserve { isCreationPending in
|
||||
if (ConferenceViewModel.shared.conferenceExists.value == true && isCreationPending == true) {
|
||||
if (isCreationPending == true) {
|
||||
self.fullScreenMutableContainerView.addSubview(self.conferenceJoinSpinner)
|
||||
self.conferenceJoinSpinner.square(IncomingOutgoingCommonView.spinner_size).center().done()
|
||||
self.conferenceJoinSpinner.startRotation()
|
||||
|
|
@ -186,7 +192,7 @@ import linphonesw
|
|||
}
|
||||
}
|
||||
ConferenceViewModel.shared.isConferenceLocallyPaused.readCurrentAndObserve { (paused) in
|
||||
self.conferencePausedView?.isHidden = paused != true || ConferenceViewModel.shared.conferenceExists.value != true
|
||||
self.conferencePausedView?.isHidden = paused != true
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -340,6 +346,7 @@ import linphonesw
|
|||
extraButtonsView.refresh()
|
||||
ControlsViewModel.shared.callStatsVisible.notifyValue()
|
||||
CallsViewModel.shared.currentCallData.notifyValue()
|
||||
ConferenceViewModel.shared.conferenceExists.notifyValue()
|
||||
ControlsViewModel.shared.audioRoutesSelected.value = false
|
||||
ControlsViewModel.shared.fullScreenMode.value = true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,9 @@ import linphonesw
|
|||
override func viewWillAppear(_ animated: Bool) {
|
||||
ControlsViewModel.shared.audioRoutesSelected.value = false
|
||||
super.viewWillAppear(animated)
|
||||
if (Core.get().callsNb == 0) {
|
||||
PhoneMainView.instance().popView(self.compositeViewDescription())
|
||||
}
|
||||
}
|
||||
|
||||
@objc override func setCall(call:OpaquePointer) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue