From f2cb6ed82ccc072080aadce722aa6b176e01af99 Mon Sep 17 00:00:00 2001 From: ganfra Date: Tue, 10 Nov 2020 17:34:34 +0100 Subject: [PATCH] VoIP: add new types and associated contents --- .../sdk/api/session/events/model/EventType.kt | 6 ++ .../room/model/call/CallAnswerContent.kt | 6 +- .../room/model/call/CallCandidatesContent.kt | 6 +- .../room/model/call/CallHangupContent.kt | 20 ++++++- .../room/model/call/CallInviteContent.kt | 6 +- .../room/model/call/CallNegociateContent.kt | 58 +++++++++++++++++++ .../room/model/call/CallRejectContent.kt | 40 +++++++++++++ .../model/call/CallSelectAnswerContent.kt | 39 +++++++++++++ 8 files changed, 176 insertions(+), 5 deletions(-) create mode 100644 matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallNegociateContent.kt create mode 100644 matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallRejectContent.kt create mode 100644 matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallSelectAnswerContent.kt diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/EventType.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/EventType.kt index 82dea81a5b..b291f087ef 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/EventType.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/EventType.kt @@ -61,6 +61,9 @@ object EventType { const val CALL_INVITE = "m.call.invite" const val CALL_CANDIDATES = "m.call.candidates" const val CALL_ANSWER = "m.call.answer" + const val CALL_SELECT_ANSWER = "m.call.select_answer" + const val CALL_NEGOTIATE = "m.call.negotiate" + const val CALL_REJECT = "m.call.reject" const val CALL_HANGUP = "m.call.hangup" // Key share events @@ -91,5 +94,8 @@ object EventType { || type == CALL_CANDIDATES || type == CALL_ANSWER || type == CALL_HANGUP + || type == CALL_SELECT_ANSWER + || type == CALL_NEGOTIATE + || type == CALL_REJECT } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallAnswerContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallAnswerContent.kt index c4d1f6486f..d6df2f36a4 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallAnswerContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallAnswerContent.kt @@ -28,6 +28,10 @@ data class CallAnswerContent( * Required. The ID of the call this event relates to. */ @Json(name = "call_id") val callId: String, + /** + * Required. ID to let user identify remote echo of their own events + */ + @Json(name = "party_id") val partyId: String? = null, /** * Required. The session description object */ @@ -35,7 +39,7 @@ data class CallAnswerContent( /** * Required. The version of the VoIP specification this messages adheres to. This specification is version 0. */ - @Json(name = "version") val version: Int = 0 + @Json(name = "version") val version: String? = "0" ) { @JsonClass(generateAdapter = true) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallCandidatesContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallCandidatesContent.kt index cad2356c2d..d2a88a6793 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallCandidatesContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallCandidatesContent.kt @@ -29,6 +29,10 @@ data class CallCandidatesContent( * Required. The ID of the call this event relates to. */ @Json(name = "call_id") val callId: String, + /** + * Required. ID to let user identify remote echo of their own events + */ + @Json(name = "party_id") val partyId: String? = null, /** * Required. Array of objects describing the candidates. */ @@ -36,7 +40,7 @@ data class CallCandidatesContent( /** * Required. The version of the VoIP specification this messages adheres to. This specification is version 0. */ - @Json(name = "version") val version: Int = 0 + @Json(name = "version") val version: String? = "0" ) { @JsonClass(generateAdapter = true) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallHangupContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallHangupContent.kt index d30441df4b..d4a626d609 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallHangupContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallHangupContent.kt @@ -29,10 +29,14 @@ data class CallHangupContent( * Required. The ID of the call this event relates to. */ @Json(name = "call_id") val callId: String, + /** + * Required. ID to let user identify remote echo of their own events + */ + @Json(name = "party_id") val partyId: String? = null, /** * Required. The version of the VoIP specification this message adheres to. This specification is version 0. */ - @Json(name = "version") val version: Int = 0, + @Json(name = "version") val version: String? = "0", /** * Optional error reason for the hangup. This should not be provided when the user naturally ends or rejects the call. * When there was an error in the call negotiation, this should be `ice_failed` for when ICE negotiation fails @@ -45,7 +49,19 @@ data class CallHangupContent( @Json(name = "ice_failed") ICE_FAILED, + @Json(name = "ice_timeout") + ICE_TIMEOUT, + + @Json(name = "user_hangup") + USER_HANGUP, + + @Json(name = "user_media_failed") + USER_MEDIA_FAILED, + @Json(name = "invite_timeout") - INVITE_TIMEOUT + INVITE_TIMEOUT, + + @Json(name = "unknown_error") + UNKWOWN_ERROR } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallInviteContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallInviteContent.kt index b961a6f654..c1e84b988c 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallInviteContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallInviteContent.kt @@ -28,6 +28,10 @@ data class CallInviteContent( * Required. A unique identifier for the call. */ @Json(name = "call_id") val callId: String?, + /** + * Required. ID to let user identify remote echo of their own events + */ + @Json(name = "party_id") val partyId: String? = null, /** * Required. The session description object */ @@ -35,7 +39,7 @@ data class CallInviteContent( /** * Required. The version of the VoIP specification this message adheres to. This specification is version 0. */ - @Json(name = "version") val version: Int? = 0, + @Json(name = "version") val version: String? = "0", /** * Required. The time in milliseconds that the invite is valid for. * Once the invite age exceeds this value, clients should discard it. diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallNegociateContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallNegociateContent.kt new file mode 100644 index 0000000000..be8ee1d9fc --- /dev/null +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallNegociateContent.kt @@ -0,0 +1,58 @@ +/* + * Copyright 2020 The Matrix.org Foundation C.I.C. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.matrix.android.sdk.api.session.room.model.call + +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass + +/** + * This introduces SDP negotiation semantics for media pause, hold/resume, ICE restarts and voice/video call up/downgrading. + */ +@JsonClass(generateAdapter = true) +data class CallNegociateContent( + /** + * Required. The ID of the call this event relates to. + */ + @Json(name = "call_id") val callId: String, + /** + * Required. ID to let user identify remote echo of their own events + */ + @Json(name = "party_id") val partyId: String? = null, + /** + * Required. The time in milliseconds that the negotiation is valid for. Once exceeded the sender + * of the negotiate event should consider the negotiation failed (timed out) and the recipient should ignore it. + **/ + @Json(name = "lifetime") val lifetime: Int?, + /** + * Required. The session description object + */ + @Json(name = "description") val description: Description? = null, +) { + @JsonClass(generateAdapter = true) + data class Description( + /** + * Required. The type of session description. + */ + @Json(name = "type") val type: SdpType?, + /** + * Required. The SDP text of the session description. + */ + @Json(name = "sdp") val sdp: String? + ) + +} + diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallRejectContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallRejectContent.kt new file mode 100644 index 0000000000..96735b60bb --- /dev/null +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallRejectContent.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2020 The Matrix.org Foundation C.I.C. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.matrix.android.sdk.api.session.room.model.call + +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass + +/** + * Sent by either party to signal their termination of the call. This can be sent either once + * the call has been established or before to abort the call. + */ +@JsonClass(generateAdapter = true) +data class CallRejectContent( + /** + * Required. The ID of the call this event relates to. + */ + @Json(name = "call_id") val callId: String, + /** + * Required. ID to let user identify remote echo of their own events + */ + @Json(name = "party_id") val partyId: String? = null, + /** + * Required. The version of the VoIP specification this message adheres to. This specification is version 0. + */ + @Json(name = "version") val version: String? = "0", +) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallSelectAnswerContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallSelectAnswerContent.kt new file mode 100644 index 0000000000..9205be1e83 --- /dev/null +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallSelectAnswerContent.kt @@ -0,0 +1,39 @@ +/* + * Copyright 2020 The Matrix.org Foundation C.I.C. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.matrix.android.sdk.api.session.room.model.call + +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass + +/** + * This event is sent by the callee when they wish to answer the call. + */ +@JsonClass(generateAdapter = true) +data class CallSelectAnswerContent( + /** + * Required. The ID of the call this event relates to. + */ + @Json(name = "call_id") val callId: String, + /** + * Required. ID to let user identify remote echo of their own events + */ + @Json(name = "party_id") val partyId: String? = null, + /** + * Required. Indicates the answer user has chosen. + */ + @Json(name = "selected_party_id") val selectedPartyId: String? = null, +)