VoIP: add new types and associated contents

This commit is contained in:
ganfra 2020-11-10 17:34:34 +01:00
parent dc17e5c3fa
commit f2cb6ed82c
8 changed files with 176 additions and 5 deletions

View File

@ -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
}
}

View File

@ -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)

View File

@ -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)

View File

@ -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
}
}

View File

@ -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.

View File

@ -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?
)
}

View File

@ -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",
)

View File

@ -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,
)