Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions livekit-ffi/protocol/participant.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,18 @@ message ParticipantInfo {
string identity = 3;
string metadata = 4;
map<string, string> attributes = 5;
ParticipantKind kind = 6;
}

message OwnedParticipant {
FfiOwnedHandle handle = 1;
ParticipantInfo info = 2;
}

enum ParticipantKind {
PARTICIPANT_KIND_STANDARD = 0;
PARTICIPANT_KIND_INGRESS = 1;
PARTICIPANT_KIND_EGRESS = 2;
PARTICIPANT_KIND_SIP = 3;
PARTICIPANT_KIND_AGENT = 4;
}
14 changes: 14 additions & 0 deletions livekit-ffi/src/conversion/participant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

use crate::{proto, server::room::FfiParticipant};
use livekit::ParticipantKind;

impl From<&FfiParticipant> for proto::ParticipantInfo {
fn from(value: &FfiParticipant) -> Self {
Expand All @@ -23,6 +24,19 @@ impl From<&FfiParticipant> for proto::ParticipantInfo {
identity: participant.identity().into(),
metadata: participant.metadata(),
attributes: participant.attributes(),
kind: proto::ParticipantKind::from(participant.kind()).into(),
}
}
}

impl From<ParticipantKind> for proto::ParticipantKind {
fn from(kind: ParticipantKind) -> Self {
match kind {
ParticipantKind::Standard => proto::ParticipantKind::Standard,
ParticipantKind::Sip => proto::ParticipantKind::Sip,
ParticipantKind::Ingress => proto::ParticipantKind::Ingress,
ParticipantKind::Egress => proto::ParticipantKind::Egress,
ParticipantKind::Agent => proto::ParticipantKind::Agent,
}
}
}
37 changes: 37 additions & 0 deletions livekit-ffi/src/livekit.proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,8 @@ pub struct ParticipantInfo {
pub metadata: ::prost::alloc::string::String,
#[prost(map="string, string", tag="5")]
pub attributes: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>,
#[prost(enumeration="ParticipantKind", tag="6")]
pub kind: i32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand All @@ -1551,6 +1553,41 @@ pub struct OwnedParticipant {
#[prost(message, optional, tag="2")]
pub info: ::core::option::Option<ParticipantInfo>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ParticipantKind {
Standard = 0,
Ingress = 1,
Egress = 2,
Sip = 3,
Agent = 4,
}
impl ParticipantKind {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
ParticipantKind::Standard => "PARTICIPANT_KIND_STANDARD",
ParticipantKind::Ingress => "PARTICIPANT_KIND_INGRESS",
ParticipantKind::Egress => "PARTICIPANT_KIND_EGRESS",
ParticipantKind::Sip => "PARTICIPANT_KIND_SIP",
ParticipantKind::Agent => "PARTICIPANT_KIND_AGENT",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"PARTICIPANT_KIND_STANDARD" => Some(Self::Standard),
"PARTICIPANT_KIND_INGRESS" => Some(Self::Ingress),
"PARTICIPANT_KIND_EGRESS" => Some(Self::Egress),
"PARTICIPANT_KIND_SIP" => Some(Self::Sip),
"PARTICIPANT_KIND_AGENT" => Some(Self::Agent),
_ => None,
}
}
}
/// Create a new VideoStream
/// VideoStream is used to receive video frames from a track
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down
2 changes: 1 addition & 1 deletion livekit/src/room/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use proto::{promise::Promise, SignalTarget};
use thiserror::Error;
use tokio::sync::{mpsc, oneshot, Mutex as AsyncMutex};

use self::{
pub use self::{
e2ee::{manager::E2eeManager, E2eeOptions},
participant::ParticipantKind,
};
Expand Down
1 change: 1 addition & 0 deletions livekit/src/room/participant/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ impl Participant {
pub fn is_speaking(self: &Self) -> bool;
pub fn audio_level(self: &Self) -> f32;
pub fn connection_quality(self: &Self) -> ConnectionQuality;
pub fn kind(self: &Self) -> ParticipantKind;

pub(crate) fn update_info(self: &Self, info: proto::ParticipantInfo) -> ();

Expand Down