events: Add unstable support for muting in VoIP calls

According to MSC3291
This commit is contained in:
Kévin Commaille 2024-04-19 16:39:56 +02:00 committed by Kévin Commaille
parent 3760d69ade
commit a28d1428e0
6 changed files with 81 additions and 1 deletions

View File

@ -32,6 +32,7 @@ Improvements:
- Add `filename` and `formatted` fields to media event contents to support media captions
as per [MSC2530](https://github.com/matrix-org/matrix-spec-proposals/pull/2530) / Matrix 1.10
- Add support for multi-stream VoIP, according to MSC3077 / Matrix 1.10
- Add unstable support for muting in VoIP calls, according to MSC3291
# 0.27.11

View File

@ -30,6 +30,7 @@ unstable-msc3245 = ["unstable-msc3246"]
# https://github.com/matrix-org/matrix-spec-proposals/blob/83f6c5b469c1d78f714e335dcaa25354b255ffa5/proposals/3245-voice-messages.md
unstable-msc3245-v1-compat = []
unstable-msc3246 = ["unstable-msc3927"]
unstable-msc3291 = []
unstable-msc3381 = ["unstable-msc1767"]
unstable-msc3401 = []
unstable-msc3488 = ["unstable-msc1767"]

View File

@ -12,6 +12,8 @@ pub mod negotiate;
#[cfg(feature = "unstable-msc4075")]
pub mod notify;
pub mod reject;
#[cfg(feature = "unstable-msc3291")]
pub mod sdp_stream_metadata_changed;
pub mod select_answer;
use ruma_macros::StringEnum;
@ -53,12 +55,32 @@ impl SessionDescription {
pub struct StreamMetadata {
/// The purpose of the stream.
pub purpose: StreamPurpose,
/// Whether the audio track of the stream is muted.
///
/// Defaults to `false`.
#[cfg(feature = "unstable-msc3291")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
pub audio_muted: bool,
/// Whether the video track of the stream is muted.
///
/// Defaults to `false`.
#[cfg(feature = "unstable-msc3291")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
pub video_muted: bool,
}
impl StreamMetadata {
/// Creates a new `StreamMetadata` with the given purpose.
pub fn new(purpose: StreamPurpose) -> Self {
Self { purpose }
Self {
purpose,
#[cfg(feature = "unstable-msc3291")]
audio_muted: false,
#[cfg(feature = "unstable-msc3291")]
video_muted: false,
}
}
}

View File

@ -0,0 +1,49 @@
//! Types for the [`m.call.sdp_stream_metadata_changed`] event.
//!
//! [`m.call.sdp_stream_metadata_changed`]: https://github.com/matrix-org/matrix-spec-proposals/pull/3291
use std::collections::BTreeMap;
use ruma_common::{OwnedVoipId, VoipVersionId};
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize};
use super::StreamMetadata;
/// The content of an `m.call.sdp_stream_metadata_changed` event.
///
/// This event is sent by any party when a stream metadata changes but no negotiation is required.
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "org.matrix.call.sdp_stream_metadata_changed", kind = MessageLike)]
pub struct CallSdpStreamMetadataChangedEventContent {
/// A unique identifier for the call.
pub call_id: OwnedVoipId,
/// A unique ID for this session for the duration of the call.
pub party_id: OwnedVoipId,
/// The version of the VoIP specification this messages adheres to.
///
/// Must be at least [`VoipVersionId::V1`].
pub version: VoipVersionId,
/// Metadata describing the streams that will be sent.
///
/// This is a map of stream ID to metadata about the stream.
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
pub sdp_stream_metadata: BTreeMap<String, StreamMetadata>,
}
impl CallSdpStreamMetadataChangedEventContent {
/// Creates a new `SdpStreamMetadataChangedEventContent` with the given call ID, party ID, VoIP
/// version and stream metadata.
pub fn new(
call_id: OwnedVoipId,
party_id: OwnedVoipId,
version: VoipVersionId,
sdp_stream_metadata: BTreeMap<String, StreamMetadata>,
) -> Self {
Self { call_id, party_id, version, sdp_stream_metadata }
}
}

View File

@ -45,6 +45,9 @@ event_enum! {
"m.call.candidates" => super::call::candidates,
"m.call.negotiate" => super::call::negotiate,
"m.call.reject" => super::call::reject,
#[cfg(feature = "unstable-msc3291")]
#[ruma_enum(alias = "m.call.sdp_stream_metadata_changed")]
"org.matrix.call.sdp_stream_metadata_changed" => super::call::sdp_stream_metadata_changed,
"m.call.select_answer" => super::call::select_answer,
#[cfg(feature = "unstable-msc3954")]
#[ruma_enum(alias = "m.emote")]
@ -360,6 +363,8 @@ impl AnyMessageLikeEventContent {
Self::PollStart(_) | Self::UnstablePollStart(_) => None,
#[cfg(feature = "unstable-msc4075")]
Self::CallNotify(_) => None,
#[cfg(feature = "unstable-msc3291")]
Self::CallSdpStreamMetadataChanged(_) => None,
Self::CallNegotiate(_)
| Self::CallReject(_)
| Self::CallSelectAnswer(_)

View File

@ -195,6 +195,7 @@ unstable-msc3245 = ["ruma-events?/unstable-msc3245"]
unstable-msc3245-v1-compat = ["ruma-events?/unstable-msc3245-v1-compat"]
unstable-msc3246 = ["ruma-events?/unstable-msc3246"]
unstable-msc3266 = ["ruma-client-api?/unstable-msc3266"]
unstable-msc3291 = ["ruma-events?/unstable-msc3291"]
unstable-msc3381 = ["ruma-events?/unstable-msc3381"]
unstable-msc3401 = ["ruma-events?/unstable-msc3401"]
unstable-msc3488 = ["ruma-client-api?/unstable-msc3488", "ruma-events?/unstable-msc3488"]
@ -246,6 +247,7 @@ __ci = [
"unstable-msc3245-v1-compat",
"unstable-msc3246",
"unstable-msc3266",
"unstable-msc3291",
"unstable-msc3381",
"unstable-msc3401",
"unstable-msc3488",