Skip to content

Commit 0196f71

Browse files
committed
livekit-ffi: remove FfiClient GetRoomSid
1 parent f9e2008 commit 0196f71

File tree

6 files changed

+60
-100
lines changed

6 files changed

+60
-100
lines changed

livekit-ffi/protocol/ffi.proto

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,17 @@ message FfiRequest {
6767
UpdateLocalNameRequest update_local_name = 10;
6868
GetSessionStatsRequest get_session_stats = 11;
6969
PublishTranscriptionRequest publish_transcription = 12;
70-
GetRoomSidRequest get_room_sid = 13;
7170

7271
// Track
73-
CreateVideoTrackRequest create_video_track = 14;
74-
CreateAudioTrackRequest create_audio_track = 15;
75-
GetStatsRequest get_stats = 16;
72+
CreateVideoTrackRequest create_video_track = 13;
73+
CreateAudioTrackRequest create_audio_track = 14;
74+
GetStatsRequest get_stats = 15;
7675

7776
// Video
78-
NewVideoStreamRequest new_video_stream = 17;
79-
NewVideoSourceRequest new_video_source = 18;
80-
CaptureVideoFrameRequest capture_video_frame = 19;
81-
VideoConvertRequest video_convert = 20;
77+
NewVideoStreamRequest new_video_stream = 16;
78+
NewVideoSourceRequest new_video_source = 17;
79+
CaptureVideoFrameRequest capture_video_frame = 18;
80+
VideoConvertRequest video_convert = 19;
8281

8382
// Audio
8483
NewAudioStreamRequest new_audio_stream = 22;
@@ -106,18 +105,17 @@ message FfiResponse {
106105
UpdateLocalNameResponse update_local_name = 10;
107106
GetSessionStatsResponse get_session_stats = 11;
108107
PublishTranscriptionResponse publish_transcription = 12;
109-
GetRoomSidResponse get_room_sid = 13;
110108

111109
// Track
112-
CreateVideoTrackResponse create_video_track = 14;
113-
CreateAudioTrackResponse create_audio_track = 15;
114-
GetStatsResponse get_stats = 16;
110+
CreateVideoTrackResponse create_video_track = 13;
111+
CreateAudioTrackResponse create_audio_track = 14;
112+
GetStatsResponse get_stats = 15;
115113

116114
// Video
117-
NewVideoStreamResponse new_video_stream = 17;
118-
NewVideoSourceResponse new_video_source = 18;
119-
CaptureVideoFrameResponse capture_video_frame = 19;
120-
VideoConvertResponse video_convert = 20;
115+
NewVideoStreamResponse new_video_stream = 16;
116+
NewVideoSourceResponse new_video_source = 17;
117+
CaptureVideoFrameResponse capture_video_frame = 18;
118+
VideoConvertResponse video_convert = 19;
121119

122120
// Audio
123121
NewAudioStreamResponse new_audio_stream = 22;
@@ -152,7 +150,6 @@ message FfiEvent {
152150
LogBatch logs = 16;
153151
GetSessionStatsCallback get_session_stats = 17;
154152
Panic panic = 18;
155-
GetRoomSidCallback get_room_sid = 19;
156153
}
157154
}
158155

livekit-ffi/protocol/room.proto

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,6 @@ message GetSessionStatsCallback {
161161
repeated RtcStats subscriber_stats = 4;
162162
}
163163

164-
message GetRoomSidRequest {
165-
uint64 room_handle = 1;
166-
}
167-
message GetRoomSidResponse {
168-
uint64 async_id = 1;
169-
}
170-
message GetRoomSidCallback {
171-
uint64 async_id = 1;
172-
string sid = 2;
173-
}
174-
175164
//
176165
// Options
177166
//
@@ -284,9 +273,10 @@ message RoomEvent {
284273
TrackUnmuted track_unmuted = 12;
285274
ActiveSpeakersChanged active_speakers_changed = 13;
286275
RoomMetadataChanged room_metadata_changed = 14;
287-
ParticipantMetadataChanged participant_metadata_changed = 15;
288-
ParticipantNameChanged participant_name_changed = 16;
289-
ConnectionQualityChanged connection_quality_changed = 17;
276+
RoomSidChanged room_sid_changed = 15;
277+
ParticipantMetadataChanged participant_metadata_changed = 16;
278+
ParticipantNameChanged participant_name_changed = 17;
279+
ConnectionQualityChanged connection_quality_changed = 18;
290280
ConnectionStateChanged connection_state_changed = 19;
291281
// Connected connected = 20;
292282
Disconnected disconnected = 21;
@@ -375,6 +365,10 @@ message RoomMetadataChanged {
375365
string metadata = 1;
376366
}
377367

368+
message RoomSidChanged {
369+
string sid = 1;
370+
}
371+
378372
message ParticipantMetadataChanged {
379373
string participant_sid = 1;
380374
string metadata = 2;

livekit-ffi/src/livekit.proto.rs

Lines changed: 28 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,26 +2150,6 @@ pub struct GetSessionStatsCallback {
21502150
#[prost(message, repeated, tag="4")]
21512151
pub subscriber_stats: ::prost::alloc::vec::Vec<RtcStats>,
21522152
}
2153-
#[allow(clippy::derive_partial_eq_without_eq)]
2154-
#[derive(Clone, PartialEq, ::prost::Message)]
2155-
pub struct GetRoomSidRequest {
2156-
#[prost(uint64, tag="1")]
2157-
pub room_handle: u64,
2158-
}
2159-
#[allow(clippy::derive_partial_eq_without_eq)]
2160-
#[derive(Clone, PartialEq, ::prost::Message)]
2161-
pub struct GetRoomSidResponse {
2162-
#[prost(uint64, tag="1")]
2163-
pub async_id: u64,
2164-
}
2165-
#[allow(clippy::derive_partial_eq_without_eq)]
2166-
#[derive(Clone, PartialEq, ::prost::Message)]
2167-
pub struct GetRoomSidCallback {
2168-
#[prost(uint64, tag="1")]
2169-
pub async_id: u64,
2170-
#[prost(string, tag="2")]
2171-
pub sid: ::prost::alloc::string::String,
2172-
}
21732153
//
21742154
// Options
21752155
//
@@ -2280,7 +2260,7 @@ pub struct OwnedBuffer {
22802260
pub struct RoomEvent {
22812261
#[prost(uint64, tag="1")]
22822262
pub room_handle: u64,
2283-
#[prost(oneof="room_event::Message", tags="2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, 22, 23, 24, 25, 26")]
2263+
#[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")]
22842264
pub message: ::core::option::Option<room_event::Message>,
22852265
}
22862266
/// Nested message and enum types in `RoomEvent`.
@@ -2315,10 +2295,12 @@ pub mod room_event {
23152295
#[prost(message, tag="14")]
23162296
RoomMetadataChanged(super::RoomMetadataChanged),
23172297
#[prost(message, tag="15")]
2318-
ParticipantMetadataChanged(super::ParticipantMetadataChanged),
2298+
RoomSidChanged(super::RoomSidChanged),
23192299
#[prost(message, tag="16")]
2320-
ParticipantNameChanged(super::ParticipantNameChanged),
2300+
ParticipantMetadataChanged(super::ParticipantMetadataChanged),
23212301
#[prost(message, tag="17")]
2302+
ParticipantNameChanged(super::ParticipantNameChanged),
2303+
#[prost(message, tag="18")]
23222304
ConnectionQualityChanged(super::ConnectionQualityChanged),
23232305
#[prost(message, tag="19")]
23242306
ConnectionStateChanged(super::ConnectionStateChanged),
@@ -2466,6 +2448,12 @@ pub struct RoomMetadataChanged {
24662448
}
24672449
#[allow(clippy::derive_partial_eq_without_eq)]
24682450
#[derive(Clone, PartialEq, ::prost::Message)]
2451+
pub struct RoomSidChanged {
2452+
#[prost(string, tag="1")]
2453+
pub sid: ::prost::alloc::string::String,
2454+
}
2455+
#[allow(clippy::derive_partial_eq_without_eq)]
2456+
#[derive(Clone, PartialEq, ::prost::Message)]
24692457
pub struct ParticipantMetadataChanged {
24702458
#[prost(string, tag="1")]
24712459
pub participant_sid: ::prost::alloc::string::String,
@@ -2987,7 +2975,7 @@ impl AudioSourceType {
29872975
#[allow(clippy::derive_partial_eq_without_eq)]
29882976
#[derive(Clone, PartialEq, ::prost::Message)]
29892977
pub struct FfiRequest {
2990-
#[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")]
2978+
#[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")]
29912979
pub message: ::core::option::Option<ffi_request::Message>,
29922980
}
29932981
/// Nested message and enum types in `FfiRequest`.
@@ -3018,23 +3006,21 @@ pub mod ffi_request {
30183006
GetSessionStats(super::GetSessionStatsRequest),
30193007
#[prost(message, tag="12")]
30203008
PublishTranscription(super::PublishTranscriptionRequest),
3021-
#[prost(message, tag="13")]
3022-
GetRoomSid(super::GetRoomSidRequest),
30233009
/// Track
3024-
#[prost(message, tag="14")]
3010+
#[prost(message, tag="13")]
30253011
CreateVideoTrack(super::CreateVideoTrackRequest),
3026-
#[prost(message, tag="15")]
3012+
#[prost(message, tag="14")]
30273013
CreateAudioTrack(super::CreateAudioTrackRequest),
3028-
#[prost(message, tag="16")]
3014+
#[prost(message, tag="15")]
30293015
GetStats(super::GetStatsRequest),
30303016
/// Video
3031-
#[prost(message, tag="17")]
3017+
#[prost(message, tag="16")]
30323018
NewVideoStream(super::NewVideoStreamRequest),
3033-
#[prost(message, tag="18")]
3019+
#[prost(message, tag="17")]
30343020
NewVideoSource(super::NewVideoSourceRequest),
3035-
#[prost(message, tag="19")]
3021+
#[prost(message, tag="18")]
30363022
CaptureVideoFrame(super::CaptureVideoFrameRequest),
3037-
#[prost(message, tag="20")]
3023+
#[prost(message, tag="19")]
30383024
VideoConvert(super::VideoConvertRequest),
30393025
/// Audio
30403026
#[prost(message, tag="22")]
@@ -3055,7 +3041,7 @@ pub mod ffi_request {
30553041
#[allow(clippy::derive_partial_eq_without_eq)]
30563042
#[derive(Clone, PartialEq, ::prost::Message)]
30573043
pub struct FfiResponse {
3058-
#[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")]
3044+
#[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")]
30593045
pub message: ::core::option::Option<ffi_response::Message>,
30603046
}
30613047
/// Nested message and enum types in `FfiResponse`.
@@ -3086,23 +3072,21 @@ pub mod ffi_response {
30863072
GetSessionStats(super::GetSessionStatsResponse),
30873073
#[prost(message, tag="12")]
30883074
PublishTranscription(super::PublishTranscriptionResponse),
3089-
#[prost(message, tag="13")]
3090-
GetRoomSid(super::GetRoomSidResponse),
30913075
/// Track
3092-
#[prost(message, tag="14")]
3076+
#[prost(message, tag="13")]
30933077
CreateVideoTrack(super::CreateVideoTrackResponse),
3094-
#[prost(message, tag="15")]
3078+
#[prost(message, tag="14")]
30953079
CreateAudioTrack(super::CreateAudioTrackResponse),
3096-
#[prost(message, tag="16")]
3080+
#[prost(message, tag="15")]
30973081
GetStats(super::GetStatsResponse),
30983082
/// Video
3099-
#[prost(message, tag="17")]
3083+
#[prost(message, tag="16")]
31003084
NewVideoStream(super::NewVideoStreamResponse),
3101-
#[prost(message, tag="18")]
3085+
#[prost(message, tag="17")]
31023086
NewVideoSource(super::NewVideoSourceResponse),
3103-
#[prost(message, tag="19")]
3087+
#[prost(message, tag="18")]
31043088
CaptureVideoFrame(super::CaptureVideoFrameResponse),
3105-
#[prost(message, tag="20")]
3089+
#[prost(message, tag="19")]
31063090
VideoConvert(super::VideoConvertResponse),
31073091
/// Audio
31083092
#[prost(message, tag="22")]
@@ -3125,7 +3109,7 @@ pub mod ffi_response {
31253109
#[allow(clippy::derive_partial_eq_without_eq)]
31263110
#[derive(Clone, PartialEq, ::prost::Message)]
31273111
pub struct FfiEvent {
3128-
#[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")]
3112+
#[prost(oneof="ffi_event::Message", tags="1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18")]
31293113
pub message: ::core::option::Option<ffi_event::Message>,
31303114
}
31313115
/// Nested message and enum types in `FfiEvent`.
@@ -3169,8 +3153,6 @@ pub mod ffi_event {
31693153
GetSessionStats(super::GetSessionStatsCallback),
31703154
#[prost(message, tag="18")]
31713155
Panic(super::Panic),
3172-
#[prost(message, tag="19")]
3173-
GetRoomSid(super::GetRoomSidCallback),
31743156
}
31753157
}
31763158
/// Stop all rooms synchronously (Do we need async here?).

livekit-ffi/src/server/requests.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -548,25 +548,6 @@ fn on_get_session_stats(
548548
Ok(proto::GetSessionStatsResponse { async_id })
549549
}
550550

551-
fn on_get_room_sid(
552-
server: &'static FfiServer,
553-
get_room_sid: proto::GetRoomSidRequest,
554-
) -> FfiResult<proto::GetRoomSidResponse> {
555-
let ffi_room = server.retrieve_handle::<room::FfiRoom>(get_room_sid.room_handle)?.clone();
556-
let async_id = server.next_id();
557-
558-
let handle =
559-
server.async_runtime.spawn(async move {
560-
let sid = ffi_room.inner.room.sid().await;
561-
let _ = server.send_event(proto::ffi_event::Message::GetRoomSid(
562-
proto::GetRoomSidCallback { async_id, sid: sid.into() },
563-
));
564-
});
565-
566-
server.watch_panic(handle);
567-
Ok(proto::GetRoomSidResponse { async_id })
568-
}
569-
570551
#[allow(clippy::field_reassign_with_default)] // Avoid uggly format
571552
pub fn handle_request(
572553
server: &'static FfiServer,
@@ -655,9 +636,6 @@ pub fn handle_request(
655636
get_session_stats,
656637
)?)
657638
}
658-
proto::ffi_request::Message::GetRoomSid(get_room_sid) => {
659-
proto::ffi_response::Message::GetRoomSid(on_get_room_sid(server, get_room_sid)?)
660-
}
661639
});
662640

663641
Ok(res)

livekit-ffi/src/server/room.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,11 @@ async fn forward_event(
715715
proto::RoomMetadataChanged { metadata },
716716
));
717717
}
718+
RoomEvent::RoomSidChanged { sid } => {
719+
let _ = send_event(proto::room_event::Message::RoomSidChanged(proto::RoomSidChanged {
720+
sid,
721+
}));
722+
}
718723
RoomEvent::ParticipantMetadataChanged { participant, old_metadata: _, metadata } => {
719724
let _ = send_event(proto::room_event::Message::ParticipantMetadataChanged(
720725
proto::ParticipantMetadataChanged {

livekit/src/room/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ pub enum RoomEvent {
116116
old_metadata: String,
117117
metadata: String,
118118
},
119+
RoomSidChanged {
120+
sid: String,
121+
},
119122
ParticipantMetadataChanged {
120123
participant: Participant,
121124
old_metadata: String,
@@ -846,7 +849,8 @@ impl RoomSession {
846849
});
847850
}
848851
if !room.sid.is_empty() {
849-
let _ = self.sid.resolve(room.sid.try_into().unwrap());
852+
let _ = self.sid.resolve(room.sid.clone().try_into().unwrap());
853+
self.dispatcher.dispatch(&RoomEvent::RoomSidChanged { sid: room.sid });
850854
}
851855
}
852856

0 commit comments

Comments
 (0)