feat(gst): enhance GStreamer integration with new modules and improved API
This commit introduces significant enhancements to the GStreamer integration by: - Adding new modules for bins, caps, elements, pads, and plugins - Implementing a more ergonomic API with helper methods like play(), pause(), ready() - Adding support for various GStreamer plugins including app, autodetect, playback, and videoconvertscale - Improving error handling with better context attachment - Updating dependencies to latest versions including gstreamer-video 0.24.4 - Refactoring existing code to use modern Rust patterns and features
This commit is contained in:
49
gst/src/plugins/videoconvertscale/videoconvert.rs
Normal file
49
gst/src/plugins/videoconvertscale/videoconvert.rs
Normal file
@@ -0,0 +1,49 @@
|
||||
use crate::*;
|
||||
#[doc(inline)]
|
||||
pub use gstreamer_video::VideoFormat;
|
||||
|
||||
#[repr(transparent)]
|
||||
pub struct VideoConvert {
|
||||
inner: gstreamer::Element,
|
||||
}
|
||||
|
||||
impl IsElement for VideoConvert {
|
||||
fn as_element(&self) -> &Element {
|
||||
unsafe { core::mem::transmute(&self.inner) }
|
||||
}
|
||||
|
||||
fn into_element(self) -> Element {
|
||||
Element { inner: self.inner }
|
||||
}
|
||||
}
|
||||
|
||||
impl Sink for VideoConvert {}
|
||||
impl Source for VideoConvert {}
|
||||
|
||||
impl VideoConvert {
|
||||
pub fn new(name: impl AsRef<str>) -> Result<Self> {
|
||||
use gstreamer::prelude::*;
|
||||
let element = gstreamer::ElementFactory::make("videoconvert")
|
||||
.name(name.as_ref())
|
||||
.build()
|
||||
.change_context(Error)
|
||||
.attach("Failed to create videoconvert element")?;
|
||||
Ok(VideoConvert { inner: element })
|
||||
}
|
||||
|
||||
// pub fn with_caps(mut self, caps: &gstreamer::Caps) -> Self {
|
||||
// use gstreamer::prelude::*;
|
||||
// self.inner.set_property("caps", caps);
|
||||
// self
|
||||
// }
|
||||
pub fn with_output_format(self, format: VideoFormat) -> Result<Self> {
|
||||
use gstreamer::prelude::*;
|
||||
let caps = Caps::builder(CapsType::Video)
|
||||
.field("format", format.to_str())
|
||||
.build();
|
||||
self.inner.set_property("caps", &caps.inner);
|
||||
// .change_context(Error)
|
||||
// .attach("Failed to set output format on videoconvert")?;
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user