events: Stabilize VoIP signalling improvements
This commit is contained in:
parent
a2b64c20bc
commit
07ea09548f
@ -18,6 +18,8 @@ Breaking changes:
|
|||||||
- Remove `SessionDescriptionType`, use a `String` instead. A clarification in MSC2746 / Matrix 1.7
|
- Remove `SessionDescriptionType`, use a `String` instead. A clarification in MSC2746 / Matrix 1.7
|
||||||
explains that the `type` field should not be validated but passed as-is to the WebRTC API. It
|
explains that the `type` field should not be validated but passed as-is to the WebRTC API. It
|
||||||
also avoids an unnecessary conversion between the WebRTC API and the Ruma type.
|
also avoids an unnecessary conversion between the WebRTC API and the Ruma type.
|
||||||
|
- The `reason` field in `CallHangupEventContent` is now required an defaults to `Reason::UserHangup`
|
||||||
|
(MSC2746 / Matrix 1.7)
|
||||||
|
|
||||||
Improvements:
|
Improvements:
|
||||||
|
|
||||||
@ -43,6 +45,7 @@ Improvements:
|
|||||||
- Add `MatrixVersion::V1_7`
|
- Add `MatrixVersion::V1_7`
|
||||||
- Stabilize support for annotations and reactions (MSC2677 / Matrix 1.7)
|
- Stabilize support for annotations and reactions (MSC2677 / Matrix 1.7)
|
||||||
- Add support for intentional mentions push rules (MSC3952 / Matrix 1.7)
|
- Add support for intentional mentions push rules (MSC3952 / Matrix 1.7)
|
||||||
|
- Stabilize support for VoIP signalling improvements (MSC2746 / Matrix 1.7)
|
||||||
|
|
||||||
# 0.11.3
|
# 0.11.3
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ rand = ["dep:rand", "dep:uuid"]
|
|||||||
unstable-exhaustive-types = []
|
unstable-exhaustive-types = []
|
||||||
unstable-msc1767 = []
|
unstable-msc1767 = []
|
||||||
unstable-msc2448 = []
|
unstable-msc2448 = []
|
||||||
unstable-msc2746 = []
|
|
||||||
unstable-msc2747 = []
|
unstable-msc2747 = []
|
||||||
unstable-msc2870 = []
|
unstable-msc2870 = []
|
||||||
unstable-msc3245 = ["unstable-msc3246"]
|
unstable-msc3245 = ["unstable-msc3246"]
|
||||||
|
@ -6,11 +6,8 @@ pub mod answer;
|
|||||||
pub mod candidates;
|
pub mod candidates;
|
||||||
pub mod hangup;
|
pub mod hangup;
|
||||||
pub mod invite;
|
pub mod invite;
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
pub mod negotiate;
|
pub mod negotiate;
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
pub mod reject;
|
pub mod reject;
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
pub mod select_answer;
|
pub mod select_answer;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@ -31,9 +28,8 @@ pub struct SessionDescription {
|
|||||||
|
|
||||||
/// The SDP text of the session description.
|
/// The SDP text of the session description.
|
||||||
///
|
///
|
||||||
/// With the `unstable-msc2746` feature, this field is unused if the type is `rollback` and
|
/// Defaults to an empty string.
|
||||||
/// defaults to an empty string.
|
#[serde(default)]
|
||||||
#[cfg_attr(feature = "unstable-msc2746", serde(default))]
|
|
||||||
pub sdp: String,
|
pub sdp: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ pub struct CallAnswerEventContent {
|
|||||||
/// A unique identifier for the call.
|
/// A unique identifier for the call.
|
||||||
pub call_id: OwnedVoipId,
|
pub call_id: OwnedVoipId,
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
/// **Required in VoIP version 1.** A unique ID for this session for the duration of the call.
|
/// **Required in VoIP version 1.** A unique ID for this session for the duration of the call.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub party_id: Option<OwnedVoipId>,
|
pub party_id: Option<OwnedVoipId>,
|
||||||
@ -43,7 +42,6 @@ impl CallAnswerEventContent {
|
|||||||
Self {
|
Self {
|
||||||
answer,
|
answer,
|
||||||
call_id,
|
call_id,
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
party_id: None,
|
party_id: None,
|
||||||
version,
|
version,
|
||||||
#[cfg(feature = "unstable-msc2747")]
|
#[cfg(feature = "unstable-msc2747")]
|
||||||
@ -59,7 +57,6 @@ impl CallAnswerEventContent {
|
|||||||
|
|
||||||
/// Convenience method to create a VoIP version 1 `CallAnswerEventContent` with all the required
|
/// Convenience method to create a VoIP version 1 `CallAnswerEventContent` with all the required
|
||||||
/// fields.
|
/// fields.
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
pub fn version_1(
|
pub fn version_1(
|
||||||
answer: SessionDescription,
|
answer: SessionDescription,
|
||||||
call_id: OwnedVoipId,
|
call_id: OwnedVoipId,
|
||||||
|
@ -19,7 +19,6 @@ pub struct CallCandidatesEventContent {
|
|||||||
/// A unique identifier for the call.
|
/// A unique identifier for the call.
|
||||||
pub call_id: OwnedVoipId,
|
pub call_id: OwnedVoipId,
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
/// **Required in VoIP version 1.** The unique ID for this session for the duration of the
|
/// **Required in VoIP version 1.** The unique ID for this session for the duration of the
|
||||||
/// call.
|
/// call.
|
||||||
///
|
///
|
||||||
@ -30,8 +29,8 @@ pub struct CallCandidatesEventContent {
|
|||||||
|
|
||||||
/// A list of candidates.
|
/// A list of candidates.
|
||||||
///
|
///
|
||||||
/// With the `unstable-msc2746` feature, in VoIP version 1, this list should end with a
|
/// In VoIP version 1, this list should end with a `Candidate` with an empty `candidate` field
|
||||||
/// `Candidate` with an empty `candidate` field when no more candidates will be sent.
|
/// when no more candidates will be sent.
|
||||||
pub candidates: Vec<Candidate>,
|
pub candidates: Vec<Candidate>,
|
||||||
|
|
||||||
/// The version of the VoIP specification this messages adheres to.
|
/// The version of the VoIP specification this messages adheres to.
|
||||||
@ -42,13 +41,7 @@ impl CallCandidatesEventContent {
|
|||||||
/// Creates a new `CallCandidatesEventContent` with the given call id, candidate list and VoIP
|
/// Creates a new `CallCandidatesEventContent` with the given call id, candidate list and VoIP
|
||||||
/// version.
|
/// version.
|
||||||
pub fn new(call_id: OwnedVoipId, candidates: Vec<Candidate>, version: VoipVersionId) -> Self {
|
pub fn new(call_id: OwnedVoipId, candidates: Vec<Candidate>, version: VoipVersionId) -> Self {
|
||||||
Self {
|
Self { call_id, candidates, version, party_id: None }
|
||||||
call_id,
|
|
||||||
candidates,
|
|
||||||
version,
|
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
party_id: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convenience method to create a VoIP version 0 `CallCandidatesEventContent` with all the
|
/// Convenience method to create a VoIP version 0 `CallCandidatesEventContent` with all the
|
||||||
@ -59,7 +52,6 @@ impl CallCandidatesEventContent {
|
|||||||
|
|
||||||
/// Convenience method to create a VoIP version 1 `CallCandidatesEventContent` with all the
|
/// Convenience method to create a VoIP version 1 `CallCandidatesEventContent` with all the
|
||||||
/// required fields.
|
/// required fields.
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
pub fn version_1(
|
pub fn version_1(
|
||||||
call_id: OwnedVoipId,
|
call_id: OwnedVoipId,
|
||||||
party_id: OwnedVoipId,
|
party_id: OwnedVoipId,
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
//! [`m.call.hangup`]: https://spec.matrix.org/latest/client-server-api/#mcallhangup
|
//! [`m.call.hangup`]: https://spec.matrix.org/latest/client-server-api/#mcallhangup
|
||||||
|
|
||||||
use ruma_macros::EventContent;
|
use ruma_macros::EventContent;
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
use serde::Serializer;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{serde::StringEnum, OwnedVoipId, PrivOwnedStr, VoipVersionId};
|
use crate::{serde::StringEnum, OwnedVoipId, PrivOwnedStr, VoipVersionId};
|
||||||
@ -16,9 +14,9 @@ use crate::{serde::StringEnum, OwnedVoipId, PrivOwnedStr, VoipVersionId};
|
|||||||
/// In VoIP version 0, this can be sent either once the call has been established or before to abort
|
/// In VoIP version 0, this can be sent either once the call has been established or before to abort
|
||||||
/// the call.
|
/// the call.
|
||||||
///
|
///
|
||||||
/// With the `unstable-msc2746` feature, and if the call is using VoIP version 1, this should only
|
/// If the call is using VoIP version 1, this should only be sent by the caller after sending the
|
||||||
/// be sent by the caller after sending the invite or by the callee after answering the invite. To
|
/// invite or by the callee after answering the invite. To reject an invite, send an
|
||||||
/// reject an invite, send an [`m.call.reject`] event.
|
/// [`m.call.reject`] event.
|
||||||
///
|
///
|
||||||
/// [`m.call.reject`]: super::reject::CallRejectEventContent
|
/// [`m.call.reject`]: super::reject::CallRejectEventContent
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
|
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
|
||||||
@ -28,7 +26,6 @@ pub struct CallHangupEventContent {
|
|||||||
/// A unique identifier for the call.
|
/// A unique identifier for the call.
|
||||||
pub call_id: OwnedVoipId,
|
pub call_id: OwnedVoipId,
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
/// **Required in VoIP version 1.** A unique ID for this session for the duration of the call.
|
/// **Required in VoIP version 1.** A unique ID for this session for the duration of the call.
|
||||||
///
|
///
|
||||||
/// Must be the same as the one sent by the previous invite or answer from
|
/// Must be the same as the one sent by the previous invite or answer from
|
||||||
@ -39,30 +36,17 @@ pub struct CallHangupEventContent {
|
|||||||
/// The version of the VoIP specification this messages adheres to.
|
/// The version of the VoIP specification this messages adheres to.
|
||||||
pub version: VoipVersionId,
|
pub version: VoipVersionId,
|
||||||
|
|
||||||
/// Optional error reason for the hangup.
|
/// Error reason for the hangup.
|
||||||
///
|
///
|
||||||
/// With the `unstable-msc2746` feature, this field defaults to `Some(Reason::UserHangup)`.
|
/// Defaults to `Reason::UserHangup`.
|
||||||
#[cfg_attr(not(feature = "unstable-msc2746"), serde(skip_serializing_if = "Option::is_none"))]
|
#[serde(default)]
|
||||||
#[cfg_attr(
|
pub reason: Reason,
|
||||||
feature = "unstable-msc2746",
|
|
||||||
serde(
|
|
||||||
default = "Reason::option_with_default",
|
|
||||||
serialize_with = "Reason::serialize_option_with_default"
|
|
||||||
)
|
|
||||||
)]
|
|
||||||
pub reason: Option<Reason>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CallHangupEventContent {
|
impl CallHangupEventContent {
|
||||||
/// Creates a new `CallHangupEventContent` with the given call ID and VoIP version.
|
/// Creates a new `CallHangupEventContent` with the given call ID and VoIP version.
|
||||||
pub fn new(call_id: OwnedVoipId, version: VoipVersionId) -> Self {
|
pub fn new(call_id: OwnedVoipId, version: VoipVersionId) -> Self {
|
||||||
Self {
|
Self { call_id, party_id: None, version, reason: Default::default() }
|
||||||
call_id,
|
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
party_id: None,
|
|
||||||
version,
|
|
||||||
reason: Default::default(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convenience method to create a VoIP version 0 `CallHangupEventContent` with all the required
|
/// Convenience method to create a VoIP version 0 `CallHangupEventContent` with all the required
|
||||||
@ -73,9 +57,8 @@ impl CallHangupEventContent {
|
|||||||
|
|
||||||
/// Convenience method to create a VoIP version 1 `CallHangupEventContent` with all the required
|
/// Convenience method to create a VoIP version 1 `CallHangupEventContent` with all the required
|
||||||
/// fields.
|
/// fields.
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
pub fn version_1(call_id: OwnedVoipId, party_id: OwnedVoipId, reason: Reason) -> Self {
|
pub fn version_1(call_id: OwnedVoipId, party_id: OwnedVoipId, reason: Reason) -> Self {
|
||||||
Self { call_id, party_id: Some(party_id), version: VoipVersionId::V1, reason: Some(reason) }
|
Self { call_id, party_id: Some(party_id), version: VoipVersionId::V1, reason }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,8 +68,7 @@ impl CallHangupEventContent {
|
|||||||
/// in the call negotiation, this should be `ice_failed` for when ICE negotiation fails or
|
/// in the call negotiation, this should be `ice_failed` for when ICE negotiation fails or
|
||||||
/// `invite_timeout` for when the other party did not answer in time.
|
/// `invite_timeout` for when the other party did not answer in time.
|
||||||
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
|
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
|
||||||
#[derive(Clone, PartialEq, Eq, StringEnum)]
|
#[derive(Clone, Default, PartialEq, Eq, StringEnum)]
|
||||||
#[cfg_attr(feature = "unstable-msc2746", derive(Default))]
|
|
||||||
#[ruma_enum(rename_all = "snake_case")]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum Reason {
|
pub enum Reason {
|
||||||
@ -101,50 +83,23 @@ pub enum Reason {
|
|||||||
/// Note that, in the case of an ICE renegotiation, a client should be sure to send
|
/// Note that, in the case of an ICE renegotiation, a client should be sure to send
|
||||||
/// `ice_timeout` rather than `ice_failed` if media had previously been received successfully,
|
/// `ice_timeout` rather than `ice_failed` if media had previously been received successfully,
|
||||||
/// even if the ICE renegotiation itself failed.
|
/// even if the ICE renegotiation itself failed.
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
IceTimeout,
|
IceTimeout,
|
||||||
|
|
||||||
/// The user chose to end the call.
|
/// The user chose to end the call.
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
#[default]
|
#[default]
|
||||||
UserHangup,
|
UserHangup,
|
||||||
|
|
||||||
/// The client was unable to start capturing media in such a way as it is unable to continue
|
/// The client was unable to start capturing media in such a way as it is unable to continue
|
||||||
/// the call.
|
/// the call.
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
UserMediaFailed,
|
UserMediaFailed,
|
||||||
|
|
||||||
/// The user is busy.
|
/// The user is busy.
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
UserBusy,
|
UserBusy,
|
||||||
|
|
||||||
/// Some other failure occurred that meant the client was unable to continue the call rather
|
/// Some other failure occurred that meant the client was unable to continue the call rather
|
||||||
/// than the user choosing to end it.
|
/// than the user choosing to end it.
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
UnknownError,
|
UnknownError,
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
_Custom(PrivOwnedStr),
|
_Custom(PrivOwnedStr),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Reason {
|
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
fn serialize_option_with_default<S>(
|
|
||||||
reason: &Option<Reason>,
|
|
||||||
serializer: S,
|
|
||||||
) -> Result<S::Ok, S::Error>
|
|
||||||
where
|
|
||||||
S: Serializer,
|
|
||||||
{
|
|
||||||
if let Some(reason) = &reason {
|
|
||||||
reason.serialize(serializer)
|
|
||||||
} else {
|
|
||||||
Self::default().serialize(serializer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
fn option_with_default() -> Option<Self> {
|
|
||||||
Some(Self::default())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -9,9 +9,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
#[cfg(feature = "unstable-msc2747")]
|
#[cfg(feature = "unstable-msc2747")]
|
||||||
use super::CallCapabilities;
|
use super::CallCapabilities;
|
||||||
use super::SessionDescription;
|
use super::SessionDescription;
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
use crate::{OwnedUserId, OwnedVoipId, VoipVersionId};
|
||||||
use crate::OwnedUserId;
|
|
||||||
use crate::{OwnedVoipId, VoipVersionId};
|
|
||||||
|
|
||||||
/// The content of an `m.call.invite` event.
|
/// The content of an `m.call.invite` event.
|
||||||
///
|
///
|
||||||
@ -23,7 +21,6 @@ pub struct CallInviteEventContent {
|
|||||||
/// A unique identifier for the call.
|
/// A unique identifier for the call.
|
||||||
pub call_id: OwnedVoipId,
|
pub call_id: OwnedVoipId,
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
/// **Required in VoIP version 1.** A unique ID for this session for the duration of the call.
|
/// **Required in VoIP version 1.** A unique ID for this session for the duration of the call.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub party_id: Option<OwnedVoipId>,
|
pub party_id: Option<OwnedVoipId>,
|
||||||
@ -45,7 +42,6 @@ pub struct CallInviteEventContent {
|
|||||||
#[serde(default, skip_serializing_if = "CallCapabilities::is_default")]
|
#[serde(default, skip_serializing_if = "CallCapabilities::is_default")]
|
||||||
pub capabilities: CallCapabilities,
|
pub capabilities: CallCapabilities,
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
/// **Added in VoIP version 1.** The intended target of the invite, if any.
|
/// **Added in VoIP version 1.** The intended target of the invite, if any.
|
||||||
///
|
///
|
||||||
/// If this is `None`, the invite is intended for any member of the room, except the sender.
|
/// If this is `None`, the invite is intended for any member of the room, except the sender.
|
||||||
@ -66,14 +62,12 @@ impl CallInviteEventContent {
|
|||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
call_id,
|
call_id,
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
party_id: None,
|
party_id: None,
|
||||||
lifetime,
|
lifetime,
|
||||||
offer,
|
offer,
|
||||||
version,
|
version,
|
||||||
#[cfg(feature = "unstable-msc2747")]
|
#[cfg(feature = "unstable-msc2747")]
|
||||||
capabilities: Default::default(),
|
capabilities: Default::default(),
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
invitee: None,
|
invitee: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,7 +80,6 @@ impl CallInviteEventContent {
|
|||||||
|
|
||||||
/// Convenience method to create a version 1 `CallInviteEventContent` with all the required
|
/// Convenience method to create a version 1 `CallInviteEventContent` with all the required
|
||||||
/// fields.
|
/// fields.
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
pub fn version_1(
|
pub fn version_1(
|
||||||
call_id: OwnedVoipId,
|
call_id: OwnedVoipId,
|
||||||
party_id: OwnedVoipId,
|
party_id: OwnedVoipId,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! Types for the `m.call.negotiate` event [MSC2746].
|
//! Types for the [`m.call.negotiate`] event.
|
||||||
//!
|
//!
|
||||||
//! [MSC2746]: https://github.com/matrix-org/matrix-spec-proposals/pull/2746
|
//! [`m.call.negotiate`]: https://spec.matrix.org/latest/client-server-api/#mcallnegotiate
|
||||||
|
|
||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_macros::EventContent;
|
use ruma_macros::EventContent;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! Types for the `m.call.reject` event [MSC2746].
|
//! Types for the [`m.call.reject`] event.
|
||||||
//!
|
//!
|
||||||
//! [MSC2746]: https://github.com/matrix-org/matrix-spec-proposals/pull/2746
|
//! [`m.call.reject`]: https://spec.matrix.org/latest/client-server-api/#mcallreject
|
||||||
|
|
||||||
use ruma_macros::EventContent;
|
use ruma_macros::EventContent;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! Types for the `m.call.select_answer` event [MSC2746].
|
//! Types for the [`m.call.select_answer`] event.
|
||||||
//!
|
//!
|
||||||
//! [MSC2746]: https://github.com/matrix-org/matrix-spec-proposals/pull/2746
|
//! [`m.call.select_answer`]: https://spec.matrix.org/latest/client-server-api/#mcallselect_answer
|
||||||
|
|
||||||
use ruma_macros::EventContent;
|
use ruma_macros::EventContent;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -40,11 +40,8 @@ event_enum! {
|
|||||||
"m.call.invite" => super::call::invite,
|
"m.call.invite" => super::call::invite,
|
||||||
"m.call.hangup" => super::call::hangup,
|
"m.call.hangup" => super::call::hangup,
|
||||||
"m.call.candidates" => super::call::candidates,
|
"m.call.candidates" => super::call::candidates,
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
"m.call.negotiate" => super::call::negotiate,
|
"m.call.negotiate" => super::call::negotiate,
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
"m.call.reject" => super::call::reject,
|
"m.call.reject" => super::call::reject,
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
"m.call.select_answer" => super::call::select_answer,
|
"m.call.select_answer" => super::call::select_answer,
|
||||||
#[cfg(feature = "unstable-msc3954")]
|
#[cfg(feature = "unstable-msc3954")]
|
||||||
#[ruma_enum(alias = "m.emote")]
|
#[ruma_enum(alias = "m.emote")]
|
||||||
@ -340,9 +337,10 @@ impl AnyMessageLikeEventContent {
|
|||||||
}
|
}
|
||||||
#[cfg(feature = "unstable-msc3381")]
|
#[cfg(feature = "unstable-msc3381")]
|
||||||
Self::PollStart(_) => None,
|
Self::PollStart(_) => None,
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
Self::CallNegotiate(_)
|
||||||
Self::CallNegotiate(_) | Self::CallReject(_) | Self::CallSelectAnswer(_) => None,
|
| Self::CallReject(_)
|
||||||
Self::CallAnswer(_)
|
| Self::CallSelectAnswer(_)
|
||||||
|
| Self::CallAnswer(_)
|
||||||
| Self::CallInvite(_)
|
| Self::CallInvite(_)
|
||||||
| Self::CallHangup(_)
|
| Self::CallHangup(_)
|
||||||
| Self::CallCandidates(_)
|
| Self::CallCandidates(_)
|
||||||
|
@ -34,7 +34,6 @@ pub enum VoipVersionId {
|
|||||||
V0,
|
V0,
|
||||||
|
|
||||||
/// A version 1 VoIP call.
|
/// A version 1 VoIP call.
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
V1,
|
V1,
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
@ -46,7 +45,6 @@ impl VoipVersionId {
|
|||||||
pub fn as_str(&self) -> &str {
|
pub fn as_str(&self) -> &str {
|
||||||
match &self {
|
match &self {
|
||||||
Self::V0 => "0",
|
Self::V0 => "0",
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
Self::V1 => "1",
|
Self::V1 => "1",
|
||||||
Self::_Custom(PrivOwnedStr(s)) => s,
|
Self::_Custom(PrivOwnedStr(s)) => s,
|
||||||
}
|
}
|
||||||
@ -133,7 +131,6 @@ where
|
|||||||
T: AsRef<str> + Into<Box<str>>,
|
T: AsRef<str> + Into<Box<str>>,
|
||||||
{
|
{
|
||||||
match s.as_ref() {
|
match s.as_ref() {
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
"1" => VoipVersionId::V1,
|
"1" => VoipVersionId::V1,
|
||||||
_ => VoipVersionId::_Custom(PrivOwnedStr(s.into())),
|
_ => VoipVersionId::_Custom(PrivOwnedStr(s.into())),
|
||||||
}
|
}
|
||||||
@ -174,7 +171,6 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
fn valid_version_1() {
|
fn valid_version_1() {
|
||||||
assert_eq!(VoipVersionId::try_from("1"), Ok(VoipVersionId::V1));
|
assert_eq!(VoipVersionId::try_from("1"), Ok(VoipVersionId::V1));
|
||||||
}
|
}
|
||||||
@ -199,13 +195,11 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
fn serialize_version_1() {
|
fn serialize_version_1() {
|
||||||
assert_eq!(to_json_value(&VoipVersionId::V1).unwrap(), json!("1"));
|
assert_eq!(to_json_value(&VoipVersionId::V1).unwrap(), json!("1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
fn deserialize_version_1() {
|
fn deserialize_version_1() {
|
||||||
assert_eq!(from_json_value::<VoipVersionId>(json!("1")).unwrap(), VoipVersionId::V1);
|
assert_eq!(from_json_value::<VoipVersionId>(json!("1")).unwrap(), VoipVersionId::V1);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,19 @@
|
|||||||
use assert_matches::assert_matches;
|
use assert_matches::assert_matches;
|
||||||
|
#[cfg(feature = "unstable-msc2747")]
|
||||||
|
use assign::assign;
|
||||||
use js_int::uint;
|
use js_int::uint;
|
||||||
|
#[cfg(feature = "unstable-msc2747")]
|
||||||
|
use ruma_common::events::call::CallCapabilities;
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
events::{
|
events::{
|
||||||
call::{
|
call::{
|
||||||
answer::CallAnswerEventContent,
|
answer::CallAnswerEventContent,
|
||||||
candidates::{CallCandidatesEventContent, Candidate},
|
candidates::{CallCandidatesEventContent, Candidate},
|
||||||
hangup::CallHangupEventContent,
|
hangup::{CallHangupEventContent, Reason},
|
||||||
invite::CallInviteEventContent,
|
invite::CallInviteEventContent,
|
||||||
|
negotiate::CallNegotiateEventContent,
|
||||||
|
reject::CallRejectEventContent,
|
||||||
|
select_answer::CallSelectAnswerEventContent,
|
||||||
SessionDescription,
|
SessionDescription,
|
||||||
},
|
},
|
||||||
AnyMessageLikeEvent, AnySyncMessageLikeEvent, MessageLikeEvent,
|
AnyMessageLikeEvent, AnySyncMessageLikeEvent, MessageLikeEvent,
|
||||||
@ -19,7 +25,7 @@ use ruma_common::{
|
|||||||
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn answer_content_serialization() {
|
fn answer_v0_content_serialization() {
|
||||||
let event_content = CallAnswerEventContent::version_0(
|
let event_content = CallAnswerEventContent::version_0(
|
||||||
SessionDescription::new("answer".to_owned(), "not a real sdp".to_owned()),
|
SessionDescription::new("answer".to_owned(), "not a real sdp".to_owned()),
|
||||||
"abcdef".into(),
|
"abcdef".into(),
|
||||||
@ -39,7 +45,7 @@ fn answer_content_serialization() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn answer_content_deserialization() {
|
fn answer_v0_content_deserialization() {
|
||||||
let json_data = json!({
|
let json_data = json!({
|
||||||
"answer": {
|
"answer": {
|
||||||
"type": "answer",
|
"type": "answer",
|
||||||
@ -58,7 +64,7 @@ fn answer_content_deserialization() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn answer_event_deserialization() {
|
fn answer_v0_event_deserialization() {
|
||||||
let json_data = json!({
|
let json_data = json!({
|
||||||
"content": {
|
"content": {
|
||||||
"answer": {
|
"answer": {
|
||||||
@ -93,7 +99,7 @@ fn answer_event_deserialization() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn answer_event_deserialization_then_convert_to_full() {
|
fn answer_v0_event_deserialization_then_convert_to_full() {
|
||||||
let rid = room_id!("!roomid:room.com");
|
let rid = room_id!("!roomid:room.com");
|
||||||
let json_data = json!({
|
let json_data = json!({
|
||||||
"content": {
|
"content": {
|
||||||
@ -129,7 +135,7 @@ fn answer_event_deserialization_then_convert_to_full() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn invite_content_serialization() {
|
fn invite_v0_content_serialization() {
|
||||||
let event_content = CallInviteEventContent::version_0(
|
let event_content = CallInviteEventContent::version_0(
|
||||||
"abcdef".into(),
|
"abcdef".into(),
|
||||||
uint!(30000),
|
uint!(30000),
|
||||||
@ -151,7 +157,7 @@ fn invite_content_serialization() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn candidates_content_serialization() {
|
fn candidates_v0_content_serialization() {
|
||||||
let event_content = CallCandidatesEventContent::version_0(
|
let event_content = CallCandidatesEventContent::version_0(
|
||||||
"abcdef".into(),
|
"abcdef".into(),
|
||||||
vec![Candidate::new("not a real candidate".to_owned(), "0".to_owned(), uint!(0))],
|
vec![Candidate::new("not a real candidate".to_owned(), "0".to_owned(), uint!(0))],
|
||||||
@ -174,7 +180,7 @@ fn candidates_content_serialization() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hangup_content_serialization() {
|
fn hangup_v0_content_serialization() {
|
||||||
let event_content = CallHangupEventContent::version_0("abcdef".into());
|
let event_content = CallHangupEventContent::version_0("abcdef".into());
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -187,34 +193,8 @@ fn hangup_content_serialization() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc2746")]
|
|
||||||
mod msc2746 {
|
|
||||||
use assert_matches::assert_matches;
|
|
||||||
#[cfg(feature = "unstable-msc2747")]
|
|
||||||
use assign::assign;
|
|
||||||
use js_int::uint;
|
|
||||||
#[cfg(feature = "unstable-msc2747")]
|
|
||||||
use ruma_common::events::call::CallCapabilities;
|
|
||||||
use ruma_common::{
|
|
||||||
events::{
|
|
||||||
call::{
|
|
||||||
answer::CallAnswerEventContent,
|
|
||||||
candidates::{CallCandidatesEventContent, Candidate},
|
|
||||||
hangup::{CallHangupEventContent, Reason},
|
|
||||||
invite::CallInviteEventContent,
|
|
||||||
negotiate::CallNegotiateEventContent,
|
|
||||||
reject::CallRejectEventContent,
|
|
||||||
select_answer::CallSelectAnswerEventContent,
|
|
||||||
SessionDescription,
|
|
||||||
},
|
|
||||||
AnyMessageLikeEvent, MessageLikeEvent,
|
|
||||||
},
|
|
||||||
VoipVersionId,
|
|
||||||
};
|
|
||||||
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn invite_event_serialization() {
|
fn invite_v1_event_serialization() {
|
||||||
let content = CallInviteEventContent::version_1(
|
let content = CallInviteEventContent::version_1(
|
||||||
"abcdef".into(),
|
"abcdef".into(),
|
||||||
"9876".into(),
|
"9876".into(),
|
||||||
@ -238,7 +218,7 @@ mod msc2746 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn invite_event_deserialization() {
|
fn invite_v1_event_deserialization() {
|
||||||
let json_data = json!({
|
let json_data = json!({
|
||||||
"content": {
|
"content": {
|
||||||
"call_id": "abcdef",
|
"call_id": "abcdef",
|
||||||
@ -272,7 +252,7 @@ mod msc2746 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn answer_event_serialization() {
|
fn answer_v1_event_serialization() {
|
||||||
let content = CallAnswerEventContent::version_1(
|
let content = CallAnswerEventContent::version_1(
|
||||||
SessionDescription::new("answer".to_owned(), "not a real sdp".to_owned()),
|
SessionDescription::new("answer".to_owned(), "not a real sdp".to_owned()),
|
||||||
"abcdef".into(),
|
"abcdef".into(),
|
||||||
@ -295,7 +275,7 @@ mod msc2746 {
|
|||||||
|
|
||||||
#[cfg(feature = "unstable-msc2747")]
|
#[cfg(feature = "unstable-msc2747")]
|
||||||
#[test]
|
#[test]
|
||||||
fn answer_event_capabilities_serialization() {
|
fn answer_v1_event_capabilities_serialization() {
|
||||||
let content = assign!(
|
let content = assign!(
|
||||||
CallAnswerEventContent::version_1(
|
CallAnswerEventContent::version_1(
|
||||||
SessionDescription::new("answer".to_owned(), "not a real sdp".to_owned()),
|
SessionDescription::new("answer".to_owned(), "not a real sdp".to_owned()),
|
||||||
@ -325,7 +305,7 @@ mod msc2746 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn answer_event_deserialization() {
|
fn answer_unknown_version_event_deserialization() {
|
||||||
let json_data = json!({
|
let json_data = json!({
|
||||||
"content": {
|
"content": {
|
||||||
"call_id": "abcdef",
|
"call_id": "abcdef",
|
||||||
@ -362,7 +342,7 @@ mod msc2746 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn candidates_event_serialization() {
|
fn candidates_v1_event_serialization() {
|
||||||
let content = CallCandidatesEventContent::version_1(
|
let content = CallCandidatesEventContent::version_1(
|
||||||
"abcdef".into(),
|
"abcdef".into(),
|
||||||
"9876".into(),
|
"9876".into(),
|
||||||
@ -395,7 +375,7 @@ mod msc2746 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn candidates_event_deserialization() {
|
fn candidates_v1_event_deserialization() {
|
||||||
let json_data = json!({
|
let json_data = json!({
|
||||||
"content": {
|
"content": {
|
||||||
"call_id": "abcdef",
|
"call_id": "abcdef",
|
||||||
@ -440,7 +420,7 @@ mod msc2746 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hangup_event_serialization() {
|
fn hangup_v1_event_serialization() {
|
||||||
let content =
|
let content =
|
||||||
CallHangupEventContent::version_1("abcdef".into(), "9876".into(), Reason::IceFailed);
|
CallHangupEventContent::version_1("abcdef".into(), "9876".into(), Reason::IceFailed);
|
||||||
|
|
||||||
@ -456,7 +436,7 @@ mod msc2746 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hangup_event_deserialization() {
|
fn hangup_v1_event_deserialization() {
|
||||||
let json_data = json!({
|
let json_data = json!({
|
||||||
"content": {
|
"content": {
|
||||||
"call_id": "abcdef",
|
"call_id": "abcdef",
|
||||||
@ -479,11 +459,11 @@ mod msc2746 {
|
|||||||
assert_eq!(content.call_id, "abcdef");
|
assert_eq!(content.call_id, "abcdef");
|
||||||
assert_eq!(content.party_id.unwrap(), "9876");
|
assert_eq!(content.party_id.unwrap(), "9876");
|
||||||
assert_eq!(content.version, VoipVersionId::V1);
|
assert_eq!(content.version, VoipVersionId::V1);
|
||||||
assert_eq!(content.reason, Some(Reason::UserHangup));
|
assert_eq!(content.reason, Reason::UserHangup);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn negotiate_event_serialization() {
|
fn negotiate_v1_event_serialization() {
|
||||||
let content = CallNegotiateEventContent::version_1(
|
let content = CallNegotiateEventContent::version_1(
|
||||||
"abcdef".into(),
|
"abcdef".into(),
|
||||||
"9876".into(),
|
"9876".into(),
|
||||||
@ -507,7 +487,7 @@ mod msc2746 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn negotiate_event_deserialization() {
|
fn negotiate_v1_event_deserialization() {
|
||||||
let json_data = json!({
|
let json_data = json!({
|
||||||
"content": {
|
"content": {
|
||||||
"call_id": "abcdef",
|
"call_id": "abcdef",
|
||||||
@ -540,7 +520,7 @@ mod msc2746 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn reject_event_serialization() {
|
fn reject_v1_event_serialization() {
|
||||||
let content = CallRejectEventContent::version_1("abcdef".into(), "9876".into());
|
let content = CallRejectEventContent::version_1("abcdef".into(), "9876".into());
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -554,7 +534,7 @@ mod msc2746 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn reject_event_deserialization() {
|
fn reject_v1_event_deserialization() {
|
||||||
let json_data = json!({
|
let json_data = json!({
|
||||||
"content": {
|
"content": {
|
||||||
"call_id": "abcdef",
|
"call_id": "abcdef",
|
||||||
@ -580,7 +560,7 @@ mod msc2746 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn select_answer_event_serialization() {
|
fn select_v1_answer_event_serialization() {
|
||||||
let content =
|
let content =
|
||||||
CallSelectAnswerEventContent::version_1("abcdef".into(), "9876".into(), "6336".into());
|
CallSelectAnswerEventContent::version_1("abcdef".into(), "9876".into(), "6336".into());
|
||||||
|
|
||||||
@ -596,7 +576,7 @@ mod msc2746 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn select_answer_event_deserialization() {
|
fn select_v1_answer_event_deserialization() {
|
||||||
let json_data = json!({
|
let json_data = json!({
|
||||||
"content": {
|
"content": {
|
||||||
"call_id": "abcdef",
|
"call_id": "abcdef",
|
||||||
@ -622,4 +602,3 @@ mod msc2746 {
|
|||||||
assert_eq!(content.selected_party_id, "6336");
|
assert_eq!(content.selected_party_id, "6336");
|
||||||
assert_eq!(content.version, VoipVersionId::V1);
|
assert_eq!(content.version, VoipVersionId::V1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -156,7 +156,6 @@ unstable-msc2448 = [
|
|||||||
]
|
]
|
||||||
unstable-msc2654 = ["ruma-client-api?/unstable-msc2654"]
|
unstable-msc2654 = ["ruma-client-api?/unstable-msc2654"]
|
||||||
unstable-msc2666 = ["ruma-client-api?/unstable-msc2666"]
|
unstable-msc2666 = ["ruma-client-api?/unstable-msc2666"]
|
||||||
unstable-msc2746 = ["ruma-common/unstable-msc2746"]
|
|
||||||
unstable-msc2747 = ["ruma-common/unstable-msc2747"]
|
unstable-msc2747 = ["ruma-common/unstable-msc2747"]
|
||||||
unstable-msc2870 = ["ruma-common/unstable-msc2870"]
|
unstable-msc2870 = ["ruma-common/unstable-msc2870"]
|
||||||
unstable-msc2965 = ["ruma-client-api?/unstable-msc2965"]
|
unstable-msc2965 = ["ruma-client-api?/unstable-msc2965"]
|
||||||
@ -200,7 +199,6 @@ __ci = [
|
|||||||
"unstable-msc2448",
|
"unstable-msc2448",
|
||||||
"unstable-msc2654",
|
"unstable-msc2654",
|
||||||
"unstable-msc2666",
|
"unstable-msc2666",
|
||||||
"unstable-msc2746",
|
|
||||||
"unstable-msc2747",
|
"unstable-msc2747",
|
||||||
"unstable-msc2870",
|
"unstable-msc2870",
|
||||||
"unstable-msc2965",
|
"unstable-msc2965",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user