Skip to content

Commit

Permalink
More Update -> Set Renames that were missed (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
keepingitneil authored Jul 15, 2024
1 parent fb70404 commit a2d0382
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 38 deletions.
12 changes: 6 additions & 6 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;
SetLocalMetadataRequest update_local_metadata = 9;
SetLocalNameRequest update_local_name = 10;
SetLocalAttributesRequest update_local_attributes = 11;
SetLocalMetadataRequest set_local_metadata = 9;
SetLocalNameRequest set_local_name = 10;
SetLocalAttributesRequest set_local_attributes = 11;
GetSessionStatsRequest get_session_stats = 12;
PublishTranscriptionRequest publish_transcription = 13;

Expand Down Expand Up @@ -146,9 +146,9 @@ message FfiEvent {
PublishDataCallback publish_data = 11;
PublishTranscriptionCallback publish_transcription = 12;
CaptureAudioFrameCallback capture_audio_frame = 13;
SetLocalMetadataCallback update_local_metadata = 14;
SetLocalNameCallback update_local_name = 15;
SetLocalAttributesCallback update_local_attributes = 16;
SetLocalMetadataCallback set_local_metadata = 14;
SetLocalNameCallback set_local_name = 15;
SetLocalAttributesCallback set_local_attributes = 16;
GetStatsCallback get_stats = 17;
LogBatch logs = 18;
GetSessionStatsCallback get_session_stats = 19;
Expand Down
12 changes: 6 additions & 6 deletions livekit-ffi/src/livekit.proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3043,11 +3043,11 @@ pub mod ffi_request {
#[prost(message, tag="8")]
SetSubscribed(super::SetSubscribedRequest),
#[prost(message, tag="9")]
UpdateLocalMetadata(super::SetLocalMetadataRequest),
SetLocalMetadata(super::SetLocalMetadataRequest),
#[prost(message, tag="10")]
UpdateLocalName(super::SetLocalNameRequest),
SetLocalName(super::SetLocalNameRequest),
#[prost(message, tag="11")]
UpdateLocalAttributes(super::SetLocalAttributesRequest),
SetLocalAttributes(super::SetLocalAttributesRequest),
#[prost(message, tag="12")]
GetSessionStats(super::GetSessionStatsRequest),
#[prost(message, tag="13")]
Expand Down Expand Up @@ -3190,11 +3190,11 @@ pub mod ffi_event {
#[prost(message, tag="13")]
CaptureAudioFrame(super::CaptureAudioFrameCallback),
#[prost(message, tag="14")]
UpdateLocalMetadata(super::SetLocalMetadataCallback),
SetLocalMetadata(super::SetLocalMetadataCallback),
#[prost(message, tag="15")]
UpdateLocalName(super::SetLocalNameCallback),
SetLocalName(super::SetLocalNameCallback),
#[prost(message, tag="16")]
UpdateLocalAttributes(super::SetLocalAttributesCallback),
SetLocalAttributes(super::SetLocalAttributesCallback),
#[prost(message, tag="17")]
GetStats(super::GetStatsCallback),
#[prost(message, tag="18")]
Expand Down
27 changes: 13 additions & 14 deletions livekit-ffi/src/server/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,35 +140,34 @@ fn on_set_subscribed(

fn on_set_local_metadata(
server: &'static FfiServer,
update_local_metadata: proto::SetLocalMetadataRequest,
set_local_metadata: proto::SetLocalMetadataRequest,
) -> FfiResult<proto::SetLocalMetadataResponse> {
let ffi_participant = server
.retrieve_handle::<FfiParticipant>(update_local_metadata.local_participant_handle)?
.retrieve_handle::<FfiParticipant>(set_local_metadata.local_participant_handle)?
.clone();

Ok(ffi_participant.room.update_local_metadata(server, update_local_metadata))
Ok(ffi_participant.room.set_local_metadata(server, set_local_metadata))
}

fn on_set_local_name(
server: &'static FfiServer,
update_local_name: proto::SetLocalNameRequest,
set_local_name: proto::SetLocalNameRequest,
) -> FfiResult<proto::SetLocalNameResponse> {
let ffi_participant = server
.retrieve_handle::<FfiParticipant>(update_local_name.local_participant_handle)?
.clone();
let ffi_participant =
server.retrieve_handle::<FfiParticipant>(set_local_name.local_participant_handle)?.clone();

Ok(ffi_participant.room.update_local_name(server, update_local_name))
Ok(ffi_participant.room.set_local_name(server, set_local_name))
}

fn on_set_local_attributes(
server: &'static FfiServer,
update_local_attributes: proto::SetLocalAttributesRequest,
set_local_attributes: proto::SetLocalAttributesRequest,
) -> FfiResult<proto::SetLocalAttributesResponse> {
let ffi_participant = server
.retrieve_handle::<FfiParticipant>(update_local_attributes.local_participant_handle)?
.retrieve_handle::<FfiParticipant>(set_local_attributes.local_participant_handle)?
.clone();

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

/// Create a new video track from a source
Expand Down Expand Up @@ -596,13 +595,13 @@ pub fn handle_request(
proto::ffi_request::Message::SetSubscribed(subscribed) => {
proto::ffi_response::Message::SetSubscribed(on_set_subscribed(server, subscribed)?)
}
proto::ffi_request::Message::UpdateLocalMetadata(u) => {
proto::ffi_request::Message::SetLocalMetadata(u) => {
proto::ffi_response::Message::SetLocalMetadata(on_set_local_metadata(server, u)?)
}
proto::ffi_request::Message::UpdateLocalName(update) => {
proto::ffi_request::Message::SetLocalName(update) => {
proto::ffi_response::Message::SetLocalName(on_set_local_name(server, update)?)
}
proto::ffi_request::Message::UpdateLocalAttributes(update) => {
proto::ffi_request::Message::SetLocalAttributes(update) => {
proto::ffi_response::Message::SetLocalAttributes(on_set_local_attributes(
server, update,
)?)
Expand Down
24 changes: 12 additions & 12 deletions livekit-ffi/src/server/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,18 +426,18 @@ impl RoomInner {
proto::UnpublishTrackResponse { async_id }
}

pub fn update_local_metadata(
pub fn set_local_metadata(
self: &Arc<Self>,
server: &'static FfiServer,
update_local_metadata: proto::SetLocalMetadataRequest,
set_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 res =
inner.room.local_participant().set_metadata(update_local_metadata.metadata).await;
inner.room.local_participant().set_metadata(set_local_metadata.metadata).await;

let _ = server.send_event(proto::ffi_event::Message::UpdateLocalMetadata(
let _ = server.send_event(proto::ffi_event::Message::SetLocalMetadata(
proto::SetLocalMetadataCallback {
async_id,
error: res.err().map(|e| e.to_string()),
Expand All @@ -448,39 +448,39 @@ impl RoomInner {
proto::SetLocalMetadataResponse { async_id }
}

pub fn update_local_name(
pub fn set_local_name(
self: &Arc<Self>,
server: &'static FfiServer,
update_local_name: proto::SetLocalNameRequest,
set_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 res = inner.room.local_participant().set_name(update_local_name.name).await;
let res = inner.room.local_participant().set_name(set_local_name.name).await;

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

pub fn update_local_attributes(
pub fn set_local_attributes(
self: &Arc<Self>,
server: &'static FfiServer,
update_local_attributes: proto::SetLocalAttributesRequest,
set_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 res = inner
.room
.local_participant()
.set_attributes(update_local_attributes.attributes)
.set_attributes(set_local_attributes.attributes)
.await;

let _ = server.send_event(proto::ffi_event::Message::UpdateLocalAttributes(
let _ = server.send_event(proto::ffi_event::Message::SetLocalAttributes(
proto::SetLocalAttributesCallback {
async_id,
error: res.err().map(|e| e.to_string()),
Expand Down

0 comments on commit a2d0382

Please sign in to comment.