mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-05 10:20:51 +00:00
Move ownership of MacOSDisplay
to the rust side
This commit is contained in:
parent
4222f86537
commit
c25acc155d
3 changed files with 5 additions and 15 deletions
|
@ -59,14 +59,8 @@ fn main() {
|
|||
room2.connect(&live_kit_url, &user2_token).await.unwrap();
|
||||
cx.add_window(Default::default(), |cx| ScreenCaptureView::new(room2, cx));
|
||||
|
||||
let display = live_kit::display_sources()
|
||||
.await
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.next()
|
||||
.unwrap();
|
||||
|
||||
let track = LocalVideoTrack::screen_share_for_display(display);
|
||||
let display_sources = live_kit::display_sources().await.unwrap();
|
||||
let track = LocalVideoTrack::screen_share_for_display(display_sources.first().unwrap());
|
||||
room1.publish_video_track(&track).await.unwrap();
|
||||
})
|
||||
.detach();
|
||||
|
|
|
@ -88,7 +88,7 @@ public func LKRoomPublishVideoTrack(room: UnsafeRawPointer, track: UnsafeRawPoin
|
|||
|
||||
@_cdecl("LKCreateScreenShareTrackForDisplay")
|
||||
public func LKCreateScreenShareTrackForDisplay(display: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer {
|
||||
let display = Unmanaged<MacOSDisplay>.fromOpaque(display).takeRetainedValue()
|
||||
let display = Unmanaged<MacOSDisplay>.fromOpaque(display).takeUnretainedValue()
|
||||
let track = LocalVideoTrack.createMacOSScreenShareTrack(source: display, preferredMethod: .legacy)
|
||||
return Unmanaged.passRetained(track).toOpaque()
|
||||
}
|
||||
|
|
|
@ -187,11 +187,8 @@ impl Drop for RoomDelegate {
|
|||
pub struct LocalVideoTrack(*const c_void);
|
||||
|
||||
impl LocalVideoTrack {
|
||||
pub fn screen_share_for_display(display: MacOSDisplay) -> Self {
|
||||
let ptr = display.0;
|
||||
let this = Self(unsafe { LKCreateScreenShareTrackForDisplay(ptr) });
|
||||
std::mem::forget(display);
|
||||
this
|
||||
pub fn screen_share_for_display(display: &MacOSDisplay) -> Self {
|
||||
Self(unsafe { LKCreateScreenShareTrackForDisplay(display.0) })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,7 +256,6 @@ pub fn display_sources() -> impl Future<Output = Result<Vec<MacOSDisplay>>> {
|
|||
let sources = CFArray::wrap_under_get_rule(sources);
|
||||
let sources_vec = sources.iter().map(|source| MacOSDisplay(*source)).collect();
|
||||
let _ = tx.send(Ok(sources_vec));
|
||||
std::mem::forget(sources); // HACK: If I drop the CFArray, all the objects inside it get dropped and we get issues accessing the display later.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue