Skip to content

Commit

Permalink
Reapply "Use livekit's Rust SDK instead of their swift SDK (#13343)" (#…
Browse files Browse the repository at this point in the history
…20809)

This reverts commit d92166f.

# Conflicts:
#	Cargo.lock
  • Loading branch information
SomeoneToIgnore committed Nov 19, 2024
1 parent 9454f0f commit 46329d6
Show file tree
Hide file tree
Showing 47 changed files with 2,768 additions and 2,753 deletions.
6 changes: 6 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ rustflags = ["-C", "link-arg=-fuse-ld=mold"]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=mold"]

[target.aarch64-apple-darwin]
rustflags = ["-C", "link-args=-Objc -all_load"]

[target.x86_64-apple-darwin]
rustflags = ["-C", "link-args=-Objc -all_load"]

# This cfg will reduce the size of `windows::core::Error` from 16 bytes to 4 bytes
[target.'cfg(target_os = "windows")']
rustflags = ["--cfg", "windows_slim_errors"]
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ heed = { version = "0.20.1", features = ["read-txn-no-tls"] }
hex = "0.4.3"
html5ever = "0.27.0"
hyper = "0.14"
http = "1.1"
ignore = "0.4.22"
image = "0.25.1"
indexmap = { version = "1.6.2", features = ["serde"] }
Expand All @@ -372,6 +373,7 @@ jupyter-protocol = { version = "0.2.0" }
jupyter-websocket-client = { version = "0.4.1" }
libc = "0.2"
linkify = "0.10.0"
livekit = { git = "https://github.com/zed-industries/rust-sdks", rev="4262308983646ab5b0e0802c3d8bc52154f99aab", features = ["dispatcher", "services-dispatcher", "rustls-tls-native-roots"], default-features = false }
log = { version = "0.4.16", features = ["kv_unstable_serde", "serde"] }
markup5ever_rcdom = "0.3.0"
nanoid = "0.4"
Expand Down Expand Up @@ -550,6 +552,10 @@ features = [
"Win32_UI_WindowsAndMessaging",
]

# TODO livekit https://github.com/RustAudio/cpal/pull/891
[patch.crates-io]
cpal = { git = "https://github.com/zed-industries/cpal", rev = "fd8bc2fd39f1f5fdee5a0690656caff9a26d9d50" }

[profile.dev]
split-debuginfo = "unpacked"
debug = "limited"
Expand Down
1 change: 1 addition & 0 deletions crates/call/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ anyhow.workspace = true
audio.workspace = true
client.workspace = true
collections.workspace = true
feature_flags.workspace = true
fs.workspace = true
futures.workspace = true
gpui.workspace = true
Expand Down
9 changes: 9 additions & 0 deletions crates/call/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ use room::Event;
use settings::Settings;
use std::sync::Arc;

#[cfg(not(target_os = "windows"))]
pub use live_kit_client::play_remote_video_track;
pub use live_kit_client::{
track::RemoteVideoTrack, RemoteVideoTrackView, RemoteVideoTrackViewEvent,
};
pub use participant::ParticipantLocation;
pub use room::Room;

Expand All @@ -26,6 +31,10 @@ struct GlobalActiveCall(Model<ActiveCall>);
impl Global for GlobalActiveCall {}

pub fn init(client: Arc<Client>, user_store: Model<UserStore>, cx: &mut AppContext) {
live_kit_client::init(
cx.background_executor().dispatcher.clone(),
cx.http_client(),
);
CallSettings::register(cx);

let active_call = cx.new_model(|cx| ActiveCall::new(client, user_store, cx));
Expand Down
28 changes: 21 additions & 7 deletions crates/call/src/participant.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#![cfg_attr(target_os = "windows", allow(unused))]

use anyhow::{anyhow, Result};
use client::ParticipantIndex;
use client::{proto, User};
use client::{proto, ParticipantIndex, User};
use collections::HashMap;
use gpui::WeakModel;
pub use live_kit_client::Frame;
pub use live_kit_client::{RemoteAudioTrack, RemoteVideoTrack};
use live_kit_client::AudioStream;
use project::Project;
use std::sync::Arc;

#[cfg(not(target_os = "windows"))]
pub use live_kit_client::id::TrackSid;
pub use live_kit_client::track::{RemoteAudioTrack, RemoteVideoTrack};

#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum ParticipantLocation {
SharedProject { project_id: u64 },
Expand Down Expand Up @@ -39,7 +43,6 @@ pub struct LocalParticipant {
pub role: proto::ChannelRole,
}

#[derive(Clone, Debug)]
pub struct RemoteParticipant {
pub user: Arc<User>,
pub peer_id: proto::PeerId,
Expand All @@ -49,6 +52,17 @@ pub struct RemoteParticipant {
pub participant_index: ParticipantIndex,
pub muted: bool,
pub speaking: bool,
pub video_tracks: HashMap<live_kit_client::Sid, Arc<RemoteVideoTrack>>,
pub audio_tracks: HashMap<live_kit_client::Sid, Arc<RemoteAudioTrack>>,
#[cfg(not(target_os = "windows"))]
pub video_tracks: HashMap<TrackSid, RemoteVideoTrack>,
#[cfg(not(target_os = "windows"))]
pub audio_tracks: HashMap<TrackSid, (RemoteAudioTrack, AudioStream)>,
}

impl RemoteParticipant {
pub fn has_video_tracks(&self) -> bool {
#[cfg(not(target_os = "windows"))]
return !self.video_tracks.is_empty();
#[cfg(target_os = "windows")]
return false;
}
}
Loading

0 comments on commit 46329d6

Please sign in to comment.