From 07963c3afd28b04eb57a5e5cf79617ca2bcb5b63 Mon Sep 17 00:00:00 2001 From: Neil Dwyer Date: Tue, 16 Jul 2024 16:11:24 -0700 Subject: [PATCH] Use identity instead of sid where possible (#375) --- livekit-ffi/protocol/room.proto | 29 +++++++++++++------------- livekit-ffi/src/livekit.proto.rs | 32 +++++++++++++---------------- livekit-ffi/src/server/room.rs | 35 ++++++++++++++++---------------- 3 files changed, 46 insertions(+), 50 deletions(-) diff --git a/livekit-ffi/protocol/room.proto b/livekit-ffi/protocol/room.proto index cd347353e..9f9915728 100644 --- a/livekit-ffi/protocol/room.proto +++ b/livekit-ffi/protocol/room.proto @@ -318,7 +318,7 @@ message OwnedRoom { message ParticipantConnected { OwnedParticipant info = 1; } message ParticipantDisconnected { - string participant_sid = 1; + string participant_identity = 1; } message LocalTrackPublished { @@ -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; @@ -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 old_attributes = 2; map 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; } @@ -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; diff --git a/livekit-ffi/src/livekit.proto.rs b/livekit-ffi/src/livekit.proto.rs index c754b6823..3aaf58948 100644 --- a/livekit-ffi/src/livekit.proto.rs +++ b/livekit-ffi/src/livekit.proto.rs @@ -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)] @@ -2400,7 +2400,7 @@ 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, } @@ -2408,7 +2408,7 @@ pub struct TrackPublished { #[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, } @@ -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, } @@ -2427,7 +2427,7 @@ 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, } @@ -2435,7 +2435,7 @@ pub struct TrackUnsubscribed { #[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")] @@ -2445,7 +2445,7 @@ 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, } @@ -2453,7 +2453,7 @@ pub struct TrackMuted { #[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, } @@ -2462,7 +2462,7 @@ 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, } @@ -2470,7 +2470,7 @@ pub struct E2eeStateChanged { #[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)] @@ -2488,7 +2488,7 @@ 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, } @@ -2496,7 +2496,7 @@ pub struct ParticipantMetadataChanged { #[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")] @@ -2506,7 +2506,7 @@ 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, } @@ -2514,7 +2514,7 @@ pub struct ParticipantNameChanged { #[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, } @@ -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, } diff --git a/livekit-ffi/src/server/room.rs b/livekit-ffi/src/server/room.rs index 4f7aefd0c..00aa63d7f 100644 --- a/livekit-ffi/src/server/room.rs +++ b/livekit-ffi/src/server/room.rs @@ -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: _ } => { @@ -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), @@ -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(), })); } @@ -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), @@ -724,7 +726,7 @@ 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(), }, )); @@ -732,7 +734,7 @@ async fn forward_event( 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(), }, @@ -740,13 +742,13 @@ async fn forward_event( } 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(), })); } @@ -758,7 +760,7 @@ 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, }, )); @@ -766,7 +768,7 @@ async fn forward_event( 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, }, )); @@ -774,23 +776,24 @@ async fn forward_event( 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::>(); + let participant_identities = + speakers.iter().map(|p| p.identity().to_string()).collect::>(); 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(), }, )); @@ -817,7 +820,6 @@ async fn forward_event( topic, })), participant_identity: identity, - participant_sid: sid, kind: proto::DataPacketKind::from(kind).into(), }, )); @@ -834,7 +836,6 @@ async fn forward_event( digit, })), participant_identity: identity, - participant_sid: sid, kind: proto::DataPacketKind::KindReliable.into(), }, )); @@ -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(), })); }