Skip to content
Snippets Groups Projects
Commit 6e37f0d1 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Kateryna Kostiuk
Browse files

call: stop camera when peer refuse call

Gitlab: #136

Change-Id: I67831e9603380a516a06f8baf2a177c28d042a02
parent c606eadf
Branches
No related tags found
No related merge requests found
......@@ -84,6 +84,10 @@ class CallViewModel: Stateable, ViewModel {
if oldValue != nil {
return
}
if !(self.call?.isAudioOnly ?? true) {
self.videoService.startVideoCaptureBeforeCall()
}
self.subscribeToCallFinished()
self.callService.currentConferenceEvent
.asObservable()
.filter({ [weak self] conference-> Bool in
......@@ -103,8 +107,6 @@ class CallViewModel: Stateable, ViewModel {
}
let isModerator = self.callService.isModerator(participantId: account.jamiId, inConference: conf.conferenceID)
if isModerator != self.containerViewModel?.isConference {
// guard let updatedCall = self.callService.call(callID: call.callId) else { return }
// self.call = updatedCall
self.containerViewModel?.isConference = isModerator
self.conferenceMode.accept(isModerator)
}
......@@ -183,9 +185,6 @@ class CallViewModel: Stateable, ViewModel {
var rendererId = ""
lazy var capturedFrame: Observable<UIImage?> = {
if !(self.call?.isAudioOnly ?? true) {
videoService.startVideoCaptureBeforeCall()
}
return videoService.capturedVideoFrame.asObservable().map({ frame in
return frame
})
......@@ -213,10 +212,6 @@ class CallViewModel: Stateable, ViewModel {
return !hide
}
}
if hide {
self?.videoService.setCameraOrientation(orientation: UIDevice.current.orientation)
self?.callsProvider.stopCall(callUUID: call.callUUID)
}
return hide
})
}()
......@@ -638,6 +633,21 @@ extension CallViewModel {
func showDialpad() {
self.stateSubject.onNext(ConversationState.showDialpad(inCall: true))
}
func subscribeToCallFinished() {
dismisVC
.share()
.filter { dismised in
return dismised
}
.subscribe { [weak self ] _ in
guard let self = self, let call = self.call else { return }
self.videoService.stopCapture()
self.videoService.setCameraOrientation(orientation: UIDevice.current.orientation)
self.callsProvider.stopCall(callUUID: call.callUUID)
}
.disposed(by: self.disposeBag)
}
}
// MARK: conference layout
extension CallViewModel {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment