Skip to main content

opentalk_roomserver_types_livekit/
event.rs

1// SPDX-FileCopyrightText: OpenTalk GmbH <mail@opentalk.eu>
2//
3// SPDX-License-Identifier: EUPL-1.2
4
5use std::collections::BTreeSet;
6
7use opentalk_types_signaling::ParticipantId;
8
9use crate::{Credentials, error::LiveKitError};
10
11/// The events emitted for livekit
12#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
13#[serde(tag = "message", rename_all = "snake_case")]
14pub enum LiveKitEvent {
15    /// The credentials for a client to use livekit
16    Credentials(Credentials),
17
18    /// A livekit access token that cannot publish and is hidden to other participants
19    PopoutStreamAccessToken {
20        /// The token
21        token: String,
22    },
23
24    /// LiveKit permissions have been updated.
25    ///
26    /// This event is the response to [`LiveKitCommand::RevokeScreenSharePermission`]
27    /// and [`LiveKitCommand::GrantScreenSharePermission`] and only received by the
28    /// moderator who issued the command. The participant who was the target of the
29    /// command will be notified by the LiveKit server.
30    ///
31    /// [`LiveKitCommand::RevokeScreenSharePermission`]: crate::command::LiveKitCommand::RevokeScreenSharePermission
32    /// [`LiveKitCommand::GrantScreenSharePermission`]: crate::command::LiveKitCommand::GrantScreenSharePermission
33    ScreenSharePermissionsUpdated {
34        /// `true` if screen share permissions where granted, `false` otherwise.
35        grant: bool,
36        /// The participants who received a screen share permission change.
37        participants: BTreeSet<ParticipantId>,
38    },
39
40    /// The last message couldn't be processed since an unexpected error occurred.
41    Error(LiveKitError),
42}
43
44impl From<LiveKitError> for LiveKitEvent {
45    fn from(error: LiveKitError) -> Self {
46        Self::Error(error)
47    }
48}