Fixed auto start call recording setting

This commit is contained in:
Sylvain Berfini 2024-06-04 14:22:36 +02:00
parent ee4e332330
commit a71ba2096b
2 changed files with 29 additions and 5 deletions

View file

@ -128,6 +128,8 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
}
}
private var previousCallState = Call.State.Idle
private val coreListener = object : CoreListenerStub() {
@WorkerThread
override fun onGlobalStateChanged(core: Core, state: GlobalState, message: String) {
@ -176,8 +178,11 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
state: Call.State?,
message: String
) {
Log.i("$TAG Call [${call.remoteAddress.asStringUriOnly()}] state changed [$state]")
when (state) {
val currentState = call.state
Log.i(
"$TAG Call [${call.remoteAddress.asStringUriOnly()}] state changed [$currentState]"
)
when (currentState) {
Call.State.OutgoingInit -> {
val conferenceInfo = core.findConferenceInformationFromUri(call.remoteAddress)
// Do not show outgoing call view for conference calls, wait for connected state
@ -196,6 +201,16 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
showCallActivity()
}
}
Call.State.StreamsRunning -> {
if (previousCallState == Call.State.Connected) {
if (corePreferences.automaticallyStartCallRecording && !call.params.isRecording) {
if (call.conference == null) { // TODO: FIXME: Conference recordings are currently disabled
Log.i("$TAG Auto record calls is enabled, starting it now")
call.startRecording()
}
}
}
}
Call.State.Error -> {
val errorInfo = call.errorInfo
Log.w(
@ -209,6 +224,8 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
else -> {
}
}
previousCallState = currentState
}
@WorkerThread

View file

@ -313,6 +313,10 @@ class CurrentCallViewModel @UiThread constructor() : GenericViewModel() {
} else {
conferenceModel.destroy()
}
} else if (call.state == Call.State.StreamsRunning) {
if (corePreferences.automaticallyStartCallRecording) {
isRecording.postValue(call.params.isRecording)
}
}
}
@ -1103,9 +1107,12 @@ class CurrentCallViewModel @UiThread constructor() : GenericViewModel() {
displayedName.postValue(model.friend.name)
isRecording.postValue(call.params.isRecording)
isRemoteRecordingEvent.postValue(
Event(Pair(call.remoteParams?.isRecording ?: false, displayedName.value.orEmpty()))
)
val isRemoteRecording = call.remoteParams?.isRecording ?: false
if (isRemoteRecording) {
Log.w("$TAG Remote end [${displayedName.value.orEmpty()}] is recording the call")
isRemoteRecordingEvent.postValue(Event(Pair(true, displayedName.value.orEmpty())))
}
callDuration.postValue(call.duration)
}