Skip to content

Commit

Permalink
Address comments + update -> set
Browse files Browse the repository at this point in the history
  • Loading branch information
keepingitneil committed Jul 15, 2024
1 parent ce842e1 commit b1138c0
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 57 deletions.
18 changes: 9 additions & 9 deletions livekit-ffi/protocol/ffi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ message FfiRequest {
UnpublishTrackRequest unpublish_track = 6;
PublishDataRequest publish_data = 7;
SetSubscribedRequest set_subscribed = 8;
UpdateLocalMetadataRequest update_local_metadata = 9;
UpdateLocalNameRequest update_local_name = 10;
UpdateLocalAttributesRequest update_local_attributes = 11;
SetLocalMetadataRequest update_local_metadata = 9;
SetLocalNameRequest update_local_name = 10;
SetLocalAttributesRequest update_local_attributes = 11;
GetSessionStatsRequest get_session_stats = 12;
PublishTranscriptionRequest publish_transcription = 13;

Expand Down Expand Up @@ -102,9 +102,9 @@ message FfiResponse {
UnpublishTrackResponse unpublish_track = 6;
PublishDataResponse publish_data = 7;
SetSubscribedResponse set_subscribed = 8;
UpdateLocalMetadataResponse update_local_metadata = 9;
UpdateLocalNameResponse update_local_name = 10;
UpdateLocalAttributesResponse update_local_attributes = 11;
SetLocalMetadataResponse update_local_metadata = 9;
SetLocalNameResponse update_local_name = 10;
SetLocalAttributesResponse update_local_attributes = 11;
GetSessionStatsResponse get_session_stats = 12;
PublishTranscriptionResponse publish_transcription = 13;

Expand Down Expand Up @@ -146,9 +146,9 @@ message FfiEvent {
PublishDataCallback publish_data = 10;
PublishTranscriptionCallback publish_transcription = 11;
CaptureAudioFrameCallback capture_audio_frame = 12;
UpdateLocalMetadataCallback update_local_metadata = 13;
UpdateLocalNameCallback update_local_name = 14;
UpdateLocalAttributesCallback update_local_attributes = 15;
SetLocalMetadataCallback update_local_metadata = 13;
SetLocalNameCallback update_local_name = 14;
SetLocalAttributesCallback update_local_attributes = 15;
GetStatsCallback get_stats = 16;
LogBatch logs = 17;
GetSessionStatsCallback get_session_stats = 18;
Expand Down
21 changes: 12 additions & 9 deletions livekit-ffi/protocol/room.proto
Original file line number Diff line number Diff line change
Expand Up @@ -117,39 +117,42 @@ message PublishTranscriptionCallback {
}

// Change the local participant's metadata
message UpdateLocalMetadataRequest {
message SetLocalMetadataRequest {
uint64 local_participant_handle = 1;
string metadata = 2;
}
message UpdateLocalMetadataResponse {
message SetLocalMetadataResponse {
uint64 async_id = 1;
}
message UpdateLocalMetadataCallback {
message SetLocalMetadataCallback {
uint64 async_id = 1;
optional string error = 2;
}

// Change the local participant's attributes
message UpdateLocalAttributesRequest {
message SetLocalAttributesRequest {
uint64 local_participant_handle = 1;
map<string, string> attributes = 2;
}
message UpdateLocalAttributesResponse {
message SetLocalAttributesResponse {
uint64 async_id = 1;
}
message UpdateLocalAttributesCallback {
message SetLocalAttributesCallback {
uint64 async_id = 1;
optional string error = 2;
}

// Change the local participant's name
message UpdateLocalNameRequest {
message SetLocalNameRequest {
uint64 local_participant_handle = 1;
string name = 2;
}
message UpdateLocalNameResponse {
message SetLocalNameResponse {
uint64 async_id = 1;
}
message UpdateLocalNameCallback {
message SetLocalNameCallback {
uint64 async_id = 1;
optional string error = 2;
}

// Change the "desire" to subs2ribe to a track
Expand Down
42 changes: 24 additions & 18 deletions livekit-ffi/src/livekit.proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2075,65 +2075,71 @@ pub struct PublishTranscriptionCallback {
/// Change the local participant's metadata
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateLocalMetadataRequest {
pub struct SetLocalMetadataRequest {
#[prost(uint64, tag="1")]
pub local_participant_handle: u64,
#[prost(string, tag="2")]
pub metadata: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateLocalMetadataResponse {
pub struct SetLocalMetadataResponse {
#[prost(uint64, tag="1")]
pub async_id: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateLocalMetadataCallback {
pub struct SetLocalMetadataCallback {
#[prost(uint64, tag="1")]
pub async_id: u64,
#[prost(string, optional, tag="2")]
pub error: ::core::option::Option<::prost::alloc::string::String>,
}
/// Change the local participant's attributes
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateLocalAttributesRequest {
pub struct SetLocalAttributesRequest {
#[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 {
pub struct SetLocalAttributesResponse {
#[prost(uint64, tag="1")]
pub async_id: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateLocalAttributesCallback {
pub struct SetLocalAttributesCallback {
#[prost(uint64, tag="1")]
pub async_id: u64,
#[prost(string, optional, tag="2")]
pub error: ::core::option::Option<::prost::alloc::string::String>,
}
/// Change the local participant's name
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateLocalNameRequest {
pub struct SetLocalNameRequest {
#[prost(uint64, tag="1")]
pub local_participant_handle: u64,
#[prost(string, tag="2")]
pub name: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateLocalNameResponse {
pub struct SetLocalNameResponse {
#[prost(uint64, tag="1")]
pub async_id: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateLocalNameCallback {
pub struct SetLocalNameCallback {
#[prost(uint64, tag="1")]
pub async_id: u64,
#[prost(string, optional, tag="2")]
pub error: ::core::option::Option<::prost::alloc::string::String>,
}
/// Change the "desire" to subs2ribe to a track
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down Expand Up @@ -3037,11 +3043,11 @@ pub mod ffi_request {
#[prost(message, tag="8")]
SetSubscribed(super::SetSubscribedRequest),
#[prost(message, tag="9")]
UpdateLocalMetadata(super::UpdateLocalMetadataRequest),
UpdateLocalMetadata(super::SetLocalMetadataRequest),
#[prost(message, tag="10")]
UpdateLocalName(super::UpdateLocalNameRequest),
UpdateLocalName(super::SetLocalNameRequest),
#[prost(message, tag="11")]
UpdateLocalAttributes(super::UpdateLocalAttributesRequest),
UpdateLocalAttributes(super::SetLocalAttributesRequest),
#[prost(message, tag="12")]
GetSessionStats(super::GetSessionStatsRequest),
#[prost(message, tag="13")]
Expand Down Expand Up @@ -3105,11 +3111,11 @@ pub mod ffi_response {
#[prost(message, tag="8")]
SetSubscribed(super::SetSubscribedResponse),
#[prost(message, tag="9")]
UpdateLocalMetadata(super::UpdateLocalMetadataResponse),
UpdateLocalMetadata(super::SetLocalMetadataResponse),
#[prost(message, tag="10")]
UpdateLocalName(super::UpdateLocalNameResponse),
UpdateLocalName(super::SetLocalNameResponse),
#[prost(message, tag="11")]
UpdateLocalAttributes(super::UpdateLocalAttributesResponse),
UpdateLocalAttributes(super::SetLocalAttributesResponse),
#[prost(message, tag="12")]
GetSessionStats(super::GetSessionStatsResponse),
#[prost(message, tag="13")]
Expand Down Expand Up @@ -3184,11 +3190,11 @@ pub mod ffi_event {
#[prost(message, tag="12")]
CaptureAudioFrame(super::CaptureAudioFrameCallback),
#[prost(message, tag="13")]
UpdateLocalMetadata(super::UpdateLocalMetadataCallback),
UpdateLocalMetadata(super::SetLocalMetadataCallback),
#[prost(message, tag="14")]
UpdateLocalName(super::UpdateLocalNameCallback),
UpdateLocalName(super::SetLocalNameCallback),
#[prost(message, tag="15")]
UpdateLocalAttributes(super::UpdateLocalAttributesCallback),
UpdateLocalAttributes(super::SetLocalAttributesCallback),
#[prost(message, tag="16")]
GetStats(super::GetStatsCallback),
#[prost(message, tag="17")]
Expand Down
12 changes: 6 additions & 6 deletions livekit-ffi/src/server/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ fn on_set_subscribed(

fn on_update_local_metadata(
server: &'static FfiServer,
update_local_metadata: proto::UpdateLocalMetadataRequest,
) -> FfiResult<proto::UpdateLocalMetadataResponse> {
update_local_metadata: proto::SetLocalMetadataRequest,
) -> FfiResult<proto::SetLocalMetadataResponse> {
let ffi_participant = server
.retrieve_handle::<FfiParticipant>(update_local_metadata.local_participant_handle)?
.clone();
Expand All @@ -151,8 +151,8 @@ fn on_update_local_metadata(

fn on_update_local_name(
server: &'static FfiServer,
update_local_name: proto::UpdateLocalNameRequest,
) -> FfiResult<proto::UpdateLocalNameResponse> {
update_local_name: proto::SetLocalNameRequest,
) -> FfiResult<proto::SetLocalNameResponse> {
let ffi_participant = server
.retrieve_handle::<FfiParticipant>(update_local_name.local_participant_handle)?
.clone();
Expand All @@ -162,8 +162,8 @@ fn on_update_local_name(

fn on_update_local_attributes(
server: &'static FfiServer,
update_local_attributes: proto::UpdateLocalAttributesRequest,
) -> FfiResult<proto::UpdateLocalAttributesResponse> {
update_local_attributes: proto::SetLocalAttributesRequest,
) -> FfiResult<proto::SetLocalAttributesResponse> {
let ffi_participant = server
.retrieve_handle::<FfiParticipant>(update_local_attributes.local_participant_handle)?
.clone();
Expand Down
30 changes: 15 additions & 15 deletions livekit-ffi/src/server/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,63 +429,63 @@ impl RoomInner {
pub fn update_local_metadata(
self: &Arc<Self>,
server: &'static FfiServer,
update_local_metadata: proto::UpdateLocalMetadataRequest,
) -> proto::UpdateLocalMetadataResponse {
update_local_metadata: proto::SetLocalMetadataRequest,
) -> proto::SetLocalMetadataResponse {
let async_id = server.next_id();
let inner = self.clone();
let handle = server.async_runtime.spawn(async move {
let _ = inner
let res = inner
.room
.local_participant()
.update_metadata(update_local_metadata.metadata)
.await;

let _ = server.send_event(proto::ffi_event::Message::UpdateLocalMetadata(
proto::UpdateLocalMetadataCallback { async_id },
proto::SetLocalMetadataCallback { async_id, error: res.err().map(|e| e.to_string()) },
));
});
server.watch_panic(handle);
proto::UpdateLocalMetadataResponse { async_id }
proto::SetLocalMetadataResponse { async_id }
}

pub fn update_local_name(
self: &Arc<Self>,
server: &'static FfiServer,
update_local_name: proto::UpdateLocalNameRequest,
) -> proto::UpdateLocalNameResponse {
update_local_name: proto::SetLocalNameRequest,
) -> proto::SetLocalNameResponse {
let async_id = server.next_id();
let inner = self.clone();
let handle = server.async_runtime.spawn(async move {
let _ = inner.room.local_participant().update_name(update_local_name.name).await;
let res = inner.room.local_participant().update_name(update_local_name.name).await;

let _ = server.send_event(proto::ffi_event::Message::UpdateLocalName(
proto::UpdateLocalNameCallback { async_id },
proto::SetLocalNameCallback { async_id, error: res.err().map(|e| e.to_string()) },
));
});
server.watch_panic(handle);
proto::UpdateLocalNameResponse { async_id }
proto::SetLocalNameResponse { async_id }
}

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

let _ = server.send_event(proto::ffi_event::Message::UpdateLocalAttributes(
proto::UpdateLocalAttributesCallback { async_id },
proto::SetLocalAttributesCallback { async_id, error: res.err().map(|e| e.to_string()) },
));
});
server.watch_panic(handle);
proto::UpdateLocalAttributesResponse { async_id }
proto::SetLocalAttributesResponse { async_id }
}
}

Expand Down

0 comments on commit b1138c0

Please sign in to comment.