Skip to content

Commit

Permalink
collab: Make unsupported for MinGW toolchain (#23518)
Browse files Browse the repository at this point in the history
Closes #23451

reverts #23117 for MinGW. collab can't be compiled for MinGW because
webrtc itself doesn't support MinGW compilers

Release Notes:

- N/A
  • Loading branch information
ognevny authored Jan 26, 2025
1 parent 5d005a7 commit 64a5153
Show file tree
Hide file tree
Showing 10 changed files with 199 additions and 26 deletions.
10 changes: 9 additions & 1 deletion crates/call/src/cross_platform/participant.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg_attr(all(target_os = "windows", target_env = "gnu"), allow(unused))]

use anyhow::{anyhow, Result};
use client::{proto, ParticipantIndex, User};
use collections::HashMap;
Expand All @@ -6,6 +8,7 @@ use livekit_client::AudioStream;
use project::Project;
use std::sync::Arc;

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

Expand Down Expand Up @@ -58,13 +61,18 @@ pub struct RemoteParticipant {
pub participant_index: ParticipantIndex,
pub muted: bool,
pub speaking: bool,
#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
pub video_tracks: HashMap<TrackSid, RemoteVideoTrack>,
#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
pub audio_tracks: HashMap<TrackSid, (RemoteAudioTrack, AudioStream)>,
}

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

pub fn can_write(&self) -> bool {
Expand Down
96 changes: 79 additions & 17 deletions crates/call/src/cross_platform/room.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg_attr(all(target_os = "windows", target_env = "gnu"), allow(unused))]

