diff --git a/Cargo.lock b/Cargo.lock index ea38dc54ab..e7cb404acc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2792,9 +2792,9 @@ dependencies = [ "jsonwebtoken", "language", "language_model", + "livekit_api", "livekit_client", "livekit_client_macos", - "livekit_server", "log", "lsp", "menu", @@ -7404,6 +7404,21 @@ dependencies = [ "futures 0.3.31", ] +[[package]] +name = "livekit_api" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-trait", + "jsonwebtoken", + "log", + "prost 0.9.0", + "prost-build 0.9.0", + "prost-types 0.9.0", + "reqwest 0.12.8", + "serde", +] + [[package]] name = "livekit_client" version = "0.1.0" @@ -7420,7 +7435,7 @@ dependencies = [ "http_client", "image", "livekit", - "livekit_server", + "livekit_api", "log", "media", "nanoid", @@ -7445,7 +7460,7 @@ dependencies = [ "core-foundation 0.9.4", "futures 0.3.31", "gpui", - "livekit_server", + "livekit_api", "log", "media", "nanoid", @@ -7457,21 +7472,6 @@ dependencies = [ "simplelog", ] -[[package]] -name = "livekit_server" -version = "0.1.0" -dependencies = [ - "anyhow", - "async-trait", - "jsonwebtoken", - "log", - "prost 0.9.0", - "prost-build 0.9.0", - "prost-types 0.9.0", - "reqwest 0.12.8", - "serde", -] - [[package]] name = "lmdb-master-sys" version = "0.2.4" diff --git a/Cargo.toml b/Cargo.toml index d2cff4d48d..bb60f44394 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -74,9 +74,9 @@ members = [ "crates/language_selector", "crates/language_tools", "crates/languages", + "crates/livekit_api", "crates/livekit_client", "crates/livekit_client_macos", - "crates/livekit_server", "crates/lmstudio", "crates/lsp", "crates/markdown", @@ -274,9 +274,9 @@ language_models = { path = "crates/language_models" } language_selector = { path = "crates/language_selector" } language_tools = { path = "crates/language_tools" } languages = { path = "crates/languages" } +livekit_api = { path = "crates/livekit_api" } livekit_client = { path = "crates/livekit_client" } livekit_client_macos = { path = "crates/livekit_client_macos" } -livekit_server = { path = "crates/livekit_server" } lmstudio = { path = "crates/lmstudio" } lsp = { path = "crates/lsp" } markdown = { path = "crates/markdown" } diff --git a/crates/collab/Cargo.toml b/crates/collab/Cargo.toml index 2dd571677e..1af098416b 100644 --- a/crates/collab/Cargo.toml +++ b/crates/collab/Cargo.toml @@ -40,7 +40,7 @@ google_ai.workspace = true hex.workspace = true http_client.workspace = true jsonwebtoken.workspace = true -livekit_server.workspace = true +livekit_api.workspace = true log.workspace = true nanoid.workspace = true open_ai.workspace = true diff --git a/crates/collab/src/lib.rs b/crates/collab/src/lib.rs index a0f5fa371c..334d015d4b 100644 --- a/crates/collab/src/lib.rs +++ b/crates/collab/src/lib.rs @@ -274,7 +274,7 @@ impl ServiceMode { pub struct AppState { pub db: Arc, pub llm_db: Option>, - pub livekit_client: Option>, + pub livekit_client: Option>, pub blob_store_client: Option, pub stripe_client: Option>, pub stripe_billing: Option>, @@ -311,11 +311,11 @@ impl AppState { .zip(config.livekit_key.as_ref()) .zip(config.livekit_secret.as_ref()) { - Some(Arc::new(livekit_server::api::LiveKitClient::new( + Some(Arc::new(livekit_api::LiveKitClient::new( server.clone(), key.clone(), secret.clone(), - )) as Arc) + )) as Arc) } else { None }; diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rs index e795a3f1d8..189a5e5471 100644 --- a/crates/collab/src/rpc.rs +++ b/crates/collab/src/rpc.rs @@ -1545,7 +1545,7 @@ async fn set_room_participant_role( .update_participant( livekit_room.clone(), request.user_id.to_string(), - livekit_server::proto::ParticipantPermission { + livekit_api::proto::ParticipantPermission { can_subscribe: true, can_publish, can_publish_data: can_publish, diff --git a/crates/livekit_server/Cargo.toml b/crates/livekit_api/Cargo.toml similarity index 90% rename from crates/livekit_server/Cargo.toml rename to crates/livekit_api/Cargo.toml index afbdbf5c9a..b087d6b451 100644 --- a/crates/livekit_server/Cargo.toml +++ b/crates/livekit_api/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "livekit_server" +name = "livekit_api" version = "0.1.0" edition.workspace = true description = "SDK for the LiveKit server API" @@ -10,7 +10,7 @@ license = "AGPL-3.0-or-later" workspace = true [lib] -path = "src/livekit_server.rs" +path = "src/livekit_api.rs" doctest = false [dependencies] diff --git a/crates/livekit_server/LICENSE-AGPL b/crates/livekit_api/LICENSE-AGPL similarity index 100% rename from crates/livekit_server/LICENSE-AGPL rename to crates/livekit_api/LICENSE-AGPL diff --git a/crates/livekit_server/build.rs b/crates/livekit_api/build.rs similarity index 100% rename from crates/livekit_server/build.rs rename to crates/livekit_api/build.rs diff --git a/crates/livekit_server/src/api.rs b/crates/livekit_api/src/livekit_api.rs similarity index 99% rename from crates/livekit_server/src/api.rs rename to crates/livekit_api/src/livekit_api.rs index e7e933c9c3..d68099c0e3 100644 --- a/crates/livekit_server/src/api.rs +++ b/crates/livekit_api/src/livekit_api.rs @@ -1,4 +1,6 @@ -use crate::{proto, token}; +pub mod proto; +pub mod token; + use anyhow::{anyhow, Result}; use async_trait::async_trait; use prost::Message; diff --git a/crates/livekit_server/src/proto.rs b/crates/livekit_api/src/proto.rs similarity index 100% rename from crates/livekit_server/src/proto.rs rename to crates/livekit_api/src/proto.rs diff --git a/crates/livekit_server/src/token.rs b/crates/livekit_api/src/token.rs similarity index 100% rename from crates/livekit_server/src/token.rs rename to crates/livekit_api/src/token.rs diff --git a/crates/livekit_server/vendored/protocol/README.md b/crates/livekit_api/vendored/protocol/README.md similarity index 100% rename from crates/livekit_server/vendored/protocol/README.md rename to crates/livekit_api/vendored/protocol/README.md diff --git a/crates/livekit_server/vendored/protocol/livekit_analytics.proto b/crates/livekit_api/vendored/protocol/livekit_analytics.proto similarity index 100% rename from crates/livekit_server/vendored/protocol/livekit_analytics.proto rename to crates/livekit_api/vendored/protocol/livekit_analytics.proto diff --git a/crates/livekit_server/vendored/protocol/livekit_egress.proto b/crates/livekit_api/vendored/protocol/livekit_egress.proto similarity index 100% rename from crates/livekit_server/vendored/protocol/livekit_egress.proto rename to crates/livekit_api/vendored/protocol/livekit_egress.proto diff --git a/crates/livekit_server/vendored/protocol/livekit_ingress.proto b/crates/livekit_api/vendored/protocol/livekit_ingress.proto similarity index 100% rename from crates/livekit_server/vendored/protocol/livekit_ingress.proto rename to crates/livekit_api/vendored/protocol/livekit_ingress.proto diff --git a/crates/livekit_server/vendored/protocol/livekit_internal.proto b/crates/livekit_api/vendored/protocol/livekit_internal.proto similarity index 100% rename from crates/livekit_server/vendored/protocol/livekit_internal.proto rename to crates/livekit_api/vendored/protocol/livekit_internal.proto diff --git a/crates/livekit_server/vendored/protocol/livekit_models.proto b/crates/livekit_api/vendored/protocol/livekit_models.proto similarity index 100% rename from crates/livekit_server/vendored/protocol/livekit_models.proto rename to crates/livekit_api/vendored/protocol/livekit_models.proto diff --git a/crates/livekit_server/vendored/protocol/livekit_room.proto b/crates/livekit_api/vendored/protocol/livekit_room.proto similarity index 100% rename from crates/livekit_server/vendored/protocol/livekit_room.proto rename to crates/livekit_api/vendored/protocol/livekit_room.proto diff --git a/crates/livekit_server/vendored/protocol/livekit_rpc_internal.proto b/crates/livekit_api/vendored/protocol/livekit_rpc_internal.proto similarity index 100% rename from crates/livekit_server/vendored/protocol/livekit_rpc_internal.proto rename to crates/livekit_api/vendored/protocol/livekit_rpc_internal.proto diff --git a/crates/livekit_server/vendored/protocol/livekit_rtc.proto b/crates/livekit_api/vendored/protocol/livekit_rtc.proto similarity index 100% rename from crates/livekit_server/vendored/protocol/livekit_rtc.proto rename to crates/livekit_api/vendored/protocol/livekit_rtc.proto diff --git a/crates/livekit_server/vendored/protocol/livekit_webhook.proto b/crates/livekit_api/vendored/protocol/livekit_webhook.proto similarity index 100% rename from crates/livekit_server/vendored/protocol/livekit_webhook.proto rename to crates/livekit_api/vendored/protocol/livekit_webhook.proto diff --git a/crates/livekit_client/Cargo.toml b/crates/livekit_client/Cargo.toml index 7e853f5b2f..8d492984ba 100644 --- a/crates/livekit_client/Cargo.toml +++ b/crates/livekit_client/Cargo.toml @@ -28,7 +28,7 @@ cpal = "0.15" futures.workspace = true gpui.workspace = true http_2 = { package = "http", version = "0.2.1" } -livekit_server.workspace = true +livekit_api.workspace = true log.workspace = true media.workspace = true nanoid = { workspace = true, optional = true } diff --git a/crates/livekit_client/examples/test_app.rs b/crates/livekit_client/examples/test_app.rs index 5d43c2b191..c0ea6dd855 100644 --- a/crates/livekit_client/examples/test_app.rs +++ b/crates/livekit_client/examples/test_app.rs @@ -33,7 +33,7 @@ use livekit_client::{ AudioStream, RemoteVideoTrackView, Room, RoomEvent, }; -use livekit_server::token::{self, VideoGrant}; +use livekit_api::token::{self, VideoGrant}; use log::LevelFilter; use simplelog::SimpleLogger; diff --git a/crates/livekit_client/src/test.rs b/crates/livekit_client/src/test.rs index 38af9a43e8..363b51c84b 100644 --- a/crates/livekit_client/src/test.rs +++ b/crates/livekit_client/src/test.rs @@ -14,7 +14,7 @@ use collections::{btree_map::Entry as BTreeEntry, hash_map::Entry, BTreeMap, Has use gpui::BackgroundExecutor; #[cfg(not(all(target_os = "windows", target_env = "gnu")))] use livekit::options::TrackPublishOptions; -use livekit_server::{proto, token}; +use livekit_api::{proto, token}; use parking_lot::Mutex; use postage::{mpsc, sink::Sink}; use std::sync::{ @@ -107,7 +107,7 @@ impl TestServer { async fn join_room(&self, token: String, client_room: Room) -> Result { self.executor.simulate_random_delay().await; - let claims = livekit_server::token::validate(&token, &self.secret_key)?; + let claims = livekit_api::token::validate(&token, &self.secret_key)?; let identity = ParticipantIdentity(claims.sub.unwrap().to_string()); let room_name = claims.video.room.unwrap(); let mut server_rooms = self.rooms.lock(); @@ -174,7 +174,7 @@ impl TestServer { async fn leave_room(&self, token: String) -> Result<()> { self.executor.simulate_random_delay().await; - let claims = livekit_server::token::validate(&token, &self.secret_key)?; + let claims = livekit_api::token::validate(&token, &self.secret_key)?; let identity = ParticipantIdentity(claims.sub.unwrap().to_string()); let room_name = claims.video.room.unwrap(); let mut server_rooms = self.rooms.lock(); @@ -195,7 +195,7 @@ impl TestServer { &self, token: String, ) -> Result> { - let claims = livekit_server::token::validate(&token, &self.secret_key)?; + let claims = livekit_api::token::validate(&token, &self.secret_key)?; let local_identity = ParticipantIdentity(claims.sub.unwrap().to_string()); let room_name = claims.video.room.unwrap().to_string(); @@ -288,7 +288,7 @@ impl TestServer { ) -> Result { self.executor.simulate_random_delay().await; - let claims = livekit_server::token::validate(&token, &self.secret_key)?; + let claims = livekit_api::token::validate(&token, &self.secret_key)?; let identity = ParticipantIdentity(claims.sub.unwrap().to_string()); let room_name = claims.video.room.unwrap(); @@ -354,7 +354,7 @@ impl TestServer { ) -> Result { self.executor.simulate_random_delay().await; - let claims = livekit_server::token::validate(&token, &self.secret_key)?; + let claims = livekit_api::token::validate(&token, &self.secret_key)?; let identity = ParticipantIdentity(claims.sub.unwrap().to_string()); let room_name = claims.video.room.unwrap(); @@ -419,7 +419,7 @@ impl TestServer { } fn set_track_muted(&self, token: &str, track_sid: &TrackSid, muted: bool) -> Result<()> { - let claims = livekit_server::token::validate(&token, &self.secret_key)?; + let claims = livekit_api::token::validate(&token, &self.secret_key)?; let room_name = claims.video.room.unwrap(); let identity = ParticipantIdentity(claims.sub.unwrap().to_string()); let mut server_rooms = self.rooms.lock(); @@ -473,7 +473,7 @@ impl TestServer { } fn is_track_muted(&self, token: &str, track_sid: &TrackSid) -> Option { - let claims = livekit_server::token::validate(&token, &self.secret_key).ok()?; + let claims = livekit_api::token::validate(&token, &self.secret_key).ok()?; let room_name = claims.video.room.unwrap(); let mut server_rooms = self.rooms.lock(); @@ -488,7 +488,7 @@ impl TestServer { } fn video_tracks(&self, token: String) -> Result> { - let claims = livekit_server::token::validate(&token, &self.secret_key)?; + let claims = livekit_api::token::validate(&token, &self.secret_key)?; let room_name = claims.video.room.unwrap(); let identity = ParticipantIdentity(claims.sub.unwrap().to_string()); @@ -511,7 +511,7 @@ impl TestServer { } fn audio_tracks(&self, token: String) -> Result> { - let claims = livekit_server::token::validate(&token, &self.secret_key)?; + let claims = livekit_api::token::validate(&token, &self.secret_key)?; let room_name = claims.video.room.unwrap(); let identity = ParticipantIdentity(claims.sub.unwrap().to_string()); @@ -641,7 +641,7 @@ pub enum RoomEvent { #[cfg(not(all(target_os = "windows", target_env = "gnu")))] #[async_trait] -impl livekit_server::api::Client for TestApiClient { +impl livekit_api::Client for TestApiClient { fn url(&self) -> &str { &self.url } @@ -670,7 +670,7 @@ impl livekit_server::api::Client for TestApiClient { &self, room: String, identity: String, - permission: livekit_server::proto::ParticipantPermission, + permission: livekit_api::proto::ParticipantPermission, ) -> Result<()> { let server = TestServer::get(&self.url)?; server diff --git a/crates/livekit_client_macos/Cargo.toml b/crates/livekit_client_macos/Cargo.toml index 405515bf29..ddf55ceed9 100644 --- a/crates/livekit_client_macos/Cargo.toml +++ b/crates/livekit_client_macos/Cargo.toml @@ -22,7 +22,7 @@ test-support = [ "async-trait", "collections/test-support", "gpui/test-support", - "livekit_server", + "livekit_api", "nanoid", ] @@ -33,7 +33,7 @@ async-trait = { workspace = true, optional = true } collections = { workspace = true, optional = true } futures.workspace = true gpui = { workspace = true, optional = true } -livekit_server = { workspace = true, optional = true } +livekit_api = { workspace = true, optional = true } log.workspace = true media.workspace = true nanoid = { workspace = true, optional = true} @@ -47,14 +47,14 @@ core-foundation.workspace = true async-trait = { workspace = true } collections = { workspace = true } gpui = { workspace = true } -livekit_server.workspace = true +livekit_api.workspace = true nanoid.workspace = true [dev-dependencies] async-trait.workspace = true collections = { workspace = true, features = ["test-support"] } gpui = { workspace = true, features = ["test-support"] } -livekit_server.workspace = true +livekit_api.workspace = true nanoid.workspace = true sha2.workspace = true simplelog.workspace = true diff --git a/crates/livekit_client_macos/examples/test_app_macos.rs b/crates/livekit_client_macos/examples/test_app_macos.rs index 87aebdef0a..fefe08e5f8 100644 --- a/crates/livekit_client_macos/examples/test_app_macos.rs +++ b/crates/livekit_client_macos/examples/test_app_macos.rs @@ -2,8 +2,8 @@ use std::time::Duration; use futures::StreamExt; use gpui::{actions, KeyBinding, Menu, MenuItem}; +use livekit_api::token::{self, VideoGrant}; use livekit_client_macos::{LocalAudioTrack, LocalVideoTrack, Room, RoomUpdate}; -use livekit_server::token::{self, VideoGrant}; use log::LevelFilter; use simplelog::SimpleLogger; diff --git a/crates/livekit_client_macos/src/test.rs b/crates/livekit_client_macos/src/test.rs index 9445a468ca..bccc713c87 100644 --- a/crates/livekit_client_macos/src/test.rs +++ b/crates/livekit_client_macos/src/test.rs @@ -4,7 +4,7 @@ use async_trait::async_trait; use collections::{btree_map::Entry as BTreeEntry, hash_map::Entry, BTreeMap, HashMap, HashSet}; use futures::Stream; use gpui::{BackgroundExecutor, SurfaceSource}; -use livekit_server::{proto, token}; +use livekit_api::{proto, token}; use parking_lot::Mutex; use postage::watch; @@ -102,7 +102,7 @@ impl TestServer { #[cfg(any(test, feature = "test-support"))] self.executor.simulate_random_delay().await; - let claims = livekit_server::token::validate(&token, &self.secret_key)?; + let claims = livekit_api::token::validate(&token, &self.secret_key)?; let identity = claims.sub.unwrap().to_string(); let room_name = claims.video.room.unwrap(); let mut server_rooms = self.rooms.lock(); @@ -150,7 +150,7 @@ impl TestServer { // todo(linux): Remove this once the cross-platform LiveKit implementation is merged #[cfg(any(test, feature = "test-support"))] self.executor.simulate_random_delay().await; - let claims = livekit_server::token::validate(&token, &self.secret_key)?; + let claims = livekit_api::token::validate(&token, &self.secret_key)?; let identity = claims.sub.unwrap().to_string(); let room_name = claims.video.room.unwrap(); let mut server_rooms = self.rooms.lock(); @@ -224,7 +224,7 @@ impl TestServer { // todo(linux): Remove this once the cross-platform LiveKit implementation is merged #[cfg(any(test, feature = "test-support"))] self.executor.simulate_random_delay().await; - let claims = livekit_server::token::validate(&token, &self.secret_key)?; + let claims = livekit_api::token::validate(&token, &self.secret_key)?; let identity = claims.sub.unwrap().to_string(); let room_name = claims.video.room.unwrap(); @@ -280,7 +280,7 @@ impl TestServer { #[cfg(any(test, feature = "test-support"))] self.executor.simulate_random_delay().await; - let claims = livekit_server::token::validate(&token, &self.secret_key)?; + let claims = livekit_api::token::validate(&token, &self.secret_key)?; let identity = claims.sub.unwrap().to_string(); let room_name = claims.video.room.unwrap(); @@ -332,7 +332,7 @@ impl TestServer { } fn set_track_muted(&self, token: &str, track_sid: &str, muted: bool) -> Result<()> { - let claims = livekit_server::token::validate(token, &self.secret_key)?; + let claims = livekit_api::token::validate(token, &self.secret_key)?; let room_name = claims.video.room.unwrap(); let identity = claims.sub.unwrap(); let mut server_rooms = self.rooms.lock(); @@ -363,7 +363,7 @@ impl TestServer { } fn is_track_muted(&self, token: &str, track_sid: &str) -> Option { - let claims = livekit_server::token::validate(token, &self.secret_key).ok()?; + let claims = livekit_api::token::validate(token, &self.secret_key).ok()?; let room_name = claims.video.room.unwrap(); let mut server_rooms = self.rooms.lock(); @@ -378,7 +378,7 @@ impl TestServer { } fn video_tracks(&self, token: String) -> Result>> { - let claims = livekit_server::token::validate(&token, &self.secret_key)?; + let claims = livekit_api::token::validate(&token, &self.secret_key)?; let room_name = claims.video.room.unwrap(); let identity = claims.sub.unwrap(); @@ -401,7 +401,7 @@ impl TestServer { } fn audio_tracks(&self, token: String) -> Result>> { - let claims = livekit_server::token::validate(&token, &self.secret_key)?; + let claims = livekit_api::token::validate(&token, &self.secret_key)?; let room_name = claims.video.room.unwrap(); let identity = claims.sub.unwrap(); @@ -455,7 +455,7 @@ pub struct TestApiClient { } #[async_trait] -impl livekit_server::api::Client for TestApiClient { +impl livekit_api::Client for TestApiClient { fn url(&self) -> &str { &self.url } @@ -482,7 +482,7 @@ impl livekit_server::api::Client for TestApiClient { &self, room: String, identity: String, - permission: livekit_server::proto::ParticipantPermission, + permission: livekit_api::proto::ParticipantPermission, ) -> Result<()> { let server = TestServer::get(&self.url)?; server diff --git a/crates/livekit_server/src/livekit_server.rs b/crates/livekit_server/src/livekit_server.rs deleted file mode 100644 index aa7c1f2fd0..0000000000 --- a/crates/livekit_server/src/livekit_server.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod api; -pub mod proto; -pub mod token; diff --git a/typos.toml b/typos.toml index 8deed5882d..7c8bd02c74 100644 --- a/typos.toml +++ b/typos.toml @@ -22,7 +22,7 @@ extend-exclude = [ # Stripe IDs are flagged as typos. "crates/collab/src/db/tests/processed_stripe_event_tests.rs", # Not our typos. - "crates/livekit_server/", + "crates/livekit_api/", # Vim makes heavy use of partial typing tables. "crates/vim/", # Editor and file finder rely on partial typing and custom in-string syntax.