Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add participant attributes to the FFI #367

Merged
merged 9 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
47 changes: 25 additions & 22 deletions livekit-ffi/protocol/ffi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,20 @@ message FfiRequest {
SetSubscribedRequest set_subscribed = 8;
UpdateLocalMetadataRequest update_local_metadata = 9;
UpdateLocalNameRequest update_local_name = 10;
GetSessionStatsRequest get_session_stats = 11;
PublishTranscriptionRequest publish_transcription = 12;
UpdateLocalAttributesRequest update_local_attributes = 11;
GetSessionStatsRequest get_session_stats = 12;
PublishTranscriptionRequest publish_transcription = 13;

// Track
CreateVideoTrackRequest create_video_track = 13;
CreateAudioTrackRequest create_audio_track = 14;
GetStatsRequest get_stats = 15;
CreateVideoTrackRequest create_video_track = 14;
CreateAudioTrackRequest create_audio_track = 15;
GetStatsRequest get_stats = 16;

// Video
NewVideoStreamRequest new_video_stream = 16;
NewVideoSourceRequest new_video_source = 17;
CaptureVideoFrameRequest capture_video_frame = 18;
VideoConvertRequest video_convert = 19;
NewVideoStreamRequest new_video_stream = 17;
NewVideoSourceRequest new_video_source = 18;
CaptureVideoFrameRequest capture_video_frame = 19;
VideoConvertRequest video_convert = 20;

// Audio
NewAudioStreamRequest new_audio_stream = 22;
Expand All @@ -103,19 +104,20 @@ message FfiResponse {
SetSubscribedResponse set_subscribed = 8;
UpdateLocalMetadataResponse update_local_metadata = 9;
UpdateLocalNameResponse update_local_name = 10;
GetSessionStatsResponse get_session_stats = 11;
PublishTranscriptionResponse publish_transcription = 12;
UpdateLocalAttributesResponse update_local_attributes = 11;
GetSessionStatsResponse get_session_stats = 12;
PublishTranscriptionResponse publish_transcription = 13;

// Track
CreateVideoTrackResponse create_video_track = 13;
CreateAudioTrackResponse create_audio_track = 14;
GetStatsResponse get_stats = 15;
CreateVideoTrackResponse create_video_track = 14;
CreateAudioTrackResponse create_audio_track = 15;
GetStatsResponse get_stats = 16;

// Video
NewVideoStreamResponse new_video_stream = 16;
NewVideoSourceResponse new_video_source = 17;
CaptureVideoFrameResponse capture_video_frame = 18;
VideoConvertResponse video_convert = 19;
NewVideoStreamResponse new_video_stream = 17;
NewVideoSourceResponse new_video_source = 18;
CaptureVideoFrameResponse capture_video_frame = 19;
VideoConvertResponse video_convert = 20;

// Audio
NewAudioStreamResponse new_audio_stream = 22;
Expand Down Expand Up @@ -146,10 +148,11 @@ message FfiEvent {
CaptureAudioFrameCallback capture_audio_frame = 12;
UpdateLocalMetadataCallback update_local_metadata = 13;
UpdateLocalNameCallback update_local_name = 14;
GetStatsCallback get_stats = 15;
LogBatch logs = 16;
GetSessionStatsCallback get_session_stats = 17;
Panic panic = 18;
UpdateLocalAttributesCallback update_local_attributes = 15;
GetStatsCallback get_stats = 16;
LogBatch logs = 17;
GetSessionStatsCallback get_session_stats = 18;
Panic panic = 19;
}
}

Expand Down
1 change: 1 addition & 0 deletions livekit-ffi/protocol/participant.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ message ParticipantInfo {
string name = 2;
string identity = 3;
string metadata = 4;
map<string, string> attributes = 5;
}

message OwnedParticipant {
Expand Down
37 changes: 28 additions & 9 deletions livekit-ffi/protocol/room.proto
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ message UpdateLocalMetadataCallback {
uint64 async_id = 1;
}

// Change the local participant's attributes
message UpdateLocalAttributesRequest {
keepingitneil marked this conversation as resolved.
Show resolved Hide resolved
uint64 local_participant_handle = 1;
map<string, string> attributes = 2;
}
message UpdateLocalAttributesResponse {
uint64 async_id = 1;
}
message UpdateLocalAttributesCallback {
uint64 async_id = 1;
keepingitneil marked this conversation as resolved.
Show resolved Hide resolved
}

// Change the local participant's name
message UpdateLocalNameRequest {
uint64 local_participant_handle = 1;
Expand Down Expand Up @@ -276,15 +288,16 @@ message RoomEvent {
RoomSidChanged room_sid_changed = 15;
ParticipantMetadataChanged participant_metadata_changed = 16;
ParticipantNameChanged participant_name_changed = 17;
ConnectionQualityChanged connection_quality_changed = 18;
keepingitneil marked this conversation as resolved.
Show resolved Hide resolved
ConnectionStateChanged connection_state_changed = 19;
// Connected connected = 20;
Disconnected disconnected = 21;
Reconnecting reconnecting = 22;
Reconnected reconnected = 23;
E2eeStateChanged e2ee_state_changed = 24;
RoomEOS eos = 25; // The stream of room events has ended
DataPacketReceived data_packet_received = 26;
ParticipantAttributesChanged participant_attributes_changed = 18;
ConnectionQualityChanged connection_quality_changed = 19;
ConnectionStateChanged connection_state_changed = 20;
// Connected connected = 21;
Disconnected disconnected = 22;
Reconnecting reconnecting = 23;
Reconnected reconnected = 24;
E2eeStateChanged e2ee_state_changed = 25;
RoomEOS eos = 26; // The stream of room events has ended
DataPacketReceived data_packet_received = 27;
}
}

Expand Down Expand Up @@ -374,6 +387,12 @@ message ParticipantMetadataChanged {
string metadata = 2;
}

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

message ParticipantNameChanged {
string participant_sid = 1;
string name = 2;
Expand Down
1 change: 1 addition & 0 deletions livekit-ffi/src/conversion/participant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ impl From<&FfiParticipant> for proto::ParticipantInfo {
name: participant.name(),
identity: participant.identity().into(),
metadata: participant.metadata(),
attributes: participant.attributes(),
}
}
}
103 changes: 72 additions & 31 deletions livekit-ffi/src/livekit.proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1510,6 +1510,8 @@ pub struct ParticipantInfo {
pub identity: ::prost::alloc::string::String,
#[prost(string, tag="4")]
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>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand Down Expand Up @@ -2091,6 +2093,27 @@ pub struct UpdateLocalMetadataCallback {
#[prost(uint64, tag="1")]
pub async_id: u64,
}
/// Change the local participant's attributes
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateLocalAttributesRequest {
#[prost(uint64, tag="1")]
pub local_participant_handle: u64,
#[prost(map="string, string", tag="2")]
pub attributes: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateLocalAttributesResponse {
#[prost(uint64, tag="1")]
pub async_id: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateLocalAttributesCallback {
#[prost(uint64, tag="1")]
pub async_id: u64,
}
/// Change the local participant's name
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand Down Expand Up @@ -2261,7 +2284,7 @@ pub struct OwnedBuffer {
pub struct RoomEvent {
#[prost(uint64, tag="1")]
pub room_handle: u64,
#[prost(oneof="room_event::Message", tags="2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26")]
#[prost(oneof="room_event::Message", tags="2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 23, 24, 25, 26, 27")]
pub message: ::core::option::Option<room_event::Message>,
}
/// Nested message and enum types in `RoomEvent`.
Expand Down Expand Up @@ -2302,22 +2325,24 @@ pub mod room_event {
#[prost(message, tag="17")]
ParticipantNameChanged(super::ParticipantNameChanged),
#[prost(message, tag="18")]
ConnectionQualityChanged(super::ConnectionQualityChanged),
ParticipantAttributesChanged(super::ParticipantAttributesChanged),
#[prost(message, tag="19")]
ConnectionQualityChanged(super::ConnectionQualityChanged),
#[prost(message, tag="20")]
ConnectionStateChanged(super::ConnectionStateChanged),
/// Connected connected = 20;
#[prost(message, tag="21")]
Disconnected(super::Disconnected),
/// Connected connected = 21;
#[prost(message, tag="22")]
Reconnecting(super::Reconnecting),
Disconnected(super::Disconnected),
#[prost(message, tag="23")]
Reconnected(super::Reconnected),
Reconnecting(super::Reconnecting),
#[prost(message, tag="24")]
Reconnected(super::Reconnected),
#[prost(message, tag="25")]
E2eeStateChanged(super::E2eeStateChanged),
/// The stream of room events has ended
#[prost(message, tag="25")]
Eos(super::RoomEos),
#[prost(message, tag="26")]
Eos(super::RoomEos),
#[prost(message, tag="27")]
DataPacketReceived(super::DataPacketReceived),
}
}
Expand Down Expand Up @@ -2463,6 +2488,16 @@ pub struct ParticipantMetadataChanged {
}
#[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,
#[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")]
pub attributes: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ParticipantNameChanged {
#[prost(string, tag="1")]
pub participant_sid: ::prost::alloc::string::String,
Expand Down Expand Up @@ -2978,7 +3013,7 @@ impl AudioSourceType {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FfiRequest {
#[prost(oneof="ffi_request::Message", tags="2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 22, 23, 24, 25, 26, 27")]
#[prost(oneof="ffi_request::Message", tags="2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 23, 24, 25, 26, 27")]
pub message: ::core::option::Option<ffi_request::Message>,
}
/// Nested message and enum types in `FfiRequest`.
Expand Down Expand Up @@ -3006,24 +3041,26 @@ pub mod ffi_request {
#[prost(message, tag="10")]
UpdateLocalName(super::UpdateLocalNameRequest),
#[prost(message, tag="11")]
GetSessionStats(super::GetSessionStatsRequest),
UpdateLocalAttributes(super::UpdateLocalAttributesRequest),
#[prost(message, tag="12")]
GetSessionStats(super::GetSessionStatsRequest),
#[prost(message, tag="13")]
PublishTranscription(super::PublishTranscriptionRequest),
/// Track
#[prost(message, tag="13")]
CreateVideoTrack(super::CreateVideoTrackRequest),
#[prost(message, tag="14")]
CreateAudioTrack(super::CreateAudioTrackRequest),
CreateVideoTrack(super::CreateVideoTrackRequest),
#[prost(message, tag="15")]
CreateAudioTrack(super::CreateAudioTrackRequest),
#[prost(message, tag="16")]
GetStats(super::GetStatsRequest),
/// Video
#[prost(message, tag="16")]
NewVideoStream(super::NewVideoStreamRequest),
#[prost(message, tag="17")]
NewVideoSource(super::NewVideoSourceRequest),
NewVideoStream(super::NewVideoStreamRequest),
#[prost(message, tag="18")]
CaptureVideoFrame(super::CaptureVideoFrameRequest),
NewVideoSource(super::NewVideoSourceRequest),
#[prost(message, tag="19")]
CaptureVideoFrame(super::CaptureVideoFrameRequest),
#[prost(message, tag="20")]
VideoConvert(super::VideoConvertRequest),
/// Audio
#[prost(message, tag="22")]
Expand All @@ -3044,7 +3081,7 @@ pub mod ffi_request {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FfiResponse {
#[prost(oneof="ffi_response::Message", tags="2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 22, 23, 24, 25, 26, 27")]
#[prost(oneof="ffi_response::Message", tags="2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 23, 24, 25, 26, 27")]
pub message: ::core::option::Option<ffi_response::Message>,
}
/// Nested message and enum types in `FfiResponse`.
Expand Down Expand Up @@ -3072,24 +3109,26 @@ pub mod ffi_response {
#[prost(message, tag="10")]
UpdateLocalName(super::UpdateLocalNameResponse),
#[prost(message, tag="11")]
GetSessionStats(super::GetSessionStatsResponse),
UpdateLocalAttributes(super::UpdateLocalAttributesResponse),
#[prost(message, tag="12")]
GetSessionStats(super::GetSessionStatsResponse),
#[prost(message, tag="13")]
PublishTranscription(super::PublishTranscriptionResponse),
/// Track
#[prost(message, tag="13")]
CreateVideoTrack(super::CreateVideoTrackResponse),
#[prost(message, tag="14")]
CreateAudioTrack(super::CreateAudioTrackResponse),
CreateVideoTrack(super::CreateVideoTrackResponse),
#[prost(message, tag="15")]
CreateAudioTrack(super::CreateAudioTrackResponse),
#[prost(message, tag="16")]
GetStats(super::GetStatsResponse),
/// Video
#[prost(message, tag="16")]
NewVideoStream(super::NewVideoStreamResponse),
#[prost(message, tag="17")]
NewVideoSource(super::NewVideoSourceResponse),
NewVideoStream(super::NewVideoStreamResponse),
#[prost(message, tag="18")]
CaptureVideoFrame(super::CaptureVideoFrameResponse),
NewVideoSource(super::NewVideoSourceResponse),
#[prost(message, tag="19")]
CaptureVideoFrame(super::CaptureVideoFrameResponse),
#[prost(message, tag="20")]
VideoConvert(super::VideoConvertResponse),
/// Audio
#[prost(message, tag="22")]
Expand All @@ -3112,7 +3151,7 @@ pub mod ffi_response {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FfiEvent {
#[prost(oneof="ffi_event::Message", tags="1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18")]
#[prost(oneof="ffi_event::Message", tags="1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19")]
pub message: ::core::option::Option<ffi_event::Message>,
}
/// Nested message and enum types in `FfiEvent`.
Expand Down Expand Up @@ -3149,12 +3188,14 @@ pub mod ffi_event {
#[prost(message, tag="14")]
UpdateLocalName(super::UpdateLocalNameCallback),
#[prost(message, tag="15")]
GetStats(super::GetStatsCallback),
UpdateLocalAttributes(super::UpdateLocalAttributesCallback),
#[prost(message, tag="16")]
Logs(super::LogBatch),
GetStats(super::GetStatsCallback),
#[prost(message, tag="17")]
GetSessionStats(super::GetSessionStatsCallback),
Logs(super::LogBatch),
#[prost(message, tag="18")]
GetSessionStats(super::GetSessionStatsCallback),
#[prost(message, tag="19")]
Panic(super::Panic),
}
}
Expand Down
16 changes: 16 additions & 0 deletions livekit-ffi/src/server/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,17 @@ fn on_update_local_name(
Ok(ffi_participant.room.update_local_name(server, update_local_name))
}

fn on_update_local_attributes(
server: &'static FfiServer,
update_local_attributes: proto::UpdateLocalAttributesRequest,
) -> FfiResult<proto::UpdateLocalAttributesResponse> {
let ffi_participant = server
.retrieve_handle::<FfiParticipant>(update_local_attributes.local_participant_handle)?
.clone();

Ok(ffi_participant.room.update_local_attributes(server, update_local_attributes))
}

/// Create a new video track from a source
fn on_create_video_track(
server: &'static FfiServer,
Expand Down Expand Up @@ -591,6 +602,11 @@ pub fn handle_request(
proto::ffi_request::Message::UpdateLocalName(update) => {
proto::ffi_response::Message::UpdateLocalName(on_update_local_name(server, update)?)
}
proto::ffi_request::Message::UpdateLocalAttributes(update) => {
proto::ffi_response::Message::UpdateLocalAttributes(on_update_local_attributes(
server, update,
)?)
}
proto::ffi_request::Message::CreateVideoTrack(create) => {
proto::ffi_response::Message::CreateVideoTrack(on_create_video_track(server, create)?)
}
Expand Down
Loading
Loading