Small cleanup during review

This commit is contained in:
Benoit Marty 2021-05-28 16:36:03 +02:00
parent 34b012732e
commit fca74e9eb4
5 changed files with 41 additions and 28 deletions

View File

@ -89,6 +89,7 @@ interface MxCall : MxCallDetail {
/**
* Send a m.call.replaces event to initiate call transfer.
* See [org.matrix.android.sdk.api.session.room.model.call.CallReplacesContent] for documentation about the parameters
*/
suspend fun transfer(targetUserId: String,
targetRoomId: String?,

View File

@ -38,23 +38,23 @@ data class CallReplacesContent(
*/
@Json(name = "replacement_id") val replacementId: String? = null,
/**
* Optional. If specified, the transferee client waits for an invite to this room and joins it
* (possibly waiting for user confirmation) and then continues the transfer in this room.
* If absent, the transferee contacts the Matrix User ID given in the target_user field in a room of its choosing.
* Optional. If specified, the transferee client waits for an invite to this room and joins it
* (possibly waiting for user confirmation) and then continues the transfer in this room.
* If absent, the transferee contacts the Matrix User ID given in the target_user field in a room of its choosing.
*/
@Json(name = "target_room") val targetRoomId: String? = null,
/**
* An object giving information about the transfer target
* An object giving information about the transfer target
*/
@Json(name = "target_user") val targetUser: TargetUser? = null,
/**
* If specified, gives the call ID for the transferee's client to use when placing the replacement call.
* Mutually exclusive with await_call
* If specified, gives the call ID for the transferee's client to use when placing the replacement call.
* Mutually exclusive with await_call
*/
@Json(name = "create_call") val createCall: String? = null,
/**
* If specified, gives the call ID that the transferee's client should wait for.
* Mutually exclusive with create_call.
* If specified, gives the call ID that the transferee's client should wait for.
* Mutually exclusive with create_call.
*/
@Json(name = "await_call") val awaitCall: String? = null,
/**
@ -77,6 +77,5 @@ data class CallReplacesContent(
* Optional. The avatar URL of the transfer target.
*/
@Json(name = "avatar_url") val avatarUrl: String?
)
}

View File

@ -75,7 +75,10 @@ internal class MxCallFactory @Inject constructor(
}
}
fun updateOutgoingCallWithOpponentData(call: MxCall, userId: String, content: CallSignalingContent, callCapabilities: CallCapabilities?) {
fun updateOutgoingCallWithOpponentData(call: MxCall,
userId: String,
content: CallSignalingContent,
callCapabilities: CallCapabilities?) {
(call as? MxCallImpl)?.updateOpponentData(userId, content, callCapabilities)
}
}

View File

@ -46,9 +46,9 @@ data class VectorCallViewState(
) : MvRxState {
sealed class TransfereeState {
object NoTransferee: TransfereeState()
data class KnownTransferee(val name:String): TransfereeState()
object UnknownTransferee: TransfereeState()
object NoTransferee : TransfereeState()
data class KnownTransferee(val name: String) : TransfereeState()
object UnknownTransferee : TransfereeState()
}
data class CallInfo(
@ -56,7 +56,7 @@ data class VectorCallViewState(
val otherUserItem: MatrixItem? = null
)
constructor(callArgs: CallArgs): this(
constructor(callArgs: CallArgs) : this(
callId = callArgs.callId,
roomId = callArgs.signalingRoomId,
isVideoCall = callArgs.isVideoCall

View File

@ -86,16 +86,19 @@ private const val AUDIO_TRACK_ID = "ARDAMSa0"
private const val VIDEO_TRACK_ID = "ARDAMSv0"
private val DEFAULT_AUDIO_CONSTRAINTS = MediaConstraints()
class WebRtcCall(val mxCall: MxCall,
// This is where the call is placed from an ui perspective. In case of virtual room, it can differs from the signalingRoomId.
val nativeRoomId: String,
private val rootEglBase: EglBase?,
private val context: Context,
private val dispatcher: CoroutineContext,
private val sessionProvider: Provider<Session?>,
private val peerConnectionFactoryProvider: Provider<PeerConnectionFactory?>,
private val onCallBecomeActive: (WebRtcCall) -> Unit,
private val onCallEnded: (String) -> Unit) : MxCall.StateListener {
class WebRtcCall(
val mxCall: MxCall,
// This is where the call is placed from an ui perspective.
// In case of virtual room, it can differs from the signalingRoomId.
val nativeRoomId: String,
private val rootEglBase: EglBase?,
private val context: Context,
private val dispatcher: CoroutineContext,
private val sessionProvider: Provider<Session?>,
private val peerConnectionFactoryProvider: Provider<PeerConnectionFactory?>,
private val onCallBecomeActive: (WebRtcCall) -> Unit,
private val onCallEnded: (String) -> Unit
) : MxCall.StateListener {
interface Listener : MxCall.StateListener {
fun onCaptureStateChanged() {}
@ -119,6 +122,7 @@ class WebRtcCall(val mxCall: MxCall,
}
val callId = mxCall.callId
// room where call signaling is placed. In case of virtual room it can differs from the nativeRoomId.
val signalingRoomId = mxCall.roomId
@ -290,6 +294,9 @@ class WebRtcCall(val mxCall: MxCall,
}
}
/**
* Without consultation
*/
suspend fun transferToUser(targetUserId: String, targetRoomId: String?) {
mxCall.transfer(
targetUserId = targetUserId,
@ -300,22 +307,25 @@ class WebRtcCall(val mxCall: MxCall,
endCall(sendEndSignaling = false)
}
/**
* With consultation
*/
suspend fun transferToCall(transferTargetCall: WebRtcCall) {
val newCallId = CallIdGenerator.generate()
transferTargetCall.mxCall.transfer(
targetUserId = this@WebRtcCall.mxCall.opponentUserId,
targetUserId = mxCall.opponentUserId,
targetRoomId = null,
createCallId = null,
awaitCallId = newCallId
)
this@WebRtcCall.mxCall.transfer(
mxCall.transfer(
targetUserId = transferTargetCall.mxCall.opponentUserId,
targetRoomId = null,
createCallId = newCallId,
awaitCallId = null
)
this@WebRtcCall.endCall(sendEndSignaling = false)
transferTargetCall.endCall(sendEndSignaling = false)
endCall(sendEndSignaling = false)
transferTargetCall.endCall(sendEndSignaling = false)
}
fun acceptIncomingCall() {