VoIP: made some minor changes after review

This commit is contained in:
ganfra 2021-02-09 19:42:05 +01:00
parent 2cbce016bc
commit 370b9dabff
8 changed files with 36 additions and 16 deletions

View file

@ -72,6 +72,7 @@ object EventType {
const val CALL_NEGOTIATE = "m.call.negotiate"
const val CALL_REJECT = "m.call.reject"
const val CALL_HANGUP = "m.call.hangup"
// This type is not processed by the client, just sent to the server
const val CALL_REPLACES = "m.call.replaces"
// Key share events

View file

@ -20,11 +20,15 @@ import org.matrix.android.sdk.api.session.events.model.EventType
object RoomSummaryConstants {
/**
*
*/
val PREVIEWABLE_TYPES = listOf(
// TODO filter message type (KEY_VERIFICATION_READY, etc.)
EventType.MESSAGE,
EventType.CALL_INVITE,
EventType.CALL_HANGUP,
EventType.CALL_REJECT,
EventType.CALL_ANSWER,
EventType.ENCRYPTED,
EventType.STICKER,

View file

@ -33,7 +33,6 @@ import im.vector.app.features.call.telecom.CallConnection
import im.vector.app.features.call.webrtc.WebRtcCall
import im.vector.app.features.call.webrtc.WebRtcCallManager
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.RoomDetailActivity
import im.vector.app.features.notifications.NotificationUtils
import im.vector.app.features.popup.IncomingCallAlert
import im.vector.app.features.popup.PopupAlertManager
@ -160,9 +159,7 @@ class CallService : VectorService() {
Timber.v("displayIncomingCallNotification : display the dedicated notification")
val incomingCallAlert = IncomingCallAlert(callId,
shouldBeDisplayedIn = { activity ->
if (activity is RoomDetailActivity) {
call.roomId != activity.currentRoomId
} else if (activity is VectorCallActivity) {
if (activity is VectorCallActivity) {
activity.intent.getParcelableExtra<CallArgs>(MvRx.KEY_ARG)?.callId != call.callId
} else true
}

View file

@ -129,7 +129,7 @@ class PeerConnectionObserver(private val webRtcCall: WebRtcCall) : PeerConnectio
* It is, however, possible that the ICE agent did find compatible connections for some components.
*/
PeerConnection.IceConnectionState.FAILED -> {
webRtcCall.onRenegationNeeded(restartIce = true)
webRtcCall.onRenegotiationNeeded(restartIce = true)
}
/**
* The ICE agent has finished gathering candidates, has checked all pairs against one another, and has found a connection for all components.
@ -168,7 +168,7 @@ class PeerConnectionObserver(private val webRtcCall: WebRtcCall) : PeerConnectio
override fun onRenegotiationNeeded() {
Timber.v("## VOIP StreamObserver onRenegotiationNeeded")
webRtcCall.onRenegationNeeded(restartIce = false)
webRtcCall.onRenegotiationNeeded(restartIce = false)
}
/**

View file

@ -190,7 +190,7 @@ class WebRtcCall(val mxCall: MxCall,
fun onIceCandidate(iceCandidate: IceCandidate) = iceCandidateSource.onNext(iceCandidate)
fun onRenegationNeeded(restartIce: Boolean) {
fun onRenegotiationNeeded(restartIce: Boolean) {
GlobalScope.launch(dispatcher) {
if (mxCall.state != CallState.CreateOffer && mxCall.opponentVersion == 0) {
Timber.v("Opponent does not support renegotiation: ignoring onRenegotiationNeeded event")

View file

@ -26,7 +26,6 @@ import im.vector.app.features.home.room.detail.timeline.helper.RoomSummariesHold
import im.vector.app.features.home.room.detail.timeline.item.CallTileTimelineItem
import im.vector.app.features.home.room.detail.timeline.item.CallTileTimelineItem_
import im.vector.app.features.home.room.detail.timeline.item.MessageInformationData
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.model.call.CallAnswerContent
@ -57,10 +56,10 @@ class CallItemFactory @Inject constructor(
val callSignalingContent = event.getCallSignallingContent() ?: return null
val callId = callSignalingContent.callId ?: return null
val call = callManager.getCallById(callId)
val callKind = if (call?.mxCall?.isVideoCall.orFalse()) {
CallTileTimelineItem.CallKind.VIDEO
} else {
CallTileTimelineItem.CallKind.AUDIO
val callKind = when {
call == null -> CallTileTimelineItem.CallKind.UNKNOWN
call.mxCall.isVideoCall -> CallTileTimelineItem.CallKind.VIDEO
else -> CallTileTimelineItem.CallKind.AUDIO
}
return when (event.root.getClearType()) {
EventType.CALL_ANSWER -> {

View file

@ -91,7 +91,11 @@ class NoticeEventFormatter @Inject constructor(
EventType.CALL_INVITE,
EventType.CALL_CANDIDATES,
EventType.CALL_HANGUP,
EventType.CALL_REJECT,
EventType.CALL_ANSWER -> formatCallEvent(type, timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
EventType.CALL_NEGOTIATE,
EventType.CALL_SELECT_ANSWER,
EventType.CALL_REPLACES,
EventType.MESSAGE,
EventType.REACTION,
EventType.KEY_VERIFICATION_START,
@ -179,6 +183,7 @@ class NoticeEventFormatter @Inject constructor(
EventType.STATE_ROOM_HISTORY_VISIBILITY -> formatRoomHistoryVisibilityEvent(event, senderName, rs)
EventType.CALL_INVITE,
EventType.CALL_HANGUP,
EventType.CALL_REJECT,
EventType.CALL_ANSWER -> formatCallEvent(type, event, senderName)
EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(event, senderName, rs)
else -> {
@ -347,6 +352,11 @@ class NoticeEventFormatter @Inject constructor(
} else {
sp.getString(R.string.notice_call_candidates, senderName)
}
EventType.CALL_REJECT -> if (event.isSentByCurrentUser()) {
sp.getString(R.string.call_tile_you_declined, "")
} else {
sp.getString(R.string.call_tile_other_declined, senderName)
}
else -> null
}
}

View file

@ -35,6 +35,7 @@ import im.vector.app.features.home.room.detail.RoomDetailAction
import im.vector.app.features.home.room.detail.timeline.MessageColorProvider
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
import org.matrix.android.sdk.api.util.MatrixItem
import timber.log.Timber
@EpoxyModelClass(layout = R.layout.item_timeline_event_base_state)
abstract class CallTileTimelineItem : AbsBaseMessageItem<CallTileTimelineItem.Holder>() {
@ -52,11 +53,15 @@ abstract class CallTileTimelineItem : AbsBaseMessageItem<CallTileTimelineItem.Ho
holder.endGuideline.updateLayoutParams<RelativeLayout.LayoutParams> {
this.marginEnd = leftGuideline
}
holder.creatorNameView.text = attributes.userOfInterest.getBestName()
attributes.avatarRenderer.render(attributes.userOfInterest, holder.creatorAvatarView)
if (attributes.callKind != CallKind.UNKNOWN) {
holder.callKindView.isVisible = true
holder.callKindView.setText(attributes.callKind.title)
holder.callKindView.setLeftDrawable(attributes.callKind.icon)
} else {
holder.callKindView.isVisible = false
}
if (attributes.callStatus == CallStatus.INVITED && !attributes.informationData.sentByMe && attributes.isStillActive) {
holder.acceptRejectViewGroup.isVisible = true
holder.acceptView.setOnClickListener {
@ -83,6 +88,9 @@ abstract class CallTileTimelineItem : AbsBaseMessageItem<CallTileTimelineItem.Ho
holder.acceptView.setText(R.string.call_notification_answer)
holder.acceptView.setLeftDrawable(R.drawable.ic_call_video_small, R.color.riotx_accent)
}
else -> {
Timber.w("Shouldn't be in that state")
}
}
} else {
holder.acceptRejectViewGroup.isVisible = false
@ -147,7 +155,8 @@ abstract class CallTileTimelineItem : AbsBaseMessageItem<CallTileTimelineItem.Ho
enum class CallKind(@DrawableRes val icon: Int, @StringRes val title: Int) {
VIDEO(R.drawable.ic_call_video_small, R.string.action_video_call),
AUDIO(R.drawable.ic_call_audio_small, R.string.action_voice_call),
CONFERENCE(R.drawable.ic_call_conference_small, R.string.conference_call_in_progress)
CONFERENCE(R.drawable.ic_call_conference_small, R.string.conference_call_in_progress),
UNKNOWN(0, 0)
}
enum class CallStatus {