diff --git a/crates/ruma-common/src/events/call/negotiate.rs b/crates/ruma-common/src/events/call/negotiate.rs index cf94a98c..e7f3a81f 100644 --- a/crates/ruma-common/src/events/call/negotiate.rs +++ b/crates/ruma-common/src/events/call/negotiate.rs @@ -7,7 +7,7 @@ use ruma_macros::EventContent; use serde::{Deserialize, Serialize}; use super::SessionDescription; -use crate::OwnedVoipId; +use crate::{OwnedVoipId, VoipVersionId}; /// **Added in VoIP version 1.** The content of an `m.call.negotiate` event. /// @@ -29,6 +29,9 @@ pub struct CallNegotiateEventContent { /// this session. pub party_id: OwnedVoipId, + /// The version of the VoIP specification this messages adheres to. + pub version: VoipVersionId, + /// The time in milliseconds that the negotiation is valid for. pub lifetime: UInt, @@ -42,9 +45,21 @@ impl CallNegotiateEventContent { pub fn new( call_id: OwnedVoipId, party_id: OwnedVoipId, + version: VoipVersionId, lifetime: UInt, description: SessionDescription, ) -> Self { - Self { call_id, party_id, lifetime, description } + Self { call_id, party_id, version, lifetime, description } + } + + /// Convenience method to create a version 1 `CallNegotiateEventContent` with all the required + /// fields. + pub fn version_1( + call_id: OwnedVoipId, + party_id: OwnedVoipId, + lifetime: UInt, + description: SessionDescription, + ) -> Self { + Self::new(call_id, party_id, VoipVersionId::V1, lifetime, description) } } diff --git a/crates/ruma-common/tests/events/call.rs b/crates/ruma-common/tests/events/call.rs index 9e433caa..54d9d2dd 100644 --- a/crates/ruma-common/tests/events/call.rs +++ b/crates/ruma-common/tests/events/call.rs @@ -481,7 +481,7 @@ mod msc2746 { #[test] fn negotiate_event_serialization() { - let content = CallNegotiateEventContent::new( + let content = CallNegotiateEventContent::version_1( "abcdef".into(), "9876".into(), uint!(30000), @@ -493,6 +493,7 @@ mod msc2746 { json!({ "call_id": "abcdef", "party_id": "9876", + "version": "1", "lifetime": 30000, "description": { "type": "offer", @@ -508,6 +509,7 @@ mod msc2746 { "content": { "call_id": "abcdef", "party_id": "9876", + "version": "1", "lifetime": 30000, "description": { "type": "pranswer",