Skip to content

Commit

Permalink
Use identity instead of sid where possible (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
keepingitneil authored Jul 16, 2024
1 parent a2d0382 commit 07963c3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 50 deletions.
29 changes: 14 additions & 15 deletions livekit-ffi/protocol/room.proto
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ message OwnedRoom {
message ParticipantConnected { OwnedParticipant info = 1; }

message ParticipantDisconnected {
string participant_sid = 1;
string participant_identity = 1;
}

message LocalTrackPublished {
Expand All @@ -332,50 +332,50 @@ message LocalTrackUnpublished {
}

message TrackPublished {
string participant_sid = 1;
string participant_identity = 1;
OwnedTrackPublication publication = 2;
}

message TrackUnpublished {
string participant_sid = 1;
string participant_identity = 1;
string publication_sid = 2;
}

// Publication isn't needed for subscription events on the FFI
// The FFI will retrieve the publication using the Track sid
message TrackSubscribed {
string participant_sid = 1;
string participant_identity = 1;
OwnedTrack track = 2;
}

message TrackUnsubscribed {
// The FFI language can dispose/remove the VideoSink here
string participant_sid = 1;
string participant_identity = 1;
string track_sid = 2;
}

message TrackSubscriptionFailed {
string participant_sid = 1;
string participant_identity = 1;
string track_sid = 2;
string error = 3;
}

message TrackMuted {
string participant_sid = 1;
string participant_identity = 1;
string track_sid = 2;
}

message TrackUnmuted {
string participant_sid = 1;
string participant_identity = 1;
string track_sid = 2;
}

message E2eeStateChanged {
string participant_sid = 1; // Using sid instead of identity for ffi communication
string participant_identity = 1; // Using sid instead of identity for ffi communication
EncryptionState state = 2;
}

message ActiveSpeakersChanged { repeated string participant_sids = 1; }
message ActiveSpeakersChanged { repeated string participant_identities = 1; }

message RoomMetadataChanged {
string metadata = 1;
Expand All @@ -386,23 +386,23 @@ message RoomSidChanged {
}

message ParticipantMetadataChanged {
string participant_sid = 1;
string participant_identity = 1;
string metadata = 2;
}

message ParticipantAttributesChanged {
string participant_sid = 1;
string participant_identity = 1;
map<string, string> old_attributes = 2;
map<string, string> attributes = 3;
}

message ParticipantNameChanged {
string participant_sid = 1;
string participant_identity = 1;
string name = 2;
}

message ConnectionQualityChanged {
string participant_sid = 1;
string participant_identity = 1;
ConnectionQuality quality = 2;
}

Expand All @@ -419,7 +419,6 @@ message SipDTMF {
message DataPacketReceived {
DataPacketKind kind = 1;
string participant_identity = 2; // Can be empty if the data is sent a server SDK
optional string participant_sid = 3 [deprecated=true]; // Can be empty if the data is sent a server SDK
oneof value {
UserPacket user = 4;
SipDTMF sip_dtmf = 5;
Expand Down
32 changes: 14 additions & 18 deletions livekit-ffi/src/livekit.proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2380,7 +2380,7 @@ pub struct ParticipantConnected {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ParticipantDisconnected {
#[prost(string, tag="1")]
pub participant_sid: ::prost::alloc::string::String,
pub participant_identity: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand All @@ -2400,15 +2400,15 @@ pub struct LocalTrackUnpublished {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TrackPublished {
#[prost(string, tag="1")]
pub participant_sid: ::prost::alloc::string::String,
pub participant_identity: ::prost::alloc::string::String,
#[prost(message, optional, tag="2")]
pub publication: ::core::option::Option<OwnedTrackPublication>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TrackUnpublished {
#[prost(string, tag="1")]
pub participant_sid: ::prost::alloc::string::String,
pub participant_identity: ::prost::alloc::string::String,
#[prost(string, tag="2")]
pub publication_sid: ::prost::alloc::string::String,
}
Expand All @@ -2418,7 +2418,7 @@ pub struct TrackUnpublished {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TrackSubscribed {
#[prost(string, tag="1")]
pub participant_sid: ::prost::alloc::string::String,
pub participant_identity: ::prost::alloc::string::String,
#[prost(message, optional, tag="2")]
pub track: ::core::option::Option<OwnedTrack>,
}
Expand All @@ -2427,15 +2427,15 @@ pub struct TrackSubscribed {
pub struct TrackUnsubscribed {
/// The FFI language can dispose/remove the VideoSink here
#[prost(string, tag="1")]
pub participant_sid: ::prost::alloc::string::String,
pub participant_identity: ::prost::alloc::string::String,
#[prost(string, tag="2")]
pub track_sid: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TrackSubscriptionFailed {
#[prost(string, tag="1")]
pub participant_sid: ::prost::alloc::string::String,
pub participant_identity: ::prost::alloc::string::String,
#[prost(string, tag="2")]
pub track_sid: ::prost::alloc::string::String,
#[prost(string, tag="3")]
Expand All @@ -2445,15 +2445,15 @@ pub struct TrackSubscriptionFailed {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TrackMuted {
#[prost(string, tag="1")]
pub participant_sid: ::prost::alloc::string::String,
pub participant_identity: ::prost::alloc::string::String,
#[prost(string, tag="2")]
pub track_sid: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TrackUnmuted {
#[prost(string, tag="1")]
pub participant_sid: ::prost::alloc::string::String,
pub participant_identity: ::prost::alloc::string::String,
#[prost(string, tag="2")]
pub track_sid: ::prost::alloc::string::String,
}
Expand All @@ -2462,15 +2462,15 @@ pub struct TrackUnmuted {
pub struct E2eeStateChanged {
/// Using sid instead of identity for ffi communication
#[prost(string, tag="1")]
pub participant_sid: ::prost::alloc::string::String,
pub participant_identity: ::prost::alloc::string::String,
#[prost(enumeration="EncryptionState", tag="2")]
pub state: i32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ActiveSpeakersChanged {
#[prost(string, repeated, tag="1")]
pub participant_sids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
pub participant_identities: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand All @@ -2488,15 +2488,15 @@ pub struct RoomSidChanged {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ParticipantMetadataChanged {
#[prost(string, tag="1")]
pub participant_sid: ::prost::alloc::string::String,
pub participant_identity: ::prost::alloc::string::String,
#[prost(string, tag="2")]
pub metadata: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ParticipantAttributesChanged {
#[prost(string, tag="1")]
pub participant_sid: ::prost::alloc::string::String,
pub participant_identity: ::prost::alloc::string::String,
#[prost(map="string, string", tag="2")]
pub old_attributes: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>,
#[prost(map="string, string", tag="3")]
Expand All @@ -2506,15 +2506,15 @@ pub struct ParticipantAttributesChanged {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ParticipantNameChanged {
#[prost(string, tag="1")]
pub participant_sid: ::prost::alloc::string::String,
pub participant_identity: ::prost::alloc::string::String,
#[prost(string, tag="2")]
pub name: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ConnectionQualityChanged {
#[prost(string, tag="1")]
pub participant_sid: ::prost::alloc::string::String,
pub participant_identity: ::prost::alloc::string::String,
#[prost(enumeration="ConnectionQuality", tag="2")]
pub quality: i32,
}
Expand Down Expand Up @@ -2542,10 +2542,6 @@ pub struct DataPacketReceived {
/// Can be empty if the data is sent a server SDK
#[prost(string, tag="2")]
pub participant_identity: ::prost::alloc::string::String,
/// Can be empty if the data is sent a server SDK
#[deprecated]
#[prost(string, optional, tag="3")]
pub participant_sid: ::core::option::Option<::prost::alloc::string::String>,
#[prost(oneof="data_packet_received::Value", tags="4, 5")]
pub value: ::core::option::Option<data_packet_received::Value>,
}
Expand Down
35 changes: 18 additions & 17 deletions livekit-ffi/src/server/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,9 @@ async fn forward_event(
}
RoomEvent::ParticipantDisconnected(participant) => {
let _ = send_event(proto::room_event::Message::ParticipantDisconnected(
proto::ParticipantDisconnected { participant_sid: participant.sid().into() },
proto::ParticipantDisconnected {
participant_identity: participant.identity().into(),
},
));
}
RoomEvent::LocalTrackPublished { publication, track: _, participant: _ } => {
Expand Down Expand Up @@ -691,7 +693,7 @@ async fn forward_event(
server.store_handle(ffi_publication.handle, ffi_publication);

let _ = send_event(proto::room_event::Message::TrackPublished(proto::TrackPublished {
participant_sid: participant.sid().to_string(),
participant_identity: participant.identity().to_string(),
publication: Some(proto::OwnedTrackPublication {
handle: Some(proto::FfiOwnedHandle { id: handle_id }),
info: Some(publication_info),
Expand All @@ -701,7 +703,7 @@ async fn forward_event(
RoomEvent::TrackUnpublished { publication, participant } => {
let _ =
send_event(proto::room_event::Message::TrackUnpublished(proto::TrackUnpublished {
participant_sid: participant.sid().to_string(),
participant_identity: participant.identity().to_string(),
publication_sid: publication.sid().into(),
}));
}
Expand All @@ -714,7 +716,7 @@ async fn forward_event(

let _ =
send_event(proto::room_event::Message::TrackSubscribed(proto::TrackSubscribed {
participant_sid: participant.sid().to_string(),
participant_identity: participant.identity().to_string(),
track: Some(proto::OwnedTrack {
handle: Some(proto::FfiOwnedHandle { id: handle_id }),
info: Some(track_info),
Expand All @@ -724,29 +726,29 @@ async fn forward_event(
RoomEvent::TrackUnsubscribed { track, publication: _, participant } => {
let _ = send_event(proto::room_event::Message::TrackUnsubscribed(
proto::TrackUnsubscribed {
participant_sid: participant.sid().to_string(),
participant_identity: participant.identity().to_string(),
track_sid: track.sid().to_string(),
},
));
}
RoomEvent::TrackSubscriptionFailed { participant, error, track_sid } => {
let _ = send_event(proto::room_event::Message::TrackSubscriptionFailed(
proto::TrackSubscriptionFailed {
participant_sid: participant.sid().to_string(),
participant_identity: participant.identity().to_string(),
error: error.to_string(),
track_sid: track_sid.into(),
},
));
}
RoomEvent::TrackMuted { participant, publication } => {
let _ = send_event(proto::room_event::Message::TrackMuted(proto::TrackMuted {
participant_sid: participant.sid().to_string(),
participant_identity: participant.identity().to_string(),
track_sid: publication.sid().into(),
}));
}
RoomEvent::TrackUnmuted { participant, publication } => {
let _ = send_event(proto::room_event::Message::TrackUnmuted(proto::TrackUnmuted {
participant_sid: participant.sid().to_string(),
participant_identity: participant.identity().to_string(),
track_sid: publication.sid().into(),
}));
}
Expand All @@ -758,39 +760,40 @@ async fn forward_event(
RoomEvent::ParticipantMetadataChanged { participant, old_metadata: _, metadata } => {
let _ = send_event(proto::room_event::Message::ParticipantMetadataChanged(
proto::ParticipantMetadataChanged {
participant_sid: participant.sid().to_string(),
participant_identity: participant.identity().to_string(),
metadata,
},
));
}
RoomEvent::ParticipantNameChanged { participant, old_name: _, name } => {
let _ = send_event(proto::room_event::Message::ParticipantNameChanged(
proto::ParticipantNameChanged {
participant_sid: participant.sid().to_string(),
participant_identity: participant.identity().to_string(),
name,
},
));
}
RoomEvent::ParticipantAttributesChanged { participant, old_attributes, attributes } => {
let _ = send_event(proto::room_event::Message::ParticipantAttributesChanged(
proto::ParticipantAttributesChanged {
participant_sid: participant.sid().to_string(),
participant_identity: participant.identity().to_string(),
old_attributes,
attributes,
},
));
}
RoomEvent::ActiveSpeakersChanged { speakers } => {
let participant_sids = speakers.iter().map(|p| p.sid().to_string()).collect::<Vec<_>>();
let participant_identities =
speakers.iter().map(|p| p.identity().to_string()).collect::<Vec<_>>();

let _ = send_event(proto::room_event::Message::ActiveSpeakersChanged(
proto::ActiveSpeakersChanged { participant_sids },
proto::ActiveSpeakersChanged { participant_identities },
));
}
RoomEvent::ConnectionQualityChanged { quality, participant } => {
let _ = send_event(proto::room_event::Message::ConnectionQualityChanged(
proto::ConnectionQualityChanged {
participant_sid: participant.sid().to_string(),
participant_identity: participant.identity().to_string(),
quality: proto::ConnectionQuality::from(quality).into(),
},
));
Expand All @@ -817,7 +820,6 @@ async fn forward_event(
topic,
})),
participant_identity: identity,
participant_sid: sid,
kind: proto::DataPacketKind::from(kind).into(),
},
));
Expand All @@ -834,7 +836,6 @@ async fn forward_event(
digit,
})),
participant_identity: identity,
participant_sid: sid,
kind: proto::DataPacketKind::KindReliable.into(),
},
));
Expand All @@ -861,7 +862,7 @@ async fn forward_event(
RoomEvent::E2eeStateChanged { participant, state } => {
let _ =
send_event(proto::room_event::Message::E2eeStateChanged(proto::E2eeStateChanged {
participant_sid: participant.sid().to_string(),
participant_identity: participant.identity().to_string(),
state: proto::EncryptionState::from(state).into(),
}));
}
Expand Down

0 comments on commit 07963c3

Please sign in to comment.