portal: make pipewire optional
This commit is contained in:
parent
21916017c1
commit
b359b2648d
2 changed files with 22 additions and 10 deletions
|
|
@ -14,7 +14,7 @@ use {
|
||||||
forker::ForkerError,
|
forker::ForkerError,
|
||||||
io_uring::IoUring,
|
io_uring::IoUring,
|
||||||
logger::Logger,
|
logger::Logger,
|
||||||
pipewire::pw_con::{PwCon, PwConHolder, PwConOwner},
|
pipewire::pw_con::{PwConHolder, PwConOwner},
|
||||||
portal::{
|
portal::{
|
||||||
ptl_display::{watch_displays, PortalDisplay, PortalDisplayId},
|
ptl_display::{watch_displays, PortalDisplay, PortalDisplayId},
|
||||||
ptl_render_ctx::PortalRenderCtx,
|
ptl_render_ctx::PortalRenderCtx,
|
||||||
|
|
@ -181,9 +181,10 @@ async fn run_async(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let pw_con = match PwConHolder::new(&eng, &ring).await {
|
let pw_con = match PwConHolder::new(&eng, &ring).await {
|
||||||
Ok(p) => p,
|
Ok(p) => Some(p),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
fatal!("Could not connect to pipewire: {}", ErrorFmt(e));
|
log::error!("Could not connect to pipewire: {}", ErrorFmt(e));
|
||||||
|
None
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let state = Rc::new(PortalState {
|
let state = Rc::new(PortalState {
|
||||||
|
|
@ -191,7 +192,6 @@ async fn run_async(
|
||||||
ring,
|
ring,
|
||||||
eng,
|
eng,
|
||||||
wheel,
|
wheel,
|
||||||
pw_con: pw_con.con.clone(),
|
|
||||||
displays: Default::default(),
|
displays: Default::default(),
|
||||||
dbus,
|
dbus,
|
||||||
screencasts: Default::default(),
|
screencasts: Default::default(),
|
||||||
|
|
@ -199,15 +199,19 @@ async fn run_async(
|
||||||
render_ctxs: Default::default(),
|
render_ctxs: Default::default(),
|
||||||
dma_buf_ids: Default::default(),
|
dma_buf_ids: Default::default(),
|
||||||
});
|
});
|
||||||
|
if let Some(pw_con) = &pw_con {
|
||||||
|
pw_con.con.owner.set(Some(state.clone()));
|
||||||
|
}
|
||||||
let _root = {
|
let _root = {
|
||||||
let obj = state
|
let obj = state
|
||||||
.dbus
|
.dbus
|
||||||
.add_object("/org/freedesktop/portal/desktop")
|
.add_object("/org/freedesktop/portal/desktop")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
add_screencast_dbus_members(&state, &obj);
|
if let Some(pw_con) = &pw_con {
|
||||||
|
add_screencast_dbus_members(&state, &pw_con.con, &obj);
|
||||||
|
}
|
||||||
obj
|
obj
|
||||||
};
|
};
|
||||||
state.pw_con.owner.set(Some(state.clone()));
|
|
||||||
watch_displays(state.clone()).await;
|
watch_displays(state.clone()).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -281,7 +285,6 @@ struct PortalState {
|
||||||
ring: Rc<IoUring>,
|
ring: Rc<IoUring>,
|
||||||
eng: Rc<AsyncEngine>,
|
eng: Rc<AsyncEngine>,
|
||||||
wheel: Rc<Wheel>,
|
wheel: Rc<Wheel>,
|
||||||
pw_con: Rc<PwCon>,
|
|
||||||
displays: CopyHashMap<PortalDisplayId, Rc<PortalDisplay>>,
|
displays: CopyHashMap<PortalDisplayId, Rc<PortalDisplay>>,
|
||||||
dbus: Rc<DbusSocket>,
|
dbus: Rc<DbusSocket>,
|
||||||
screencasts: CopyHashMap<String, Rc<ScreencastSession>>,
|
screencasts: CopyHashMap<String, Rc<ScreencastSession>>,
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ use {
|
||||||
crate::{
|
crate::{
|
||||||
dbus::{prelude::Variant, DbusObject, DictEntry, DynamicType, PendingReply},
|
dbus::{prelude::Variant, DbusObject, DictEntry, DynamicType, PendingReply},
|
||||||
pipewire::{
|
pipewire::{
|
||||||
|
pw_con::PwCon,
|
||||||
pw_ifs::pw_client_node::{
|
pw_ifs::pw_client_node::{
|
||||||
PwClientNode, PwClientNodeBufferConfig, PwClientNodeOwner, PwClientNodePort,
|
PwClientNode, PwClientNodeBufferConfig, PwClientNodeOwner, PwClientNodePort,
|
||||||
PwClientNodePortSupportedFormats, SUPPORTED_META_VIDEO_CROP,
|
PwClientNodePortSupportedFormats, SUPPORTED_META_VIDEO_CROP,
|
||||||
|
|
@ -56,6 +57,7 @@ shared_ids!(ScreencastSessionId);
|
||||||
pub struct ScreencastSession {
|
pub struct ScreencastSession {
|
||||||
_id: ScreencastSessionId,
|
_id: ScreencastSessionId,
|
||||||
state: Rc<PortalState>,
|
state: Rc<PortalState>,
|
||||||
|
pw_con: Rc<PwCon>,
|
||||||
pub app: String,
|
pub app: String,
|
||||||
session_obj: DbusObject,
|
session_obj: DbusObject,
|
||||||
pub phase: CloneCell<ScreencastPhase>,
|
pub phase: CloneCell<ScreencastPhase>,
|
||||||
|
|
@ -234,7 +236,7 @@ impl PwClientNodeOwner for StartedScreencast {
|
||||||
|
|
||||||
impl SelectingScreencastCore {
|
impl SelectingScreencastCore {
|
||||||
pub fn starting(&self, dpy: &Rc<PortalDisplay>, target: ScreencastTarget) {
|
pub fn starting(&self, dpy: &Rc<PortalDisplay>, target: ScreencastTarget) {
|
||||||
let node = dpy.state.pw_con.create_client_node(&[
|
let node = self.session.pw_con.create_client_node(&[
|
||||||
("media.class".to_string(), "Video/Source".to_string()),
|
("media.class".to_string(), "Video/Source".to_string()),
|
||||||
("node.name".to_string(), "jay-desktop-portal".to_string()),
|
("node.name".to_string(), "jay-desktop-portal".to_string()),
|
||||||
("node.driver".to_string(), "true".to_string()),
|
("node.driver".to_string(), "true".to_string()),
|
||||||
|
|
@ -462,11 +464,16 @@ impl UsrJayScreencastOwner for StartedScreencast {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn add_screencast_dbus_members(state_: &Rc<PortalState>, object: &DbusObject) {
|
pub(super) fn add_screencast_dbus_members(
|
||||||
|
state_: &Rc<PortalState>,
|
||||||
|
pw_con: &Rc<PwCon>,
|
||||||
|
object: &DbusObject,
|
||||||
|
) {
|
||||||
use org::freedesktop::impl_::portal::screen_cast::*;
|
use org::freedesktop::impl_::portal::screen_cast::*;
|
||||||
let state = state_.clone();
|
let state = state_.clone();
|
||||||
|
let pw_con = pw_con.clone();
|
||||||
object.add_method::<CreateSession, _>(move |req, pr| {
|
object.add_method::<CreateSession, _>(move |req, pr| {
|
||||||
dbus_create_session(&state, req, pr);
|
dbus_create_session(&state, &pw_con, req, pr);
|
||||||
});
|
});
|
||||||
let state = state_.clone();
|
let state = state_.clone();
|
||||||
object.add_method::<SelectSources, _>(move |req, pr| {
|
object.add_method::<SelectSources, _>(move |req, pr| {
|
||||||
|
|
@ -483,6 +490,7 @@ pub(super) fn add_screencast_dbus_members(state_: &Rc<PortalState>, object: &Dbu
|
||||||
|
|
||||||
fn dbus_create_session(
|
fn dbus_create_session(
|
||||||
state: &Rc<PortalState>,
|
state: &Rc<PortalState>,
|
||||||
|
pw_con: &Rc<PwCon>,
|
||||||
req: CreateSession,
|
req: CreateSession,
|
||||||
reply: PendingReply<CreateSessionReply<'static>>,
|
reply: PendingReply<CreateSessionReply<'static>>,
|
||||||
) {
|
) {
|
||||||
|
|
@ -501,6 +509,7 @@ fn dbus_create_session(
|
||||||
let session = Rc::new(ScreencastSession {
|
let session = Rc::new(ScreencastSession {
|
||||||
_id: state.id(),
|
_id: state.id(),
|
||||||
state: state.clone(),
|
state: state.clone(),
|
||||||
|
pw_con: pw_con.clone(),
|
||||||
app: req.app_id.to_string(),
|
app: req.app_id.to_string(),
|
||||||
session_obj: obj,
|
session_obj: obj,
|
||||||
phase: CloneCell::new(ScreencastPhase::Init),
|
phase: CloneCell::new(ScreencastPhase::Init),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue