mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-18 07:43:01 +08:00
fix unsafe code
This commit is contained in:
parent
38f66df091
commit
3643870287
@ -130,7 +130,7 @@ impl PipeWireRecorder {
|
|||||||
pub fn new(capturable: PipeWireCapturable) -> Result<Self, Box<dyn Error>> {
|
pub fn new(capturable: PipeWireCapturable) -> Result<Self, Box<dyn Error>> {
|
||||||
let pipeline = gst::Pipeline::new(None);
|
let pipeline = gst::Pipeline::new(None);
|
||||||
|
|
||||||
let src = gst::ElementFactory::make_with_name("pipewiresrc", None).unwrap();
|
let src = gst::ElementFactory::make_with_name("pipewiresrc", None)?;
|
||||||
src.set_property("fd", &capturable.fd.as_raw_fd());
|
src.set_property("fd", &capturable.fd.as_raw_fd());
|
||||||
src.set_property("path", &format!("{}", capturable.path));
|
src.set_property("path", &format!("{}", capturable.path));
|
||||||
src.set_property("keepalive_time", &1_000.as_raw_fd());
|
src.set_property("keepalive_time", &1_000.as_raw_fd());
|
||||||
@ -139,7 +139,7 @@ impl PipeWireRecorder {
|
|||||||
// see: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/982
|
// see: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/982
|
||||||
src.set_property("always-copy", &true);
|
src.set_property("always-copy", &true);
|
||||||
|
|
||||||
let sink = gst::ElementFactory::make_with_name("appsink", None).unwrap();
|
let sink = gst::ElementFactory::make_with_name("appsink", None)?;
|
||||||
sink.set_property("drop", &true);
|
sink.set_property("drop", &true);
|
||||||
sink.set_property("max-buffers", &1u32);
|
sink.set_property("max-buffers", &1u32);
|
||||||
|
|
||||||
@ -254,12 +254,18 @@ impl Recorder for PipeWireRecorder {
|
|||||||
let buf = if self.is_cropped {
|
let buf = if self.is_cropped {
|
||||||
self.buffer_cropped.as_slice()
|
self.buffer_cropped.as_slice()
|
||||||
} else {
|
} else {
|
||||||
self.buffer.as_ref().unwrap().as_slice()
|
self.buffer
|
||||||
|
.as_ref()
|
||||||
|
.ok_or("Failed to get buffer as ref")?
|
||||||
|
.as_slice()
|
||||||
};
|
};
|
||||||
match self.pix_fmt.as_str() {
|
match self.pix_fmt.as_str() {
|
||||||
"BGRx" => Ok(PixelProvider::BGR0(self.width, self.height, buf)),
|
"BGRx" => Ok(PixelProvider::BGR0(self.width, self.height, buf)),
|
||||||
"RGBx" => Ok(PixelProvider::RGB0(self.width, self.height, buf)),
|
"RGBx" => Ok(PixelProvider::RGB0(self.width, self.height, buf)),
|
||||||
_ => unreachable!(),
|
_ => Err(Box::new(GStreamerError(format!(
|
||||||
|
"Unreachable! Unknown pix_fmt, {}",
|
||||||
|
&self.pix_fmt
|
||||||
|
)))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user