use crate::{
call_settings::CallSettings,
participant::{LocalParticipant, ParticipantLocation, RemoteParticipant},
Expand All @@ -13,6 +15,7 @@ use fs::Fs;
use futures::{FutureExt, StreamExt};
use gpui::{App, AppContext, AsyncAppContext, Context, Entity, EventEmitter, Task, WeakEntity};
use language::LanguageRegistry;
#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
use livekit::{
capture_local_audio_track, capture_local_video_track,
id::ParticipantIdentity,
Expand All @@ -22,6 +25,8 @@ use livekit::{
track::{TrackKind, TrackSource},
RoomEvent, RoomOptions,
};
#[cfg(all(target_os = "windows", target_env = "gnu"))]
use livekit::{publication::LocalTrackPublication, RoomEvent};
use livekit_client as livekit;
use postage::{sink::Sink, stream::Stream, watch};
use project::Project;
Expand Down Expand Up @@ -99,7 +104,10 @@ impl Room {
!self.shared_projects.is_empty()
}

#[cfg(any(test, feature = "test-support"))]
#[cfg(all(
any(test, feature = "test-support"),
not(all(target_os = "windows", target_env = "gnu"))
))]
pub fn is_connected(&self) -> bool {
if let Some(live_kit) = self.live_kit.as_ref() {
live_kit.room.connection_state() == livekit::ConnectionState::Connected
Expand Down Expand Up @@ -664,6 +672,12 @@ impl Room {
}
}

#[cfg(all(target_os = "windows", target_env = "gnu"))]
fn start_room_connection(&self, mut room: proto::Room, cx: &mut Context<Self>) -> Task<()> {
Task::ready(())
}

#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
fn start_room_connection(&self, mut room: proto::Room, cx: &mut Context<Self>) -> Task<()> {
// Filter ourselves out from the room's participants.
let local_participant_ix = room
Expand Down Expand Up @@ -816,6 +830,7 @@ impl Room {
muted: true,
speaking: false,
video_tracks: Default::default(),
#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
audio_tracks: Default::default(),
},
);
Expand Down Expand Up @@ -918,6 +933,7 @@ impl Room {
);

match event {
#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
RoomEvent::TrackSubscribed {
track,
participant,
Expand Down Expand Up @@ -952,6 +968,7 @@ impl Room {
}
}

#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
RoomEvent::TrackUnsubscribed {
track, participant, ..
} => {
Expand Down Expand Up @@ -979,6 +996,7 @@ impl Room {
}
}

#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
RoomEvent::ActiveSpeakersChanged { speakers } => {
let mut speaker_ids = speakers
.into_iter()
Expand All @@ -995,6 +1013,7 @@ impl Room {
}
}

#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
RoomEvent::TrackMuted {
participant,
publication,
Expand All @@ -1019,6 +1038,7 @@ impl Room {
}
}

#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
RoomEvent::LocalTrackUnpublished { publication, .. } => {
log::info!("unpublished track {}", publication.sid());
if let Some(room) = &mut self.live_kit {
Expand All @@ -1041,10 +1061,12 @@ impl Room {
}
}

#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
RoomEvent::LocalTrackPublished { publication, .. } => {
log::info!("published track {:?}", publication.sid());
}

#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
RoomEvent::Disconnected { reason } => {
log::info!("disconnected from room: {reason:?}");
self.leave(cx).detach_and_log_err(cx);
Expand Down Expand Up @@ -1274,6 +1296,13 @@ impl Room {
pub fn can_use_microphone(&self) -> bool {
use proto::ChannelRole::*;

#[cfg(not(any(test, feature = "test-support")))]
{
if cfg!(all(target_os = "windows", target_env = "gnu")) {
return false;
}
}

match self.local_participant.role {
Admin | Member | Talker => true,
Guest | Banned => false,
Expand All @@ -1288,6 +1317,12 @@ impl Room {
}
}

#[cfg(all(target_os = "windows", target_env = "gnu"))]
pub fn share_microphone(&mut self, cx: &mut ModelContext<Self>) -> Task<Result<()>> {
Task::ready(Err(anyhow!("MinGW is not supported yet")))
}

#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
#[track_caller]
pub fn share_microphone(&mut self, cx: &mut Context<Self>) -> Task<Result<()>> {
if self.status.is_offline() {
Expand Down Expand Up @@ -1365,6 +1400,12 @@ impl Room {
})
}

#[cfg(all(target_os = "windows", target_env = "gnu"))]
pub fn share_screen(&mut self, cx: &mut Context<Self>) -> Task<Result<()>> {
Task::ready(Err(anyhow!("MinGW is not supported yet")))
}

#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
pub fn share_screen(&mut self, cx: &mut Context<Self>) -> Task<Result<()>> {
if self.status.is_offline() {
return Task::ready(Err(anyhow!("room is offline")));
Expand Down Expand Up @@ -1512,12 +1553,15 @@ impl Room {
LocalTrack::Published {
track_publication, ..
} => {
let local_participant = live_kit.room.local_participant();
let sid = track_publication.sid();
cx.background_executor()
.spawn(async move { local_participant.unpublish_track(&sid).await })
.detach_and_log_err(cx);
cx.notify();
#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
{
let local_participant = live_kit.room.local_participant();
let sid = track_publication.sid();
cx.background_executor()
.spawn(async move { local_participant.unpublish_track(&sid).await })
.detach_and_log_err(cx);
cx.notify();
}

Audio::play_sound(Sound::StopScreenshare, cx);
Ok(())
Expand All @@ -1526,12 +1570,15 @@ impl Room {
}

fn set_deafened(&mut self, deafened: bool, cx: &mut Context<Self>) -> Option<()> {
let live_kit = self.live_kit.as_mut()?;
cx.notify();
for (_, participant) in live_kit.room.remote_participants() {
for (_, publication) in participant.track_publications() {
if publication.kind() == TrackKind::Audio {
publication.set_enabled(!deafened);
#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
{
let live_kit = self.live_kit.as_mut()?;
cx.notify();
for (_, participant) in live_kit.room.remote_participants() {
for (_, publication) in participant.track_publications() {
if publication.kind() == TrackKind::Audio {
publication.set_enabled(!deafened);
}
}
}
}
Expand Down Expand Up @@ -1561,10 +1608,13 @@ impl Room {
LocalTrack::Published {
track_publication, ..
} => {
if should_mute {
track_publication.mute()
} else {
track_publication.unmute()
#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
{
if should_mute {
track_publication.mute()
} else {
track_publication.unmute()
}
}

None
Expand All @@ -1573,6 +1623,14 @@ impl Room {
}
}

#[cfg(all(target_os = "windows", target_env = "gnu"))]
fn spawn_room_connection(
livekit_connection_info: Option<proto::LiveKitConnectionInfo>,
cx: &mut ModelContext<'_, Room>,
) {
}

#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
fn spawn_room_connection(
livekit_connection_info: Option<proto::LiveKitConnectionInfo>,
cx: &mut Context<'_, Room>,
Expand Down Expand Up @@ -1637,6 +1695,10 @@ struct LiveKitRoom {
}

impl LiveKitRoom {
#[cfg(all(target_os = "windows", target_env = "gnu"))]
fn stop_publishing(&mut self, _cx: &mut Context<Room>) {}

#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
fn stop_publishing(&mut self, cx: &mut Context<Room>) {
let mut tracks_to_unpublish = Vec::new();
if let LocalTrack::Published {
Expand Down
4 changes: 3 additions & 1 deletion crates/livekit_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ cpal = "0.15"
futures.workspace = true
gpui.workspace = true
http_2 = { package = "http", version = "0.2.1" }
livekit.workspace = true
livekit_server.workspace = true
log.workspace = true
media.workspace = true
Expand All @@ -40,6 +39,9 @@ http_client.workspace = true
smallvec.workspace = true
image.workspace = true

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

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

0 comments on commit 64a5153

Please sign in to comment.