Skip to content

Commit

Permalink
WIP progress towards having both LiveKit swift and rust sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
mgsloan committed Dec 4, 2024
1 parent cd71d7c commit c0a0887
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 34 deletions.
24 changes: 24 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ members = [
"crates/language_tools",
"crates/languages",
"crates/livekit_client",
"crates/livekit_client_macos",
"crates/livekit_server",
"crates/lsp",
"crates/markdown",
Expand Down Expand Up @@ -249,6 +250,7 @@ language_selector = { path = "crates/language_selector" }
language_tools = { path = "crates/language_tools" }
languages = { path = "crates/languages" }
livekit_client = { path = "crates/livekit_client" }
livekit_client_macos = { path = "crates/livekit_client_macos" }
livekit_server = { path = "crates/livekit_server" }
lsp = { path = "crates/lsp" }
markdown = { path = "crates/markdown" }
Expand Down
6 changes: 4 additions & 2 deletions crates/call/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ fs.workspace = true
futures.workspace = true
gpui.workspace = true
language.workspace = true
livekit_client.workspace = true
log.workspace = true
livekit_client.workspace = true
livekit_client_macos.workspace = true
postage.workspace = true
project.workspace = true
schemars.workspace = true
Expand All @@ -48,7 +49,8 @@ collections = { workspace = true, features = ["test-support"] }
fs = { workspace = true, features = ["test-support"] }
gpui = { workspace = true, features = ["test-support"] }
language = { workspace = true, features = ["test-support"] }
livekit_client = { workspace = true, features = ["test-support"] }
project = { workspace = true, features = ["test-support"] }
util = { workspace = true, features = ["test-support"] }
http_client = { workspace = true, features = ["test-support"] }
livekit_client = { workspace = true, features = ["test-support"] }
livekit_client_macos = { workspace = true, features = ["test-support"] }
8 changes: 6 additions & 2 deletions crates/call/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ use room::Event;
use settings::Settings;
use std::sync::Arc;

#[cfg(not(target_os = "windows"))]
pub use livekit_client::play_remote_video_track;
#[cfg(target_os = "macos")]
pub use livekit_client_macos::{
track::RemoteVideoTrack, RemoteVideoTrackView, RemoteVideoTrackViewEvent,
};

#[cfg(not(target_os = "macos"))]
pub use livekit_client::{
track::RemoteVideoTrack, RemoteVideoTrackView, RemoteVideoTrackViewEvent,
};
Expand Down
34 changes: 18 additions & 16 deletions crates/livekit_client_macos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "livekit_client"
name = "livekit_client_macos"
version = "0.1.0"
edition = "2021"
description = "Logic for using LiveKit with GPUI"
description = "Bindings to LiveKit Swift client SDK"
publish = false
license = "GPL-3.0-or-later"

Expand All @@ -19,40 +19,42 @@ name = "test_app"
[features]
no-webrtc = []
test-support = [
"async-trait",
"collections/test-support",
"gpui/test-support",
"livekit_server",
"nanoid",
]

[dependencies]
anyhow.workspace = true
async-trait.workspace = true
collections.workspace = true
cpal = "0.15"
async-broadcast = "0.7"
async-trait = { workspace = true, optional = true }
collections = { workspace = true, optional = true }
futures.workspace = true
gpui.workspace = true
http_2 = { package = "http", version = "0.2.1" }
livekit_server.workspace = true
gpui = { workspace = true, optional = true }
livekit_server = { workspace = true, optional = true }
log.workspace = true
media.workspace = true
nanoid = { workspace = true, optional = true}
parking_lot.workspace = true
postage.workspace = true
util.workspace = true
http_client.workspace = true
smallvec.workspace = true
image.workspace = true

[target.'cfg(not(target_os = "windows"))'.dependencies]
livekit.workspace = true

[target.'cfg(target_os = "macos")'.dependencies]
core-foundation.workspace = true
coreaudio-rs = "0.12.1"

[target.'cfg(all(not(target_os = "macos")))'.dependencies]
async-trait = { workspace = true }
collections = { workspace = true }
gpui = { workspace = true }
livekit_server.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
nanoid.workspace = true
sha2.workspace = true
simplelog.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions crates/livekit_client_macos/examples/test_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use std::time::Duration;

use futures::StreamExt;
use gpui::{actions, KeyBinding, Menu, MenuItem};
use live_kit_client::{LocalAudioTrack, LocalVideoTrack, Room, RoomUpdate};
use live_kit_server::token::{self, VideoGrant};
use livekit_client_macos::{LocalAudioTrack, LocalVideoTrack, Room, RoomUpdate};
use livekit_server::token::{self, VideoGrant};
use log::LevelFilter;
use simplelog::SimpleLogger;

actions!(live_kit_client, [Quit]);
actions!(livekit_client_macos, [Quit]);

fn main() {
SimpleLogger::init(LevelFilter::Info, Default::default()).expect("could not initialize logger");
Expand Down
22 changes: 11 additions & 11 deletions crates/livekit_client_macos/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 live_kit_server::{proto, token};
use livekit_server::{proto, token};

use parking_lot::Mutex;
use postage::watch;
Expand Down Expand Up @@ -102,7 +102,7 @@ impl TestServer {
#[cfg(any(test, feature = "test-support"))]
self.executor.simulate_random_delay().await;

let claims = live_kit_server::token::validate(&token, &self.secret_key)?;
let claims = livekit_server::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();
Expand Down Expand Up @@ -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 = live_kit_server::token::validate(&token, &self.secret_key)?;
let claims = livekit_server::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();
Expand Down Expand Up @@ -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 = live_kit_server::token::validate(&token, &self.secret_key)?;
let claims = livekit_server::token::validate(&token, &self.secret_key)?;
let identity = claims.sub.unwrap().to_string();
let room_name = claims.video.room.unwrap();

Expand Down Expand Up @@ -280,7 +280,7 @@ impl TestServer {
#[cfg(any(test, feature = "test-support"))]
self.executor.simulate_random_delay().await;

let claims = live_kit_server::token::validate(&token, &self.secret_key)?;
let claims = livekit_server::token::validate(&token, &self.secret_key)?;
let identity = claims.sub.unwrap().to_string();
let room_name = claims.video.room.unwrap();

Expand Down Expand Up @@ -332,7 +332,7 @@ impl TestServer {
}

fn set_track_muted(&self, token: &str, track_sid: &str, muted: bool) -> Result<()> {
let claims = live_kit_server::token::validate(token, &self.secret_key)?;
let claims = livekit_server::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();
Expand Down Expand Up @@ -363,7 +363,7 @@ impl TestServer {
}

fn is_track_muted(&self, token: &str, track_sid: &str) -> Option<bool> {
let claims = live_kit_server::token::validate(token, &self.secret_key).ok()?;
let claims = livekit_server::token::validate(token, &self.secret_key).ok()?;
let room_name = claims.video.room.unwrap();

let mut server_rooms = self.rooms.lock();
Expand All @@ -378,7 +378,7 @@ impl TestServer {
}

fn video_tracks(&self, token: String) -> Result<Vec<Arc<RemoteVideoTrack>>> {
let claims = live_kit_server::token::validate(&token, &self.secret_key)?;
let claims = livekit_server::token::validate(&token, &self.secret_key)?;
let room_name = claims.video.room.unwrap();
let identity = claims.sub.unwrap();

Expand All @@ -401,7 +401,7 @@ impl TestServer {
}

fn audio_tracks(&self, token: String) -> Result<Vec<Arc<RemoteAudioTrack>>> {
let claims = live_kit_server::token::validate(&token, &self.secret_key)?;
let claims = livekit_server::token::validate(&token, &self.secret_key)?;
let room_name = claims.video.room.unwrap();
let identity = claims.sub.unwrap();

Expand Down Expand Up @@ -455,7 +455,7 @@ pub struct TestApiClient {
}

#[async_trait]
impl live_kit_server::api::Client for TestApiClient {
impl livekit_server::api::Client for TestApiClient {
fn url(&self) -> &str {
&self.url
}
Expand All @@ -482,7 +482,7 @@ impl live_kit_server::api::Client for TestApiClient {
&self,
room: String,
identity: String,
permission: live_kit_server::proto::ParticipantPermission,
permission: livekit_server::proto::ParticipantPermission,
) -> Result<()> {
let server = TestServer::get(&self.url)?;
server
Expand Down

0 comments on commit c0a0887

Please sign in to comment.