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. * 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, suspend fun transfer(targetUserId: String,
targetRoomId: String?, targetRoomId: String?,

View file

@ -38,23 +38,23 @@ data class CallReplacesContent(
*/ */
@Json(name = "replacement_id") val replacementId: String? = null, @Json(name = "replacement_id") val replacementId: String? = null,
/** /**
* Optional. If specified, the transferee client waits for an invite to this room and joins it * 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. * (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. * 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, @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, @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. * If specified, gives the call ID for the transferee's client to use when placing the replacement call.
* Mutually exclusive with await_call * Mutually exclusive with await_call
*/ */
@Json(name = "create_call") val createCall: String? = null, @Json(name = "create_call") val createCall: String? = null,
/** /**
* If specified, gives the call ID that the transferee's client should wait for. * If specified, gives the call ID that the transferee's client should wait for.
* Mutually exclusive with create_call. * Mutually exclusive with create_call.
*/ */
@Json(name = "await_call") val awaitCall: String? = null, @Json(name = "await_call") val awaitCall: String? = null,
/** /**
@ -77,6 +77,5 @@ data class CallReplacesContent(
* Optional. The avatar URL of the transfer target. * Optional. The avatar URL of the transfer target.
*/ */
@Json(name = "avatar_url") val avatarUrl: String? @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) (call as? MxCallImpl)?.updateOpponentData(userId, content, callCapabilities)
} }
} }

View file

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

View file

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