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_NEGOTIATE = "m.call.negotiate"
const val CALL_REJECT = "m.call.reject" const val CALL_REJECT = "m.call.reject"
const val CALL_HANGUP = "m.call.hangup" 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" const val CALL_REPLACES = "m.call.replaces"
// Key share events // Key share events

View file

@ -20,11 +20,15 @@ import org.matrix.android.sdk.api.session.events.model.EventType
object RoomSummaryConstants { object RoomSummaryConstants {
/**
*
*/
val PREVIEWABLE_TYPES = listOf( val PREVIEWABLE_TYPES = listOf(
// TODO filter message type (KEY_VERIFICATION_READY, etc.) // TODO filter message type (KEY_VERIFICATION_READY, etc.)
EventType.MESSAGE, EventType.MESSAGE,
EventType.CALL_INVITE, EventType.CALL_INVITE,
EventType.CALL_HANGUP, EventType.CALL_HANGUP,
EventType.CALL_REJECT,
EventType.CALL_ANSWER, EventType.CALL_ANSWER,
EventType.ENCRYPTED, EventType.ENCRYPTED,
EventType.STICKER, 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.WebRtcCall
import im.vector.app.features.call.webrtc.WebRtcCallManager import im.vector.app.features.call.webrtc.WebRtcCallManager
import im.vector.app.features.home.AvatarRenderer 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.notifications.NotificationUtils
import im.vector.app.features.popup.IncomingCallAlert import im.vector.app.features.popup.IncomingCallAlert
import im.vector.app.features.popup.PopupAlertManager import im.vector.app.features.popup.PopupAlertManager
@ -160,9 +159,7 @@ class CallService : VectorService() {
Timber.v("displayIncomingCallNotification : display the dedicated notification") Timber.v("displayIncomingCallNotification : display the dedicated notification")
val incomingCallAlert = IncomingCallAlert(callId, val incomingCallAlert = IncomingCallAlert(callId,
shouldBeDisplayedIn = { activity -> shouldBeDisplayedIn = { activity ->
if (activity is RoomDetailActivity) { if (activity is VectorCallActivity) {
call.roomId != activity.currentRoomId
} else if (activity is VectorCallActivity) {
activity.intent.getParcelableExtra<CallArgs>(MvRx.KEY_ARG)?.callId != call.callId activity.intent.getParcelableExtra<CallArgs>(MvRx.KEY_ARG)?.callId != call.callId
} else true } 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. * It is, however, possible that the ICE agent did find compatible connections for some components.
*/ */
PeerConnection.IceConnectionState.FAILED -> { 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. * 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() { override fun onRenegotiationNeeded() {
Timber.v("## VOIP StreamObserver 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 onIceCandidate(iceCandidate: IceCandidate) = iceCandidateSource.onNext(iceCandidate)
fun onRenegationNeeded(restartIce: Boolean) { fun onRenegotiationNeeded(restartIce: Boolean) {
GlobalScope.launch(dispatcher) { GlobalScope.launch(dispatcher) {
if (mxCall.state != CallState.CreateOffer && mxCall.opponentVersion == 0) { if (mxCall.state != CallState.CreateOffer && mxCall.opponentVersion == 0) {
Timber.v("Opponent does not support renegotiation: ignoring onRenegotiationNeeded event") 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.CallTileTimelineItem_ import im.vector.app.features.home.room.detail.timeline.item.CallTileTimelineItem_
import im.vector.app.features.home.room.detail.timeline.item.MessageInformationData 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.EventType
import org.matrix.android.sdk.api.session.events.model.toModel import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.model.call.CallAnswerContent 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 callSignalingContent = event.getCallSignallingContent() ?: return null
val callId = callSignalingContent.callId ?: return null val callId = callSignalingContent.callId ?: return null
val call = callManager.getCallById(callId) val call = callManager.getCallById(callId)
val callKind = if (call?.mxCall?.isVideoCall.orFalse()) { val callKind = when {
CallTileTimelineItem.CallKind.VIDEO call == null -> CallTileTimelineItem.CallKind.UNKNOWN
} else { call.mxCall.isVideoCall -> CallTileTimelineItem.CallKind.VIDEO
CallTileTimelineItem.CallKind.AUDIO else -> CallTileTimelineItem.CallKind.AUDIO
} }
return when (event.root.getClearType()) { return when (event.root.getClearType()) {
EventType.CALL_ANSWER -> { EventType.CALL_ANSWER -> {

View file

@ -91,7 +91,11 @@ class NoticeEventFormatter @Inject constructor(
EventType.CALL_INVITE, EventType.CALL_INVITE,
EventType.CALL_CANDIDATES, EventType.CALL_CANDIDATES,
EventType.CALL_HANGUP, EventType.CALL_HANGUP,
EventType.CALL_REJECT,
EventType.CALL_ANSWER -> formatCallEvent(type, timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) EventType.CALL_ANSWER -> formatCallEvent(type, timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
EventType.CALL_NEGOTIATE,
EventType.CALL_SELECT_ANSWER,
EventType.CALL_REPLACES,
EventType.MESSAGE, EventType.MESSAGE,
EventType.REACTION, EventType.REACTION,
EventType.KEY_VERIFICATION_START, EventType.KEY_VERIFICATION_START,
@ -179,6 +183,7 @@ class NoticeEventFormatter @Inject constructor(
EventType.STATE_ROOM_HISTORY_VISIBILITY -> formatRoomHistoryVisibilityEvent(event, senderName, rs) EventType.STATE_ROOM_HISTORY_VISIBILITY -> formatRoomHistoryVisibilityEvent(event, senderName, rs)
EventType.CALL_INVITE, EventType.CALL_INVITE,
EventType.CALL_HANGUP, EventType.CALL_HANGUP,
EventType.CALL_REJECT,
EventType.CALL_ANSWER -> formatCallEvent(type, event, senderName) EventType.CALL_ANSWER -> formatCallEvent(type, event, senderName)
EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(event, senderName, rs) EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(event, senderName, rs)
else -> { else -> {
@ -347,6 +352,11 @@ class NoticeEventFormatter @Inject constructor(
} else { } else {
sp.getString(R.string.notice_call_candidates, senderName) 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 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.MessageColorProvider
import im.vector.app.features.home.room.detail.timeline.TimelineEventController import im.vector.app.features.home.room.detail.timeline.TimelineEventController
import org.matrix.android.sdk.api.util.MatrixItem import org.matrix.android.sdk.api.util.MatrixItem
import timber.log.Timber
@EpoxyModelClass(layout = R.layout.item_timeline_event_base_state) @EpoxyModelClass(layout = R.layout.item_timeline_event_base_state)
abstract class CallTileTimelineItem : AbsBaseMessageItem<CallTileTimelineItem.Holder>() { abstract class CallTileTimelineItem : AbsBaseMessageItem<CallTileTimelineItem.Holder>() {
@ -52,11 +53,15 @@ abstract class CallTileTimelineItem : AbsBaseMessageItem<CallTileTimelineItem.Ho
holder.endGuideline.updateLayoutParams<RelativeLayout.LayoutParams> { holder.endGuideline.updateLayoutParams<RelativeLayout.LayoutParams> {
this.marginEnd = leftGuideline this.marginEnd = leftGuideline
} }
holder.creatorNameView.text = attributes.userOfInterest.getBestName() holder.creatorNameView.text = attributes.userOfInterest.getBestName()
attributes.avatarRenderer.render(attributes.userOfInterest, holder.creatorAvatarView) attributes.avatarRenderer.render(attributes.userOfInterest, holder.creatorAvatarView)
holder.callKindView.setText(attributes.callKind.title) if (attributes.callKind != CallKind.UNKNOWN) {
holder.callKindView.setLeftDrawable(attributes.callKind.icon) 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) { if (attributes.callStatus == CallStatus.INVITED && !attributes.informationData.sentByMe && attributes.isStillActive) {
holder.acceptRejectViewGroup.isVisible = true holder.acceptRejectViewGroup.isVisible = true
holder.acceptView.setOnClickListener { holder.acceptView.setOnClickListener {
@ -83,6 +88,9 @@ abstract class CallTileTimelineItem : AbsBaseMessageItem<CallTileTimelineItem.Ho
holder.acceptView.setText(R.string.call_notification_answer) holder.acceptView.setText(R.string.call_notification_answer)
holder.acceptView.setLeftDrawable(R.drawable.ic_call_video_small, R.color.riotx_accent) holder.acceptView.setLeftDrawable(R.drawable.ic_call_video_small, R.color.riotx_accent)
} }
else -> {
Timber.w("Shouldn't be in that state")
}
} }
} else { } else {
holder.acceptRejectViewGroup.isVisible = false 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) { enum class CallKind(@DrawableRes val icon: Int, @StringRes val title: Int) {
VIDEO(R.drawable.ic_call_video_small, R.string.action_video_call), VIDEO(R.drawable.ic_call_video_small, R.string.action_video_call),
AUDIO(R.drawable.ic_call_audio_small, R.string.action_voice_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 { enum class CallStatus {