Temporarily use legacy screen capture API
This commit is contained in:
parent
9569323f93
commit
4222f86537
2 changed files with 2 additions and 60 deletions
|
@ -86,17 +86,10 @@ public func LKRoomPublishVideoTrack(room: UnsafeRawPointer, track: UnsafeRawPoin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@_cdecl("LKCreateScreenShareTrackForWindow")
|
|
||||||
public func LKCreateScreenShareTrackForWindow(windowId: uint32) -> UnsafeMutableRawPointer {
|
|
||||||
let track = LocalVideoTrack.createMacOSScreenShareTrack(source: .window(id: windowId))
|
|
||||||
return Unmanaged.passRetained(track).toOpaque()
|
|
||||||
}
|
|
||||||
|
|
||||||
@_cdecl("LKCreateScreenShareTrackForDisplay")
|
@_cdecl("LKCreateScreenShareTrackForDisplay")
|
||||||
public func LKCreateScreenShareTrackForDisplay(display: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer {
|
public func LKCreateScreenShareTrackForDisplay(display: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer {
|
||||||
let display = Unmanaged<MacOSDisplay>.fromOpaque(display).takeRetainedValue()
|
let display = Unmanaged<MacOSDisplay>.fromOpaque(display).takeRetainedValue()
|
||||||
print("!!!!!!!!!! display id", display.displayID)
|
let track = LocalVideoTrack.createMacOSScreenShareTrack(source: display, preferredMethod: .legacy)
|
||||||
let track = LocalVideoTrack.createMacOSScreenShareTrack(source: display)
|
|
||||||
return Unmanaged.passRetained(track).toOpaque()
|
return Unmanaged.passRetained(track).toOpaque()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use core_foundation::{
|
use core_foundation::{
|
||||||
array::{CFArray, CFArrayRef},
|
array::{CFArray, CFArrayRef},
|
||||||
base::{TCFType, TCFTypeRef},
|
base::TCFType,
|
||||||
dictionary::CFDictionary,
|
|
||||||
number::CFNumber,
|
|
||||||
string::{CFString, CFStringRef},
|
string::{CFString, CFStringRef},
|
||||||
};
|
};
|
||||||
use core_graphics::window::{
|
|
||||||
kCGNullWindowID, kCGWindowListOptionExcludeDesktopElements, kCGWindowListOptionOnScreenOnly,
|
|
||||||
kCGWindowNumber, kCGWindowOwnerName, kCGWindowOwnerPID, CGWindowListCopyWindowInfo,
|
|
||||||
};
|
|
||||||
use futures::{
|
use futures::{
|
||||||
channel::{mpsc, oneshot},
|
channel::{mpsc, oneshot},
|
||||||
Future,
|
Future,
|
||||||
|
@ -63,7 +57,6 @@ extern "C" {
|
||||||
error: CFStringRef,
|
error: CFStringRef,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
fn LKCreateScreenShareTrackForWindow(windowId: u32) -> *const c_void;
|
|
||||||
fn LKCreateScreenShareTrackForDisplay(display: *const c_void) -> *const c_void;
|
fn LKCreateScreenShareTrackForDisplay(display: *const c_void) -> *const c_void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,10 +187,6 @@ impl Drop for RoomDelegate {
|
||||||
pub struct LocalVideoTrack(*const c_void);
|
pub struct LocalVideoTrack(*const c_void);
|
||||||
|
|
||||||
impl LocalVideoTrack {
|
impl LocalVideoTrack {
|
||||||
pub fn screen_share_for_window(window_id: u32) -> Self {
|
|
||||||
Self(unsafe { LKCreateScreenShareTrackForWindow(window_id) })
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn screen_share_for_display(display: MacOSDisplay) -> Self {
|
pub fn screen_share_for_display(display: MacOSDisplay) -> Self {
|
||||||
let ptr = display.0;
|
let ptr = display.0;
|
||||||
let this = Self(unsafe { LKCreateScreenShareTrackForDisplay(ptr) });
|
let this = Self(unsafe { LKCreateScreenShareTrackForDisplay(ptr) });
|
||||||
|
@ -251,46 +240,6 @@ impl Drop for RemoteVideoTrack {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct WindowInfo {
|
|
||||||
pub id: u32,
|
|
||||||
pub owner_pid: i32,
|
|
||||||
pub owner_name: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn list_windows() -> Vec<WindowInfo> {
|
|
||||||
unsafe {
|
|
||||||
let dicts = CFArray::<CFDictionary>::wrap_under_get_rule(CGWindowListCopyWindowInfo(
|
|
||||||
kCGWindowListOptionOnScreenOnly | kCGWindowListOptionExcludeDesktopElements,
|
|
||||||
kCGNullWindowID,
|
|
||||||
));
|
|
||||||
|
|
||||||
dicts
|
|
||||||
.iter()
|
|
||||||
.map(|dict| {
|
|
||||||
let id =
|
|
||||||
CFNumber::wrap_under_get_rule(*dict.get(kCGWindowNumber.as_void_ptr()) as _)
|
|
||||||
.to_i64()
|
|
||||||
.unwrap() as u32;
|
|
||||||
|
|
||||||
let owner_pid =
|
|
||||||
CFNumber::wrap_under_get_rule(*dict.get(kCGWindowOwnerPID.as_void_ptr()) as _)
|
|
||||||
.to_i32()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let owner_name = dict
|
|
||||||
.find(kCGWindowOwnerName.as_void_ptr())
|
|
||||||
.map(|name| CFString::wrap_under_get_rule(*name as _).to_string());
|
|
||||||
WindowInfo {
|
|
||||||
id,
|
|
||||||
owner_pid,
|
|
||||||
owner_name,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct MacOSDisplay(*const c_void);
|
pub struct MacOSDisplay(*const c_void);
|
||||||
|
|
||||||
impl Drop for MacOSDisplay {
|
impl Drop for MacOSDisplay {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue