Skip to content

Commit

Permalink
participant attributes work
Browse files Browse the repository at this point in the history
  • Loading branch information
keepingitneil committed Jul 12, 2024
1 parent 77460b8 commit e4bac56
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 65 deletions.
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
32 changes: 22 additions & 10 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 {
uint64 local_participant_handle = 1;
map<string, string> attributes = 2;
}
message UpdateLocalAttributesResponse {
uint64 async_id = 1;
}
message UpdateLocalAttributesCallback {
uint64 async_id = 1;
}

// Change the local participant's name
message UpdateLocalNameRequest {
uint64 local_participant_handle = 1;
Expand Down Expand Up @@ -276,16 +288,16 @@ message RoomEvent {
RoomSidChanged room_sid_changed = 15;
ParticipantMetadataChanged participant_metadata_changed = 16;
ParticipantNameChanged participant_name_changed = 17;
ConnectionQualityChanged connection_quality_changed = 18;
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 = 27;
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
93 changes: 60 additions & 33 deletions livekit-ffi/src/livekit.proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2093,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 @@ -2263,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, 27")]
#[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 @@ -2304,25 +2325,25 @@ 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")]
DataPacketReceived(super::DataPacketReceived),
Eos(super::RoomEos),
#[prost(message, tag="27")]
ParticipantAttributesChanged(super::ParticipantAttributesChanged),
DataPacketReceived(super::DataPacketReceived),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down Expand Up @@ -2992,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 @@ -3020,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 @@ -3058,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 @@ -3086,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 @@ -3126,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 @@ -3163,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
22 changes: 22 additions & 0 deletions livekit-ffi/src/server/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,28 @@ impl RoomInner {
server.watch_panic(handle);
proto::UpdateLocalNameResponse { async_id }
}

pub fn update_local_attributes(
self: &Arc<Self>,
server: &'static FfiServer,
update_local_attributes: proto::UpdateLocalAttributesRequest,
) -> proto::UpdateLocalAttributesResponse {
let async_id = server.next_id();
let inner = self.clone();
let handle = server.async_runtime.spawn(async move {
let _ = inner
.room
.local_participant()
.update_attributes(update_local_attributes.attributes)
.await;

let _ = server.send_event(proto::ffi_event::Message::UpdateLocalAttributes(
proto::UpdateLocalAttributesCallback { async_id },
));
});
server.watch_panic(handle);
proto::UpdateLocalAttributesResponse { async_id }
}
}

// Task used to publish data without blocking the client thread
Expand Down

0 comments on commit e4bac56

Please sign in to comment.