screencast: re-negotiate format/modifier when size changes
This commit is contained in:
parent
b91c42aa38
commit
9595cc43ec
3 changed files with 46 additions and 20 deletions
|
|
@ -181,24 +181,7 @@ impl PwClientNodeOwner for StartingScreencast {
|
|||
modifiers: vec![LINEAR_MODIFIER],
|
||||
}],
|
||||
};
|
||||
if let Some(ctx) = self.dpy.render_ctx.get() {
|
||||
if let Some(server_formats) = &ctx.server_formats {
|
||||
supported_formats.formats.clear();
|
||||
for format in server_formats.values() {
|
||||
if format.write_modifiers.is_empty() {
|
||||
continue;
|
||||
}
|
||||
if format.format.pipewire == SPA_VIDEO_FORMAT_UNKNOWN {
|
||||
continue;
|
||||
}
|
||||
let ptl_format = PwClientNodePortSupportedFormat {
|
||||
format: format.format,
|
||||
modifiers: format.write_modifiers.keys().copied().collect(),
|
||||
};
|
||||
supported_formats.formats.push(ptl_format);
|
||||
}
|
||||
}
|
||||
}
|
||||
init_supported_formats(&mut supported_formats, &self.dpy);
|
||||
let jsc_version = self.dpy.jc.version;
|
||||
let num_buffers = (jsc_version >= CLIENT_BUFFERS_SINCE).then_some(3);
|
||||
let port = self.node.create_port(true, supported_formats, num_buffers);
|
||||
|
|
@ -276,6 +259,12 @@ impl PwClientNodeOwner for StartedScreencast {
|
|||
return;
|
||||
}
|
||||
};
|
||||
log::debug!(
|
||||
"Negotiated format {} with modifier 0x{modifier:08x} at size {}x{}",
|
||||
fmt.name,
|
||||
self.width.get(),
|
||||
self.height.get(),
|
||||
);
|
||||
self.port.supported_formats.borrow_mut().formats = vec![PwClientNodePortSupportedFormat {
|
||||
format: fmt,
|
||||
modifiers: vec![modifier],
|
||||
|
|
@ -701,17 +690,50 @@ impl UsrJayScreencastOwner for StartedScreencast {
|
|||
}
|
||||
|
||||
fn config(&self, config: UsrJayScreencastServerConfig) {
|
||||
self.width.set(config.width.max(1));
|
||||
self.height.set(config.height.max(1));
|
||||
let mut changed = false;
|
||||
let width = config.width.max(1);
|
||||
let height = config.height.max(1);
|
||||
changed |= self.width.replace(width) != width;
|
||||
changed |= self.height.replace(height) != height;
|
||||
self.port.supported_formats.borrow_mut().video_size = Some(PwPodRectangle {
|
||||
width: self.width.get() as _,
|
||||
height: self.height.get() as _,
|
||||
});
|
||||
if changed && self.dpy.jc.version >= CLIENT_BUFFERS_SINCE {
|
||||
self.fixated.set(false);
|
||||
init_supported_formats(&mut self.port.supported_formats.borrow_mut(), &self.dpy);
|
||||
}
|
||||
self.node.send_port_update(&self.port, self.fixated.get());
|
||||
self.node.send_active(true);
|
||||
}
|
||||
}
|
||||
|
||||
fn init_supported_formats(
|
||||
supported_formats: &mut PwClientNodePortSupportedFormats,
|
||||
dpy: &PortalDisplay,
|
||||
) {
|
||||
let Some(ctx) = dpy.render_ctx.get() else {
|
||||
return;
|
||||
};
|
||||
let Some(server_formats) = &ctx.server_formats else {
|
||||
return;
|
||||
};
|
||||
supported_formats.formats.clear();
|
||||
for format in server_formats.values() {
|
||||
if format.write_modifiers.is_empty() {
|
||||
continue;
|
||||
}
|
||||
if format.format.pipewire == SPA_VIDEO_FORMAT_UNKNOWN {
|
||||
continue;
|
||||
}
|
||||
let ptl_format = PwClientNodePortSupportedFormat {
|
||||
format: format.format,
|
||||
modifiers: format.write_modifiers.keys().copied().collect(),
|
||||
};
|
||||
supported_formats.formats.push(ptl_format);
|
||||
}
|
||||
}
|
||||
|
||||
impl UsrLinuxBufferParamsOwner for StartedScreencast {
|
||||
fn created(&self, buffer: Rc<UsrWlBuffer>) {
|
||||
self.buffers_valid.set(true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue